JSN-SR04T and Timer
Hi,
I try to work with the JSN-SR04T distance sensor. The working principle is very simple :
- put the trigger pin to high for 10 us
- count the elapsed time in us on the echo pin between the rising and falling event
- distance is proportional to the elapsed time
For the moment, I use a simple us timer and a counter incremented by the interrupt of the timer. Each us, I read the state of the echo pin. If state is High, I count until state is Low. Work fine but my guess is that we can do better.
I try with a triggered timer but I am confused with all the options in CubeMX.
How can I have a timer who start when the echo pin is rising and stop when he is falling and get the count of the timer ? Witch event should I read ?
Thanks,
Lionel