kinetis: lptmr reload instead of spinning#10020
Conversation
|
I have noticed that bench_timers shows that the target is missed sometimes when LPTMR timer_set is called with timeout=0. This PR fixes it by reloading whenever timeout == 0 instead of trying to race update the compare register. |
kaspar030
left a comment
There was a problem hiding this comment.
Untested ACK. Don't have the hardware. Could someone give this a quick spin?
Spinning for the correct time has the side effect that it may cause infinite recursion if the callback function calls timer_set. timer_set->callback->...->timer_set->callback->...->timer_set-> infinity In theory, the drawback is that the callback for very short timeouts (<2 lptmr ticks) may be delayed up to 2 lptmr ticks (61 µs) In practice however, tests performed using tests/bench_timers shows that this change only affects the accuracy of the timer target when timer_set is called with a timeout of 0, which results in a delay of 30 µs.
d971602 to
fa3b916
Compare
|
I tested this PR with tests/periph_timer_timeout0 from #10019 on a frdm-k22f. At first it failed due to coordination of tests and reset (an the fact it is on a raspberry pi) but it passes when I frdm-k22f
I just did the test only, I am relying on @kaspar030 review. Maybe he can merge then. |
|
ping @kaspar030 @miri64 |
|
Everything is green here already - any reason not to press the button? |
|
#10020 (comment) was the only thing missing, but @MrKevinWeiss was taking care of this. Let's just give Murdock another spin, since the last build of this PR is quite old. |
Contribution description
Spinning for the correct time has the side effect that it may cause
infinite recursion if the callback function calls timer_set.
timer_set->callback->...->timer_set->callback->...->timer_set-> infinity
In theory, the drawback is that the callback for very short timeouts
(<2 lptmr ticks) may be delayed up to 2 lptmr ticks (61 µs)
In practice however, tests performed using tests/bench_timers shows that
this change only affects the accuracy of the timer target when timer_set
is called with a timeout of 0, which results in a delay of 30 µs.
Testing procedure
Run the test in #10019 on a kinetis board with an LPTMR configuration (e.g. any of the frdm boards, for k64f, see #9930) with this PR applied.
Issues/PRs references
Regression test for this bug #10019
LPTMR configuration for frdm-k64f: #9930