View previous topic :: View next topic |
Author |
Message |
ferrumvir
Joined: 01 Feb 2006 Posts: 64 Location: England
|
What's the difference between PLL and using a 4x Crystal |
Posted: Wed Jan 24, 2007 5:53 pm |
|
|
Hi,
I'm considering using PLL to increase the speed of my computation, RS232 communications. The other option is changing from a 10MHz crystal to a 40MHz.
When using PLL, do I set the entire chip up as though I have a 40MHz crystal or are there some things that are still based on the RAW 10MHz signal
Things I think I can already confirm:
* timers are 4 times faster, therefore set up like 40MHz
* UART is 4 times faster, therefore set up like 40MHz
* ADC set up like 40MHz, therefore setup_adc(ADC_CLOCK_DIV_64), rather than setup_adc(ADC_CLOCK_DIV_16);
Hence the question, what's the difference?
Is there anything I should watch out for doing this?
Cheers Scott
PS Reading other posts I've discovered that PLL (#FUSE H4) requires a power cycle to become active, that had me chasing my tail for a while! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jan 24, 2007 6:05 pm |
|
|
Regarding using a 10 MHz crystal and the PLL to get a 40 MHz clock:
Most things will be taken care of by setting up the #use delay() statement
to specify 40 MHz. The UART library code uses the #use delay() value
to calculate how to setup the baud rate generator. In the case of the
A/D clock, you will have to manually choose the correct constant.
Consult the table in the A/D section of the PIC data sheet to determine
which divisor to use. Every PIC that has an A/D will have this table.
For other issues, you need to specify the PIC. Some PICs, such as the
18F4550, have complex oscillator circuits. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Jan 24, 2007 6:53 pm |
|
|
The difference is less EMI from a 10MHz crystal. Also you will need to look at the max crystal speed that can be used. Most are 25MHz. For 40MHz operation, you would need a clock instead of a crystal. |
|
|
ferrumvir
Joined: 01 Feb 2006 Posts: 64 Location: England
|
|
Posted: Thu Jan 25, 2007 4:20 am |
|
|
Thanks,
I'm using two chips, PIC18F452 and PIC18F2580, both can take 40MHz clocks/crystals.
Except changing the "#fuse HS" to "#fuse H4", I can't see any difference in the C source for "10MHz with PLL" or "40MHz clock".
Both use #use delay (40000000) and the constants/registers for the timers/UART/ADC all have to be set up for 40MHz.
Thanks for the info
Cheers Scott |
|
|
Ttelmah Guest
|
|
Posted: Thu Jan 25, 2007 8:30 am |
|
|
Whoa.
The 18F452, _cannot_ 'take a 40Mhz crystal'. It can take a 40MHz external clock, but look carefully at able 22.4 in the data sheet. The maximum rated frequency, for 'HS' operation, is _25MHz_...
The same applies with the 2580. Here it is table 27.6 in the data sheet,and again the maximum rated frequency for HS, is 25MHz.
In general, the chips will oscillate with a 40MHz crystal, but if you want reliable operation, across the supply, and temperature range, _keep inside the spec_, and don't do it...
Best Wishes |
|
|
ferrumvir
Joined: 01 Feb 2006 Posts: 64 Location: England
|
|
Posted: Thu Jan 25, 2007 8:54 am |
|
|
Thanks for the info Ttelmah,
I'm sorry for being a little behind on the crystal/clock, I don't know what the difference between a External Clock and (EC) and a crystal (HS)?
If I understand the tables correctly then I can PLL a 10MHz crystal - effectively 40Mhz, or I can use a 40MHz exteranl clock.
Apart from the changes to the #fuse H4 to EC_IO, are there any other programming differences between these two options?
Cheers Scott |
|
|
Ttelmah Guest
|
|
Posted: Thu Jan 25, 2007 8:59 am |
|
|
None at all, except that 'EC_IO', gives you an extra I/O pin.
Best Wishes |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jan 25, 2007 9:02 am |
|
|
A clock is a TTL or CMOS level oscillator. |
|
|
ferrumvir
Joined: 01 Feb 2006 Posts: 64 Location: England
|
|
Posted: Thu Jan 25, 2007 3:33 pm |
|
|
Thanks, |
|
|
|