-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixups to timer_api test #24080
Fixups to timer_api test #24080
Conversation
@dcpleung reported this on the microchip board. I haven't tested it there, and (oddly) it doesn't seem to happen on my nRF board which should have roughly the same properties. He should validate before merge. |
621e976
to
8837b55
Compare
(FWIW: I just remembered that nRF are 1:1 with ticks:cycles, so they aren't subject to this problem. We should check, if the microchip config has a non-divisible ratio we should fix that because it can cause problems like this in app code.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixed the test_timer_remaining()
test on mec15xxevb_assy6853
. (relates to #24001)
While Nordic has ticks and cycles the same, the busywait uses a different clock. Further, on it an integral number of ticks is rarely an exact number of milliseconds. So this may also be a factor in #23106. |
just ran this on a few boards:
|
8837b55
to
9a7f902
Compare
Add a patch to fix the abs_timeout test's conversion goof. |
This test sets a timer, busy waits for half the duration, and then checks the remaining time is correct. And it correctly does all its math in tick precision and aligns to a timer interrupt to eliminate aliasing due to the tick stride. But it's waiting using k_busy_wait(), not a timer: "half the duration" in MICROSECONDS (for k_busy_wait()) is not necessarily representable as an integer number of TICKS on all platforms. Because k_busy_wait() always rounds up, we need one extra tick of buffer on those platforms. Signed-off-by: Andy Ross <[email protected]>
The test of the absolute timeout feature was a simple whitebox test that inspected the generated ticks field of different constructors for identity. But it wasn't simple enough, because it was doing a ticks->ms->ticks conversion (at compile time, sigh) on the input data, which is obviously lossy on platforms where ticks are shorter than milliseconds by non-integral factors. Fix to do the conversion in just one direction. Signed-off-by: Andy Ross <[email protected]>
9a7f902
to
c64e7fe
Compare
Rebase to clear out that weird doc failure. |
@andyross , I see your change to add one tick to the |
Fixes #24072 |
@nashif does this still cause regressions, or is it now an improvement on the master branch with your testing rig? |
This test sets a timer, busy waits for half the duration, and then
checks the remaining time is correct. And it correctly does all its
math in tick precision and aligns to a timer interrupt to eliminate
aliasing due to the tick stride.
But it's waiting using k_busy_wait(), not a timer: "half the duration"
in MICROSECONDS (for k_busy_wait()) is not necessarily representable
as an integer number of TICKS on all platforms. Because k_busy_wait()
always rounds up, we need one extra tick of buffer on those platforms.
Fixes #24001
Signed-off-by: Andy Ross [email protected]