Skip to content

time_pulse_us triggered 5 times after timeout. Why? #16045

Discussion options

You must be logged in to vote

You did not tell which port you use.

In your code you set up a Pin irq to call sense2_signal(). It is a soft irq, so the Pin.irq is sheduled for every rising slope that occurs and sense2_signal may be called several times. If the input signal can have several fast transitions like they are created from a bouncing switch, one can get a burst of IRQ calls.
Also, you mentioned it, having the IRQ handler to block for 2 seconds is not good.

I would set up two irq handlers, the Pin IRQ for detecting input transitions and a timer irq to detect the timeout, which just measures the time between a start time and the actual time. The Pin irq would reset the start time to the actual time. Time sampli…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sk8board
Comment options

Answer selected by sk8board
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants