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

wdt best practice

Hey,

I have been trying to set up wdt for my application which services some interrupts once in a while and advertises continuously. I put the nrf to sleep using sd_app_evt_wait() function. I am using a custom board with nrf51822.

I followed two different approaches and both work fine. So, I was wondering which one is a better practice for a good embedded application (low power and reliability are both important).

Approach 1-> Using a timer to reload: In this approach, I created a timer just to reload the WDT and start it just before initializing the WDT.

->In this approach, I was seeing a lot of unwanted resets around the time there was a BLE advert timoeout. I then added a line in the on_ble_evt(ble_evt_t * p_ble_evt) function to feed the dog. That helped.

->Sometimes, it would reset without reloading even once (just after start up). I then explicitly started the lfclk and haven't seen this issue in a bit.

Approach 2-> Reloading in main while loop: I reload the wdt in the loop in main but as I have sd_app_evt_wait() right after that, I have changed WDT_CONFIG_SLEEP_Run to WDT_CONFIG_SLEEP_Pause. So, as per my understanding, wdt is paused when the system goes to sleep and my main loop feeds it after any event. As there is no timer and the wdt is running and fed only when there's an event, it should save power as well.

Questions. 1) In approach 1, if any other events take long enough and casue reset, is it good practice to feed the wdt from inside such events/functions? 2) Which of these approaches is a good practice for a reliable and power efficient application?

Thanks, Vandita

The attachment shows both approaches: wdt.c

Parents Reply Children
Related