This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

WDT not firing

This is SDK 8.1.0, Softdevice 7.3.0 (not being used for this demo), running on a NRF51822-CEAA.

The minimal program below just sets the WDT for 10 seconds, then goes into a loop showing a 1-second heartbeat so I can count. There's no timer or anything else feeding the dog, so it should (?) reset every 10 seconds. But it never does (I would see the different startup LED pattern). Is the interrupt getting disabled somehow? Yes, I changed WDT_ENABLED=1 in the header.

 #include <stdbool.h>
 #include <stdint.h>
 #include "nrf.h"
 #include "app_timer.h"
 #include "app_util_platform.h"
 #include "app_error.h"
 #include "nrf_drv_wdt.h"
 #include "debug.h"      // led_on(), app_error_handler(), etc.
 
 nrf_drv_wdt_channel_id m_channel_id;
 
 void wdt_event_handler(void) { NVIC_SystemReset(); }
 
 int main(void) {
     uint32_t err_code = NRF_SUCCESS;
 
     debug_init();
     led_on(1000);
     led_off(0);
 
     nrf_drv_wdt_config_t wdt_config = {
         .behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP_HALT,
         .reload_value = 10000,
         .interrupt_priority = APP_IRQ_PRIORITY_HIGH
     };
     err_code = nrf_drv_wdt_init(&wdt_config, wdt_event_handler);
     APP_ERROR_CHECK(err_code);
 
     err_code = nrf_drv_wdt_channel_alloc(&m_channel_id);
     APP_ERROR_CHECK(err_code);
 
     nrf_drv_wdt_enable();
 
     while (1) {
         led_on(50);
         led_off(950);
     }
}
Parents Reply Children
No Data
Related