Home > Software design >  Watch Dog timeout is to short
Watch Dog timeout is to short

Time:01-05

I have a conceptual question, I'm currently working on a project that have to implement a watch dog timer to ensure that the code works properly, I'm using a STM32F4, from the datasheet I can see that the max timeout allow by the IWDG (independent Watch Dog) is 32768 ms, I'm using a SIM800L for communication via GPRS, so some communications take longer than that, during this process the UC is busy waiting for the answers, so it cannot reset the IWDG, so I was thinking on deactivating the Watchdog in those parts, or implement my own watch dog whit a timer and a simple reset function so can make longer timeout periods.

My question is:

¿is this a sign of a flaw on my code design?, ¿should instead adapt my code to reset the IWDG every 30 seconds or so and never deactivating it?, ¿implementing my own WDG whit a timer is a bad practice?

Can anyone give some feedback on this

I'm looking to have better codding practices.

CodePudding user response:

¿is this a sign of a flaw on my code design?, ¿should instead adapt my code to renew the IWDG every 30 seconds or so?

No, you simply need to write the key register or load a new value to the downcounter before the downcounter reaches zero. It shows the watchdog that your software is alive and no reset is needed.

during this process the UC is busy waiting for the answers, so it cannot reset the IWDG

This means that your implementation is bad. You need to implement it non-blocking way. It is not dificult.

¿implementing my own WDG whit a timer is a bad practice?

It is a very bad idea. What will happen if your program hardfault? Your own watchdog will be useless. Hardware WDG is also clocked from its one clock source - so if your program does something wrong with the clocks - it will still working

CodePudding user response:

I don't think you can stop the IWDG once it starts (nor would you want to). I'm not familiar with the SIM800L, but your best bet would be to find a way to kick the watchdog intermittently while GPRS is operating. You want to do this in firmware, not hardware. (Don't use a HW timer to kick the WDT because if your SW crashes, the HW timer could keep doing its thing.) Alternatively, the STM32F4 also as a window watchdog (WWDG) timer you could use. You might be able to configure longer window times with the WWDG.

  • Related