Posts

Showing posts from August, 2021

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. ...

GD32 + Non volatile Memory : NeVerMind

Image
  I'm porting the spotwelder control board from stm32duino to lnArduino, so that i can use indifferently a STM32F1/GD32F1/F3/VF3 and to have a smaller and better codebase. It had a couple of tiny bugs but it is working sort of ok. Then  i reached the last missing piece : Non volatile memory. The Stm32duino version is using the eeprom emulation code from STM that can only store couple (id,value) with value on 16 bits.  It works  but it's a bit awkard to use if you want to store 32 bits stuff or floats. Additionally, the license is a bit restrictive it seems. On the other end of the spectrum, you can switch to tinyFS. But this is way overkill to store some basic settings. I looked on github without finding something suitable. What do we want ? Sort of robust if interrupted during a write ( ~ atomic) Variable size writes (with a small maximum) Not erasing the flash at every write Since i couldn't find something suitable,  i wrote a quick & dirty non volatile me...