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

PLL with internal oscillator

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







PLL with internal oscillator
PostPosted: Fri Sep 19, 2008 7:34 am     Reply with quote

I am struggling to set up the PLL on a 18F4680. In the data sheet it says that the PLL should be software enabled;
Quote:
The 4x frequency multiplier can be used with the internal
oscillator block to produce faster device clock
speeds than are normally possible with an internal
oscillator. When enabled, the PLL produces a clock
speed of up to 32 MHz.
Unlike HSPLL mode, the PLL is controlled through software.
The control bit, PLLEN (OSCTUNE<6>), is used
to enable or disable its operation.


The help file does not say how to enable the PLL correctly with the internal oscillator.
Quote:
//application is using a 10Mhz oscillator, but using the 4x PLL

//to upscale it to 40Mhz. Compiler will set H4 config bit.

#use delay(clock=40M, oscillator=10M)


//application will use the internal oscillator at 8MHz.

//compiler will set INTOSC_IO config bit, and set the internal

//oscillator to 8MHz.


The header file has the following in it.
Quote:
#define OSC_PLL_ON 0x4000


I don't know what is required to enable and run the pic from the internal oscillator with PLL enabled.
I tried the following but I don't know if this is correct.

Code:
#fuses H4,NOWDT,NOPROTECT,PUT
#use delay(clock=32M, internal=8M)


Can someone please advise and explain to me how this is supposed to be setup and how it works.
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

Re: PLL with internal oscillator
PostPosted: Fri Sep 19, 2008 11:17 am     Reply with quote

You just need to do what the datasheet says and set the PLLEN bit (6) in OSCTUNE.

Just because you can't find a CCS library function to do something, that does not mean you have to give up. You can always talk directly to registers as follows:
Code:

#byte OSCTUNE=0xF9B
#define PLLEN 6
 . . .
  bit_set(OSCTUNE,PLLEN);

_________________
Robert Scott
Real-Time Specialties
Embedded Systems Consulting
Ttelmah
Guest







PostPosted: Fri Sep 19, 2008 2:33 pm     Reply with quote

Actually, the library function is already doing this.
The problem is in using the H4 fuse. For the internal oscillator, you need to use the RC fuse.
You can just use:
Code:

#fuses RC,NOWDT,NOPROTECT,PUT
#use delay(clock=32M)

//and the compiler will do it all automatically
//Or:

setup_oscillator(OSC_8MHZ | OSC_PLL_ON);

//Or:

setup_oscillator(OSC_32MHZ);

But you _must_ use RC, or RC_IO fuse for it to work. Setting the OSCCON bit will work once the chip is running, but it won't even run, with the H4 fuse, and no external crystal or oscillator...

Best Wishes
elrix



Joined: 25 Sep 2008
Posts: 1

View user's profile Send private message

PostPosted: Mon Sep 29, 2008 2:59 pm     Reply with quote

Ttelmah wrote:
Actually, the library function is already doing this.
The problem is in using the H4 fuse. For the internal oscillator, you need to use the RC fuse.
You can just use:
Code:

#fuses RC,NOWDT,NOPROTECT,PUT
#use delay(clock=32M)

//and the compiler will do it all automatically
//Or:

setup_oscillator(OSC_8MHZ | OSC_PLL_ON);

//Or:

setup_oscillator(OSC_32MHZ);

But you _must_ use RC, or RC_IO fuse for it to work. Setting the OSCCON bit will work once the chip is running, but it won't even run, with the H4 fuse, and no external crystal or oscillator...

Best Wishes


Hello,

I have exactly the same problem with a PIC18F2520 and I can't activate the PLL. If I use an external crystal all is OK but with INTRC_IO, it doesn't work (I have the 8MHz int oscillator). With RC or RC_IO the PIC simply doesn't start at all.

I've tried the listed solution but none worked for me.
My compiler version is 4.049 and I can't afford a new update.
Please note that I've tried the solution with direct access to the PLL register another time with no success. If you have an idea....

Thanks

EDIT: Well after a lot of tries it works sorry for the last message
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