View previous topic :: View next topic |
Author |
Message |
scottc
Joined: 16 Aug 2010 Posts: 95
|
Pic18f2331 - Configure 10Mhz Crystal Oscillator with 4X Pll |
Posted: Wed Sep 22, 2010 6:06 pm |
|
|
Hi, I am using a PIC18F2331, With a external 10MHZ crystal
My question is What code do I need in Main to enable the PLL for use
with this 10Mhz Crystal. I would also like to be able to set the fuses
so that CCSLoad can pick up the "High Speed Osc with HW enabled 4x pll"
At present I have to set the option each time I program the part with
ccsload
The compiler ver is 4.110, There is no mention of a HSPLL option in the
pic18f2331.h device file. Its in the microchip datasheet on page 23 !
I am able to use the internal 8MHZ oscillator and it works good. To
configure that I use
setup_oscillator(OSC_8MHZ|OSC_Normal);
Thanks Scott |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 22, 2010 8:29 pm |
|
|
With CCS, look at the top of the .h file for your PIC. Look for the fuse
that makes the most sense - look for the one that is closest to the idea
of what you want. It may not match the terms used in the PIC data sheet.
In this case it's the H4 fuse. High speed oscillator, with 4x PLL enabled:
Quote: |
#include <18F2331.H>
#fuses H4,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=40000000)
//=================================
void main()
{
while (1);
} |
|
|
|
Geps
Joined: 05 Jul 2010 Posts: 129
|
|
Posted: Thu Sep 23, 2010 4:14 am |
|
|
Remember you also need to update the delay statements as shown in PCM's example. |
|
|
scottc
Joined: 16 Aug 2010 Posts: 95
|
|
Posted: Thu Sep 23, 2010 7:08 pm |
|
|
Thanks guys,
Code: |
#include <18F2331.H>
#fuses H4,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=40000000)
//=================================
|
I believe when using the 10Mhz Crystal OSC with the 4x pll
the #use delay(clock=40000000) is incorrect.
I tried this and using ccsload, checking the config did not show
the "High Speed Osc with HW enabled 4x pll" as the option that
was to be configured.
I looked in the help file and found under Delay the following.
Code: |
//application is using a 10Mhz oscillator, but using the 4x PLL
//to upscale it to 40Mhz. Compiler will set config bits.
#use delay(oscillator=10Mhz, clock=40Mhz)
|
Using this option and checking the ccsload config showed that the
"High Speed Osc with HW enabled 4x pll" was indeed selected.
I assume this is correct, Can anyone verify ?
Thanks Scott |
|
|
|