Repository navigation
fix(emulator): drive the timer 1 PWM waveform of the ATtiny85 - #341
Merged
ttbombadil merged 3 commits intoOct 24, 2026
Merged
Conversation
avr8js 0.21.1 drives no OC1A/OC1B signal when CTC1 is set, as ATTinyCore configures analogWrite on PB1/PB4, and counts phase-correct without CTC1. On the chip the counter runs from 0 to OCR1C in PWM mode and OC1x is high until the match with OCR1x (datasheet 12.2.2). The profile now drives both outputs from the counter and counts that sawtooth. Members are replaced as plain properties: an accessor on the instance slowed the emulation from 11x to 8x. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… title Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 24, 2026
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.
Worum es geht
Offener Fund aus M3 (#334, #337): avr8js 0.21.1 erzeugt beim ATtiny85 in der PWM-Konfiguration, die ATTinyCore für
analogWriteauf PB1/PB4 verwendet (CTC1 + PWM1x, OCR1C = 255), kein Signal an OC1A/OC1B. Ohne CTC1 zählt es außerdem phasenkorrekt, der Chip zählt aber in jedem Fall als Sägezahn von 0 bis OCR1C (Datenblatt 12.2.2; ATTinyCore: „this module doesn't have a 8bit PWM mode“).Änderung
mcu/attiny85.ts:correctTimer1Pwmtreibt OC1A/OC1B aus dem Zählerstand (HIGH von 0 bis zum Vergleich mit OCR1x, mit COM1x = 11 invertiert). Bei CTC1 zählt avr8js schon richtig, es fehlte nur das Signal. Ohne CTC1 ersetzt die Korrektur die phasenkorrekte Zählung durch den Sägezahn samt Flags (TOV1 beim Sprung auf 0).Object.defineProperty) bremste die ganze ATtiny-Emulation in V8 von 11 × auf 8 × Echtzeit; das steht jetzt im Kommentar.Tests
attiny85-profile.test.ts: Signal an PB4 austiny_probe(analogWrite(4, 200)→ 200/256 HIGH) sowie drei taktgenaue Registertests (Periode OCR1C + 1 mit CTC1, Sägezahn ohne CTC1, invertiert mit TOV1). Gegenprobe: ohne Korrektur sind alle vier rot.npm run test:unit:emulator: 34 Dateien, 685 Tests grün, Korpus eingeschlossen (attiny_pwm_dutyunverändert grün).npm run emulate -- … --board attiny85 --ms 1500 --repeat 7, M2 Pro):tiny_serial10,9 × (vorher 10,9–11,3 ×),tiny_probe10,8 ×.Dokumentation
README des Pakets (Abschnitt avr8js-Korrekturen), Plan P6.2, M3-Bericht (Fund behoben statt Restpunkt), Statusdatei.
🤖 Generated with Claude Code