Period - is a variable/constant which determines the duration of the reduced-power nap (normally 0-7 but M2 parts also support 0-14).
Period Time Delay 0 18ms 1 36ms 2 72ms 3 144ms 4 288ms 5 576ms 6 1.1s 7 2.3s 8 4s 9 8s 10 16s 11 32s 12 64s (1 min) 13 128s (2 mins) 14 256s (4 mins)
Nap for a short period. Power consumption is reduced, but some timing accuracy is lost. A longer delay is possible with the sleep command.
The nap command puts the microcontroller into low power mode for a short period of time. When in low power mode all timers are switched off and so the pwmout and servo commands will cease to function (see the doze command). The nominal approximate period of time is given by this table. Due to tolerances in the microcontrollers internal timers, this time is subject to -50 to +100% tolerance. The external temperature affects these tolerances and so no design that requires an accurate time base should use this command. A hard-reset will always be required during very long naps.
Effect of increased clock speed:
The nap command uses the internal watchdog timer which is not affected by changes in resonator clock speed.
Effect of decreased clock speed:
At 31kHz operation (setfreq k31) a 'nap 1' can cause a reset of the microcontroller. When using 31kHz operation please specify 'nap 0' or use a minimum of 'nap 2'.
Submit Your Own Code!
You must be logged in to submit code examples. Login now.