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

How to enable watchdog

Hi, I'm a beginner in programming Nordic uC and I would like to know how to enable the watchdog in my application. Are there particular functions to call? Thanks!

Parents
  • Hi,

    This is how i do it

    Init

    static void System_task_initWatchdog(void)
    {
      nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
      uint32_t err_code = nrf_drv_wdt_init(&config,WatchdogHadler);
      APP_ERROR_CHECK(err_code);
      err_code = nrf_drv_wdt_channel_alloc(&m_channel_id);
      APP_ERROR_CHECK(err_code);
      nrf_drv_wdt_enable();
      
    }
    

    Feed

    nrf_drv_wdt_channel_feed(m_channel_id);
    

    sdk_config.h

    #ifndef WDT_ENABLED
    #if WDOG
    #define WDT_ENABLED 1
    #else
    #define WDT_ENABLED 0
    #endif
    #endif
    #if  WDT_ENABLED
    // <o> WDT_CONFIG_BEHAVIOUR  - WDT behavior in CPU SLEEP or HALT mode
    
    // <1=> Run in SLEEP, Pause in HALT 
    // <8=> Pause in SLEEP, Run in HALT 
    // <9=> Run in SLEEP and HALT 
    // <0=> Pause in SLEEP and HALT 
    
    #ifndef WDT_CONFIG_BEHAVIOUR
    #define WDT_CONFIG_BEHAVIOUR 0
    #endif
    
    // <o> WDT_CONFIG_RELOAD_VALUE - Reload value  <15-4294967295> 
    
    
    #ifndef WDT_CONFIG_RELOAD_VALUE
    #define WDT_CONFIG_RELOAD_VALUE 20000
    #endif
    
    // <o> WDT_CONFIG_IRQ_PRIORITY  - Interrupt priority
    
    
    // <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef WDT_CONFIG_IRQ_PRIORITY
    #define WDT_CONFIG_IRQ_PRIORITY 7
    #endif
    
  • feed can be placed in the main loop WDT_CONFIG_RELOAD_VALUE is a time in milliseconds before the WD is accrues. every feed you reload the timer aggain

Reply Children
No Data
Related