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

rtic-monotonic: Is handling intermediate interrupts for housekeeping OK? #775

Open
romancardenas opened this issue Feb 28, 2023 · 1 comment

Comments

@romancardenas
Copy link
Contributor

From the documentation, I assume that the set_compare method aims to schedule an interruption for a given time instant. However, in my use case, there is a chance that I must do some housekeeping and need two different interrupts to handle timer overflows.

I was thinking about making set_compare and on_interrupt work jointly to handle this particularity. However, I am not sure if RTIC supports "fake" interrupts in intermediate instants that do not correspond to the instant provided when calling set_compare. Is it OK to trigger extra interruptions?

@AfoHT AfoHT transferred this issue from rtic-rs/rtic-monotonic Jul 5, 2023
@AfoHT AfoHT changed the title Is handling intermediate interrupts for housekeeping OK? rtic-monotonic: Is handling intermediate interrupts for housekeeping OK? Jul 5, 2023
@Finomnis
Copy link
Contributor

Finomnis commented Dec 6, 2023

EDIT: I assume you are talking about RTIC 2.

Yes, it is ok. If a spurious interrupt happens, RTIC will simply re-check the timer queue and do another set_compare.

"need two different interrupts to handle timer overflows" - Check out the imxrt-gpt monotonic on how to deal with overflows, it uses one rollover interrupt and one half-period interrupt.

Also check out this new helper utility specifically geared towards implementing a monotonic based on those two interrupts.

Be careful with race conditions - handling timer overflows is very race condition prone, as the timer register is inherently asynchronous. The aforementioned helper utility describes this problem and how to solve it reliably.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants