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

Setting Oscillator speed and Reseting it?

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



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

Setting Oscillator speed and Reseting it?
PostPosted: Wed Aug 30, 2006 12:42 am     Reply with quote

Hi

I have an external 4MHz Xstal. I need relatively accurate timing and I use the standard #use delay (clock=4000000)

The first part of my code however, the initialization part, does not care for accurate timing, and has to be done as quickly as possible.

I was thinking of:
(a) Using the internal oscillator to run at the maximum 8MHz to do all the initialization (this will speed up the initialization 2 times?)
(b) Resetting to using the external Xstal to run the remainder of the code.

Is this possible?
and if yes, can someone please tell me how to do this?

Thank you in advance.
a.
Ttelmah
Guest







PostPosted: Wed Aug 30, 2006 2:36 am     Reply with quote

You need to say 'what chip'...
The details of the options available for setup_oscillator, are in the chip's header file. However (you will need to check, for your chip), probably:
Code:

setup_oscillator(OSC_8MHz | OSC_INTRC);
//perform initialisation

setup_oscillator(OSC_NORMAL);


Best Wishes
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Wed Aug 30, 2006 2:53 am     Reply with quote

Hi Ttelmah

Thank you - it works! that is great.

I am using the 18LF4550.

Now I have two more question:
(a) I looked up the header information.
And it says for the 4550 I can use as high as OSC_32MHz.
I looked up on the data sheet for this chip, and it says that
the internal oscillator can go only as highn as 8MHz.
Could you please explain this difference?

Also, I am using Vdd=3V; the data sheet says I can go up to 16MHz Xstal. Does this apply to the internal oscillator as well? i.e. can I go only to 16MHz with the internal oscillaotr? (assuming that the header file is right)

Thank you once again
a.
Ttelmah
Guest







PostPosted: Wed Aug 30, 2006 4:10 am     Reply with quote

The data sheet, does not say that you can go to a 16MHz crystal at 3v. The chart you are referring to, says you can go to a 16MHz _clock_. This is an important difference on the latter chips. On many chips for example, the maximum 'crystal' frequency is 25MHz, but the maximum 'clock' frequency is 40, or 48Mhz. The difference here is that you can use a slower crystal with the *4PLL, or use an external oscillator.
Now, at 3v, the actual 'processor', is not warranted to run above 16Mhz (it almost certainly will run well above this, but not if you want reliability...). Hence, yes, of course this limit applies when using the internal oscillator.
The internal oscillator, can run a up to 8MHz, but again the *4PLL can be used, to give a 32Mhz master clock. However at 3v, the highest guaranteed to work, is the 16MHz option.
If you look at the definitions, 16MHz, is 0x4060. The defintion for a 4MHz oscillator, is 0x60, and the definition for the *4PLL, is 0x4000. Or the two together, and you have the '16Mhz' definition.

Best Wishes
arrow



Joined: 17 May 2005
Posts: 213

View user's profile Send private message

PostPosted: Wed Aug 30, 2006 5:29 am     Reply with quote

Hi Ttelmah

Thank you for your thorough explanation.

However, I tried:

Code:

setup_oscillator(OSC_8MHz | OSC_INTRC);


and it worked!

I tried:

Code:

setup_oscillator(OSC_16MHz | OSC_INTRC);


and it *did not* work. In fact it seems that it skipped this comment
and just uses the Xstal (4MHz).

Are there commands that I have to use for the *4PPL to be initialized?

Thank you once again.
a.
Ttelmah
Guest







PostPosted: Wed Aug 30, 2006 7:17 am     Reply with quote

Unfortunately, I suspect this is a fault in the include file...
Looking at the data sheet for the 4550, it shows the required bit (bit 6 of the OSCTUNE register) as 'not used'. Chips like the 4525, have an extra 'PLLEN' bit here. I'm afraid you'll have to make do with 8MHz, and drop a 'moan' to CCS. The fault exists in the include file for V4 as well...

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