I am trying to stop RTC by pressing one button and wake up again by releasing the same button. My RTC now runs around 4 uA while being on system-on sleep mode by __SEV(); __WFE(); __WFE(); However, the current goes to around 200 uA when the button is being hold after pressing. It only goes back to 4 uA if I release the button.
I realized the line below makes the current go to 200 uA.
nrf_gpio_cfg_sense_input(BUTTON_2, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_HIGH);
Is there a way to truely go to sleep when the button is pressed (not released), and wake up after releasing the button?
// Configure BUTTON 2 with SENSE enabled
nrf_gpio_cfg_sense_input(BUTTON_2, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_HIGH);
while(true)
{
__SEV();
__WFE();
__WFE();
// If BUTTON 2 is pressed..
if(nrf_gpio_pin_read(BUTTON_2) == 0)
{
NRF_POWER->SYSTEMOFF = 1;
}
}