Repository navigation
fix(teensy-flexio): TRGSEL=3 for Timer 1/Timer 3 + emit FlexPWM RX diag for FlexIO - #3413
Merged
Merged
Conversation
…M RX diag #3410 Round 3, two related changes: 1. FlexIO Timer 1 and Timer 3 had TRGSEL=0 -- which encodes "Pin 0 input" per i.MX RT1062 RM 47.4.10 -- when the intent was "Timer 0 output". The correct encoding is TRGSEL = 4*M + pattern; for "Timer M output" pattern is 3, so for Timer 0 output the value is 3, not 0. With TRGSEL=0 Timer 1 was waiting for an external rising edge on pin 0 that never came, so the WS2812 low-bit PWM never fired and no signal appeared on the TX pad. 2. The flexPwmRxDiagnostics JSON block was only emitted when `is_object_fled_driver`, but the FlexPWM RX path is useful for ANY Teensy driver using a FlexPWM-capable pin as RX -- e.g. FlexIO TX on pin 8 -> FlexPWM RX on pin 22 during this round's bring-up. Now emits on every Teensy 4.x test and context.py renders it unconditionally. Hardware result: bash autoresearch teensy41 --flex-io --tx-pin 8 --rx-pin 22 \ --timeout 30 --skip-lint TEST FLEX_IO lanes=1 leds=100 FAIL 460 ms class=zero_capture flexPwmRxDiagnostics: activeMuxValueLive: 17 (pin 22 ALT1 + SION) OK activeSelectValueLive: 1 (#3404 fix) OK mctrl: 3840 captctrla: 25 dmaen: 96 dmaErq: 24 -- RX armed cval2..5: 0 citer: 4096 biter: 4096 -- ZERO edges captured So FlexIO TX is still NOT producing edges on pin 8 even after the TRGSEL fix. The shifter+timer architecture needs deeper auditing against a known-working WS2812-via-FlexIO reference (cross-check with NXP AN12491 or similar). At minimum: - Timer 2 enable condition (currently TRGSEL=1 = shifter status flag; needs to fire only on data=1 bits) - Shifter 0 SHIFTCTL pin output routing (SMOD=2 TX, PINCFG=3) - Whether the design even works with the current 4-timer architecture or needs an alternative Driver state after this PR: - No crashes, no hangs, no IMPRECISERR (#3411 + #3412 stable) - Test classifies cleanly as zero_capture (~460 ms per run) - RX diagnostic confirms TX is silent on the wire - Next round = make TX actually drive the pad Refs: #3410, #3411, #3412 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)
📝 WalkthroughWalkthroughThe PR adjusts ObjectFLED diagnostics gating and Teensy 4 response field emission, and corrects two FlexIO timer TRGSEL encodings in the Teensy 4 driver. ChangesTeensy 4 diagnostics and FlexIO encoding
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
zackees
added a commit
that referenced
this pull request
Jun 26, 2026
…12 + SION + primed shifter (#3414) #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]>
1 task done
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.
#3410 Round 3
Two changes:
1. Timer 1 + Timer 3 TRGSEL encoding fix
Per i.MX RT1062 RM 47.4.10,
TRGSEL = 4*M + pattern. For "Timer M output" pattern is 3, so for Timer 0 output the value is 3 (NOT 0). Driver had Timer 1 + Timer 3 set to TRGSEL=0 which encodes "Pin 0 input" — they were waiting for an external rising edge on pin 0 that never came, so the WS2812 low-bit PWM never fired.2. FlexPWM RX diagnostics emitted for ALL Teensy drivers
Previously only ObjectFLED runs got the FlexPWM RX state dump. FlexIO TX → pin 22 RX needs it too. Now emits unconditionally on Teensy 4.x;
context.pyrenders regardless of TX driver.Hardware result
So FlexIO TX is still not producing edges on pin 8 even after the TRGSEL fix. The shifter+timer architecture needs deeper auditing — possibly Timer 2's enable condition (currently TRGSEL=1 = shifter status flag, but needs to fire only on data=1 bits) or the shifter SMOD/PINCFG routing.
Test plan
bash test --unit→ 254/254bash lint --cpp→ cleanbash autoresearch teensy41 --flex-io ...→ completes 460 ms, no crash, RX diag now visible and shows TX is silent on the wireRefs: #3410, #3411, #3412
🤖 Generated with Claude Code
Summary by CodeRabbit