Jump to content
43oh

Strange breadboarding issue (MSP430G2231 + TLC5940)


Recommended Posts

Trying a sample knight rider LED code using MSP430G2231 and TLC5940. MSP, TLC and LEDs powered at 3.3V, 47k ohm resistor on MSP RST, 750 ohm on TLC IRef. 0.1uF cap on MSP Vcc/GND.

 

Got everything connected on the breadboard and applied power. Not only did the sequence not work, the LEDs were going crazy...flashing at different PWM frequencies, sometimes not on at all, sometimes fully bright, etc. Double checked my connections, no change. Tried powering the TLC at 5V, no change. Tried another TLC5940, same result. Tried another MSP, same. Tried another breadboard, same. Tried a different LaunchPad, same result.

 

Then I noticed if I move my hand to within 6" of the TLC or the wires connecting the MSP to the TLC the LEDs would react quite noticeably. If they were flashing dim they'd become fully bright. If they were off they would turn on, etc. etc.... Even if I connected the LEDs to pins that weren't used on the TLC, same thing. I disconnected the TLC from the MSP and they would still do the same! I removed the jumper wires from the board which reduced the reaction to my hand being near it but there was still definitely a reaction. I have another array using a G2231 and two TLC5916s that wokrs just fine, none of the above symptoms...

 

What in the world could cause something like this?

 

Here's the code being used:

 

#include 
#include "BinaryConst.h"

#define SIN		BIT1
#define GSCLK	BIT2
#define XLAT	BIT3
#define BLANK	BIT4
#define SCLK	BIT5

#define CLOCK_PERIOD      256

// MSB - CH1, LSB - CH15
const unsigned int RiderData[17] = {
B16(10000000, 00000000),
B16(11000000, 00000000),
B16(11100000, 00000000),
B16(01111000, 00000000),
B16(00111100, 00000000),
B16(00011110, 00000000),
B16(00000111, 00000000),
B16(00000011, 00000000),
B16(00000001, 00000000),
B16(00000011, 00000000),
B16(00000111, 00000000),
B16(00011110, 00000000),
B16(00111100, 00000000),
B16(01111000, 00000000),
B16(11100000, 00000000),
B16(11000000, 00000000),
B16(10000000, 00000000),
};


int PWMCount = 0; // Counter for GSCLK pulse


void ConfigureTimer(void);
void InitializeClocks(void);

void RunKnightRiderSeq(unsigned int Brightness);
void SendData(unsigned int data, unsigned int Brightness);

void main(void)
{
int BrightnessDuty = CLOCK_PERIOD - 1; // Duty for Brightness
int BrightnessDelta = CLOCK_PERIOD / 8; // Brightness change for each round

unsigned int count;

WDTCTL = WDTPW + WDTHOLD;

P1OUT = 0;
P1DIR = 0;
P1DIR |= (SIN + SCLK + XLAT + BLANK + GSCLK);

SendData(0, 0); // Clear all output

InitializeClocks(); // Setup clock
ConfigureTimer(); // Setup Timer to generate GSCLK

while (1)
{
	_BIS_SR(GIE); // Enable Interrupt

	RunKnightRiderSeq(BrightnessDuty);

	//for (count = 0; count < 30000; count++) {} // Delay for next run

	// Change direction for brightness delta
	if ((BrightnessDuty + BrightnessDelta) >= (CLOCK_PERIOD - 1) ||
		(BrightnessDuty + BrightnessDelta) < (CLOCK_PERIOD / 8))
		BrightnessDelta *= -1;

	BrightnessDuty += BrightnessDelta; // Setup the brightness level for next round
}
}

void RunKnightRiderSeq(unsigned int Brightness)
{
unsigned int count;
unsigned char CurStep;

for (CurStep = 0; CurStep < 17; CurStep++)
{
	SendData(RiderData[CurStep], Brightness); // Send current Step data to TLC5940
	for (count = 0; count < 1024; count++) {} // Delay for each step
}
}

void SendData(unsigned int data, unsigned int Brightness)
{
char i, j;
int k;

TACTL = TASSEL_2 | MC_0;  // Disable Timer

P1OUT &= ~(SCLK + XLAT + BLANK);

for (i = 0; i < 16; i++)
{
	// Send data for each channel, CH15 first
	if (data & 0x1) // Channel is ON
	{
		k = Brightness;
		// Send duty bits, 12-bit, MSB first
		for (j = 0; j < 12; j++)
		{
			if (k & 0x800)
				P1OUT |= SIN;
			else
				P1OUT &= ~SIN;

			// pulse SCLK
			P1OUT |= SCLK;
			P1OUT &= ~SCLK;

			k <<= 1; // next bit for duty
		}
	}
	else // Channel is OFF, send 0 for Duty
	{
		P1OUT &= ~SIN; // 0 for all duty bits

		for (j = 0; j < 12; j++)
		{
			// pulse SCLK
			P1OUT |= SCLK;
			P1OUT &= ~SCLK;
		}
	}

	data >>= 1; // next Channel
}

// Pulse BLANK, XLAT, SCLK to latch data to TLC5940, reset PWMcount
P1OUT |= BLANK;
PWMCount = 0;
P1OUT |= XLAT;
P1OUT &= ~XLAT;
P1OUT &= ~BLANK;
P1OUT |= SCLK;
P1OUT &= ~SCLK;

TACTL = TASSEL_2 | MC_1;  // Enable Timer
}

void InitializeClocks(void)
{
 BCSCTL1 = CALBC1_1MHZ;
 DCOCTL = CALDCO_1MHZ;
}

void ConfigureTimer(void)
{
 TACTL = TASSEL_2 | MC_0 | TACLR;  // TACLK = SMCLK, Up mode, reset count
 TACCR0 = 40;						// Timer Frequency
 TACCTL0 = CCIE;					// Trigger Interrupt whenever Timer reach TACCR0
 TACTL = TASSEL_2 | MC_1;  		// TACLK = SMCLK, Up mode
}

#pragma vector=TIMERA0_VECTOR
__interrupt void ta0_isr(void)
{
// Pulse GSCLK
P1OUT |= GSCLK;
P1OUT &= ~GSCLK;

// pulse BLANK to restart PWM cycle when GSCLK pulse reach max count
if (++PWMCount >= CLOCK_PERIOD)
{
	P1OUT |= BLANK;
	P1OUT &= ~BLANK;
	PWMCount = 0;
}

TACCTL1 &= ~CCIFG;
}

 

And here's a photo of the board:

 

msptlc.jpg

Link to post
Share on other sites

I do actually have a 0.1uF cap for the TLC, just forgot to include it in the photo. As for the RST, I am dumb...that's what I get for doing that at 1am. Was told elsewhere that VPRG needs to be connected to ground and DCPRG needs to be low. Did this and the LEDs aren't going crazy anymore but the sequence isn't working (Out0 is lit steady).

 

Anything else I'm missing?

Link to post
Share on other sites
I do actually have a 0.1uF cap for the TLC, just forgot to include it in the photo. As for the RST, I am dumb...that's what I get for doing that at 1am. Was told elsewhere that VPRG needs to be connected to ground and DCPRG needs to be low. Did this and the LEDs aren't going crazy anymore but the sequence isn't working (Out0 is lit steady).

 

Anything else I'm missing?

 

VPRG & DCPRG (TLC) has to be @GND.

RST(MSP) has to be @Vcc (on the pic, 47k resistor is @GND)

 

Someone needs more coffee :)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...