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
tests/periph_rtc: test sub-second precision #10763
Conversation
3e68135
to
f68987f
Compare
I think this test is useful and necessary, although I'm concerned about the case where the RTC and Xtimer are powered by the same clock. Wouldn't the test stop working in that case? |
It works for me on kw41z where both xtimer and periph_rtc use the same low power clock source. I think most low power platforms will be this way. I can't think of a reason it should be a problem. |
I think this change is useful. It already helped in #10764.
@jcarrano I'm no convinced about that but also lacking knowledge about xtimers internals so I'd rather run some tests on exemplary devices. Do you know of any where your concerns apply? |
I fully agree. |
I didn't see those scripts until now. Wow that's a very nice system. Should we check that the error is less than some predetermined value? I didn't expect to see any platform with an error over 100us but @PeterKietzmann found in #10764 that it can be higher. Although it's possible that that's due to another problem. |
I think this would be a nice improvement. However, this requires certain board specific assumptions about maximum deviations. @MrKevinWeiss came to the great idea to look up worst-case parameters of clock sources at DigiKey which lead to a total number around 500ppm. With that we would at least find misconfigured timers |
BTW: @MrKevinWeiss would you like to take this PR over? |
Only for +-250ppm for frequency stability and +-250ppm for frequency tolerance (not necessarily compounded but we can say that as a dumb worst case) for crystals... Not to mention internal RC oscillators. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Oops. I need to find time to take this over! |
That's pretty useful (also for RTT) - want to give it a rebase? |
Adapted from @benemorius PR RIOT-OS#10763. Add mircosecond precision test to RTC. Adapt automated python test to match test API changes. Assert max of 100 us error. This is needed to test that an RTC alarm fires at the desired time and not with an arbitrary offset up to +/-1 second. It also tests that rtc_set_time() behaves equivalently correctly, which is what I needed to test when I wrote this.
I have #13483 to replace this. It takes care of the conflict and adapts the python test. |
Adapted from @benemorius PR RIOT-OS#10763. Add mircosecond precision test to RTC. Adapt automated python test to match test API changes. Assert max of 100 ms error. This is needed to test that an RTC alarm fires at the desired time and not with an arbitrary offset up to +/-1 second. It also tests that rtc_set_time() behaves equivalently correctly, which is what I needed to test when I wrote this.
Adapted from @benemorius PR RIOT-OS#10763. Add mircosecond precision test to RTC. Adapt automated python test to match test API changes. Assert max of 100 ms error. This is needed to test that an RTC alarm fires at the desired time and not with an arbitrary offset up to +/-1 second. It also tests that rtc_set_time() behaves equivalently correctly, which is what I needed to test when I wrote this.
Adapted from @benemorius PR RIOT-OS#10763. Add mircosecond precision test to RTC. Adapt automated python test to match test API changes. Assert max of 100 ms error. This is needed to test that an RTC alarm fires at the desired time and not with an arbitrary offset up to +/-1 second. It also tests that rtc_set_time() behaves equivalently correctly, which is what I needed to test when I wrote this.
Adapted from @benemorius PR RIOT-OS#10763. Add mircosecond precision test to RTC. Adapt automated python test to match test API changes. Assert max of 100 ms error. This is needed to test that an RTC alarm fires at the desired time and not with an arbitrary offset up to +/-1 second. It also tests that rtc_set_time() behaves equivalently correctly, which is what I needed to test when I wrote this.
Adapted from @benemorius PR RIOT-OS#10763. Add mircosecond precision test to RTC. Adapt automated python test to match test API changes. Assert max of 100 ms error. This is needed to test that an RTC alarm fires at the desired time and not with an arbitrary offset up to +/-1 second. It also tests that rtc_set_time() behaves equivalently correctly, which is what I needed to test when I wrote this.
Adapted from @benemorius PR RIOT-OS#10763. Add mircosecond precision test to RTC. Adapt automated python test to match test API changes. Assert max of 100 ms error. This is needed to test that an RTC alarm fires at the desired time and not with an arbitrary offset up to +/-1 second. It also tests that rtc_set_time() behaves equivalently correctly, which is what I needed to test when I wrote this.
Adapted from @benemorius PR RIOT-OS#10763. Add mircosecond precision test to RTC. Adapt automated python test to match test API changes. Assert max of 100 ms error. This is needed to test that an RTC alarm fires at the desired time and not with an arbitrary offset up to +/-1 second. It also tests that rtc_set_time() behaves equivalently correctly, which is what I needed to test when I wrote this.
Contribution description
This expands
tests/periph_rtc
to verify the microsecond precision of RTC timers. This is needed to test that an RTC alarm fires at the desired time and not with an arbitrary offset up to +/-1 second. It also tests thatrtc_set_time()
behaves equivalently correctly, which is what I needed to test when I wrote this.Testing procedure
Run
tests/periph_rtc
and observe new output (error -177429 microseconds
).Currently it fails for
kinetis/kw41z
(perhaps allkinetis
) and that looks like this:In the case of
kw41z
the error is always a random value (abs(error) < 1 second) depending on what value is randomly in the RTC subsecond register which is currently ignored bykinetis/periph/rtt_set_counter()
.A successful test should have output similar to:
The error precision is limited by the frequency of
xtimer
's timer, hence the 30us error forkw41z
with a 16bit 32kHzxtimer
where 30us is only 1 clock tick. Platforms with a fasterxtimer
should have a smaller error. Perhaps no platform should have an error over 100us.Comments
Must test other platforms.
Perhaps I should have updated the readme.
Why doesn't newlib declare
settimeofday()
?Issues/PRs references
#10764 fixes
kinetis/periph_rtt
to give the successful test output shown above.