Greetings everybody!
I apologize if this was asked before; this is the problem (for atmega 1284P):
1. I enable the watchdog (8 seconds)
2. I put the device (atmega1284P) to sleep in power-down or power-save mode.
3. A PCINT wakes it up
before the 8 second timeout.
4. I need to know how log it slept.
I'd really like to avoid using the Timer2, since it can only count a maximum of 256 * 1024 MCU cycles (it has an 8 bit resolution and a maximum pre-scale factor of 1024).
The code looks something like this:
wdt_enable(WDTO_8S);
sleep_cpu();
...
ISR(WDT_vect)
{
// Here's where I need to know how long the device slept. I need milliseconds, or MCU cycles, or Watchdog oscillator ticks, or whatever else.
}
Thanks a lot!
Bogdan.