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

watchdog timer

Is there an app-note, tutorial, or example of how to use the watchdog timer to reset the MCU if the application hangs?

Parents
  • Hi Ole,

    I tried the code below, but it doesn't work. It does not go to the handler, and it doesn't reset either. I closed the debugger and did a power cycle as required. In the handler, all I do is turn the LED on (LED function works with a button press, for example). I'm not reloading it anywhere yet either. What am I doing wrong?

    void watchdog_init(void) { NRF_WDT->CONFIG = (WDT_CONFIG_HALT_Pause << WDT_CONFIG_HALT_Pos) | (WDT_CONFIG_SLEEP_Pause << WDT_CONFIG_SLEEP_Pos);

    NRF_WDT->CRV = (32768 * 1); // Timeout period of 1 s

    NRF_WDT->RREN |= WDT_RREN_RR0_Msk; //Enable reload register 0

    NRF_WDT->INTENSET = WDT_INTENSET_TIMEOUT_Msk;

    NVIC_ClearPendingIRQ(WDT_IRQn); NVIC_SetPriority(WDT_IRQn, APP_IRQ_PRIORITY_HIGH); NVIC_EnableIRQ(WDT_IRQn);

    NRF_WDT->TASKS_START = 1; // Watchdog start }

    Thank you!

    Gil

  • Another update: It is going to the WDT_IRQHandler() ISR as intended. I couldn't tell earlier because it's only there for 2 clock cycles (of the 32 kHz clock - 60 us) before it finally resets. So, it works!!!

Reply Children
No Data
Related