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

How to configure interrupt on gpio pin to detect button state.

Hi Team,

I am using sdk12.2.2 and nrf52. I want to use one gpio to detect button state & have to operation on that event.

I used one method to configure(code snippet written below)

nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
in_config.pull = NRF_GPIO_PIN_PULLUP;

err_code = nrf_drv_gpiote_in_init(ARDUINO_1_PIN, &in_config, in_pin_handler);
APP_ERROR_CHECK(err_code);

nrf_drv_gpiote_in_event_enable(ARDUINO_1_PIN, true);

However this method is working as per my requirement but this is consuming 20uA of current that will ruin my battery life requirement.So, can anyone help me for the same.

Parents
  • You don't use interrupts to detect GPIO value LOW/HIGH (= "button state" if you want). Simply configure GPIO line as input and read it (see functions nrf_gpio_cfg_input and nrf_gpio_pin_read in components\drivers_nrf\hal\nrf_gpio.h file).

    However if you also want to detect change of that value then you need to configure and use GPIOTE and that comes at cost of few micro Amps. It cannot live from nothing, that looks logical to me. If 20uA ruins your device then you are probably building thing according to unrealistic requirements/assumptions.

Reply
  • You don't use interrupts to detect GPIO value LOW/HIGH (= "button state" if you want). Simply configure GPIO line as input and read it (see functions nrf_gpio_cfg_input and nrf_gpio_pin_read in components\drivers_nrf\hal\nrf_gpio.h file).

    However if you also want to detect change of that value then you need to configure and use GPIOTE and that comes at cost of few micro Amps. It cannot live from nothing, that looks logical to me. If 20uA ruins your device then you are probably building thing according to unrealistic requirements/assumptions.

Children
No Data
Related