CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Using PLL with an external crystal oscillator

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kgng97ccs



Joined: 02 Apr 2022
Posts: 97

View user's profile Send private message

Using PLL with an external crystal oscillator
PostPosted: Sat May 21, 2022 8:14 am     Reply with quote

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: 19551

View user's profile Send private message

PostPosted: Sat May 21, 2022 10:49 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun May 22, 2022 8:19 pm     Reply with quote

Thank you, Ttelmah, for highlighting that. I had misunderstood the 4xPLL to mean "up to 4x".
Ttelmah



Joined: 11 Mar 2010
Posts: 19551

View user's profile Send private message

PostPosted: Sun May 22, 2022 11:04 pm     Reply with quote

Very Happy
On the DsPic'x, there are programmable PLL's. On the standard PIC's,
they are only fixed multiples... Sad
kgng97ccs



Joined: 02 Apr 2022
Posts: 97

View user's profile Send private message

PostPosted: Tue May 24, 2022 10:20 pm     Reply with quote

Thank you, Ttelmah. It is good to know that.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group