PDA

View Full Version : Precision NAP or SLEEP



Zebryk
- 28th July 2013, 15:40
I would like to NAP or SLEEP to save power but need to wake up precisely after a random delay. (Yes, that's rather contrary.) I am computing the delay no problem and storing it in a 8Bit variable "Xwait" which is between 67mS to 200mS. I would like to feed the equivalent of NAP or SLEEP with this variable. All I/O is disabled during this period and the uC is a 16F684 using it's 4MHz internal oscillator. 1mS resolution would be great, but as much as 10mS would be acceptable. Setting a timer would be ok as well if NAP or SLEEP are unworkable.(This pseudo random repeat wake-up delay is used to avoid collisions between multiple transmitters.)

HenrikOlsson
- 28th July 2013, 18:56
Hi,
Both NAP and SLEEP uses the wathcdog timer of the PIC so the accuracy depends on the accuracy of the watchdog timer oscillator - a figure you should be able to find in the datasheet for the PIC.

SLEEP is programmed in units of seconds so it won't work for you.
NAP can be set to either 18, 36, 72, 144, 288ms and so on so it probably won't work either.

Timers are usually clocked by the main oscillator which is shut down when you put the PIC into sleep.

You probably need to run a timer with an external x-tal or oscillator in order to keep it running when you power down the actual core.

/Henrik.