Skip to main content

wdt-feed

Open the watchdog, feed it on a cadence, observe a reset when feeding stops. The minimal demo for <alp/wdt.h>.

Source: examples/wdt-feed/.

board.yaml

schema_version: 2

som:
sku: E1M-AEN701

carrier:
name: E1M-EVK

cores:
m55_hp:
os: zephyr
app: ./src
peripherals: [wdt]

diagnostics:
log_level: info

Source (abbreviated)

#include <alp/wdt.h>

int main(void) {
alp_wdt_t *wdt = alp_wdt_open(&(alp_wdt_config_t){
.timeout_ms = 2000,
});
if (wdt == NULL) return -1;

alp_wdt_start(wdt);
for (int i = 0; i < 5; i++) {
printk("[wdt] feed %d/5\n", i);
alp_wdt_feed(wdt);
k_msleep(1500); /* 1.5 s < 2 s timeout, safe */
}

printk("[wdt] stopping feed; expecting reset in ~2 s\n");
k_msleep(5000); /* watchdog fires here */
return 0;
}

Expected behaviour

Five feeds, then the device resets ~2 s after the last feed. Re-boots into the same example, which logs the reset cause from alp_wdt_last_reset_was_watchdog().

See also

Questions about this page? Discuss in Community Forum