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

Parents
  • Hi, sorry for the late response. I tried adding the code you posted, and the configs to a standard sample in NCS, but it compiles just fine. Are you able to post the complete project here?

  • Hi,

    Now I can build with watchdog.

    I add the following flag: WDT_OPT_PAUSE_HALTED_BY_DBG

    err = ::wdt_setup(wdt, WDT_OPT_PAUSE_HALTED_BY_DBG);

    Otherwise stepping isn't possible,

    Now I've the following problem.

    I feed the dog until i press a key.

    When I press the key the watchdog timeout and a hardfault is executed

    [00:00:00.009,338] <err> os: ***** HARD FAULT *****
    [00:00:00.014,953] <err> os: r0/a1: 0x00000001 r1/a2: 0xffffffff r2/a3: 0x00000001
    [00:00:00.023,773] <err> os: r3/a4: 0x2001065c r12/ip: 0x0000f9c0 r14/lr: 0x0001071d
    [00:00:00.032,592] <err> os: xpsr: 0x21000000
    [00:00:00.037,872] <err> os: r4/v1: 0x000165cd r5/v2: 0x00000000 r6/v3: 0x00013880
    [00:00:00.046,691] <err> os: r7/v4: 0x00013880 r8/v5: 0x00013880 r9/v6: 0x00013880
    [00:00:00.055,511] <err> os: r10/v7: 0x00013880 r11/v8: 0x00013880 psp: 0x20010a30
    [00:00:00.064,300] <err> os: EXC_RETURN: 0xffffffbc
    [00:00:00.069,946] <err> os: Faulting instruction address (r15/pc): 0x0001836c
    [00:00:00.077,972] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
    [00:00:00.085,906] <err> os: Current thread: 0x20010218 (unknown)
    [00:00:00.092,773] <err> fatal_error: Resetting system

    As Reset reasen 00010000 is set. This is not a watchdog reset!

    After that the debugger does no longer break on a breakpoint.

    A power on Reset is required to work again.

    Can this improuved?

Reply
  • Hi,

    Now I can build with watchdog.

    I add the following flag: WDT_OPT_PAUSE_HALTED_BY_DBG

    err = ::wdt_setup(wdt, WDT_OPT_PAUSE_HALTED_BY_DBG);

    Otherwise stepping isn't possible,

    Now I've the following problem.

    I feed the dog until i press a key.

    When I press the key the watchdog timeout and a hardfault is executed

    [00:00:00.009,338] <err> os: ***** HARD FAULT *****
    [00:00:00.014,953] <err> os: r0/a1: 0x00000001 r1/a2: 0xffffffff r2/a3: 0x00000001
    [00:00:00.023,773] <err> os: r3/a4: 0x2001065c r12/ip: 0x0000f9c0 r14/lr: 0x0001071d
    [00:00:00.032,592] <err> os: xpsr: 0x21000000
    [00:00:00.037,872] <err> os: r4/v1: 0x000165cd r5/v2: 0x00000000 r6/v3: 0x00013880
    [00:00:00.046,691] <err> os: r7/v4: 0x00013880 r8/v5: 0x00013880 r9/v6: 0x00013880
    [00:00:00.055,511] <err> os: r10/v7: 0x00013880 r11/v8: 0x00013880 psp: 0x20010a30
    [00:00:00.064,300] <err> os: EXC_RETURN: 0xffffffbc
    [00:00:00.069,946] <err> os: Faulting instruction address (r15/pc): 0x0001836c
    [00:00:00.077,972] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
    [00:00:00.085,906] <err> os: Current thread: 0x20010218 (unknown)
    [00:00:00.092,773] <err> fatal_error: Resetting system

    As Reset reasen 00010000 is set. This is not a watchdog reset!

    After that the debugger does no longer break on a breakpoint.

    A power on Reset is required to work again.

    Can this improuved?

Children
No Data
Related