I'm fairly new to 'sleep' (fairly new to PICs and programming come to that), but if you intend using sleep, then I'd suggest dedicating Timer1 to any counting that must happen while asleep.
I'm not sure I'm understanding this sentence...
When you say increment all counters....from what? (I guess a bit more meat on the bones wrt what's happening in your circuit)I have assumed that the device would go to sleep, wake up via the interupt (which would be accurate), then increment all the counters & check the conditions and set outputs etc. all from inside the interupt rountine.??
How I'm doing it...
pic goes to sleep (timer 1 still counts while asleep)
WDT wakes PIC up (pretty accurately)
the PIC while briefly awake (digesting toast & supping coffee), checks timer1 blah blah
pic then goes back to sleep
WDT wakes pic up, the kettle goes on...rinse repeat.
To save more battery power, I set the WDT period initially to wake the pic up every 128mS, but then after 2 hours of no buttons being pressed (no humans about), the WDT only wakes the PIC up every 2 seconds (I have to change timer1's prescalers to reflect the longer 'sampling period'). As an aside, I've got my overall 'sleep' circuit current draw down to 10uA ....I'm pretty happy with that ( about 6 years in standby for a single 9v battery)
I've still not learned a good way to approach all the loop timing thoughs (& yes, it's a PITA when you change parts of your loop...the timing then go out the window!)...I use online stopwatch & hserout a lot!
Bookmarks