I originally coded the ISR to be a "catch-all" in the event an unexpected issue causes a lock-up, there is no actual issue to debug at the moment. I know nothing can be done if the offending code is located in the ISR.
bperrybap - I am using 1.0.1. I have seen plenty of watchdog examples which have a Serial.println in the ISR, they must have been written pre-1.x.
Nick - The "while" is in the ISR so the watchdog will timeout a second time and cause a reset. I remember reading somewhere that in order to get both the interrupt and the reset, I need to trigger the watchdog twice. Let me know if this isn't true or if there is a better alternative. I tested your claim of interrupts being disabled in the ISR and you're spot on. I altered the ISR as below and it works. The delay is needed to allow time for Serial.println before disabling interrupts again.
ISR(WDT_vect)
{
detachInterrupt(1);
detachInterrupt(0);
sei();
Serial.println("Watchdog triggered");
delay(50);
cli();
pinMode(6, OUTPUT);
digitalWrite(6, HIGH);
while(true);
}
I found this is also the reason the MicroSD doesn't work in the ISR. Is there a way to write to Serial/MicroSD without interrupts enabled? If not, what would be the best alternative?
I was thinking of writing to the EEPROM when in the ISR. Then in setup, read the EEPROM, write to MircoSD and continue on as normal. If anyone wondering why add the MicroSD to the mix, all other data is logged to it and I would like to have a central location.
Thanks everyone for the advice.