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 support@ccsinfo.com

How to use PLL mode and internal osc on 18F26x0 ?

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



Joined: 26 Sep 2004
Posts: 32

View user's profile Send private message

How to use PLL mode and internal osc on 18F26x0 ?
PostPosted: Fri Dec 30, 2005 4:26 am     Reply with quote

I would like to use the internal 8 MHz osc and to multiply it with the PLL to 32 MHz, but i donīt know how to set the fuses

is the following configuration correct (only concerning the osc):

Code:

#include <18F2620.h>
#device *=16
#fuses INTRC_IO, NOIESO,NOBROWNOUT,NOWDT,NOPUT,STVREN,NOLVP,NOFCMEN,NOXINST,NOPBADEN,NOMCLR
#use delay (clock=32000000)


Does the compiler know how to activate the PLL to achieve the 32 MHz ?

Or should i use:

Code:
   setup_oscillator(OSC_32MHZ | OSC_INTRC | OSC_PLL_ON);
Ttelmah
Guest







PostPosted: Fri Dec 30, 2005 4:55 am     Reply with quote

Looking at the chips data sheet.
Oscillator configurations:
LP
XT
HS
HSPLL
RC
RCIO
INTIO1
INTIO2
EC
ECIO

The chip itself, does not support using the PLL, with the internal oscillator, _on the setup fuses_.
If you then read on, you find that in INT OSC mode, the PLL, is enabled instead, by the control bit 'PLLEN', which has to be setup after boot. If you then look at the include file for the chip, under the section for 'setup_oscillator', you find the entry 'OSC_PLL_ON'.
So if you use:

setup_oscillator(OSC_8MHZ | OSC_PLL_ON);

or

setup_oscillator(OSC_32MHZ);

Which has the two constants already 'ored' together, then the chip will enable the PLL.
The compiler may be 'smart' enough to do this automatically, with the configuration you give, but I'd not rely on it....

Best Wishes
newby



Joined: 26 Sep 2004
Posts: 32

View user's profile Send private message

another CCS bug...
PostPosted: Fri Dec 30, 2005 10:06 am     Reply with quote

fixed it and got another problem:
my problem has "nothing" to do with the osc settings

try the following code - it wonīt work, then comment //#zero_ram and it works !!!

I tried to put in the #zero_ram on different positions, as long as it is inside, it doesnīt work....

Code:
#zero_ram
#include <18F2620.h>
#device *=16
#fuses INTRC_IO, NOIESO,NOBROWNOUT,NOWDT,NOPUT,STVREN,NOLVP,NOFCMEN,NOXINST,NOPBADEN,MCLR
#use delay(clock=32000000)


void main() {
   While (TRUE)   {
      output_toggle(PIN_A0);
   }
}
Ttelmah
Guest







PostPosted: Fri Dec 30, 2005 10:41 am     Reply with quote

#ZERO_RAM, has caused a lot of problems, for a lot of people. Why use it? If I want variables to contain 0, just declare them to contain this value. ZERO_RAM, on larger chips, takes a long time, and (though it does not apply in your case, since the WDT is disabled), is almost unuseable with the watchdog timer enabled since it takes too long to complete on bootup.

As a minor comment, get rid of the #device *=16 declaration as well. This is _not needed_on the 18 chips. It only applies to the 12/14/16 family chips. It should not be doing anything, but why ask for problems.

I wonder if the #zero_ram, really is stopping it working. Try leaving it for a minute or two. I may be that the oscillator configuration, is not being set, till _after_ the execution of this instruction. The default bootup oscillator is 32KHz. With 3968 bytes of data memory, and assuming that it may well take about ten instructions per byte to select, clear, and loop, at 32K, it'll take about 5 seconds to clear the memory.

Best Wishes
Guest








PostPosted: Fri Dec 30, 2005 12:04 pm     Reply with quote

thanks a lot for this very interesting comments, i will follow them !

I will wait for several minutes to clearify if zero_ram does what it should do !
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