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

WDT halts RTC after NVIC_SystemReset

Hei!

I recently added WDT to my existing project. After that the normal behavior/sequence of code is not as it is supposed to. Strangely it works okay every other run now.

The sequence/structure is simple:

  1. Initialize RTC module (also starts the clock)
  2. Do some stuff with the peripherals (Here it halts every other run, because I use RTC based timeouts)
  3. Initialize the watchdog and run it
  4. Application loop (WDT pings do happen here)
  5. Sleep loop (waiting pin interrupt, sleeps by RTC in 1 second periods to feed the dog)
  6. NVIC_SystemReset() - Is being triggered after the sleep loop expires or interrupt happens

PROBLEM:

After the reset the code gets stuck at the step 2. I debugged whats up and I saw that nrf_drv_rtc_counter_get() returns 0. It should be around 0.060 * 32768 (60 ms) by then. So at the step 2 the timeout on RTC module hangs because the counter does not increment. But at the same time somehow the WDT is running and resets the system soon, although the initialization comes later at the step 3. After the WDT resets the system for one iteration the whole application works okay. But the iteration after that again follows the same path as I just described. And this happens in turns.

WDT configuration:

#define WDT_CONFIG_BEHAVIOUR     NRF_WDT_BEHAVIOUR_RUN_SLEEP
#define WDT_CONFIG_RELOAD_VALUE  10000
#define WDT_CONFIG_IRQ_PRIORITY  APP_IRQ_PRIORITY_HIGH

I could hack the WDT to trigger reset at the step 6. But I would like to know what I am doing wrong or have not noticed.

Please notice that the sequence and actions taken at step 5 & 6 are purely for testing purposes (it does not happen in the real product - I know I can restart the application using more intelligent ways)

Cheers!

Parents Reply Children
Related