Repository navigation
fix(teensy-flexio): Round 5 architectural rewrite — bit-encoded WS2812 + SION + primed shifter - #3414
Conversation
…12 + SION + primed shifter #3410 Round 5. Substantive rewrite per the whatnick FRDM-K82F WS2812 reference. The previous 4-timer + 1-shifter design with OR-gated outputs could not work because FlexIO TRGSEL doesn't expose "shifter data output" as a per-bit gating source -- only pin-input, shifter- status-flag, and timer-trigger-output. Timer 2 could not be modulated by the actual shifter bit value. This rewrite drops Timers 1/2/3 and uses ONE timer + ONE shifter: - Each WS2812 bit is pre-encoded as 4 FlexIO bits in the DMA buffer (`1000` for 0-bit, `1110` for 1-bit) at ~3.16 MHz baud - Shifter 0 routes its output directly to the pin via PINCFG=3 - Timer 0 generates the shift clock; no PWM gating needed - 0-bit gets ~317 ns HIGH + ~950 ns LOW (within WS2812 spec) - 1-bit gets ~950 ns HIGH + ~317 ns LOW (within WS2812 spec) - DMA writes pre-encoded u32s to SHIFTBUF (not SHIFTBUFBIS so the MSB-first shifter naturally matches MSB-first encoding) Additional fixes inline with the rewrite: 1. Pin mux now ALT4 + SION (0x14) per Teensyduino FlexIO_t4 reference. Without SION the IOMUXC input path is gated and FlexIO cannot drive the alt-mode pad output -- root cause of all prior `zero_capture` results in Rounds 1-4. All other register settings had been correct. 2. Timer 0 TIMENA = trigger rising edge (was trigger high level) so the timer re-arms on each SSF transition instead of latching once. 3. SHIFTBUF[0] primed with first encoded word before DMA enable, so SSF transitions happen and the initial Timer 0 trigger fires. Hardware result on this branch: bash autoresearch teensy41 --flex-io --tx-pin 8 --rx-pin 22 \ --timeout 30 --skip-lint TEST FLEX_IO lanes=1 leds=100 FAIL 459 ms class=zero_capture cval2..5: 0 citer: 4096 -- still no edges on the wire The architectural rewrite is in place but TX is STILL silent. Without a logic analyzer or scope to confirm whether FlexIO is driving the pad at all, further blind register-tweaking is unproductive. The next investigator should either (a) attach a scope to pin 8 during the test, or (b) port a verified-working FlexIO WS2812 codebase line-by-line (e.g. Finomnis/ws2812-flexio Rust impl, or MCUXpresso SDK FlexIO LED driver) rather than continue iterating against the i.MX RT1062 RM in isolation. The base infrastructure (no hangs, no crashes, register offsets correct, clock init correct per Teensyduino, ALT4+SION, bounded waits, post-test diagnostic visibility) is now solid enough for that focused effort. Refs: #3410, #3411, #3412, #3413 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 (1)
📝 WalkthroughWalkthroughThe Teensy FlexIO WS2812 driver now uses a fixed baud divider, SION pin muxing, byte pre-encoding into FlexIO bitstreams, and a revised DMA transmit sequence with updated buffer sizing and startup ordering. ChangesTeensy FlexIO WS2812 transmit path
Sequence Diagram(s)sequenceDiagram
participant flexio_init
participant flexio_configure_hw
participant flexio_show
participant flexio_encode_ws2812_byte
participant DMA
participant FlexIO2
flexio_init->>flexio_configure_hw: configure SION pin mux and fixed baud_div
flexio_show->>DMA: disable and clear complete/interrupt/error state
loop each input byte
flexio_show->>flexio_encode_ws2812_byte: encode WS2812 byte
flexio_encode_ws2812_byte-->>flexio_show: 32-bit FlexIO bitstream
end
flexio_show->>DMA: program TCD for FLEXIO2_SHIFTBUF
flexio_show->>FlexIO2: enable FlexIO and prime SHIFTBUF[0]
DMA->>FlexIO2: transfer encoded words
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 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 |
#3410 Round 5 — substantive architectural rewrite
Per the whatnick FRDM-K82F WS2812 reference, the previous 4-timer + 1-shifter design with OR-gated outputs is architecturally infeasible: FlexIO TRGSEL only exposes pin-input / shifter-status-flag / timer-trigger-output — NOT shifter data output. Timer 2 cannot be modulated per-bit by the shifter's actual bit value.
This rewrite drops Timers 1/2/3 entirely and uses one timer + one shifter + bit-encoded data:
1000for 0-bit,1110for 1-bit) at ~3.16 MHz baudInline fixes alongside the rewrite:
zero_captureacross Rounds 1-4.Hardware result
TX still silent. Without a logic analyzer or scope to confirm whether FlexIO is driving the pad, further blind register-tweaking is unproductive. The next investigator should either (a) attach a scope to pin 8 during the test, or (b) port a verified-working FlexIO WS2812 codebase line-by-line (Finomnis/ws2812-flexio Rust, MCUXpresso SDK FlexIO LED driver) rather than continue iterating against the RM in isolation.
Base infrastructure is now solid for that effort: no hangs, no crashes, correct register offsets, correct clock init per Teensyduino, ALT4+SION mux, bounded waits, post-test diagnostic visibility for all Teensy 4.x drivers.
Test plan
bash test --unit→ 254/254bash lint --cpp→ cleanbash autoresearch teensy41 --flex-io --tx-pin 8 --rx-pin 22 --timeout 30 --skip-lint→ completes in 459 ms,class=zero_capture, no crashes, no hangsRefs: #3410, #3411, #3412, #3413
🤖 Generated with Claude Code
Summary by CodeRabbit