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

How does the Watchdog work?

Hi, i need to use a watchdog in my application. I read that i can use the build in one, but i thing my configuration or the usage of the watchdog is wrong. here is my config:


void WatchDogInit															(void)
{
	NRF_WDT->CONFIG =  	(WDT_CONFIG_SLEEP_Run << WDT_CONFIG_SLEEP_Pos); 
								  
	NRF_WDT->CRV = (32768 * 1); 	 
	NRF_WDT->RREN = WDT_RREN_RR0_Msk; 									
	
                    
    NRF_WDT->INTENSET=WDT_INTENSET_TIMEOUT_Msk;									
	                 
                                sd_nvic_ClearPendingIRQ(WDT_IRQn);													
	sd_nvic_SetPriority				(WDT_IRQn, APP_IRQ_PRIORITY_HIGH);		
	sd_nvic_EnableIRQ	 (WDT_IRQn);													
	NRF_WDT->TASKS_START = 1; // Watchdog start
}

when do i have to call this init method? Is tehre anything to lookfor, do i have to run it befor enabling the SD or something like that?

here is my example loop for testing it


					while (true)
					{
						NRF_WDT->RR[0] = WDT_RR_RR_Reload; ;//WDT_RR_RR_Reload;
						switch_stat_g(1);
						nrf_delay_ms(2000);
						switch_stat_g(0);
						nrf_delay_ms(2000);
					}

Do i use it in a wrong way?

Thank you for help and best regards, Nils :)

Related