From 7232dddd691fc8a92cfc91bbc0e52147e1defe2d Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Thu, 6 Nov 2025 22:22:58 -0700 Subject: [PATCH] nrf52 wdt: pause wdt in Sleep and Halt, set timeout to 90 s The 90 seconds wdt timeout matches the esp32 wdt timeout. --- src/platform/nrf52/main-nrf52.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/platform/nrf52/main-nrf52.cpp b/src/platform/nrf52/main-nrf52.cpp index 2ec122062..827863f33 100644 --- a/src/platform/nrf52/main-nrf52.cpp +++ b/src/platform/nrf52/main-nrf52.cpp @@ -5,6 +5,7 @@ #include #include +#define APP_WATCHDOG_SECS 90 #define NRFX_WDT_ENABLED 1 #define NRFX_WDT0_ENABLED 1 #define NRFX_WDT_CONFIG_NO_IRQ 1 @@ -296,15 +297,17 @@ void nrf52Setup() // the first time through the main loop), so that other threads can // allocate their own wdt channel to protect themselves from hangs. nrfx_wdt_config_t wdt0_config = { - .behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP, .reload_value = 2000, + .behaviour = NRF_WDT_BEHAVIOUR_PAUSE_SLEEP_HALT, .reload_value = APP_WATCHDOG_SECS * 1000, // Note: Not using wdt interrupts. // .interrupt_priority = NRFX_WDT_DEFAULT_CONFIG_IRQ_PRIORITY }; nrfx_err_t r = nrfx_wdt_init(&nrfx_wdt, &wdt0_config, nullptr // Watchdog event handler, not used, we just reset. ); + assert(r == NRFX_SUCCESS); r = nrfx_wdt_channel_alloc(&nrfx_wdt, &nrfx_wdt_channel_id_nrf52_main); + assert(r == NRFX_SUCCESS); } void cpuDeepSleep(uint32_t msecToWake)