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 :)

Parents
  • Hi,

    Thanks for your Help. I tried out your comment but i didn't work. I found in an other question an example how to use watchdog with Softdevice -> devzone.nordicsemi.com/.../another-nrf51822-watchdog-question

    So i tried out and came to this piece of code in my application: NRF_WDT->CONFIG = ( WDT_CONFIG_SLEEP_Run << WDT_CONFIG_SLEEP_Pos); NRF_WDT->CRV = 3*32768; //ca 3 sek. timout NRF_WDT->RREN |= WDT_RREN_RR0_Msk; //Enable reload register 0

    				NRF_WDT->TASKS_START = 1; // Watchdog start
    				while (true)
    				{
    					//NRF_WDT->RR[0] = 3*32768;;  //Reload watchdog register 0
    					switch_stat_g(1);
    					nrf_delay_ms(2000);
    					switch_stat_g(0);
    					nrf_delay_ms(2000);
    				}
    

    I set wdt to reset the device after 3 Seconds is this right?

    But nothing happens when i enter the while loop, i do not reload the RR0 but nothing happens.

    What am i doing wrong?Is there something to lookfor?

    Thank you , Nils Minor

Reply
  • Hi,

    Thanks for your Help. I tried out your comment but i didn't work. I found in an other question an example how to use watchdog with Softdevice -> devzone.nordicsemi.com/.../another-nrf51822-watchdog-question

    So i tried out and came to this piece of code in my application: NRF_WDT->CONFIG = ( WDT_CONFIG_SLEEP_Run << WDT_CONFIG_SLEEP_Pos); NRF_WDT->CRV = 3*32768; //ca 3 sek. timout NRF_WDT->RREN |= WDT_RREN_RR0_Msk; //Enable reload register 0

    				NRF_WDT->TASKS_START = 1; // Watchdog start
    				while (true)
    				{
    					//NRF_WDT->RR[0] = 3*32768;;  //Reload watchdog register 0
    					switch_stat_g(1);
    					nrf_delay_ms(2000);
    					switch_stat_g(0);
    					nrf_delay_ms(2000);
    				}
    

    I set wdt to reset the device after 3 Seconds is this right?

    But nothing happens when i enter the while loop, i do not reload the RR0 but nothing happens.

    What am i doing wrong?Is there something to lookfor?

    Thank you , Nils Minor

Children
No Data
Related