Most of the embedded microcontrollers contain watchdog timers. The watchdog variable timer is literally watchdog. The watchdog timer continuously inspects the program flow. Basically, if the microcontroller program hangs, then the watchdog timer resets it and brings the embedded system back to life.
The idea is elementary. Let’s say, you know, that your program has to be executed during 20ms. And you know that the worst-case scenario is 30ms. Then you set the watchdog variable timer connected to the highest priority interrupt RESET. Once the Watchdog timer is triggered, the timer counts up to the time you set, and then it resets the MCU. The only way to avoid resetting is to send a command to the watchdog timer to start counting. Technically watchdog variable timer is nothing more than a retriggerable one-shot multivibrator.
The use of a watchdog timer may be various. The one mentioned above is like a program execution loop. Once all procedures are performed, the MCU resets and starts over. Another more valuable and most used is for system reset if code failure occurs. You may set some flags indicating the procedure was successful or not. If not, then you can fire a watchdog timer to restart MCU and start over.
The only problem with the watchdog timer is that it runs independently of the rest of the system. It makes debugging problems because you may suspend the system while debugging, and then the watchdog timer runs out and resets the embedded system. But you can always enable or disable the watchdog timer. It is internal. It can be done in software if the watchdog timer is external, then the easiest way to do this to put a jumper that breaks the connection between the watchdog timer and reset circuit.
Watchdog timer plays an important part in RTOS systems. Usually, the main task (high priority task) checks the sanity of the program flow. And if the check fails, the watchdog timer is triggered to reset the MCU.