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

GPIOTE event for High to Low and Low to High on the same pin

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:

  1. 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.
  2. 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

Parents Reply
  • Hi,

     

    harisahmed said:
    nrf9160-dk does not work for me because sensor requires 3.3 V and nrf9160-dk only provides 1.8 V on its GPIOs.

    There's a switch near the ON/OFF main switch on the nRF9160-DK where you can set VDD_IO to 3V if needed.

     

    harisahmed said:
    Actually, I just checked. I am using nRF91-P0.10 and nRF91-P0.16 so I have nRF91-P0.13 free. I will try to connect with this one. 

    I'm glad to hear that you found some unused GPIOs!

     

    Kind regards,

    Håkon 

Children
No Data
Related