Skip to content

A callback attached while stopped is called after Resume() - #8

Merged
theAndreas merged 2 commits into
mainfrom
resume-interrupt
Nov 11, 2026
Merged

theAndreas merged 2 commits into
mainfrom
resume-interrupt

Conversation

@theAndreas

Copy link
Copy Markdown
Owner

A callback attached while the timer is stopped is now called once the timer is resumed. This is item 7 of OIL.md.

What changes for a user

  • Before, a sketch that stopped the timer, attached a callback and resumed it never got a call: the interrupt stayed off. Now the callback runs from the next overflow on, as it does when attached while the timer runs.
  • Nothing else changes; flash and RAM of the examples stay the same.

Why

AtmegaTimer, which continues TimerTwo from version 2.0.0, found the bug in the same code. It is fixed here before 2.0.0 is tagged, so that the release carries the fix.

How it was checked

  • A new test attaches a callback while the timer is stopped and expects the interrupt on after resuming; it failed before the fix and passes after it.
  • make check passes: the tests by GCC and clang, under the sanitizers, with every line of the library reached; clang-tidy, cppcheck, the documentation and the examples.

Found in AtmegaTimer, which took the code of 3: the interrupt stayed off, so the callback was
never called.
AttachInterrupt() enabled the overflow interrupt only while the timer ran, and Resume() does
not touch it: a callback attached while stopped was never called. It is enabled while the timer
is stopped as well now, where the counter stands and comes to no bottom before Resume(). OIL 7.
@theAndreas
theAndreas merged commit cd449b0 into main Nov 11, 2026
6 of 18 checks passed
@theAndreas
theAndreas deleted the resume-interrupt branch November 11, 2026 14:19
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.

2 participants