Skip to content
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

Fix nrf::rtc errata workaround #858

Merged
merged 4 commits into from
Dec 6, 2023
Merged

Conversation

Finomnis
Copy link
Contributor

@Finomnis Finomnis commented Dec 6, 2023

The problem is that the RTC peripheral will not properly deliver an interrupt if the scheduled compare is less than two ticks in the future. Together with the timer uncertainty it was determined that it is necessary to schedule always at least now + 3 ticks in the future.

The current workaround, however, did the following. If it checked the queue and if there is a delay in the queue that is less than 3 ticks in the future, it will dequeue it. This means that the delay will only get re-checked and released at whatever timer interrupt comes in the future, or not at all if it was the last thing to ever wait for, causing a deadlock.

This was the current behavior when scheduling a bunch of delays all at once:

// <desired_release_time_ticks> => <actual_release_time_ticks>
 50 =>  50
100 => 100
101 => 150
150 => 150
200 => 200
201 => ... never

This is obviously not desired behavior.

With the rework, the same situation now plays out as follows:

// <desired_release_time_ticks> => <actual_release_time_ticks>
 50 =>  50
100 => 100
101 => 103
150 => 150
200 => 200
201 => 203

Fixes #851.

Copy link
Collaborator

@korken89 korken89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@korken89 korken89 added this pull request to the merge queue Dec 6, 2023
Merged via the queue into rtic-rs:master with commit f377471 Dec 6, 2023
49 checks passed
@Finomnis Finomnis deleted the nrf_errata_fix branch December 26, 2023 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rtic_monotonic::nrf::rtc errata workaround is probably not what was intended
2 participants