Posted on Leave a comment

CH32V003 driving WS2812B LEDs with SPI – Part 3

28 February 2025

So running overnight, there were over 40,000 loops of the blinking demonstration program, and it was still going. What I shoulda but didna do was add in an error counter that updated with each loop. There’s still time!

Moving the experimental apparatus over to the “official” WCH CH32V003 development board was simple enough. I built another programming cable for power, programming and serial communications, as well as a little cable for another WS2812B module I had in the WS2812B bucket. Building bespoke, modular cables for these little devices takes a little bit of time but saves so much more time in their subsequent reuse.

And it works! Well, I expected it to work, at least as well as it was working previously, which was “mostly”. But I really do need to add that error counter to the program so that if it’s not immediately going to fail, I can leave it running overnight and see what happened in the morning.

The error count is being kept (I strongly suspect) and it is being printed alongside each loop message. It has gone through several hundred loops by now and no errors have occurred.

Using a “known good device” is a proven trouble-shooting stratagem, when that is possible. It is, however, not an “apples to apples” comparison, at least the way I have it set up. The WCH board actually does have a 24 MHz quartz crystal mounted on it, even though my code is still telling the clock control unit to use the 24 MHz HSI oscillator, turbo’d up to 48 MHz by the magic of a phase-locked loop. The WCH board hosts a CH32V003F4P6, which is a 20 pin TSSOP20 package (thin shrink small outline package), while my little board has the 20 pin QFN20 (quad flat no lead) package. And the WB2812B LED is different, although it’s not clear to me how that could affect the outcome, but I list it for completeness.

I am going to be both displeased and a little disappointed if the code works perfectly on the “known good” board and not on mine. While I have already designed and shipped several different PCB-based products using this family of chips, I’m the first one to admit that I still have a lot to learn. Lay some wisdom on me, little chips!

Leave a Reply