Skip to main content
DJ1
Associate III
July 27, 2023
Question

PWM generation for RGB LED Strip using WS2812 protocol

  • July 27, 2023
  • 2 replies
  • 3898 views

So i am using STM32F401RE board where i have written the code to for a strip of RGB led working on the WS2812 protocol which is nothing but using 24 bit PWM waveform for 1 led in GRB format. Every time i enable the PWM channel using CCR1 register for Timer2, always i am getting 1 extra pulse always at the beginning, due to which instead of 24 pulses, 25 pulses are sent and the entire data gets corrupted, how can i control the timer channel in more efficient way. I have attached the code and the datasheet below.

Note the naming conventions might change as the header file is also made by us.

This topic has been closed for replies.

2 replies

ST Employee
July 27, 2023

Hello @DJ1

Could you provide a scope capture of this behavior? Could you confirm that it's not only the first set of data output that is incorrect but also if you send data again it's incorrect ?

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.