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

gpiote event channel and gpio direction

I have an I2C device that has an bidirectional interrupt pin.

This pin is pulled high externally with a weak pullup. When an event occurs on the device it pulls this pin low (this is the normal operation). There is also a less-frequent condition where the nrf51 needs to trigger an event on the device, to do this it needs to pull the interrupt pin low.

I have the gpio configured as an input and when I want to drive it low I just toggle the direction:

NRF_GPIO->OUTCLR = 1 << MOO_INT_PIN; // not needed, cleared during init
NRF_GPIO->DIRSET = 1 << MOO_INT_PIN;
<delay>
NRF_GPIO->DIRCLR = 1 << MOO_INT_PIN;

Everything seemed to be working, so I connected the gpio to a gpiote channel looking for falling edge events on the pin. Now whenever the interrupt pin goes low I trigger an I2C transaction.

However, once the gpiote event channel is connected to the pin, I can't drive the pin low with NRF_GPIO->DIRSET.

From reading the reference manual it seems that the gpiote channel is asserting the gpio DIR_OVERRIDE signal.

If I disconnect the gpiote channel from the interrupt pin, then the DIRSET/DIRCLR works.

Is there a way to drive a pin low while it is connected to the gpiote event channel or is my only option to disconnect the gpiote event channel from the interrupt pin?

Related