Showing results for 
Search instead for 
Did you mean: 

PWM generation for RGB LED Strip using WS2812 protocol

Associate III

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.

ST Employee

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.