Repository navigation
The known bugs, each shown by a test first (OIL 2) - #5
Merged
Merged
Conversation
Each of these had a test that failed on the code of main, 18 in all, two of them by hanging: - resume() lets the timer run again, rather than leaving it marked stopped. - stop() stops only a timer that runs: before init() it took the timer for initialized. - detachInterrupt() forgets the callback, so that start() does not enable the interrupt again. - A duty of 255 keeps the output high, as 0 keeps it low: the duty is a share of 255 of the top, rounded, no longer of 256. setPeriod() applies it to the new top. - read() multiplies before it divides, and keeps the steps below 16 at 16 MHz. - The period and its longest value are computed so that the clocks below 2 MHz and at 20 MHz are right; a test of them runs at 1, 16 and 20 MHz, each a build of its own. - A period too short for one step of the counter is refused: its top of 0 stopped the counter, and start() waited for it forever. init() with a period it refuses leaves the timer as it was. Two more, found while fixing these, which no test on the host can show: attachInterrupt() keeps the interrupt off while it writes the pointer, which the AVR writes a byte at a time; and the duty is computed in 16 bits unsigned, as 255 * 255 overflows the AVR's int. A test that hangs fails after 10 s rather than stopping the run. Flash and RAM on the Uno grow: Basics from 1290 / 25 to 1372 / 26 bytes, Read from 2790 / 210 to 2894 / 211, for the duty kept across a period and the exact arithmetic. The self check in simavr is an item of its own now, OIL 5: simavr 1.6 of the dev container leaves TCNT2 at 0 in the phase correct modes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ither Measured with the registers alone in simavr 1.6 and in 1.8 built from source: TCNT2 stays at 0 in modes 1 and 5, OC2B never drives pin 3, and the overflow interrupt seems to fire without end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…orted in simavr #442 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The second of the steps in OIL.md: the bugs found while bringing TimerTwo onto the template, each shown by a test that failed on main before it was fixed. The API stays as it is; version 2.0.0 (OIL 3) is where it changes.
What changes for a sketch
What was measured
make checkpasses; coverage of the library 98 % of the lines.Not in this pull request
The self check in simavr, planned for this step, is OIL 5 now: the simavr of the dev container, 1.6, does not count this timer in its phase-correct modes at all, measured with the registers alone. Nor does the latest release, 1.8, built from source for the measurement: it lists the modes, but the counter stands, the PWM pin is never driven, and the overflow interrupt seems to fire without end. OIL 5 waits for a simavr that models them.
🤖 Generated with Claude Code