Turn-key PCB assembly services in prototype quantities or low-volume to mid-volume production runs

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 infinite loop without reset watchdog simply counts up and resets system. In this case we get pretty good program guardian who keeps an eye on program flow. In other special cases watchdog can serve as simple software-based MCU reset source. Continue reading