Electronic – Read AVR watchdog timer

attinyavrwatchdog

AVR Watchdog timers. Is there any way to read the watchdog timer from within the code?

Intended use case: To get an approximate idea (very rough, +/- 1sec) of how long it has been since the watchdog timer was last reset. This would allow my code to guess at how long it's been asleep, without an external RTC or similar.

I've tried looking in the attiny85 datasheet, and not found it. Any ideas people?

Best Answer

Set the watchdog to 1s second, then set it in interrupt mode, when the interrupt happens the watchdog set itself again to Reset mode and then your code has to manually set it to interrupt mode, that way you can use the watchdog timer as a 1 second timer and the still have the watchdog functionally because if after the interrupt execution there is a one second window to set the watchdog to interrupt mode before the timer expires and reset the micro. I have use the watchdog this way in an attiny10