From d6ba83c1acf1b3c7ecabf83bf95cd7b1ceaeb35c Mon Sep 17 00:00:00 2001 From: WGH Date: Fri, 10 Dec 2021 04:49:55 +0300 Subject: [PATCH] Fix WDIE being wrongly cleared in Interrupt Mode WDIE must be automatically cleared only in "Interrupt and System Reset Mode" (where it's used to transition to "System Reset Mode"). In other modes, watchdog interrupt must not clear WDIE. Strictly speaking, the modified condition also clears it in "System Reset Mode" as well, but the system is reset on interrupt anyway, so it doesn't matter. See #456 --- simavr/sim/avr_watchdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simavr/sim/avr_watchdog.c b/simavr/sim/avr_watchdog.c index 978d17879..b7a5d01b1 100644 --- a/simavr/sim/avr_watchdog.c +++ b/simavr/sim/avr_watchdog.c @@ -182,7 +182,7 @@ static void avr_watchdog_irq_notify( * again when cleared (after servicing), value = 0 */ - if (!value && avr_regbit_get(avr, p->watchdog.raised)) { + if (!value && avr_regbit_get(avr, p->watchdog.raised) && avr_regbit_get(avr, p->wde)) { avr_regbit_clear(avr, p->watchdog.enable); } }