nrfx_wdt_init() error NRFX_ERROR_INVALID_STATE

Hi!

I am trying to use the nrfx watchdog driver on nrf9160 on a custom board.

The application boots, but nrfx_wdt_init() throw error NRFX_ERROR_INVALID_STATE aka. "The driver was already initialized."

prj.conf

# WATCHDOG
CONFIG_WATCHDOG=y
CONFIG_WDT_NRFX=y
CONFIG_WATCHDOG_TIMEOUT_MS=30000

main.c

if (IS_ENABLED(CONFIG_WATCHDOG)) {        
    const nrfx_wdt_config_t wdt_conf = {
        .behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP_HALT,
        .reload_value = CONFIG_WATCHDOG_TIMEOUT_MS,
        NRFX_WDT_IRQ_CONFIG
    };

    nrfx_err_t err_nrfx = nrfx_wdt_init(&wdt_inst, &wdt_conf, wdt_handler);
    if (NRFX_SUCCESS != err_nrfx) {
        LOG_ERR("Watchdog init error: %d", err_nrfx);

        //sys_reboot(SYS_REBOOT_COLD);
        return;
    }
    nrfx_wdt_enable(&wdt_inst);
    LOG_INF("Watchdog started");
}

Parents
  • Hi Jon,

    I was able to reproduce and find a solution.

    CONFIG_WDT_NRFX=y shoudl be used when telling Zephyr's own watchdog to use the NRFX watchdog. If you would like to use the NRFX watchdog driver, then use CONFIG_NRFX_WDT0=y istead. With this change, I was able to run the code without any errors.

    We generally recommend using the highest level possible in Zephyr, and only use the NRFX drivers if there is a specific reason to use lower level drivers.

    Here is a sample demonstrating Zephyr's watchdog.

Reply
  • Hi Jon,

    I was able to reproduce and find a solution.

    CONFIG_WDT_NRFX=y shoudl be used when telling Zephyr's own watchdog to use the NRFX watchdog. If you would like to use the NRFX watchdog driver, then use CONFIG_NRFX_WDT0=y istead. With this change, I was able to run the code without any errors.

    We generally recommend using the highest level possible in Zephyr, and only use the NRFX drivers if there is a specific reason to use lower level drivers.

    Here is a sample demonstrating Zephyr's watchdog.

Children
Related