Repository navigation
fix(objectfled): BYTES_PER_DMA=120 + TMR4 round-to-nearest - #3408
Conversation
…fensive) Two fixes from the #3406 round-2 multi-agent audit that are correct in their own right. Empirically neither moves the residual 0.5-0.7% byte corruption rate (3 consecutive runs after this commit: 0.6%, 0.4%, 0.7%) so the root cause is in Cluster D (CA0DE vs CA1DE) or deeper. Landing these because they remove real defects. 1. BYTES_PER_DMA 60 -> 120 (ObjectFLEDDmaManager.h fallback). The ISR refill race hypothesis (Agents 2 + 6 converged) said the ISR's ~10 us memset+fillbits+cache-flush could race with dma2's ESG-chained re-arm because the inter-trigger gap was only ~1.25 us. BYTES_PER_DMA=120 doubles the major-loop period (1200 us instead of 600 us), giving the ISR much more headroom. Memory cost: bitdata grows from 15 KB to 30 KB in DMAMEM (OCRAM2). Empirical: rate didn't change, but the race window is now ~2x safer regardless of root cause. 2. TMR4 compare values now round-to-nearest instead of truncating (OjectFLED.cpp.hpp:262-267). Previous `(uint16_t)(F_BUS_ACTUAL / 1e9 * T0H)` truncates 33.75 to 33 (T0H of 220 ns, 5 ns below spec). `+ 0.5f` before the cast rounds to 34 (T0H of 226.67 ns, centered in the 215-235 ns window). Also expanded the ObjectFLEDDmaManager comment about why the ISR shared state stays non-volatile (Agent 5 suggested volatile but that breaks the memcpy() in showInternal that initializes the arrays from the local copies). Validation: - bash test --unit -> 254/254 - bash lint --cpp -> clean - bash autoresearch teensy41 --object-fled --tx-pin 22 --rx-pin 8 --timeout 60 --skip-lint, 3 runs: 0.6%, 0.4%, 0.7% byte corruption (no improvement, no regression). Refs: #3406 #3359 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 (3)
📝 WalkthroughWalkthroughThis PR increases the default ObjectFLED DMA chunk size to 120, updates related comments about ISR-shared state, and rounds timer compare values before casting in waveform setup. ChangesObjectFLED timing and DMA tuning
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 |
Defensive correctness from #3406 round-2 audit
Both fixes empirically did NOT move the residual 0.5-0.7% byte corruption rate. Landing because both are real defects regardless.
A. BYTES_PER_DMA 60 → 120
Agents 2 + 6 independently arrived at the same hypothesis: the ObjectFLED ISR refill could race with dma2's ESG-chained re-arm because the ~10 µs ISR vs ~1.25 µs inter-trigger gap. Doubling BYTES_PER_DMA doubles the major-loop period (1200 µs instead of 600 µs), giving the ISR 2× safety margin. Memory cost: bitdata grows from 15 KB to 30 KB in DMAMEM (OCRAM2, plenty of room).
B. TMR4 compare round-to-nearest
(uint16_t)(F_BUS_ACTUAL / 1e9 * T0H)was truncating 33.75 → 33 (T0H of 220 ns, 5 ns short of spec).+ 0.5fbefore the cast now rounds to 34 (T0H of 226.67 ns, centered in the WS2812B-V5 215-235 ns window).Hardware result
Unchanged from baseline. Root cause is in Cluster D (CA0DE vs CA1DE FlexPWM DMA trigger — Agent 4) or deeper. Separate PR to follow.
Test plan
bash test --unit→ 254/254bash lint --cpp→ cleanRefs: #3406 #3359
🤖 Generated with Claude Code
Summary by CodeRabbit