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

Pic18f2331 - Configure 10Mhz Crystal Oscillator with 4X Pll

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



Joined: 16 Aug 2010
Posts: 95

View user's profile Send private message

Pic18f2331 - Configure 10Mhz Crystal Oscillator with 4X Pll
PostPosted: Wed Sep 22, 2010 6:06 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 22, 2010 8:29 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Sep 23, 2010 4:14 am     Reply with quote

Remember you also need to update the delay statements as shown in PCM's example.
scottc



Joined: 16 Aug 2010
Posts: 95

View user's profile Send private message

PostPosted: Thu Sep 23, 2010 7:08 pm     Reply with quote

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