cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L432 – WS2812 LEDs not working reliably (no external crystal)

Martin42
Associate III

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.


Setup:

  • 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


Additional info:

  • I confirmed the LED strip and wiring are working:
    Using an Arduino, the same strip works immediately and reliably.


Questions:

  • 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!

23 REPLIES 23

and are you using an internal RC oscillator with it?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Martin42
Associate III

I’m now using PWM and DMA via Timer 1, Channel 2. HSI and PLL for a Sysclock of 80MHz.

Martin42_0-1747133872387.png

 


@Martin42 wrote:

 using https://github.com/nimaltd/ws28xx library.


So this one by @nimaltd - in the thread linked earlier by @TDK 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

and are you now using a voltage translator?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.