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

watchdog on nRF9160

Dear Support

I try to use Watchdog on nRF9160 DK.

I found the sample ..\v1.5.1\zephyr\samples\drivers\watchdog

From there I add to my prj.conf

CONFIG_WATCHDOG=y
CONFIG_WDT_LOG_LEVEL_DBG=y
CONFIG_WDT_DISABLE_AT_BOOT=n

And to my source

#include <drivers/watchdog.h>

#define WDT_NODE DT_INST(0, nordic_nrf_watchdog)

void Init(void)
{
  int err;
  int wdt_channel_id;
  const struct device *wdt;
  struct wdt_timeout_cfg wdt_config;
  wdt = device_get_binding(WDT_DEV_NAME);
  if (NULL == wdt)
  {
    printk("Watchdog setup error\n");
    return;
  }
  /* Reset SoC when watchdog timer expires. */
  wdt_config.flags = WDT_FLAG_RESET_SOC;

  /* Expire watchdog after 1000 milliseconds. */
  wdt_config.window.min = 0U;
  wdt_config.window.max = 1000U;

  /* Set up watchdog callback. Jump into it when watchdog expired. */
  wdt_config.callback = wdt_callback;

  wdt_channel_id = wdt_install_timeout(wdt, &wdt_config);
  if (wdt_channel_id == -ENOTSUP)
  {
    /* IWDG driver for STM32 doesn't support callback */
   wdt_config.callback = NULL;
   wdt_channel_id = wdt_install_timeout(wdt, &wdt_config);
  }
  if (wdt_channel_id < 0)
  {
   printk("Watchdog install error\n");
   return;
  }

  err = wdt_setup(wdt, 0);
  if (err < 0)
  {
    printk("Watchdog setup error\n");
    return;
  }
}

When I build I get from nrfx.wdt.c

#if !(NRFX_CHECK(NRFX_WDT0_ENABLED) || NRFX_CHECK(NRFX_WDT1_ENABLED))
#error "No enabled WDT instances. Check <nrfx_config.h>."
#endif

So something is missing.

Can You tell my what?

RetoFelix

Related