2025-06-08 11:35 PM - edited 2025-06-08 11:37 PM
Hi,
I have a situation where the configured watchdog on my STM32L031 does not trigger even though the MCU gets stuck in an I2C function. In my program flow, I first run through some initializations (as well as I2C_Init()) and then start the IWDG (Start_WDG()). I then try to establish an I2C connection to another device. In some cases this fails and I get stuck on line "while(!(I2C1->ISR & I2C_ISR_TXIS));". Surprisingly, in this situation the watchdog does not trigger as expected. I am of course aware that the code in this form is not properly programmed and error handling in this situation solves the problem (implemented a timeout which itself does a system reset). Nevertheless, it would be interesting to know why the IWDG in this version does not trigger.
Thanks in regard.
Greetings from Salzburg
2025-06-09 2:33 AM - last edited on 2025-06-09 2:42 AM by Andrew Neil
Yes a proper error handling is in deed a solution here and the way i did it to solve my problem. Never the less, a system reset would be OK for me and the process is suited for that. Like i mentioned after a reset i check the reset control bits and would recognize whether the reset was triggered by the WDG or not.
2025-06-09 2:55 AM
There is one ISR which again triggers the I2C_Read function i already postet. But this shouldn‘t have an effect on the IWDG neither?!
2025-06-09 3:38 AM
The whole purpose of IWDG is being an independent livesaver. And, since L0 was already introduced ca. 2014, such an issue would have be detected earlier and mentioned in the device errata, but it is not. So there are perharps other issues in your code. There are some I2C related errata mentioned, so check that carefully. Also make sure to understand what the MCU exactly does. Like by logging NRST and more pins with a scope or (cheap) logic analyzer or by adding blinky codes, extra delays,.... You may also comment the DBGMCU freeze line out and not pausing the debugger during tests.
The while loop checks for transmit interrupts, so "getting stuck" at that line simply means that there is no more transmit interrupt activity.
hth
KnarfB