From: Jan "Yenya" Kasprzak Date: Tue, 28 May 2013 20:29:06 +0000 (+0200) Subject: tmr.c: combine watchdog IRQ and watchdog reset X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?p=bike-lights.git;a=commitdiff_plain;h=b1cfa25b137d2d9d2b23354982e4632ab6e60b5c tmr.c: combine watchdog IRQ and watchdog reset Fortunately, WDT reset can be combined with WDT interrupt. The procedure is to reenable WDIE each time, or the next WDT timeout will be reset. --- diff --git a/firmware/tmr.c b/firmware/tmr.c index d1f1b23..2e61db8 100644 --- a/firmware/tmr.c +++ b/firmware/tmr.c @@ -8,7 +8,8 @@ volatile uint16_t jiffies; void init_tmr() { - WDTCR = _BV(WDIE) | _BV(WDP1); // interrupt mode, 64 ms + wdt_enable(WDTO_60MS); + WDTCR |= _BV(WDIE); // interrupt mode, 64 ms } void susp_tmr() @@ -25,5 +26,7 @@ ISR(WDT_vect) { if ((jiffies & 0x7FF) == 0) ambient_log_min_max(); + + WDTCR |= _BV(WDIE); // avoid WDT reset next time }