PDA

View Full Version : clarification of SLEEP command?



picster
- 4th May 2023, 20:25
<edit> - found this answered more or less elsewhere - no precision, it's WDT based.

In the manual, it states that the SLEEP Period command puts the uC in low power mode for Period seconds, BUT it wakes up "periodically" using the WDT and the internal RC clock, to CHECK and see if time is up.

My question is, does it use the WDT for counting ticks while "sleeping", or does it use its defined OSC for doing that part while sitting there doing nothing else? I understand the concept of it waking up now and then to check, but... is the periodic waking up cycle actually doing the counting itself, or is the uC doing the counting with the high precision OSC while in "sleep" mode?

I have used NAP, but it seems to be quite a different animal, from the descriptions. I want something that puts the chip into low power for a certain period of time (i.e. - 12 hours) with precision (within 2 seconds is fine).

TIA

picster

mpgmike
- 4th May 2023, 21:28
The High Speed Oscillator is shut down in SLEEP Mode, therefore the WDT relies on the 32 kHz LFINTOSC. This can be internal or external. You didn't mention which PIC you're using, but the WDT will have scalers (Pre- or Post-) to divide the 32 kHz for longer durations. The more clock divisions, the less precision you can achieve. You may need to create a Variable that can be incremented each time the WDT wakes the PIC from SLEEP. When the Variable reaches a predetermined value (equating to your 12 hours), you then go to your MAIN Function and do some work. Some PICs will allow you to achieve 12 hours in a single session. The Data Sheet will give you the details for your chosen PIC.