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

nRF9160 Watchdog driver showing strange behaviour

Hello!

I am currently trying to use the watchdog driver from the Zephyr library. I have enabled the CONFIG_WATCHDOG and set it up similarly to the asset_tracker application example.

The problems I am experiencing is that the max time window I set does not seem to be close to correct. Setting it to 300ms results in restarts after about 20 seconds, while 6000ms results in restarts after around 400s. Am I missing something?

This is how I set it up in the application:

#include <zephyr.h>
#include <device.h>
#include <drivers/watchdog.h>

static struct device *wdt_dev;
static int wdt_main_channel;
static struct wdt_timeout_cfg wdt_cfg = {
    .window =
        {
            .min = 0,
            .max = CONFIG_WDT_MAX_TIMEOUT_MS, // This is set to 6000
        },
    .callback = NULL,
    .flags = WDT_FLAG_RESET_SOC,
};

int main() {
    wdt_dev = device_get_binding(DT_LABEL(DT_NODELABEL(wdt)));
    if (wdt_dev == NULL) {
        LOG_ERR("Could not set up watchdog");
        return -1;
    }
    wdt_main_channel = wdt_install_timeout(wdt_dev, &wdt_cfg);

    if (wdt_main_channel < 0) {
        LOG_ERR("Could not install wdt timeout. (error: %d)", wdt_main_channel);
        return wdt_main_channel;
    }

    ret = wdt_setup(wdt_dev,
                    WDT_OPT_PAUSE_HALTED_BY_DBG | WDT_OPT_PAUSE_IN_SLEEP);
    if (ret < 0) {
        LOG_ERR("Could not setup WDT");
        return ret;
    }
    LOG_INF("Watchdog set up with a %ds interval", CONFIG_WDT_MAX_TIMEOUT_MS/1000);
}

My SDK is at this commit: 7c35ef35fe604c8d69096f93a460852c5023eae4 as I require manual modem toggling, and I have a v0.9.0 devkit.

Parents Reply
  • Will it pause even when a thread is just blocking?

    The reason I need the watchdog is that the aws_connect() function sometimes blocks forever, so I need to reset the chip if this happens. But when I am not connected to LTE-M I run the GPS thread, so I would expect the watchdog to trigger if I do not feed it in the GPS event handler, but this is not the case.

Children
Related