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 Children
  • Not if you require to know which event occurs. You can set the GPIOTE channel in TOGGLE mode, but this does not give you information about the edge triggering (ie. rising or falling). Are you using all GPIOs? Have you considered developing with the nRF9160-DK instead? This gives you a more flexible way of accessing GPIOs via pin headers.

     

    Kind regards,

    Håkon

  • 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. 

    nrf9160-dk does not work for me because sensor requires 3.3 V and nrf9160-dk only provides 1.8 V on its GPIOs. On Thingy91, I am making use of NMOS connected GPIO to have the voltage at 3.3V. I can try to switch VDD from 1.8 to 3.3V on the nrf9160dk but I didn't because it is not recommended in the documentation if we want to use the LTE modem as well.

  • 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 

Related