From b1cfa25b137d2d9d2b23354982e4632ab6e60b5c Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Tue, 28 May 2013 22:29:06 +0200 Subject: [PATCH] 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. --- firmware/tmr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 } -- 2.39.3