I am working on TLC5947 chip to control 24 RGB Leds to create different patterns with them. My concern is, I have to keep giving command to SIN, SCLK, XLAT pin of microcontroller every loop to keep my pattern repeating again and again.

My microcontroller is also doing other stuff, like talking with sensors, controlling external peripherals etc.

Wanted to know if there is any way/hack in hardware/ software by which I can repeat the sequence using LED driver IC while keeping my micro-controller unoccupied?

  • \$\begingroup\$ Microcontrollers are cheap. Why not dedicate one to sequence the LEDs? \$\endgroup\$
    – Tut
    Sep 29, 2014 at 14:04
  • 1
    \$\begingroup\$ Simple answer: use TLC59116 instead of TLC5947. I2C interface instead of strange constant data stream interface. \$\endgroup\$
    – Majenko
    Sep 29, 2014 at 14:10
  • \$\begingroup\$ Which arduino is it? With contemporary MCUs it is possible to make it running completely in background, using SPI with DMA in non-stop circular mode. \$\endgroup\$
    – venny
    Sep 29, 2014 at 14:27
  • \$\begingroup\$ I agree with @Majenko, I love the TLC59116!! \$\endgroup\$
    – KyranF
    Sep 29, 2014 at 14:48
  • \$\begingroup\$ @Majenko and KyranF, I am a fan of the TLC59711 (and wrote a library for it). While the interface is not I2C, data transfer rate is up to 10 MHz, and there are Adafruit boards. :) \$\endgroup\$ Mar 15, 2016 at 18:52

2 Answers 2


The usual way to handle this sort of thing is with a periodic timer interrupt. Say your loop needs to repeat every 50msec, set up a hardware timer to interrupt the processor, do your display update and return from the ISR (Interrupt Service Routine). If your current coding style includes wasting zillions of cycles in delay loops, it gets rid of that. Chances are you're using fast hardware SPI to talk to the chip, so cranking out 72 bits of on/off data won't take long, maybe < 100usec, so with a 50ms interrupt, 99.8% of your processor bandwidth is still available (virtually 'unoccupied' for practical purposes)

To the "other stuff" that you are doing, your processor looks to be somewhat (depending on how much time your ISR takes) slower and a bit more jerky in its operation (it goes away for a bit at times). It's usually not too difficult to code for that.

  • 3
    \$\begingroup\$ +1 for not wasting "zillions of cycles in delay loops", an all too common issue. The over-use of sloppy fixed delay routines may stem from all the simple example routines that often come with compilers, etc. They may work stand-alone, but create problems when trying to integrate them with other functionality. \$\endgroup\$
    – Tut
    Sep 29, 2014 at 14:19
  • 2
    \$\begingroup\$ @Tut I also think it's the terrible quality of example code given to people, which is trying to show one little piece of functionality, so they do not care to design proper delays or show proper use of time. \$\endgroup\$
    – KyranF
    Sep 29, 2014 at 14:49
  • \$\begingroup\$ Thanks for the quick responses guys, hardware interrupt is what I was trying as next thing. No more delay routines in the code ;) \$\endgroup\$
    – Pudi
    Sep 29, 2014 at 16:40
  • \$\begingroup\$ @Spehro, while your answer is good advice in general, it is less good for the TLC5947, which does not need periodic input from the microcontroller, see my answer here. \$\endgroup\$ Mar 17, 2016 at 18:34
  • 1
    \$\begingroup\$ @Spehro, I reread the question, and you may be right. It takes 12*24 = 288 bits to program the chip, and the hardware SPI you suggested can transfer at about 4 Mbit/s on an Arduino Uno (see my measurements). \$\endgroup\$ Mar 18, 2016 at 14:50

I was considering the TLC5947, and its data sheet claims it has "auto display repeat," so the PWM should work without periodic input from the microcontroller. I also took a quick look at Adafruit's Arduino library for the TLC5947, and did not see any interrupts etc.

But I ended up not using the TLC5947 because it has "flickering issues" and used the TLC59711 instead, for which I even wrote a library. For details on the flickering, see my Disqus post.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.