Go Down

Topic: controlling a TLC5940 with an ATTINY? (Read 1 time) previous topic - next topic

opal_1970

Apr 15, 2012, 10:36 pm Last Edit: Apr 15, 2012, 10:44 pm by opal_1970 Reason: 1
Hi everyone,

I just successfully hooked up a TLC5940 to my Arduino Uno (rev3) and have the Knight Rider effect with 16 LEDs going on in front of me. As the chips are going to be installed in a very small space when I am done, I would like to avoid using an Arduino to control the TLC5940 and am looking for a way to use an ATTINY (best would be an Attiny85) to do this. Searching the forum and Googling did not really produce any results that helped me.. at least the ones that I understood.

In addition to power and GND, the tlc5940 is connected to the Pin13 (SCLK), Pin11 (SIN), Pin10 (BLANK), Pin9 (XLAT), and Pin3 (GSCLK). Am I correct in assuming that whatever microcontroller I take to do the job of Arduino it needs to have these types of pins? Meaning the ATtiny85 would NOT work as the attiny85 has a SCK pin but none of the others? correct?

Does anyone know if there are resources out there that are "newbie-friendly"? or failing that able to describe how to configure an ATtiny or other microcontroller so that it can control a tlc5940?

Thanks alot in advance,
Opal_1970

James C4S

If the processor doesn't have SPI, you'll have to rewrite the library to bit bang the TLC.

I don't know if the 85 does or not.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Runaway Pancake

Is the shrinkification essential?
Why not make a minimal arduino and keep all the functionality you're familiar with already?
http://arduino.cc/en/Tutorial/ArduinoToBreadboard
"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

madworm

You CAN use the 'USI' module in the ATtiny chips to send SPI data out fast, but I wouldn't consider it newbie-friendly.

On an ATtiny24 this looks like that:

Code: [Select]

uint8_t spi_transfer(uint8_t data)
{
    USIDR = data;
    USISR = _BV(USIOIF);    // clear flag

    while ((USISR & _BV(USIOIF)) == 0) {
        USICR = (1 << USIWM0) | (1 << USICS1) | (1 << USICLK) | (1 << USITC);
    }
    return USIDR;
}


You'll still have to consult the datasheet to make sure you get what you want.
• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!

Coding Badly

If the processor doesn't have SPI


It does have hardware support for SPI but the hardware is considerably different from the ATmega processors.  It has a "Universal Serial Interface (USI)" that can be configured for SPI or I2C.  But, that's all I know about it.

Google searching was productive...
http://arduino.cc/playground/Code/USI-SPI
https://www.google.com/search?q=attiny85+spi

Go Up