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

Checking the Oscillator is stable after changing speed

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







Checking the Oscillator is stable after changing speed
PostPosted: Fri Sep 10, 2004 6:45 am     Reply with quote

How can I check the internal osciallator is stable before continuning with some time sensetive code?

I'm changing from 31kHz to 8MHz using setup_oscillator(OSC_8MHZ);

I then want to sit in a loop until the 8Mhz clock is stable (IOFS is set).

Version of compiler: 3.207
Target PIC Microcontroller: 16F737

thanks,

Gary
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri Sep 10, 2004 6:59 am     Reply with quote

The usual way is simply to wait some amount of time that is known to be long enough for the oscillator to settle.
I can think of two ways one could confirm that the oscillator is stable. 1) Use a counter to measure a known stable clock vs. the 8MHz and see if the result is stable and accurate. 2) use an FM discriminator circuit (hardware) to check the stability of the clock.
What is you application?
_________________
The search for better is endless. Instead simply find very good and get the job done.
Guest








PostPosted: Fri Sep 10, 2004 7:04 am     Reply with quote

I'm doing a bit of code (which takes a variable amount of time to complete) every 50ms or so. When my code is done I'm dividing the time left in timer1 by 256 and slowing the clock down to 31.2kHz to save power. When timer1 overflows I'm speeding back up and doing my bit of code again. This includes RS232 transmissions and receptions which are currently getting garbled when I add in the slow down.

Does that make sense?

Gary
mcafzap



Joined: 07 Sep 2003
Posts: 46
Location: Manchester, UK

View user's profile Send private message

PostPosted: Fri Sep 10, 2004 8:06 am     Reply with quote

Deleted.

Sorry. Must read the discussion before opening mouth... .
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri Sep 10, 2004 8:12 am     Reply with quote

I think I would tweak the caps and drive resistor on the crystal to get the settling time as short as I could and then just use a time delay. Watch for extreems of voltage and temperature though. I might use an external analog oscillator too to avoid the variability of the PIC's built in oscillator if it is a high volume product.
_________________
The search for better is endless. Instead simply find very good and get the job done.
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