I'm trying to set up a watchdog timer interrupt to execute a routine in the WDT_vec ISR at some recurring interval. I don't want the processor to reset, just to execute the code in the interrupt and return to "normal" operation. I have the following test jig appropriated from the 'net that claims to set that up:
#include <avr/wdt.h>
void setup_WDT() {
noInterrupts(); // disable all the interrupts
MCUSR = 0; // ensure that the reset vectors are off
/* Disable and clear all Watchdog settings. */
_WD_CONTROL_REG = (1 << WDCE) | (1 << WDE);
_WD_CONTROL_REG = 0;
/* Setup Watchdog for interrupt and not reset, and a approximately 500ms timeout */
_WD_CONTROL_REG = (1 << WDIE) | (1 << WDP2) | (1 << WDP0);
interrupts(); // re-enable interrupts
}
void setup() {
setup_WDT();
Serial.begin(9600);
Serial.println("Startup");
}
void loop() {
}
ISR(WDT_vec) {
Serial.println("Watchdog Interrupt");
}
The output indicates that the processor is just resetting repeatedly and never reaching the ISR. Also I get the following warning on compilation from the IDE (Arduino 1.8.2):
warning: 'WDT_vec' appears to be a misspelled signal handler, missing __vector prefix [-Wmisspelled-isr] ISR(WDT_vec) {