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

Read gpio state on event

Hi,

I'm implementing quadrature encoder to read motor speed/position. So far I configured a gpio pin where A channel of the quadrature encoder is connected to capture timer value on toggle using gpiote, ppi and timer.

Now I would like also to capture state of gpio pin where B channel of the quadrature encoder is connected on same event (toggle of A channel) to be able to resolve direction of the motor. I can't simply read the state of the B channel using nrf_gpio_pin_read in an event or interrupt routine as this is not guaranteed to be real time (softdevice is running).

Is that possible, using e.g. gpiote, ppi, dma ... ?

Parents
  • Hi,

    You can configure the GPIOTE to generate an event on GPIO rising edge, falling edge or any change. You can then configure an TIMER instance in counter mode, and use it to keep track of how many times the event has been generated. If you know the initial gpio state(high/low), then you also know the current GPIO state simply by looking at the counter value.

Reply
  • Hi,

    You can configure the GPIOTE to generate an event on GPIO rising edge, falling edge or any change. You can then configure an TIMER instance in counter mode, and use it to keep track of how many times the event has been generated. If you know the initial gpio state(high/low), then you also know the current GPIO state simply by looking at the counter value.

Children
Related