PDA

View Full Version : NAP vs. SLEEP



AvionicsMaster1
- 5th August 2011, 14:12
Is the major/only difference between NAP and SLEEP the time during which the processor is powered down?

I'm using a 12F683 and the data sheet only describes SLEEP. The PBPRO manual adds "short " to the description of NAP so I'm inclined to think the only difference is the time in which the processor is powered down.

I'm ready to get schooled.

Darrel Taylor
- 5th August 2011, 16:42
NAP puts the PIC to sleep for ONE watchdog timer period.
This is similar to the PIC's SLEEP instruction except that NAP sets the watchdog period first.
Depending on the PIC being used, periods are ~18mS or greater per NAP.

SLEEP uses multiple WDT periods, and approximates the requested time to 1 second resolution.
Thousands of WDT periods may be required, depending on the requested SLEEP time.
On each WDT timeout, the PIC wakes up ... checks to see if the SLEEP time is complete ... if not it decrements a counter and goes back to sleep again.

Archangel
- 7th August 2011, 04:50
Ugh, Darrel,
the sleep you refer to is PBP sleep correct?
Would you please explain how @ SLEEP works if it is different?
Thank You
JS

Darrel Taylor
- 7th August 2011, 14:19
@ SLEEP is used by both of the PBP commands NAP and SLEEP.
It is the ASM instruction that puts the PIC into Low Power Mode.

NAP and SLEEP have additional code to control the amount of time the PIC is in that mode by setting the WDT period and counting its timeouts.
If the WDT is disabled, @ SLEEP and NAP are functionally the same, and the PIC will remain in L.P. mode untill an interrupt wakes it.

Archangel
- 8th August 2011, 19:47
Thank You ! That is what I was unsure about.