2025-05-12 9:01 AM - edited 2025-05-12 9:02 AM
Hi everyone,
I'm trying to drive a WS2812 LED strip (20 LEDs - Strip has 60 LEDs) using an STM32L432KCUx, but so far without success.
I've tested multiple approaches — PWM with DMA, SPI-based encoding, and bit-banging via GPIO — but none of them produce stable or correct results. Sometimes up to 22 LEDs light up instead of 20, and the colors are often wrong or appear white.
Occasionally, the first LED doesn’t light up at all, which seems to indicate timing jitter or inaccurate bit timing.
Microcontroller: STM32L432KCUx
No external HSE crystal or LSE available
SYSCLK = 48 MHz, tested using both MSI via PLL and HSI via PLL
Output pins used:
PA12 for SPI and bit-banging
PA9 for PWM (TIM1_CH2)
SPI clock set to 2.4 MHz (used for encoded WS2812 bitstream) SYSCLK = 38MHz
3.3 V logic level used for WS2812 data line (no level shifter)
LED strip powered with 5 V USB - GND connected
I confirmed the LED strip and wiring are working:
Using an Arduino, the same strip works immediately and reliably.
Has anyone successfully driven WS2812 LEDs using an STM32L4 without an external crystal?
Could the issue be due to clock accuracy (MSI/HSI) or the 3.3 V logic level?
Does anyone have a working example project (PWM, SPI, or bit-banging) for this or a similar STM32 without HSE?
I'd really appreciate any tips, example code, or experience on this topic!
Solved! Go to Solution.
2025-05-13 3:41 AM
and are you using an internal RC oscillator with it?
2025-05-13 3:58 AM
I’m now using PWM and DMA via Timer 1, Channel 2. HSI and PLL for a Sysclock of 80MHz.
2025-05-13 4:07 AM - edited 2025-05-13 4:09 AM
@Martin42 wrote:using https://github.com/nimaltd/ws28xx library.
So this one by @nimaltd - in the thread linked earlier by @TDK
2025-05-13 4:12 AM
and are you now using a voltage translator?