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

GPIOTE and nrf_gpio_cfg_input/output

Hi, I am using a app_gpiote_user_register to register a gpiote user and then enabling it, before I set the pins this user detect to be input using nrf_gpio_cfg_input. When my program is running I have to switch the pin to be output for some occasion using nrf_gpio_cfg_output, and after I am done with the output I switch it back to be input. But then the gpiote module stops to give me any event when the voltage of the pin changes, is there something I should do to prevent the gpiote module become unavailable?

Thanks.

  • As you can see in the source code of app_gpiote.c, it manipulates the PIN_CNF register in the GPIO peripheral, to set the SENSE level for the pins (lines 230-251). This register is also manipulated by the nrf_gpio_cfg_* functions, and therefore the configuration set by app_gpiote will be lost when you manually change the direction of the pin afterwards.

    Since app_gpiote verifies the configuration each time it is enabled, calling app_gpiote_enable() after you've set the pins back to input pins should be a usable workaround.

Related