Electronic – How to stop/reset the watchdog timer from low-power sleep mode on an STM32L0C8

microcontrollersleepstm32watchdog

On an STM32L0C8 MCU, I have the watchdog enabled while executing. At certain points in execution, I would like the chip to go into low power sleep mode. When it goes into low-power sleep mode though, the watchdog timer remains activated and will reset the entire MCU after the timer goes to 0, making it seemingly impossible to use both the watchdog and low-power sleep mode at the same time.

My question is, how do I refresh the countdown timer while in low-power sleep mode or how do I disable the WDT to stop it from resetting the MCU?

I looked all around the reference manual linked below to figure out how to disable / refresh the timer but it seems like this isn't possible. On page 514 it says:

20.3.4 Behavior in Stop and Standby modes
Once running, the IWDG cannot be stopped

(IWDG being the Independent Watchdog) but it doesn't say anything about low-power sleep mode. In multiple other areas it suggests the same thing, that the IWDG can't be stopped. Am I missing something? Are we not supposed to use the watchdog if we want to go into sleep mode? Is it possible to modify the watchdog countdown timers code to stop decrementing before entering sleep mode? Please let me know!

Reference Manual:
http://www.st.com/content/ccc/resource/technical/document/reference_manual/21/bd/0f/bd/1c/88/40/f0/DM00108282.pdf/files/DM00108282.pdf/jcr:content/translations/en.DM00108282.pdf

Best Answer

The watchdog is only stopped on system reset. This way you can't accidentally turn it off.

If you want to use sleep modes and watchdog, you will have to set the watchdog the slowest clock, and wake-up regularly to restart the watchdog.

This is valid for almost all microcontrollers on the market that have an independently clocked watchdog.