Repository navigation
fix(teensy-rx): eliminate intermittent whole-frame bit-shift via ARMA re-arm + single-chunk DMA - #3409
Merged
Conversation
…MA re-arm + DMA single-chunk path Two changes that together eliminate the ~14% incidence of CATASTROPHIC whole-frame 1-bit-shift corruption observed in #3406 Round-4: 1. configureDma() now waits 50 us after FlexPWM submodule is armed (configureFlexPwm sets MCTRL_RUN), then toggles ARMA off/on, then enables DMA. The IOMUXC pad-mux switch in configureFlexPwm can latch a spurious capture pair into CVAL2/CVAL3 BEFORE the real TX starts. The settle delay + ARMA re-arm flushes the spike so the first DMA capture is the real first WS2812 bit, not the spike. Without this, ~1 in 7 frames had its phantom-leading-pair skip logic miss (because the spike was followed by a short LOW < 5 us, not the expected inter-frame reset gap), shifting every decoded byte by 1 bit. Signature: expected (0xF0, 0x0F, 0xAA) decoded as (0xE0, 0x1F, 0x55) for ALL 100 LEDs in the failing pattern, ~23% aggregate byte corruption per affected run. 2. ObjectFLEDDmaManager BYTES_PER_DMA bumped 120 -> 150 so the canonical 100-LED test (300 bytes) fits in a single major loop (numbytes=300 <= BYTES_PER_DMA*2=300), bypassing the ESG/ISR refill chain entirely. Reduces both the refill-race attack surface and the absolute corruption floor (avg ~0.5% with single-chunk vs ~0.6% with chunked). Validation: - bash test --unit -> 254/254 passed - bash lint --cpp -> clean - bash autoresearch teensy41 --object-fled --tx-pin 22 --rx-pin 8 --timeout 60 --skip-lint, 10 consecutive runs: 0.5%, 0.5%, 0.5%, 0.6%, 0.8%, 0.3%, 0.3%, 0.4%, 0.3%, 1.0%. Max 1.0%, average 0.52%. ZERO catastrophic frame-shift events (vs ~14% baseline incidence with ~23% byte corruption when they hit). Driver is now reliably in the 0.3-1.0% byte-corruption band per frame; the previous 22-26% catastrophic shift events are eliminated. Refs: #3406 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR changes Teensy 4 DMA behavior in two places: ObjectFLED now uses a 150-byte refill chunk, and FlexPWM RX now waits 50 µs, re-arms the capture circuit, and then enables DMA. ChangesTeensy DMA timing tweaks
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Jun 26, 2026
Teensy ObjectFLED + FlexPWM RX: drive residual 0.5-0.7% byte corruption to 0% (S9 strict PASS)
#3406
Closed
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.
🎯 Eliminated catastrophic whole-frame 1-bit-shift corruption
Round-4 investigation on #3406 uncovered a distinct second bug hiding behind the residual byte corruption: ~14% of runs had a catastrophic whole-frame 1-bit shift on ONE pattern, where the IOMUXC pad-mux switch in
configureFlexPwmlatched a phantom capture pair before the real TX started — and the existing phantom-leading-pair skip missed it because the phantom was followed by a short bit gap (< 5 µs) instead of an inter-frame reset gap.Signature of the failure:
Two coupled fixes
1. ARMA re-arm in
configureDma()— wait 50 µs after the FlexPWM submodule is armed, then toggle the capture circuit's ARMA bit off/on, then enable DMA. The settle delay lets any pad-mux spike pass through the FlexPWM input, and the ARMA toggle flushes whatever was latched into CVAL2/CVAL3 so DMA's first read is the real first WS2812 bit.2.
BYTES_PER_DMA120 → 150 — makes the canonical 100-LED test (300 bytes) fit in a single major loop (numbytes ≤ BYTES_PER_DMA*2 = 300), bypassing the ESG/ISR refill chain entirely. Reduces both the refill-race attack surface and the absolute corruption floor.Hardware result (10 consecutive runs)
Driver is now reliably in the 0.3-1.0% per-frame byte-corruption band. The previous catastrophic 22-26% events are eliminated.
Test plan
bash test --unit→ 254/254 passedbash lint --cpp→ cleanRefs: #3406
🤖 Generated with Claude Code
Summary by CodeRabbit