Skip to content

Preserve pending timer overflow when rewriting timer control - #31

Merged
beebono merged 1 commit into
beebono:mainfrom
shauninman:main
Oct 25, 2026
Merged

beebono merged 1 commit into
beebono:mainfrom
shauninman:main

Conversation

@shauninman

Copy link
Copy Markdown
Contributor

A timer control write can occur when its overflow is already due but has not yet been dispatched. Replacing the scheduled event at that point loses the overflow’s reload, interrupt, and cascade tick.

Settle the timer’s due event through its existing callback before applying the control write, preserving the original overflow phase.

Found while investigating uneven Electroplankton Rec-Rec playback. Offline measurements changed from variable restart intervals of roughly 3.977–4.061 seconds to approximately 4.01134 seconds, with nine consecutive intervals spanning less than 0.3 ms.

Includes a ROM-free regression test covering control writes before, at, and after overflow on both CPUs, checking reload, IRQ, cascade, and subsequent overflow timing.

caused Electroplankton's Rec-Rec drumbeat to not loop cleanly
@beebono
beebono merged commit 6276c2d into beebono:main Oct 25, 2026
abradburne added a commit to abradburne/DSperate that referenced this pull request Oct 25, 2026
…), and beebono#26-beebono#30 as merged

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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