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

Detect High to Low and Low to High EDGE using GPIO PORT Event

Hi,

I am using the pin change interrupt example provided in the SDK examples. By setting the input sense to NRF_GPIOTE_POLARITY_LOTOHI, the interrupt handler is called and in that i again set the input sense to NRF_GPIOTE_POLARITY_HITOLO so that next time it senses the high to low edge. But it never senses HITOLO. I am not able to find the reason for why this is happening.

Here is a example of the code

nrf_drv_gpiote_init();
nrf_drv_gpiote_out_init = GPIOTE_CONFIG_OUT_SIMPLE(false);
nrf_drv_gpiote_in_config_t in_config;
in_config.sense = NRF_GPIOTE_POLARITY_LOTOHI;
nrf_drv_gpiote_in_init(PIN_IN, &in_config, gpiote_event_handler);

Now in the event handler gpiote_event_handler case GPIOTE_CONFIG_POLARITY_LoToHi gets called in which i perform LED toggling and set the

in_config.sense = NRF_GPIOTE_POLARITY_HITOLO

Now the next time it should sense High to Low Edge but it never goes into the case GPIOTE_CONFIG_POLARITY_HiToLo

What could be the reason for this? I am using S110 and SDK10.

Parents
  • Can you please use the code formatting buttons to format code in your posts, they're impossible to read otherwise. I reformatted it for you, took 10 seconds.

    Is setting in_config.sense to NRF_GPIOTE_POLARITY_HITOLO all you are doing? Because just changing the value in the structure doesn't change the value in the configuration register which actually controls the transition polarity, it only uses the values in that structure at initialisation time to set up the state.

Reply
  • Can you please use the code formatting buttons to format code in your posts, they're impossible to read otherwise. I reformatted it for you, took 10 seconds.

    Is setting in_config.sense to NRF_GPIOTE_POLARITY_HITOLO all you are doing? Because just changing the value in the structure doesn't change the value in the configuration register which actually controls the transition polarity, it only uses the values in that structure at initialisation time to set up the state.

Children
Related