From 91259f9096689f9caac0faa4c23ca132082b12b6 Mon Sep 17 00:00:00 2001 From: Karai Csaba Date: Sun, 4 Jan 2015 10:15:35 +0100 Subject: [PATCH] Fixed: optiboot issue, watchdog is unintentionally enabled --- simavr/sim/avr_watchdog.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/simavr/sim/avr_watchdog.c b/simavr/sim/avr_watchdog.c index b4628ca..f8a5938 100644 --- a/simavr/sim/avr_watchdog.c +++ b/simavr/sim/avr_watchdog.c @@ -103,13 +103,14 @@ static void avr_watchdog_write(avr_t * avr, avr_io_addr_t addr, uint8_t v, void uint8_t old_wde = avr_regbit_get(avr, p->wde); uint8_t old_wdie = avr_regbit_get(avr, p->watchdog.enable); - + uint8_t old_wdce = avr_regbit_get(avr, p->wdce); + uint8_t was_enabled = (old_wde || old_wdie); uint8_t old_v = avr->data[addr]; // allow gdb to see write... avr_core_watch_write(avr, addr, v); - if (avr_regbit_get(avr, p->wdce)) { + if (old_wdce) { uint8_t old_wdp = avr_regbit_get_array(avr, p->wdp, 4); // wdrf (watchdog reset flag) must be cleared before wde can be cleared. -- 2.39.5