Checking the Oscillator is stable after changing speed
Posted: Fri Sep 10, 2004 6:45 am
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
Posted: Fri Sep 10, 2004 6:59 am
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
Posted: Fri Sep 10, 2004 7:04 am
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
Posted: Fri Sep 10, 2004 8:06 am
Deleted.
Sorry. Must read the discussion before opening mouth... .
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
Posted: Fri Sep 10, 2004 8:12 am
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.
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