Hey, the wdt_disable() macro doesn't seem to reflect the timed sequence
described int the ATmega168 manual. I was looking at this, because the
wdt_disable() macro does not seem to work on the 168. I coded up the
proper sequence described in the manual, and it seems to work fine. Is
this a known issue?
Below is the pseudocode from the manual. The current wdt.h code doesn't
do anything with the MCUSR, or clear the WDE bit after starting the WDCE
timed sequence. Depending on how the wdt is being used, the current
wdt.h wdt_disable() macro either does nothing, or causes a reset.
MANUAL SUGGESTION, p52
void WDT_off(void)
{
__disable_interrupt();
__watchdog_reset();
/* Clear WDRF in MCUSR */
MCUSR &= ~(1<<WDRF);
/* Write logical one to WDCE and WDE */
/* Keep old prescaler to prevent unintentional time-out */
WDTCSR |= (1<<WDCE) | (1<<WDE);
/* Turn off WDT */
WDTCSR = 0x00;
__enable_interrupt();
}
My wdt_disable(), which seems to work:
inline void wdt_disable() {
uint8_t origSREG = SREG;
wdt_reset();
__asm__ ( "cli" );
MCUSR &= ~(_BV(WDRF));
WDTCSR |= _BV(_WD_CHANGE_BIT) | _BV(WDE);
WDTCSR = 0;
SREG = origSREG;
}
_______________________________________________
AVR-libc-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev