Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ws2812bdemo having issues with string lengths >5 and <10 #236

Open
romain145 opened this issue Sep 12, 2023 · 1 comment
Open

ws2812bdemo having issues with string lengths >5 and <10 #236

romain145 opened this issue Sep 12, 2023 · 1 comment

Comments

@romain145
Copy link
Contributor

First of all, thanks for the great lib and examples! I'll try to contribute starting with this issue, and maybe a fix if that's at my level!

So, I noticed this strange issue of the SPI having different behaviour when changing the LED count.
Here are the scope captures with NR_LEDS set from 1 to 11:

LED1
LED2
LED3
LED4
LED5
LED6
LED7
LED8
LED9
LED10
LED11

For NR_LEDs between 6 and 9 the SPI behaviour is different, which causes issues with the WS2812B I'm using.

I noticed this in ws2812b_dma_spi_led_driver.h:

// Note first n LEDs of DMA Buffer are 0's as a "break"
// Need one extra LED at end to leave line high. 
// This must be greater than WS2812B_RESET_PERIOD.
#define WS2812B_RESET_PERIOD 2

What is the reason for keeping the line high? The 2812B's datasheet specifies that the line should be low for at least 50us after the last bit is sent.

@Randomblock1
Copy link

I was also running into this issue with 8 LEDS in the demo. If NR_LEDS is 7-9, LEDs 7 and 8 did not light up. Interestingly, it started working when NR_LEDS was >9, so I could just ignore the nonexistent LEDs. However, the better solution was to change DMALEDS in the driver code to literally any other valid value, since there's a buffer of 2, I chose 12. Somehow that worked.

Following the last guy's comment about putting the line low, I can keep everything as it was before but set the WS2812B_RESET_PERIOD to 0 and have the LEDS work fine as long as I set the SPI line low in the beginning of DMA start. If I don't set it low then the brightness is incorrect.

This is my first experience with this chip and this kind of C code so IDK what exactly is wrong, but there's clearly a bug in the DMA driver somewhere. Setting the SPI line low seems to fix it, IDK if that's the real solution but it works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants