tag:blogger.com,1999:blog-4172950626830217643.post4198023058280685268..comments2024-03-29T08:45:30.697-04:00Comments on Better Embedded System SW: How Long Should You Set Your Watchdog TimerPhil Koopmanhttp://www.blogger.com/profile/11849599272360094243noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-4172950626830217643.post-85551391615680188012018-05-03T12:35:08.816-04:002018-05-03T12:35:08.816-04:00The easy fix is to turn the watchdog on after init...The easy fix is to turn the watchdog on after initialization and before the main loop starts. This has the disadvantage of leaving you vulnerable to infinite loops in your initialization.<br /><br />A better fix is to put watchdog kicks at a few places in your initialization, but NOT inside loops. Ideally this is done in a way that it is extremely easy to determine via code inspection that there is no way for the init to stall. For example:<br /> init_part_1();<br /> kick();<br /> init_part_2();<br /> kick();<br /> .. main loop...<br />Phil Koopmanhttps://www.blogger.com/profile/11849599272360094243noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-73827807481678919732018-05-03T03:01:34.385-04:002018-05-03T03:01:34.385-04:00Hi Mr.Koopman,
Because my init.h code takes too l...Hi Mr.Koopman,<br /><br />Because my init.h code takes too long, the watchdog is triggered, and because of this my init.h code is called again. How to avoid this infinite loop? -Thanks!<br /><br />-TomAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-75010527827639660242016-01-14T09:45:04.315-05:002016-01-14T09:45:04.315-05:00This is a very reasonable question and I see this ...This is a very reasonable question and I see this practice in real systems. But it doesn't quite prove the tasks are alive. It just proves they are being scheduled/initiated successfully.<br /><br />Yes, you'll kick the watchdog periodically. The potential issue is that this kick strategy tells you that you are starting the task every period, but not that you end the task. If your task throws an exception and terminates early you'll still kick the watchdog.<br /><br />So, my recommendation is to kick at the end of the task to make sure you actually run the entire task to completion.Phil Koopmanhttps://www.blogger.com/profile/11849599272360094243noreply@blogger.comtag:blogger.com,1999:blog-4172950626830217643.post-14513969017975461572016-01-14T07:48:51.566-05:002016-01-14T07:48:51.566-05:00Hi,
Forgive me if this is a silly question:
If yo...Hi,<br /><br />Forgive me if this is a silly question:<br />If you have a task that is scheduled periodically, for example at 100ms as in the text above, and also assuming you have a soft deadline (that is, the task is allowed to run to completion, regardless of whether it exceeds the 100ms or not), is there any reason why you cannot kick the watchdog at the beginning of the period, ie. before the first instruction of each execution? In this case the maximum and minimum watchdog interval is entirely predictable: 100ms +/- some margin for jitter.<br /><br />Thanks,<br />Chris.Anonymousnoreply@blogger.com