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

nrf_drv_gpiote_in_event_enable function doesn't re-enable event

Hello,

I am writing an application using SDK version 8.1 where I have a pin using the PORT event in nrf_drv_gpiote library. I have a need to disable the event temporarily and then re-enable it at a later time. I tried to do this using the nrf_drv_gpiote_in_event_disable() and nrf_drv_gpiote_in_event_enable() functions. This didn't seem to work properly and after looking into it more, it appears that the event disable function disconnects the input and the event enable function does not reconnect. Also, when the event is re-enabled, the GPIOTE handler function is called repeatedly.

Is this the appropriate way to accomplish this goal? Should I be using some other functions such ones that directly manipulate the sense function, or is this a issue with the SDK?

Thanks.

UPDATE:

I wanted to post an alternative solution that I found in addition to Aryan's answer. I was able to enable and disable the event and still leave it attached to the PORT event. I did this with the following steps.

To initialize I called: nrf_drv_gpiote_in_init() followed by nrf_drv_gpiote_in_event_enable().

Then my disable and enable routine called nrf_gpio_cfg_sense_set() and set the sense parameter to NRF_GPIO_PIN_NOSENSEor NRF_GPIO_PIN_SENSE_LOW and this seems to have worked as well.

Parents
  • There is a bug in GPIOTE that will be resolved in the next SDK release. for now you have to enable hi_accuracy in the config file and then everything will work for you normally, there will be little increase in power consumption because of this change, but like I said, we are working on it.

    nrf_drv_gpiote_in_config_t config;
    config.hi_accuracy = true;
    

    or use the macros available like

     nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
    

    If you do not like the power consequences for this workaround, you can change the driver to reconnect the pin again nrf_gpio_cfg_input(pin,p_config->pull);

Reply
  • There is a bug in GPIOTE that will be resolved in the next SDK release. for now you have to enable hi_accuracy in the config file and then everything will work for you normally, there will be little increase in power consumption because of this change, but like I said, we are working on it.

    nrf_drv_gpiote_in_config_t config;
    config.hi_accuracy = true;
    

    or use the macros available like

     nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
    

    If you do not like the power consequences for this workaround, you can change the driver to reconnect the pin again nrf_gpio_cfg_input(pin,p_config->pull);

Children
Related