Skip to content
Discussion options

You must be logged in to vote

What you get is just the behavior of time_pulse_us(). You will get a proper reading for a high pulse only if the level at the input is low when the function is called. Otherwise only the remainder of the high period is timed. See the documentation at https://docs.micropython.org/en/latest/library/machine.html#machine.time_pulse_us:

If the current input value of the pin is different to pulse_level, the function first (*) waits until the pin input becomes equal to pulse_level, then (**) times the duration that the pin is equal to pulse_level. If the pin is already equal to pulse_level then timing starts straight away.

That makes time_pulse_us() hard to use. It may be better if the implement…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@IoTrees
Comment options

@robert-hh
Comment options

@IoTrees
Comment options

@robert-hh
Comment options

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