View previous topic :: View next topic |
Author |
Message |
kgng97ccs
Joined: 02 Apr 2022 Posts: 97
|
Using PLL with an external crystal oscillator |
Posted: Sat May 21, 2022 8:14 am |
|
|
I am using PIC18LF46K22, CCS C compiler v5.078, and MPLAB IDE v8.92.
Section 2.8.1 (PLL IN EXTERNAL OSCILLATOR MODES) of the PIC datasheet says that “The PLL can be enabled for any of the external oscillator modes using the OSC1/OSC2 pins by either setting the PLLCFG bit (CONFIG1H<4>), or setting the PLLEN bit (OSCTUNE<6>). The PLL is designed for input frequencies of 4 MHz up to 16 MHz …”
I tried to set up PLL with an external 16-MHz crystal oscillator with this code: Code: | #include "18LF46K22.h"
…
#use delay(xtal=16MHz, clock=32MHz) |
The compiler gave this error (even if “#fuses PLLEN” was added before #use delay): “Option invalid Invalid combination”.
I had expected the compiler to accept the xtal-clock combination and automatically enable the PLL fuse.
What is the correct way to set up PLL for an external crystal oscillator? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19568
|
|
Posted: Sat May 21, 2022 10:49 am |
|
|
The reason it complains is that the PLL cannot do *2. Look at the datasheet
and the clock section _*4 PLL_. Not *2.
So:
#use delay(xtal=16MHz, clock=32MHz)
Can't be done.
#use delay(xtal=16MHz, clock=64MHz)
Can |
|
|
kgng97ccs
Joined: 02 Apr 2022 Posts: 97
|
|
Posted: Sun May 22, 2022 8:19 pm |
|
|
Thank you, Ttelmah, for highlighting that. I had misunderstood the 4xPLL to mean "up to 4x". |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19568
|
|
Posted: Sun May 22, 2022 11:04 pm |
|
|
On the DsPic'x, there are programmable PLL's. On the standard PIC's,
they are only fixed multiples... |
|
|
kgng97ccs
Joined: 02 Apr 2022 Posts: 97
|
|
Posted: Tue May 24, 2022 10:20 pm |
|
|
Thank you, Ttelmah. It is good to know that. |
|
|
|