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

Same pin for wake up and system off

Hello. I want to use the same pin on nrf52832 for wake up and system off, however I have some issues, like sometimes it doesn't wake up or it is needed to press button few times for wake up.

void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    nrf_drv_timer_disable(&timer);
    nrf_drv_gpiote_out_task_disable(6);
    nrf_gpio_pin_clear(6);		
    nrf_gpio_cfg_sense_set(12, NRF_GPIO_PIN_SENSE_LOW);
    sd_power_system_off();
}

static void gpio_init(void)

{
    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
    
    nrf_drv_gpiote_in_init(12, &in_config, in_pin_handler);
    
    nrf_drv_gpiote_in_event_enable(12, true);
}
Related