Jump to content
Sign in to follow this  
pillum

Controlling TLC5940 with MSP430G2553 doesn't work

Recommended Posts

Hello,

 

I recently bought a Launchpad with an included MSP430G2553 and I tried to control some LEDs with it via the TLC5940.

I've connected it and programmed like in the official Texas Instruments Documents but somehow it doesn't work.

 

The used resistor for IREF has a value of 1.92KOhm to restrict the out current to around 20mA.

 

Here is my code:

#include 
#include 
#include 

/*
* P1.0 - GSCLK (ACLK)
* P1.2 - SIN (UART)
* P1.4 - SCLK (UART)
* P1.5 - BLANK
*
* P2.3 - VPRG
* P2.4 - DCPRG
* P2.5 - XLAT
*/

/* Defines */
/* Port 1 */
#define GSCLK_POUT P1OUT
#define GSCLK_PDIR P1DIR
#define GSCLK_PIN BIT0

#define SOUT_POUT P1OUT
#define SOUT_PDIR P1DIR
#define SOUT_PIN BIT1

#define SIN_POUT P1OUT
#define SIN_PDIR P1DIR
#define SIN_PIN BIT2

#define SCLK_POUT P1OUT
#define SCLK_PDIR P1DIR
#define SCLK_PIN BIT4

#define BLANK_POUT P1OUT
#define BLANK_PDIR P1DIR
#define BLANK_PIN BIT5

/* Port 2 */
#define VPRG_POUT P2OUT
#define VPRG_PDIR P2DIR
#define VPRG_PIN BIT3

#define DCPRG_POUT P2OUT
#define DCPRG_PDIR P2DIR
#define DCPRG_PIN BIT4

#define XLAT_POUT P2OUT
#define XLAT_PDIR P2DIR
#define XLAT_PIN BIT5

#define TLC5940_N 1


/* Macros */
#define SETINPUT(DPIN) (DPIN ## _PDIR &= ~ DPIN ## _PIN)
#define SETOUTPUT(DPIN) (DPIN ## _PDIR |= DPIN ## _PIN)

#define SETLOW(DPIN) (DPIN ## _POUT &= ~ DPIN ## _PIN)
#define SETHIGH(DPIN) (DPIN ## _POUT |= DPIN ## _PIN)

#define PULSE(DPIN) \
do { \
	SETHIGH(DPIN); \
	SETLOW(DPIN); \
} while(0);

#define OUTPUTSTATE(DPIN) (DPIN ## _POUT & DPIN ## _PIN)

/* Global Data */
uint8_t dcdata[96 * TLC5940_N] =
{
// MSB 			  LSB
1, 1, 1, 1, 1, 1, // Channel 15
1, 1, 1, 1, 1, 1, // Channel 14
1, 1, 1, 1, 1, 1, // Channel 13
1, 1, 1, 1, 1, 1, // Channel 12
1, 1, 1, 1, 1, 1, // Channel 11
1, 1, 1, 1, 1, 1, // Channel 10
1, 1, 1, 1, 1, 1, // Channel 9
1, 1, 1, 1, 1, 1, // Channel 8
1, 1, 1, 1, 1, 1, // Channel 7
1, 1, 1, 1, 1, 1, // Channel 6
1, 1, 1, 1, 1, 1, // Channel 5
1, 1, 1, 1, 1, 1, // Channel 4
1, 1, 1, 1, 1, 1, // Channel 3
1, 1, 1, 1, 1, 1, // Channel 2
1, 1, 1, 1, 1, 1, // Channel 1
1, 1, 1, 1, 1, 1, // Channel 0
};

uint8_t gsdata[192 * TLC5940_N] =
{
// MSB								LSB
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 15
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 14
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 13
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 12
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 11
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 10
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 9
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 8
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 7
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 6
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 5
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 4
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 3
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 2
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // Channel 1
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1  // Channel 0
};

bool firstcycleflag;

/* Functions */
void TLC5940_InitPins()
{
SETOUTPUT(GSCLK);
SETOUTPUT(SCLK);
SETOUTPUT(DCPRG);
SETOUTPUT(VPRG);
SETOUTPUT(XLAT);
SETOUTPUT(BLANK);
SETOUTPUT(SIN);
SETINPUT(SOUT);

   SETLOW(GSCLK);
   SETLOW(SCLK);
   SETLOW(DCPRG);
   SETHIGH(VPRG);
   SETLOW(XLAT);
   SETHIGH(BLANK);
}

void TLC5940_SendDC()
{
SETHIGH(DCPRG);
SETHIGH(VPRG);

uint8_t counter = 0;

for(;
{
	if(counter > (TLC5940_N*96-1))
	{
		PULSE(XLAT);
		break;
	}
	else
	{
		if(dcdata[counter])
			SETHIGH(SIN);
		else
			SETLOW(SIN);
		PULSE(SCLK);
		counter++;
	}
}
firstcycleflag = true;
}

void TLC5940_SendGS()
{
if(OUTPUTSTATE(VPRG))
{
	SETLOW(VPRG);
	firstcycleflag = true;
}

uint16_t gsclk_counter = 0;
uint8_t data_counter = 0;

SETLOW(BLANK);
for(;
{
	if(gsclk_counter > 4095)
	{
		SETHIGH(BLANK);
		PULSE(XLAT);
		if(firstcycleflag)
			PULSE(SCLK);
		firstcycleflag = false;
		break;
	}
	else
	{
		if(!(data_counter > TLC5940_N*192-1))
		{
			if(gsdata[data_counter])
				SETHIGH(SIN);
			else
				SETLOW(SIN);
			PULSE(SCLK);
			data_counter++;
		}
		PULSE(GSCLK);
		gsclk_counter++;
	}

}
}

void main()
{
   /* Clock Setup */
   WDTCTL = WDTPW + WDTHOLD;               // Stop WDT

   TLC5940_InitPins();
   TLC5940_SendDC();
TLC5940_SendGS();

__bis_SR_register(GIE);

for(;
{
	TLC5940_SendGS();
}

}

 

My KiCAD rendered schematics are attached.

 

I hope somebody can help me..I even bought some extra devices (like logic analyzer) to check what could be the source of the problem but didn't find anything so far. :(

 

Thank you

post-33897-135135554932_thumb.png

Share this post


Link to post
Share on other sites

Are you using this on a launchpad? If so, disconnect the tx/rx jumpers, and the led1 jumper. Also, what does your logic analyzer show, is it giving you the expected output on the msp's pins?

Share this post


Link to post
Share on other sites

I'm using this on a breadboard, only the Spy-Bi-Wire pins attached to the launchpad for programming.

The logic analyzer shows me the expected results which are documented in the TLC5940 guides.

Share this post


Link to post
Share on other sites
(Ignore the direction of the leds on this schematic)

 

There are... I think 3 other threads on here for the TLC5940. Check those?

 

And yes, the leds on the schematic image I posted are wrong, my brain was farting when doing a quick drawup of the breadboard I had running... lol

Share this post


Link to post
Share on other sites

Well, every thread, schematic and wiring documentation tells me to connect them to any positive pole.

Connecting them to GND just makes them light up all the time not dependent of the gray scale data.

 

How do I check, that the chip isnt broken?

Share this post


Link to post
Share on other sites
replaced the tlc 5940, still no change :(

nobody knows how to fix this or know why this maybe isnt working?

 

Have you tried running the other projects to see if they work?

Share this post


Link to post
Share on other sites
Reset Pin? you mean BLANK?

as you can see in the schematics, its connected with the MSP430

 

Reset on the 2553, pin 10 in the second schematic, which has nothing connected to it but needs a pull-up resistor to function.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×