Embedded Systems & Firmware

Why is it bad practice to kick (reset) the watchdog timer unconditionally inside a 1 ms timer interrupt handler?

  1. AThe watchdog may never be touched from inside an interrupt
  2. BEven if the main processing hangs in an endless loop, the interrupt keeps running, so the watchdog can no longer detect the fault
  3. CKicking every 1 ms damages the watchdog
Show answer and explanation

Answer: B. Even if the main processing hangs in an endless loop, the interrupt keeps running, so the watchdog can no longer detect the fault

A watchdog resets the microcontroller if it is not kicked within a set time, recovering from runaway code. But a timer interrupt keeps firing even when the main processing has hung, so kicking there unconditionally hides the hang. The basic practice is to confirm that the main loop and each task have completed a normal cycle and kick only when all have checked in.

  • A. There is no such rule.
  • B. Correct. Kick only after confirming normal operation.
  • C. Frequent kicking does no damage.
Practice this topic Back to topic

More Embedded Systems & Firmware questions

  1. What is the role of a bootloader in an embedded device?
  2. In devices updated over the air (OTA), why is flash divided into two firmware slots (A and B)?
  3. What is the main purpose of using a microcontroller's sleep mode in a battery-powered embedded device?
  4. A sensor device runs at 10 mA for 1% of the time and sleeps at 10 µA for the remaining 99%. What is the closest average current?
  5. Why does firmware on small microcontrollers often avoid dynamic memory allocation such as malloc?