Using watchdog timer in your projects

All AVR microcontrollers have internal watchdog timer that can be successfully used in your projects. Atmega328 and other modern AVR microcontrollers have so called Enhanced Watchdog Timer (WDT). It has few very useful features including: separate 128kHz clock source, ability to reset microcontroller and generate interrupt. From hardware perspective watchdog timer is nothing more than simple counter that gives a pulse when it counts up. This pulse can be used either to generate interrupt or simply reset MCU (or do both). Watchdog timer can be reset to zero at any time with simple WDR command, and this is where fun begins. If you enabled watchdog timer, you have to take care and reset it before it fills up and resets MCU. Otherwise if your program hangs or sticks in some… Continue reading