diff --git a/Ports.cpp b/Ports.cpp index 46d8edc1..910b8253 100644 --- a/Ports.cpp +++ b/Ports.cpp @@ -1099,19 +1099,21 @@ const word* ColorPlug::chromaCCT () { // ISR(WDT_vect) { Sleepy::watchdogEvent(); } static volatile byte watchdogCounter; +static byte backupMode = 0; void Sleepy::watchdogInterrupts (char mode) { +#ifndef WDTCSR +#define WDTCSR WDTCR +#endif // correct for the fact that WDP3 is *not* in bit position 3! if (mode & bit(3)) mode ^= bit(3) | bit(WDP3); // pre-calculate the WDTCSR value, can't do it inside the timed sequence // we only generate interrupts, no reset - byte wdtcsr = mode >= 0 ? bit(WDIE) | mode : 0; + byte wdtcsr = mode >= 0 ? bit(WDIE) | mode : backupMode; + if(mode>=0) backupMode = WDTCSR; MCUSR &= ~(1<