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

NRF_WDT: Not able to write to registers

Hi,

I am trying to power off and/or disable a RR[0] with no success.

I am Powering OFF the watchdog in main and then successfully POWERing ON in wdt_init but then I am not able to power it off the again. I have tried with and without enabling interrupts.

My code is something like the following:


void wdt_init(uint8_t reg, uint8_t wdt_sec)
{
	NRF_WDT->POWER = 1;
	NRF_WDT->CONFIG = (WDT_CONFIG_HALT_Pause << WDT_CONFIG_HALT_Pos) | (     WDT_CONFIG_SLEEP_Run << WDT_CONFIG_SLEEP_Pos);
	NRF_WDT->CRV = wdt_sec*32768;   //timeout
	NRF_WDT->RREN |= (0x1UL << reg);  //Enable reload register 0
	NRF_WDT->INTENSET = WDT_INTENSET_TIMEOUT_Msk;
	NVIC_ClearPendingIRQ(WDT_IRQn);
        NVIC_SetPriority(WDT_IRQn, APP_IRQ_PRIORITY_LOW);
        NVIC_EnableIRQ(WDT_IRQn);
	
	NRF_WDT->TASKS_START = 1;
}

void wdt_reload_reg (uint8_t reg)
{
	NRF_WDT->RR[reg] = WDT_RR_RR_Reload;  //Reload watchdog register
}

void wdt_disable_reg (uint8_t reg)
{
	NRF_WDT->RREN = WDT_RREN_RR0_Disabled << (0x1UL << reg); 
	NRF_WDT->POWER = 0; //this doesn't work
}

void WDT_IRQHandler(void)
{
	NRF_WDT->EVENTS_TIMEOUT = 0; //this works
	NRF_WDT->RREN = WDT_RREN_RR0_Disabled << (0x1UL << 0); //this has no effect
	NRF_WDT->POWER = 0; //this has no effect
	while (NRF_WDT->POWER == 1)
	{
           //stuck here
	}
}

Other question, a bit off the topic here actually (apologies for that), is on using the watchdog to check that the RADIO is working correctly (advertising or connected with central). What would be the best way of doing it? I understand that NRF_RADIO->status is not working?

Thanks!

Related