GD32/STM32 : WS2812B using Timer + DMA
Spi not good enough for you? The easy way to use WS2812B programmable RGB leds is using the SPI MOSI pin. That works fine most of the times with a couple of gotchas : The SPI divider is not very flexible on the GD32/STM32 chips, you can only divide by a power of 2. So if your APB clock is not "near" enought the WS2812B 400 us tick you are in trouble or must use complicated schemes. Using a SPI "locks" the alternate functions of ~ 4 pins. So you can't use them for PMW or any other alternate functions, even if you dont actually use them. The SPI pin is the one getting killed most often on my boards. I have a few MCUs that are working fine except the spi is fried. Also the 2nd /3rd SPI are using APB1, so not ok in terms of clock. In short, Spi0 @ 72 Mhz is ok, other setup is to be looked closely at. What's the other option ? The other option is to use PWM + DMA. We program a 1.2 us PWM mode 0 on a pin. We change the duty at every cycle to create 0s and 1s. ...