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

watchdog timer

Is there an app-note, tutorial, or example of how to use the watchdog timer to reset the MCU if the application hangs?

Parents
  • Please take a look at the main-file that should show the basics.

    main.c

  • If you want to use the watchdog interrupt, this is used like any other interrupt, you enable the event to generate an interrupt in the peripheral's INTEN register, and then enable the interrupt in the NVIC.

    As you can see in section 19.1.3 of the reference manual, this will give you 2 32.768 kHz clock cycles to do your logging and stack tracing. On reset, you can use the RESETREAS register to know the cause of the reset.

    The name of all interrupts are most easy to find in the startup file, and as you can see there, the watchdog interrupt handler will by default be WDT_IRQHandler. There are no utilities available to do stack tracing, but you can take a look at the ble_debug_assert_handler() function, which does similar things.

Reply
  • If you want to use the watchdog interrupt, this is used like any other interrupt, you enable the event to generate an interrupt in the peripheral's INTEN register, and then enable the interrupt in the NVIC.

    As you can see in section 19.1.3 of the reference manual, this will give you 2 32.768 kHz clock cycles to do your logging and stack tracing. On reset, you can use the RESETREAS register to know the cause of the reset.

    The name of all interrupts are most easy to find in the startup file, and as you can see there, the watchdog interrupt handler will by default be WDT_IRQHandler. There are no utilities available to do stack tracing, but you can take a look at the ble_debug_assert_handler() function, which does similar things.

Children
No Data
Related