Hello,
I am trying to configure an ultrasonic distance sensor with my Nordic Thingy 91. The response from the sensor would be a pulse which will remain high for some milliseconds (depending upon the distance of the object) and I want to measure the time for which the pulse remained high. For this purpose, I am trying to use GPIOTE events so that I can start the timer when the "NRF_GPIOTE_POLARITY_LOTOHI" action occurs in my interrupt handler and get the timer value when "NRF_GPIOTE_POLARITY_HITOLO" action occurs. For this I have tried the following things:
- Tried to configure the pin event as "NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(true)" but in the interrupt handler I cannot differentiate between the "NRF_GPIOTE_POLARITY_HITOLO" and "NRF_GPIOTE_POLARITY_LOTOHI" actions.
- Tried to configure the pin event as "NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(true)" and "NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(true)" but only one of them work correctly at a time. So either I can sense for rising edge and either for falling edge but not both.
One particular requirement is that the solution for this should have minimal latency otherwise I wouldn't be able to get the precise distance measurement.
Please, suggest me a solution for this problem. I am attaching a sample code which I have been trying but couldn't make it work. Thank you.3324.gpiote.rar