Using the TLC5940 with an STM32



The TLC5940 is an LED driver which I use with my VFD clock project to power 4 RGB LEDs. I couldn’t find any existing code for the STM32 so I decided to upload my code here in case anyone wants to use this component.

A better version of this code is now on github, I the pasted code on this page is just here for nostalgic reasons, please use this:

I use the grayscale mode of the chip to mix colors. You will need one timer, one hardware SPI port and some GPIO ports. I named the pins after the wirings in the code so there is no need for a schematic. For example PIN_BLANK is the pin that is connected to the BLANK input of the TLC5940.

The 4096 clock ticks for GCSLK are generated in my main loop which is not optimal. It should be outsourced in the tlc.c file.

In the current state the code switches all 16 outputs to the maximum brigthness following one after another beginning with the 5th output. You will find a video of the device in action as well as a download link for an archive containing the files below the code.




main loop

interrupt routine (stm32f10x_it.c)

Download the code (zip).

Leave a Comment

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.