pillum 0 Posted June 30, 2012 Share Posted June 30, 2012 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 Quote Link to post Share on other sites
cde 334 Posted July 1, 2012 Share Posted July 1, 2012 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? Quote Link to post Share on other sites
pillum 0 Posted July 1, 2012 Author Share Posted July 1, 2012 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. Quote Link to post Share on other sites
SugarAddict 227 Posted July 1, 2012 Share Posted July 1, 2012 Not much difference that I can see from what I used... (Ignore the direction of the leds on this schematic) Quote Link to post Share on other sites
pillum 0 Posted July 1, 2012 Author Share Posted July 1, 2012 Are the LEDs supposed to be connected to GND? Because in the docs it says they are connected to Vled. Quote Link to post Share on other sites
SugarAddict 227 Posted July 1, 2012 Share Posted July 1, 2012 (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 Quote Link to post Share on other sites
pillum 0 Posted July 1, 2012 Author Share Posted July 1, 2012 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? Quote Link to post Share on other sites
pillum 0 Posted July 2, 2012 Author Share Posted July 2, 2012 replaced the tlc 5940, still no change nobody knows how to fix this or know why this maybe isnt working? Quote Link to post Share on other sites
cde 334 Posted July 2, 2012 Share Posted July 2, 2012 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? Quote Link to post Share on other sites
pillum 0 Posted July 2, 2012 Author Share Posted July 2, 2012 Yes, I tried this one and used the pins described there: viewtopic.php?f=10&t=1700 and now its the voltage on 0.0v and it doesn't matter anymore how i place the led (out -> gnd or vcc -> out or whatever) it doesnt light up at all anymore. Quote Link to post Share on other sites
cde 334 Posted July 2, 2012 Share Posted July 2, 2012 Test the leds? Did you blow them? Quote Link to post Share on other sites
pillum 0 Posted July 2, 2012 Author Share Posted July 2, 2012 I test them after almost every hardware or software modification, they all still work. Quote Link to post Share on other sites
kylej1050 27 Posted July 6, 2012 Share Posted July 6, 2012 Have you tied the reset pin to V+ or is it floating? Quote Link to post Share on other sites
pillum 0 Posted July 6, 2012 Author Share Posted July 6, 2012 Reset Pin? you mean BLANK? as you can see in the schematics, its connected with the MSP430 Quote Link to post Share on other sites
kylej1050 27 Posted July 6, 2012 Share Posted July 6, 2012 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. RobG 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.