Hi, I am now developing a product which uses nrf51422 chip. In this product, I use buttons to turn on and off (since I don't have hard-power cut off circuit, we use system-off sleep for power off and normal mode for active mode). To turn off the device, users need to press and hold the button for 3seconds (here I just used sd_power_system_off() function to go into system-off sleep mode) and to turn on the device, users need to do the same action. I completed the firmware tested a few times and it was OK. But now we found out that after we turn on/off for a few times (23times for a unit, 50times for another unit,it's inconsistent) , the device cannot be waken up at all. But after I remove the battery and put again (power reset), then it's working again. Does anyone encounter this kind of issue before? Please help me. The device is going to be in production soon and urgently need your help.
here is some details for the device,
MCU - nrf51422
SDK - v11.0.0
SD version - SD130
System-off sleep
if(Flag.PowerOnOff==1)
{
if( nrf_drv_gpiote_in_is_set(SW_PWR_ON_PIN) == false) // if the power on button is pressed
{
for(uint8_t i=0;i<=6;i++)
{
nrf_delay_ms(500);
if( nrf_drv_gpiote_in_is_set(SW_PWR_ON_PIN) == true)
break;
if( i==6)
{
TurnOff_LEDs();
nrf_delay_ms(10);
//Disable some interrupt to prevent from waking up
nrf_drv_gpiote_in_uninit(SW_EMERGENGY_PIN);
nrf_drv_gpiote_in_event_disable(SW_EMERGENGY_PIN);
nrf_gpiote_int_disable(SW_EMERGENGY_PIN);
nrf_drv_gpiote_in_uninit(INT_PIN);
nrf_drv_gpiote_in_event_disable(INT_PIN);
nrf_gpiote_int_disable(INT_PIN);
// Go to system-off mode (this function will not return; wakeup will cause a reset).
err_code = sd_power_system_off();
APP_ERROR_CHECK(err_code);
}
}
}
}
Wake up Check whether from power reset or sleep reset
if((NRF_POWER->RESETREAS & 0x00010000)== 0x00010000) // If reset from system off mode
{
if(nrf_drv_gpiote_in_is_set(SW_PWR_ON_PIN)==false)
{
for(temp=0;temp<=6;temp++)
{
nrf_delay_ms(500);
if(nrf_drv_gpiote_in_is_set(SW_PWR_ON_PIN)==true)
{
TurnOff_LEDs();
//Disable Hi G, Low G and Emergency Interrupt pin to prevent System-off wakeup
nrf_drv_gpiote_in_uninit(SW_EMERGENGY_PIN);
nrf_drv_gpiote_in_event_disable(SW_EMERGENGY_PIN);
nrf_drv_gpiote_in_uninit(INT_PIN);
nrf_drv_gpiote_in_event_disable(INT_PIN);
NRF_POWER->SYSTEMOFF = 1; // if the power on button is released within 3seconds, goto system off again
}
}
}
}