Hi,
I want to measure one GPIO (high) pulse time. GPIO is connected to device which gives measurement results by pulling this pin HIGH in micro seconds.
Could you please help me on this if there is any better way other than keep polling?
I would suggest using a pin with PWM functionality.
I don’t have experience wiht Linux, but I think that the PWM driver should have a way to configure the pin and get the desired duration.
Most likely the only way to achieve this in an accurate fashion is either using a real-time Linux flavor or run such measuring on the M4 e.g. running FreeRTOS or Zephyr.
Thank you for your suggestion… but we have lots of interfaces up and running, changing OS is almost impossible at this stage.
Let’s see is @jaski.tx has any idea…
Hi @alex.tx
I read both links info but didn’t get some simple implementation which I can make use of.
Another approach I was thinking to set GPIO as Rising interrupt and start time, then set GPIO as falling INT and stop time, calculate the time for high pulse?
Will it be accurate enough? or do you have any example/sample code which I can use?
Yes you can use an interrupt, but be aware that reaction time is not guarantied under a Linux. So I’d recommend do it using M4 core. Unfortunately I do not have any example/sample code.
I agree with the solutions proposed by @marcel.tx and @alex.tx.
So you have the choice using an interrupt based solution on Realtime Linux or FreeRTOS or write a kernel driver for using Flextimer. Interrupt solution on non real-time Linux will not guarantee you the reaction time and the measurement will have a jitter higher than 100us.