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

Watchdog Timer Implementation

Hello, 

I am transmitting 1 byte BLE data across a central and peripheral and the central does other things like control PWM, sample SAADC (scan mode), GPIO pins interrupts etc. I need to ensure that my application is not stuck while doing any of those tasks or in any of the event handlers and hence, I want to implement a watchdog timer.

What is the ideal way for using the watchdog in such a case or in other words when should I kick the dog in such an application. I though of having a watchdog at start of every event handler and disabling at end of event handler but if SoftDevice interferes while running the SAADC event handler, the dog wont be kicked and the system will be reset.

Thanks in advance

Parents Reply
  • There is no problem with feeding the watchdog in interrupt context if you only want to prevent lockups in higher priority interrupt tasks. The problem first arises if you get a lockup in main thread or an interrupt context with lower priority than where you feed the watchdog.

    Lets say that you decide to feed the watchdog using app_timer, and you run app timer at priority 5. If you now get a lockup in a handler running at priority 0-5, the app_timer interrupt will not be able to run, as you are already stuck in a higher priority interrupt. This will lead to a watchdog timeout and will trigger a reset. If you get a lockup at priority 6-7, or in the main thread, the app_timer interrupt will preempt the execution of the thread where the lockup happens, to feed the watchdog. Since the watchdog is feed as normal, you will not get a watchdog timeout, and the watchdog is therefore ineffective for the lower priority tasks.

Children
Related