diff --git a/ports/nordic/common-hal/watchdog/WatchDogTimer.c b/ports/nordic/common-hal/watchdog/WatchDogTimer.c index b20aa0c0629..48db5014800 100644 --- a/ports/nordic/common-hal/watchdog/WatchDogTimer.c +++ b/ports/nordic/common-hal/watchdog/WatchDogTimer.c @@ -75,9 +75,6 @@ void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) { void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) { if (self->mode == WATCHDOGMODE_RESET) { - if (gc_alloc_possible()) { - mp_raise_RuntimeError(MP_ERROR_TEXT("WatchDogTimer cannot be deinitialized once mode is set to RESET")); - } // Don't change anything because RESET cannot be undone. return; } @@ -164,6 +161,10 @@ void common_hal_watchdog_set_mode(watchdog_watchdogtimer_obj_t *self, watchdog_w } nrfx_wdt_enable(&wdt); nrfx_wdt_feed(&wdt); + } else if (current_mode == WATCHDOGMODE_RESET) { + // raise exception on attempt to set mode back from RESET to None + mp_raise_RuntimeError(MP_ERROR_TEXT("WatchDogTimer cannot be deinitialized once mode is set to RESET")); + } // If we just switched away from RAISE, disable the timmer.