Back to Basics – Watchdog Timers(WDTs)

WDTs are probably one of the most skipped sections in an embedded system because a first-time firmware engineer firmly believes that the code that they wrote is 100% bug-free. Somehow they feel that it’s not needed because they have put the code through tons of testing and still couldn’t crash the firmware. Seasoned folks will tell you that this is absolutely wrong, users on the field will definitely find ways to break your system. WDTs are an absolute necessity for anything which you ship out.

So what are they basically? A WDT is a type of timer that is used to detect and recover from system hangs. It works by continuously monitoring the system and resetting itself after a certain period of time. If the system fails to reset the timer(meaning it has gotten stuck somewhere) before it expires, the WDT will trigger a system reset or other recovery action. It’s analogous to you petting a dog at a constant interval and the moment you stop or miss the petting, the dog will bark/bite to alert you. Hence the name “Watchdog”.

There are diff variations of WDT. Internal WDTs are something which you find commonly in new-age controllers wherein a certain section on the chip is a dedicated timer to perform the WDT. External WDT variant usually utilises an external chip to perform the same. The general consensus is that for anything mission-critical you use an External WDT, just avoid the hardware locking up in some extremely brutal edge cases if you can afford to have that extra part. WDTs in general are not only used for a hard reset, sometimes can be multi-staged wherein you can trigger Action#1 when Timer#1 runs out via interrupts and so on and give the system to correct it and the last one being a hard reset. Some internal WDTs can be used to trigger an interrupt and then give certain processing clock cycles so that some debug state info can be saved before issuing a hard reset.

It’s an understatement to mention that WDTs are essential. NASA Clementine moon spacecraft in 1994 was a casualty of badly implemented WDT in software whereas Mars Pathfinder had a well-built WDT which saved millions of dollars.

If you liked the post, Share it with your friends!

Comments are closed.