Library 20- Independent watchdog timer on STM32F4

Sometimes you need watchdog timer to look at your system if it gets stuck. I made a little library to work with it.

Watchdog in STM32F4xx device has it’s own clock which is independent from main system clock. You have to constantly reset it’s counter value or it will elapse and reset MCU.

Watchdog Library


  • Detect if system was reset by watchdog
  • Supports different timeouts
  • Reset watchdog


    • STM32F4xx
    • STM32F4xx RCC
    • STM32F4xx IWDG
  • TM
    • defines.h

Timeout structure

I made a structure with different timings for watchdog reset.

Initialize watchdog timer

Before you can use it, you have to initialize it. Function below initializes watchdog timer.

As parameter you have to pass one of members of watchdog structure.

This function returns 1 if system was reset by watchdog, otherwise 0.

Reset watchdog timer

You want system reset by watchdog only if system stuck somewhere. So you don’t want that watchdog reset your system all the time. For this, you have to reset timer’s counter periodically faster than he can count to it’s top value.

Reset timer with


Project available onĀ Github, download library below.


Owner of this site. Application engineer, currently employed by STMicroelectronics. Exploring latest technologies and owner of different libraries posted on Github.

You may also like...