Monotonic delays are too short
Finomnis opened this issue · comments
Given a monotonic tick rate of 1ms
and we call DelayUs::delay_us(1200)
on the monotonic.
- Desired behavior: wait between
2ms
and3ms
- Current behavior: wait between
0ms
and1ms
(which isn't even correct sometimes)
Note that there is a discrepancy of 2ms
(or rather: two timer ticks) between desired and current behavior.
1ms
comes from the fact that we need to compensate for timer uncertainty1ms
comes from the fact that we use.micros()
instead of.micros_at_least()
in ourDelayUs
impls.
This is not only a problem in general, but also directly breaks the requirements of DelayUs
:
Pauses execution for at minimum
us
microseconds. Pause can be longer if the implementation requires it due to precision/timing issues.