cancel
Showing results for 
Search instead for 
Did you mean: 

Watchdog timers and Sleep Mode

dimasusl
Associate II
Posted on July 02, 2009 at 19:20

Watchdog timers and Sleep Mode

2 REPLIES 2
dimasusl
Associate II
Posted on May 17, 2011 at 13:16

Hi, everyone!

My application must be in low power mode as often as possible, so i use sleep mode with WFE instruction (it is more convenient for me). But at the same time i need in using watchdog timers.

How can i update(reload) watchdog counters while sleep mode during? Usually it is making in some interrupt handlers (WWDG_IRQHandler for example), but after interrupt occurs, MCU exit from sleep mode.

miles
Associate II
Posted on May 17, 2011 at 13:16

You can't pet the watchdog while asleep, and if you could, it'd defeat the purpose of having a watchdog. The point of a watchdog is that you pet it in a place in the code that you get to if everything is ''okay'' (for however you'd like to define ''okay'').

If you want to keep the watchdog running, you can set a timer to wake the MCU off at least slightly more often than the watchdog period. Then when the timer wakes you, do whatever verification of everything being ''okay'', and if it is, pet the watchdog. The ''Independent Watchdog'' is configurable to run at a period as long as 26 seconds, so you could wake the MCU every 25 seconds to pet the watchdog, and you will hardly impact battery life. Personally, I'd have the watchdog period a lot shorter than that, and wake up more often to check for everything being 'okay' (I doubt you save much battery by sleeping for 25 seconds, compared to sleeping for 2 seconds. Either way you will only wake up for less than a millisecond. You ought to calculate power consumption (or better yet, measure it), and set the watchdog and the 'wakeup' timer appropriately).