Create a timer to kick the Watchdog: .
api.system.timer.create(RAK_TIMER_0, wdt_kicker, RAK_TIMER_PERIODIC);
api.system.timer.start(RAK_TIMER_0, 5000, NULL);
Inside the timer event WDT gets cleared:
api.system.wdt.reset();
This works as expected…but I have multiple instances where the module still freeze…then only a power cycle will recover it.
Question : How reliable is this WatchDog implementation? Should I rather opt for an external watchdog?
The watchdog is implemented as a timer that is running in the background. A serious firmware crash can disable the WDT. If your code has instabilities and you have to rely on a hardware WDT, it is better to use an external watchdog.
As a summary, you only need to call am_hal_wdt_init(&g_sWatchdogConfig); and am_hal_wdt_start(); to make it run. Also, don’t forget the headers and feed the WDT.
#include "am_mcu_apollo.h"
#include "am_bsp.h"
#include "am_util.h"
// some where in the code, feed WDT.
am_hal_wdt_restart();
As RUI implementation for RAK11720 uses Ambiq SDK under the hood, you don’t need to install anything else.
Cheers.
In my case, I was facing the same issue of not being able to rely on RUI timers (as WDT API or Timer API), because they are software implemented and they were sporadically stopping without a clear reason (probably memory corruption). I’m still looking why.