Hi!
I have been looking for some insight.
Why is it suggested to call WDT_reset() even when initializing the WDT from a disabled state?
As far as I can see the Watchdog timer always starts from 0 when initializing, such as
WDTCSR |= (1 << WDCE) | (1 << WDE);
WDTCSR = (0 << WDIE) | (1 << WDE) | (0 << WDP3) | (1 << WDP2) | (1 << WDP1) | (0 << WDP0);
even Nick Gammon's forum (VERY informative) has the following example when INITIALIZING:
WDTCR = bit (WDCE) | bit (WDE) | bit (WDIF);
// set interrupt mode and an interval (WDE must be changed from 1 to 0 here)
WDTCR = bit (WDIE) | bit (WDP3) | bit (WDP0); // set WDIE, and 8 seconds delay
// pat the dog
wdt_reset();
} // end of resetWatchdog
Thanks
Hi!
I have been looking for some insight.
Why is it suggested to call WDT_reset() even when initializing the WDT from a disabled state?
As far as I can see the Watchdog timer always starts from 0 when initializing, such as
WDTCSR |= (1 << WDCE) | (1 << WDE);
WDTCSR = (0 << WDIE) | (1 << WDE) | (0 << WDP3) | (1 << WDP2) | (1 << WDP1) | (0 << WDP0);
even Nick Gammon's forum (VERY informative) has the following example when INITIALIZING:
Code: [Select]
WDTCR = bit (WDCE) | bit (WDE) | bit (WDIF);
// set interrupt mode and an interval (WDE must be changed from 1 to 0 here)
WDTCR = bit (WDIE) | bit (WDP3) | bit (WDP0); // set WDIE, and 8 seconds delay
// pat the dog
wdt_reset();
} // end of resetWatchdog
I guess it's just good form - particularly for the next guy reading your code.
On some platforms - that reset by default may not occur - so why not... it's a single instruction.
@ShmuelGlick, please do not cross-post. Threads merged.
lastchancename:
I guess it's just good form - particularly for the next guy reading your code.
On some platforms - that reset by default may not occur - so why not... it's a single instruction.
Thanks.
I just want to confirm that it always starts at 0. I don't see anything about it in the datasheet.
lastchancename:
so why not... it's a single instruction.
I want a minimal instruction set.
ShmuelGlick:
I want a minimal instruction set.
For the insignificant amount of processing time it will cost, leave it in. Beware of false economies.
note: WDT_Reset() is not the same as wdt_reset()