You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
LPC845 SCT+DMA clockless: frame ending in bits '10' sends the second-to-last bit as T0H #5276
Found while addressing CodeRabbit review on #5275 (LED-indexed bench payloads).
Symptom. With ChannelEngineLpcSctDma (-DFASTLED_LPC_PWM_DMA=1) on an LPC845-BRK, a frame whose last two wire bits are 1,0 usually comes out with the second-to-last bit high for T0H (~291 ns) instead of T1H (~750 ns). Every other bit position decodes correctly, including 10 pairs in mid-frame and at chunk boundaries.
Repro (jumper P0_13 -> P0_10, CTIMER0 capture via pwmDmaClCaptureSelf, 1 LED, hold 0):
B byte
ending
result
0x02, 0x06
10
bit 22 reads 0, 3/3
0x0A, 0xFE
10
bit 22 reads 0, 2/3
0x01, 0x03, 0xFD, 0x80, 0x40
not 10
ok 3/3
On the #5275 bench, case 5 (10 LEDs, step 0x1F3B57, last byte 0x1E) fails at bit 238 in most runs. The same issue occurs on PR head a0f52ae without the review changes (0xFE failed 1 of 3 there). The rate varies with firmware timing.
Capture ruled out (mostly). Moving the CTIMER sample point from (T1H+period)/2 to T1H+2 ticks gives the same failure rate. A capture artifact would need the CR0 copy to be more than 1.3 us late, so the cause is likely in the transmitter: the last mask (the '0', CLR on EV1) takes effect before bit N-2's EV1. That means the descriptor's final transfer, the one that links to the halt slot, fires one bit early.
Where to look.src/platforms/arm/lpc/drivers/sct_dma/lpc_sct_dma_runtime.cpp.hpp: the final chunk descriptor -> halt slot hand-over (lpcSctTxWriteHaltSlot, trigger/CLRTRIG semantics on reload, SCT_DMA0 request behaviour around the last EV2).
Root cause, measured on the LPC845-BRK: this is the bench's CTIMER capture, not the transmitter.
The window: the capture's per-bit CR0 copy must land between one bit's fall and the next one's. At 1250 ns bits that is T3+T0H = 800 ns, 19 ticks at 24 MHz.
The miss: on the bit whose EV2 makes the TX reload a descriptor, the TX transfer and descriptor fetch take DMA0 first and the copy misses. It then reads the next bit's '0', which is why only 1,0 endings failed.
Evidence:
With T3 = 1450 ns (same T0H/T1H, identical TX path), 12 of 12 10-ending frames pass.
Moving the sample point earlier, closer to the TX burst, made it more frequent.
The TX's own write on the reload bit always lands in time.
Activity
fix(lpc): #5276 is the bench capture missing its DMA window, not the TX
zackees commentedon Nov 18, 2026
Root cause, measured on the LPC845-BRK: this is the bench's CTIMER capture, not the transmitter.
1,0endings failed.10-ending frames pass.1,0-ending regression cases. 27 of 27 cases passed over 3 runs.fix(lpc): LPC845 SCT+DMA clockless engine drives the wire (--pwm-dma-…