-
Notifications
You must be signed in to change notification settings - Fork 131
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
system_timer_current_time_us drifts behind us_ticker_read at a variable rate #451
Comments
Another test. Sends to serial, the difference between system_timer_current_time_us() and time calculated by counting system ticks. Also shows error when measuring the time between pressing button A and pressing a button at P0, similar to MakeCode measuring a sonar pulse. Fix is in PR #469
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
system_timer_current_time_us loses time relative to us_ticker_read at a variable rate. This affects system_timer_current_time and uBit.systemTime. The drift is usually 1.5 to 4.5 ms/s, but can be higher. Very occasionally, system_timer suddenly catches up by about 60ms.
Reading the system_timer more often speeds up the drift. I suspect interrupts occurring inside update_time cause ticks to be dropped.
This could be improved by only resetting the Timer when timer->read_us() > 2000000000.
Maybe a better solution is to ditch Timer and use us_ticker_read directly?
The example below sends to serial, when button A is clicked or B held down, the times, the difference between them and the rate of drift in microseconds per second.
The text was updated successfully, but these errors were encountered: