This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TLC5940 and Silicon Lab's 8051

Other Parts Discussed in Thread: TLC5941, TLC5940, TLC5947

Hello all,

I've been working on a project that involves getting several RGB leds to light up systematically.  After some searching I found the 5940 and decided it was the best bet for the job I had.  I'm using a Silicon Labs 8051 microcontroller board as the brains of the operation since I had it left over from a school project some time ago and it can handle several outputs at the same time, as well as leaving the serial ports open for me so I can control it via bluetooth.

However, after about two weeks, I am still unable to get the LEDs to turn on reliably.  The GSCLK signal threw me for a loop for a while, but made sense once I finally figured it out.  Once I got it, I wrote a simple assembly test program to try and turn the leds on and off, but it simply isn't doing the job.  Could the wonderful experts and kind members of this forum help me figure out what in the world I'm doing wrong?

Note: I use port 4 because it is push-pull, as opposed to ports 0-3 which are open-drain.

 

$include (C8051F020.inc)

 

mov  WDTCN,#0DEh ;Disable Watchdog

mov  WDTCN,#0ADh

mov  EMI0CF,#02Bh ;Set the upper ports for the EMI

mov  P74OUT,#0FFh ;Ports 4-7 are push-pull

mov  XBR2,#040h ;Enable Crossbar

mov  EMI0TC,#04Dh ;EMI timing

mov  OSCICN, #007h ;Internal Oscillator is 16 MHz

 

;sin - p4.0

;sclk - p4.1

;xlat - p4.2

;blank - p4.3

;gsclk - p4.4

 

;vprg - GND

;dcprg - GND

;IREF - 2K ohm

 

mov P4, #008h; blank

 

repeat:

mov P4, #010h; gsclk pulse

mov P4, #000h

 

 

mov R0, #00Ch; 12 dec

fill1:

mov P4, #012h; fill the registers with zeros

mov P4, #002h

mov P4, #010h; gsclk pulse

mov P4, #000h

djnz R0, fill1; repeat this 12 times

 

mov P4, #008h; blank

mov P4, #00Ch; blank and xlat

mov P4, #008h; blank

 

;------------------------------------------

mov R0, #00Ch; 12 dec

fill2:

mov P4, #013h; fill the registers with ones

mov P4, #003h

mov P4, #011h; gsclk pulse

mov P4, #001h

djnz R0, fill2; repeat 12 times

 

mov P4, #008h; blank

mov P4, #00Ch; blank and xlat

mov P4, #008h; blank

 

call repeat

end

 

Thanks for looking!  I appreciate any efforts you may put into this!

  • Hello Steven,

    Sorry, but I am not a programming expert, but I can describe the sequence you have to follow for the registers and clocks to make sure that the outputs turn on. Hopefully this helps.

    After startup, the dot correction (DC) information is loaded from the EEPROM into the DC register and default this is set to all 1s.

    Then you have to input the gray-scale data into the register through SCLK and SIN. This means you have to input 192 bits of data. Then you need to latch this data in with a pulse at XLAT.

    During the above time, I would keep BLANK high to make sure that nothing is seen at the LEDs.

    Now you can turn on the LEDs by setting BLANK low and toggling GSCLK for 4096 times. After 4096 pulses at GSCLK, the outputs will turn off automatically until next time BLANK is toggled.

    As long as you do not need to change the GS data, you can go on with just toggling GSCLK 4096 times and then toggling BLANK once and so on.

    If you need to program new data into the GS register, you can write the data into SIN via SCLK during a normal GS cycle, but you should toggle XLAT when BLANK is high, because XLAT immediately overwrites the GS register.

    Please also check the flow charts in the TLC5941 application note: http://www.ti.com/litv/pdf/slva267a
    The difference is that TLC5940 has an EEPROM for DC data, TLC5941 does not have such an EEPROM.

    Best regards,
    Brigitte

  • Brigitte, thank you for your reply on this problem.

     

    As it turns out, my issue still lay with the GSCLK, which I was not pulsing fast enough or enough times.  For anyone else trying to run these chips by bit-banging, I highly recommend setting up a timer and interrupt to pulse the GSCLK.  It becomes a little tricky trying to shift in the data you want this way (as you have no idea what data you are trying to write to the port when the interrupt occurs), but it is possible.

     

    However, I ordered a sample of the TLC5947 chips while I was still trying to get the TLC5940 chips to work, and I found the TLC5947 drivers to be far easier to get to work.  I bought a break-out board from sparkfun.com when I ordered the chips, and was able to get the chips soldered and working in an afternoon.  The internal oscillator made life a lot easier for me, and will leave more space on my microcontroller for my program.

     

    Good luck on your projects!

    -Steven

  • Hi Brigitte,

    I know this is an old post now.  But I am using this tlc5940 chip, for a fairly simply project to simply control 16 LEDs.  Each LED can go up to 80mA, but I most likely wont go above 40mA at this time.  I am currently using the chip and it is working fine for driving the LEDs but I was wondering if there was a way to Latch the the GS data, so that the chip keeps using the same data and I dont have to constantly keep giving it 4096 clock pulses and toggling the BLANK register.  I am trying to free up the main loop of my program to do some other things. like controlling a menu and reading a temperature sensor.  What I would like to do is just send it the data to turn the LEDS on, then return to the program loop and do something else, not having to worry about constantly updating the GSCLK and BLANK. I read your post above to Steven where you explain the sequence of events.  I was just wondering if what I wanted to do is even possible.  It doesnt seem like it from the spec sheet.

    Thanks,

    Mark