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

Measuring elapsed microseconds between 12 successive rising edges on 12 GPIOS on NRF52832 DK

Hi everyone,

I'm new with nrf52832, and I need to measure elapsed time in microsecond between rising edges of 12 different Gpios. I have 12 piezoelectric sensors filtered, amplified, getting a 0V-3.3V Logic level in input. Once one of these senors rises up, I need to start counting microseconds and store corresponding elapsed microsecond until I have 11 different values (assuming the first sensor's timing is 0). And then posting it over ble.

I red some documentations, and I heard about Timeslot API, timers and sys_tick, but I don't know which one would be better for my application.

Would you have any idea about how should I take this ?

Thanks for your help, and have a good day !

Parents
  • Hi,

    Have you considered using PPI? It is possible to have the Logic level input start a timer and a counter automatically. I'm not sure if I understand your use case, but it is e.g. possible to start a timer on the first Logic level event, then use a counter to count 11 logic level events, and finally stop the timer on the 11th event. All this can be done autonomously without using the CPU, Timeslot API, or sys ticks. The CPU can even be sleeping while you time your events. On the 11th event you can chose to trigger an interrupt to process your timer value. I wrote a little bit more about PPI at the bottom of this thread.

Reply
  • Hi,

    Have you considered using PPI? It is possible to have the Logic level input start a timer and a counter automatically. I'm not sure if I understand your use case, but it is e.g. possible to start a timer on the first Logic level event, then use a counter to count 11 logic level events, and finally stop the timer on the 11th event. All this can be done autonomously without using the CPU, Timeslot API, or sys ticks. The CPU can even be sleeping while you time your events. On the 11th event you can chose to trigger an interrupt to process your timer value. I wrote a little bit more about PPI at the bottom of this thread.

Children
  • Hi

    Thanks for your answer ! I looked at PPI but it seems like there is only 6 configurable groups. It takes me a bit of time to understand all of the concept of this but can I attach 12 inputs to PPI ? I'm working on it ! Thanks for your help :)

  • Happy to help. Apparently I didn't read your question thoroughly enough. I thought we talked about one GPIO and 12 incoming pulses, not 12 different GPIOs. Although you have 16 PPI channels, you only have 6 GPIOTE channels available (which I think is what you are referring to?). So now I don't see any obvious workarounds with PPI in your case. I don't know the details of you use case, but maybe it would be possible to:

    1. Configure the GPIOTE channels to measure a certain set of 6 pins
    2. Do 6 measurements
    3. Fire an interrupt routine and reconfigure the GPIOTE channels to use the 6 other pins.
  • Thanks for your answer. I was referring to PPI page 165 table 30 (6 groups isn't it ?), Does it mean I can only program 6 gpios over PPI to start timer or capture timer value? Or is this done as 1 group of 6 PPI channels, and another group of 6 others PPI channels (using at total 2 groups of 6 channels each) mixed with 6 GPIOTE as mentionned in your previous comment ?

    I may have missed something, In case I'm using PPI, do I have to use GPIOTE to get peripheral event?

    Thanks for your time :)

  • I'm not sure I understand why you would need PPI groups? Is it so that each of the 12 sensors are completely independent from each other and may trigger at random times? I.e. iat is not so that all of them rises at the same time, on a common start signal?

    If it is all random I can't think of any way of using PPI channels. I don't think the Timeslot API would be of any use either as it is used to schedule events at deterministic points in time. The systick option would also require the use interrupts at the mercy of the Softdevice.

    I was actually wrong about the number of GPIOTE channels, by the way. nRF52832 has 8 GPIOTE channels and 6 PPI groups as you say.

  • Thank you for this comment. I was asking about PPI Groups, because I don't understand yet how they work. My 12 sensors are independent indeed. They are listening to the same signal, and I need to measure propagation timings between the first sensor to the 12'st. As I don't know which sensor will raised first to trigger Timer, I need whole configuration to adapt depending on which of the 12 input will raise first, and all of this in micro-second timing. Thanks again for your help, I think I should now try to find a chip with 12 GPIOTE channels ? Have a good day !

Related