jgarff / rpi_ws281x

Userspace Raspberry Pi PWM library for WS281X LEDs
BSD 2-Clause "Simplified" License
1.76k stars 615 forks source link

ws2813 timings (PWM, Pi 3 b+) #509

Open sir-go opened 1 year ago

sir-go commented 1 year ago

Hi, I struggle with my w2813 strip, controlled by PWM (pin 18) on Raspberry Pi 3b+ It has different timings.

http://www.normandled.com/upload/201605/WS2813%20LED%20Datasheet.pdf

0 -> 220-380 ns / 580 - 1600 ns 1 -> 580 - 1600 ns / 220 - 420 ns reset > 280000 ns

what means the pulse of freq x 3 is too big 1 / (3 * 800 KHz) = 417 ns (> 380 ns)

so, I need symbols 0b1000 and 0b1110, then 1 / (4 * 800 KHz) = 312.5 ns 0b1000 -> 312.5 / 937.5 0b1110 -> 937.5 / 312.5

and reset: 1024 * 312.5 = 320000 ns (> 280000 ns)

Perfect!

But... it doesn't work. I don't know why.

Help me, please.

I've changed ws2811.c :

...
64: #define LED_BIT_COUNT(leds, freq) ((leds * LED_COLOURS * 8 * 4) + 1024)
...
75: #define SYMBOL_HIGH                              0b1110
76: #define SYMBOL_LOW                               0b1000
...
361: cm_clk->div = CM_CLK_DIV_PASSWD | CM_CLK_DIV_DIVI(osc_freq / (4 * freq));
...
1198: for (l = 3; l >= 0; l--)               // Symbol
...

Anything else I should check?