Go Down

Topic: Is there a way to read the WDT timer/counter value? (Read 349 times) previous topic - next topic


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:

  // 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!



Oct 12, 2017, 01:48 pm Last Edit: Oct 12, 2017, 01:50 pm by Budvar10
No, there is no way to read WDT counter. You can just to reset it. Maybe you could describe your motivation.
Normally you should do the WDR (reset) immediately. Why to wait?
Remember the seconds or time just before the WDR call.
Arduino clone with ATmega1284P   http://forum.arduino.cc/index.php?topic=277260.0


Maybe you could describe your motivation.
I have to measure the duration of some external events (PCINT), and I also need to put the device to sleep as often as possible while doing this.


How precise do you need it to be? You could set the WDT to e.g. 250ms and count the wake events until your external interrupt fires. This would give you a resolution of 0.25 seconds without introducing much time awake.
Also take into account that the WD timer is not very precise compared to the normal processor clock
[EDIT] set the WDT to interrupt mode, of course


WDT is not very precise. Use asynchronous timer with watch crystal.

Go Up