AnsweredAssumed Answered

Watchdog timer is not working properly - STM32F051K8

Question asked by pham.thai on Aug 15, 2014
Latest reply on Nov 12, 2015 by zemni.ismail.002

I am having a weird problem with Independent Watchdog timer in my STM32F051K8. Here is my initialization:

IWDG ->KR = 0x00005555;
IWDG ->PR = 0;
IWDG ->RLR = 0x000003FF;        // Reload value 1023*(1/(40kHz/4)) = 0.1s
IWDG ->KR = 0x0000AAAA;     // reload the counter with RLR
IWDG ->KR = 0x0000CCCC;             // Enable downcount of IWDG

Every 20ms, if I still see my input signals, I will reset watchdog counter. If I don't, watchdog should reset the MCU every 0.1s

This code works fine in my 1st project. I am working on 2nd project, and most of the time, my watchdog doesn't do anything. Sometimes it behaves like this:

Power on -> reset after 3+ minutes -> reset after a few seconds -> reset every 0.1s (as expected)

I am thinking about my supply circuit, the schematic is a little bit difference between 2 projects. Are there any strict rules in powering up an MCU, so the clocks can work correctly? (I am using 8 MHz HSI clock)

Any suggestions about where I should look into would help. (brown out protection, schematic design, clocks initialization, etc.)

Also when the watchdog is not working, other peripherals work just fine. I can communicate through USART and run my motors.

Thank you.