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

Watchdog timer getting reset continuously

Hello,

I wanted to implement WDT resets when my application hangs. I am working on the advertiser code, what I observe was when I implement WDT driver in SDK 15.2 examples/ble_peripheral/ble_app_beacon, the WDT would cause a watchdog reset initially, then would work fine. In the other code, in which I tried implementing the same WDT driver, it constantly reset the WDT, as seen in the picture below.

 This is what I have added in both of the codes for WDT.

static void wdt_event_handler()
{
    //bsp_board_led_on(1);
    NRF_LOG_INFO("%s", __func__);
    NRF_LOG_FLUSH();
    
}

static void wdt_timer_handler(void* p_context)
{   //NRF_LOG_INFO("%s", __func__);
    nrf_drv_wdt_channel_feed(m_channel_id);

}

static void wdt_init(void)
{
    ret_code_t err_code;
    nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
    err_code = nrf_drv_wdt_init(&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();

    err_code = app_timer_create(&wdt_timer, APP_TIMER_MODE_REPEATED, wdt_timer_handler);
    APP_ERROR_CHECK(err_code);
    err_code = app_timer_start(wdt_timer, APP_TIMER_TICKS(2000), 0);
    APP_ERROR_CHECK(err_code);
}

I also tried using registers

void init_watchdog(void)
{
    NRF_WDT->CONFIG = (WDT_CONFIG_SLEEP_Run << WDT_CONFIG_SLEEP_Pos);
    NRF_WDT->CRV = WATCHDOG_COUNTER;    
    NRF_WDT->RREN = WDT_RREN_RR0_Enabled << WDT_RREN_RR0_Pos;
    NRF_WDT->TASKS_START = 1;
}

and with this approach 


NRF_WDT->CONFIG = (WDT_CONFIG_HALT_Pause << WDT_CONFIG_HALT_Pos) | ( WDT_CONFIG_SLEEP_Pause << WDT_CONFIG_SLEEP_Pos);
  NRF_WDT->CRV = WDT_TIMER_INTERVAL_MS*32.768;   //timeout in seconds * frequency
  NRF_WDT->RREN |= WDT_RREN_RR0_Msk;  //Enable reload register 0
  NRF_WDT->TASKS_START = 1;

I got the same result, In the last two approaches, I was not sure where to place watchdog feed. Also I tried changing the timeout value but, it didn't made any changes, WDT was getting reset continuously. 1)Can you please provide me with the reason for WDT getting reset continuously, I wanted to make sure it only get reset when the application hangs. 2) I have doubt about where should we exactly place the watchdog feed. 3) I tried increasing the timeout but no changes. 

Thank you

Parents
  • Hi Pankti, 

    Have you configured the nRFX_WDT module in sdk_config.h as showed in the wdt example ?

    Please check and make sure wdt_timer_handler() is called every 2 seconds.

    If you use the default NRF_DRV_WDT_DEAFULT_CONFIG , which set the WDT timeout to 2 seconds, I would suggest to set the timer timeout to less than 2 seconds, for example 1 second. 

    Note that you must do a power reset after programing and before testing with WDT otherwise the WDT reset won't take effect if the chip is in debug mode.

    Please try to test using wdt example in the SDK. You can think of implementing a timer to reload instead of the button as in the example.  

Reply
  • Hi Pankti, 

    Have you configured the nRFX_WDT module in sdk_config.h as showed in the wdt example ?

    Please check and make sure wdt_timer_handler() is called every 2 seconds.

    If you use the default NRF_DRV_WDT_DEAFULT_CONFIG , which set the WDT timeout to 2 seconds, I would suggest to set the timer timeout to less than 2 seconds, for example 1 second. 

    Note that you must do a power reset after programing and before testing with WDT otherwise the WDT reset won't take effect if the chip is in debug mode.

    Please try to test using wdt example in the SDK. You can think of implementing a timer to reload instead of the button as in the example.  

Children
Related