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

Pin pull configuration using app_gpiote_user_register

I'm attempting to make a sense of app_gpiote.c (in SDK 11) to see if it's suitable for my application and I can't find a match between the documentation, the sample code and the actual code in the library. I want to use it to handle toggle events coming from a pin that needs to be configured as NRF_GPIO_PIN_PULLUP. The documentation on app_gpiote clearly states that the burden of the port configuration is on the user with the exception of the sense configuration which is recommended to be set at disabled. The sample code on GitHub ( github.com/.../nrf51_app_gpiote_example ) does configure the port before calling app_gpiote_user_register (even if in the case of the example the sense is configured as low). Still if one looks at what app_gpiote_user_register works in app_gpiote.c, there is clearly const nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false); for the pins of interest which, clearly again resolves in a configuration that is forced to NRF_GPIO_PIN_NOPULL.

I don't want to base my code on this just to discover that it doesn't work. Has anybody experience with this? If it works, how does it work?

  • Hi

    Not sure about what you are asking exactly, but if you are asking how to configure the pull for a pin, then it is normal to have no pull on a pin if the connected circuit drives both high and low signal. The goal is to not have the pin signal floating at any time. If my answer does not answer your question, can you please clarify.

  • The documentation of app_gpiote states The GPIOTE users are responsible for configuring all their corresponding pins, except the SENSE field, which should be initialized to GPIO_PIN_CNF_SENSE_Disabled. If I look at how app_gpiote.c is implemented (SDK 11 in my case) app_gpiote_user_register initializes the pins using nrf_drv_gpiote_in_init passing a config structure intialized by GPIOTE_CONFIG_IN_SENSE_TOGGLE(false) which is defined as #define GPIOTE_CONFIG_IN_SENSE_TOGGLE(hi_accu)
    {
    .is_watcher = false,
    .hi_accuracy = hi_accu,
    .pull = NRF_GPIO_PIN_NOPULL,
    .sense = NRF_GPIOTE_POLARITY_TOGGLE,
    }
    which seems to me that the pin configuration will be overridden to NOPULL anyway. This doesn't seem to match with the docs.

  • By the way, I'm trying to use this on an input pin, so no drive required. The pin is driven externally by something that can only drive to GND (it's basically a switch) and requires the pin to be set with internal pull up for it to work.

  • By reading the app_gpiote documentation that you refer to, I suspect it is old information for the app_gpiote library and does not apply anymore. It is clear that app_gpiote_user_register function uses the GPIOTE_CONFIG_IN_SENSE_TOGGLE in nrf_drv_gpiote.h where sense is enabled. Thanks for pointing this out. I will ask for documentation correction or clarification.

    Yes, the GPIOTE_CONFIG_IN_SENSE_TOGGLE will configure the pin with no pull. To configure a pullup on the pin you need to explicitly set that, as done in the system_off_wakeup_on_gpiote example on Github or in the pin_change_int peripheral example in the SDK. For SDK 11, the app_gpiote library is however deprecated and you should use the nrf_drv_gpiote driver directly instead if you have a new design.

  • Where is it noted that the app_gpiote library is deprecated? Also, what is the reasoning for deprecating it?

Related