zedrummer
Posts: 38
Joined: Sun Jan 07, 2018 5:15 pm

[SOLVED] Driving a TLC5940 chip inconsistent behaviour

Fri Feb 16, 2018 8:25 pm

Hello

I know this is a very specific question about an electronic chip, but I am sure some of you are expert on that too.

I try to drive a TLC5940 with a Raspberry Pi 3b in ARM assembly.

http://www.ti.com/lit/ds/symlink/tlc5940.pdf

I use 3 cores. Core 0, after managing the initializations (GPIO, screen framebuffer, etc...), is modifying the buffer where the led colors are stored, core 1 is managing BLANK, XLAT and GSCLK while core 2 is transfering data from LED color buffer to the input shift registers (SIN and SCLK). There is 1 var called "BufferFilled" in memory that allow synchronization between core1 and core 2. Initially, this var is 0 (LED color buffer not empty).

I've read comprehensively the datasheet and my loops are:

For Core 1:

- Set BLANK to H(igh)

- MainLoop1:

- While BufferFilled=0 go to MainLoop1

- Set BLANK to H

- Set XLAT to H

- Set XLAT to L(ow)

- Set BufferFilled=1 (core 2 may start again to filled the input shift registers)

- Set BLANK to L

- GSLKLoop:

- Using the internal timer to set GSLK to H then to L at a regular interval (every 4 µs for me then I have around 60 cycles per second )

- While we don't have 4096 pulses, go back to GSLKLoop

- Return to MainLoop1

For core2:

- MainLoop2:

- While BufferFilled=1 go to MainLoop2

- ByteLoop2:

- Read a byte in the buffer (from the last to the first to respect MSB to LSB)

- BitLoop2:

- Check the most significant bit and set SIN accordingly

- Set SCLK to H then to L

- Shift the data byte to the left

- If we don't have check the full byte, go back to BitLoop2

- To shift from 8 bit value to 12 bit value, add 4 more SIN=L then SCLK=H then SCLK=L

- Check if we have done with all the bytes, if not go back to ByteLoop2

- Set BufferFilled=1

- Go back to MainLoop2

It works well, but not for long, I have a video that shows it there:

https://youtu.be/yAN_dWTzKbc

And that is about the longest time it ever worked... As you see, at the end, it stops.

I have check with values written on the screen and there is no memory leak (stack pointers are constant, displaying the memory where the vars are shows that it behaves normally), so what?

Do you have any idea why this does not work indefinitely?

Thanks for your help.

Cathy L.

PS: I may produce my code if necessary.
Last edited by zedrummer on Mon Feb 19, 2018 8:14 am, edited 1 time in total.

LdB
Posts: 911
Joined: Wed Dec 07, 2016 2:29 pm

Re: Driving a TLC5940 chip inconsistent behaviour

Sun Feb 18, 2018 4:10 pm

What voltage are you running the tlc5940 and from where?

What I am worried about is you have to much current going thru the LEDS resulting in ....
The TLC5940 provides a temperature error flag (TEF) circuit to indicate an overtemperature
condition of the IC. If the junction temperature exceeds the threshold temperature (160°C typical),
TEF becomes H and XERR pin goes to low level.
If the IC gets too hot it shuts itself off to protect itself.

So what value current do you have the channels set to and check the XERR pin during operation.

Section 11.3 gives you the power dissipation calculation :-)

zedrummer
Posts: 38
Joined: Sun Jan 07, 2018 5:15 pm

Re: Driving a TLC5940 chip inconsistent behaviour

Sun Feb 18, 2018 7:26 pm

Hello LdB

1 hour ago it runs perfectly for about 2 minutes, but it generally works less than 30 sec.

I supply power to the TLC 5940 via the 5V of the RPi.

I tried:
- an external power supply 5V 4A connected to GPIO 5V and Ground. I have "tuned" it so that it supplies between 4.9V and 5V. I tried just connecting the RPi via mini USB
- to put my finger on the chip to check if it gets hot, but it doesn't (really)
- to change the chip, as I have several ones
but it didn't change anything.

Between Ground and IREF, I put 2x1k series resistors. According 8.3.7, it should be ok to supply 20mA per output.

You are right, I should have checked the XERR pin. I didn't, I'm gonna try.

Just a thing: as you can see on the video, when they stop, the LEDs continue to have some very dimmed flashes.

Thank you
Cathy L.

LdB
Posts: 911
Joined: Wed Dec 07, 2016 2:29 pm

Re: Driving a TLC5940 chip inconsistent behaviour

Mon Feb 19, 2018 12:48 am

The Pi GPIO is only 3.3V
https://www.raspberrypi.org/documentation/usage/gpio/

Trying running the TLC5940 at 3.3V from the external source it says it is valid all the way down to 3V.

So from the Pi you will need the signals plus a ground to connect up.

zedrummer
Posts: 38
Joined: Sun Jan 07, 2018 5:15 pm

Re: Driving a TLC5940 chip inconsistent behaviour

Mon Feb 19, 2018 8:12 am

OK... Shame on me :oops: , you are right, I have just tested with the 3.3V output of the RPi and it works.

When I started to code for the TLC5940, I used this wiring schematics using 5V (with an Arduino Nano):
http://howtomechatronics.com/tutorials/ ... -tutorial/
I didn't think there may be a difference of voltage between the I/O pins of the microcontrollers. But there is, the Arduino sets its pins to either 0V or 5V...

Once again LdB, you saved me a lot of time, just reading the symptoms and the TLC5940 datasheet, that is really impressive!

I thank you very much

Return to “Bare metal, Assembly language”