Repository navigation
Description
Stage 2c follow-up to meta issue #2836 — implement WS2812 output on LPC845 via 3 PWM channels triggering DMA-to-GPIO writes, as proposed in #2831.
Context
Stage 2a (#2837, merged) shipped a bit-banged M0+ C++ clockless driver for LPC845. At 30 MHz CPU clock the cycle budget is comfortable, so the bit-bang driver is the "boring, correct" baseline.
@phatpaul's original proposal in #2831 suggested an optimization: use 3 PWM channels to trigger DMA bursts that write to GPIO output registers, generating WS2812 timing entirely in hardware. This is novel in FastLED — no existing port uses PWM→DMA→GPIO for LED bit timing. Closest analogues are the RP2040 PIO driver and the Teensy 4.x FlexIO driver, both of which coordinate hardware shift/output engines with DMA but use different peripherals.
Benefits over the Stage 2a bit-bang path:
- CPU free during transmission (can run frame-rate-critical animation logic)
- Lower jitter, since timing is generated by SCT/PWM hardware not by software
- Potential to drive multiple parallel WS2812 chains from one DMA stream (if GPIO write mask is configured properly)
Reference for the same pattern on a different NXP chip (Kinetis K64F):
Proposal
Create src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.h that:
- Configures the SCT (State Configurable Timer) or MRT in PWM mode with 3 channels at the WS2812 T0/T1 timing positions (350 ns rising edge, 800 ns mid, 1250 ns end-of-bit).
- Configures DMA channels to fire on PWM channel events, each writing a fixed value (set-or-clear) to the GPIO SET/CLR registers.
- Source buffer is the serialized LED data converted into a DMA descriptor stream of GPIO write masks.
- Replaces the bit-banged driver for LPC845 when
FL_LPC845 && FASTLED_LPC_PWM_DMA=1is set.
Architectural references already in tree:
src/platforms/arm/rp/rpcommon/clockless_rp_pio.h— coordination of hardware timing engine with DMAsrc/platforms/arm/teensy/teensy4_common/drivers/flexio/— DMA-fed hardware output engine on NXP/Freescale silicon (FlexIO is the i.MX RT cousin of LPC's SCT)- NXP UM11029 §16 (SCT), §17 (DMA), and the LPC84x DMA matrix table
Acceptance criteria
-
src/platforms/arm/lpc/clockless_arm_lpc_pwm_dma.hexists, gated byFL_LPC845 && FASTLED_LPC_PWM_DMA - SCT configuration is documented with NXP register references (UM11029)
- DMA channel/trigger wiring is documented and respects the LPC84x DMA matrix
- CPU usage during a 60 Hz update of a 144-LED strip is measured and reported (target: <5% CPU)
-
examples/Blink/Blink.inocompiles for LPC845 with the PWM+DMA driver active - WS2812 output verified on hardware (scope trace + visible LED output)
- Optional: demonstrate parallel output across multiple GPIO pins from one DMA stream
Decisions
- Priority: P3 — Optimization, not a port-completeness blocker. The Stage 2a bit-bang driver covers the basic use case.
- Build-time opt-in via
FASTLED_LPC_PWM_DMA— Bit-bang remains default. This driver consumes DMA channels and SCT events that user code may want for other purposes. - Novel pattern in FastLED — Code review should confirm the SCT+DMA design before any merge, not just hardware-validate after the fact. The driver design doc should be reviewed as a separate phase from the implementation.
- Hardware validation required before merge — Same reasoning as Stage 2b.
Related issues
- Meta: meta: port FastLED to NXP LPC8xx (LPC804 + LPC845) — two-stage plan #2836 (the two-stage plan)
- Origin discussion: Porting to LPC8xx #2831
- Stage 2a (merged, gives the platform headers this driver hooks into): feat(platform): LPC845 bit-bang clockless driver (Stage 2a of #2836) #2837
- Sister optimization for LPC804: feat(platform): LPC804 PLU clockless driver (Stage 2b of #2836) #2841 (this issue and the PLU issue can be implemented in either order, but neither is on the critical path for "LPC8xx port works")
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(platform): LPC845 PWM+DMA-to-GPIO clockless driver (#2842)
feat(platform): LPC845 PWM+DMA-to-GPIO clockless driver (#2842) (#2850)