EddieM 0 Posted September 5, 2014 Share Posted September 5, 2014 Hello everyone! I'm pretty new here and I would like to ask if can someone provide a correct wiring schematic for TLC5940 to MSP430G2553? Thanks in advance! Quote Link to post Share on other sites
L.R.A 78 Posted September 5, 2014 Share Posted September 5, 2014 Look here for more info: http://forum.43oh.com/topic/2315-tlc5940-examples/ Quote Link to post Share on other sites
EddieM 0 Posted September 5, 2014 Author Share Posted September 5, 2014 I couldn't find any detailed schematic there for wiring the TLC5940 to the TI MSP430G2553. Quote Link to post Share on other sites
L.R.A 78 Posted September 5, 2014 Share Posted September 5, 2014 It's all to ports 1 says here the pin: #define SCLK_PIN BIT5 #define MOSI_PIN BIT7 #define GSCLK_PIN BIT4 #define BLANK_PIN BIT0 #define XLAT_PIN BIT2 So it's SCLK->P1.5. MOSI->P1.7, GSCLK->P1.4, BLANK->P1.0, XLAT->P1.2 Quote Link to post Share on other sites
EddieM 0 Posted September 5, 2014 Author Share Posted September 5, 2014 and do I have to use some resistors somewhere? Quote Link to post Share on other sites
abecedarian 330 Posted September 5, 2014 Share Posted September 5, 2014 http://forum.43oh.com/topic/2321-tlc5940-board/#entry20577 L.R.A 1 Quote Link to post Share on other sites
EddieM 0 Posted September 5, 2014 Author Share Posted September 5, 2014 Thank you abecedarian ! Tomorrow I will try wiring up these and will test them. Quote Link to post Share on other sites
EddieM 0 Posted September 6, 2014 Author Share Posted September 6, 2014 so I tried to connect the TLC5940 to the MSP430G2553 like this and I used this code: #include <msp430g2553.h> #define SCLK_PIN BIT5 #define MOSI_PIN BIT7 #define GSCLK_PIN BIT4 #define BLANK_PIN BITC #define XLAT_PIN BITB typedef unsigned char u_char; u_char leds[16] = { 0, }; void updateTLC(); void main(void) { WDTCTL = WDTPW + WDTHOLD; // disable WDT BCSCTL1 = CALBC1_16MHZ; // 16MHz clock DCOCTL = CALDCO_16MHZ; P1OUT &= ~(BLANK_PIN + XLAT_PIN); P1DIR |= BLANK_PIN + XLAT_PIN; P1DIR |= GSCLK_PIN; // port 1.4 configured as SMCLK out P1SEL |= GSCLK_PIN; // setup timer CCR0 = 0xFFF; TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, up mode, 1:1 CCTL0 = CCIE; // CCR0 interrupt enabled // setup UCB0 P1SEL |= SCLK_PIN + MOSI_PIN; P1SEL2 |= SCLK_PIN + MOSI_PIN; UCB0CTL0 = UCCKPH + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master UCB0CTL1 |= UCSSEL_2; // SMCLK UCB0BR0 |= 0x01; // 1:1 UCB0BR1 = 0; UCB0CTL1 &= ~UCSWRST; // clear SW updateTLC(); P1OUT |= XLAT_PIN; P1OUT &= ~XLAT_PIN; _bis_SR_register(GIE); leds[0] = 0x0F; u_char counter = 0; u_char direction = 0; while (1) { _delay_cycles(500000); if (direction) { counter--; leds[counter] = 0x0F; leds[counter + 1] = 0; if (counter == 0) direction = 0; } else { counter++; leds[counter] = 0x0F; leds[counter - 1] = 0; if (counter == 15) direction = 1; } } } void updateTLC() { u_char ledCounter = 8; while (ledCounter-- > 0) { UCB0TXBUF = leds[(ledCounter << 1) + 1] << 4; while (!(IFG2 & UCB0TXIFG)) ; // TX buffer ready? UCB0TXBUF = leds[ledCounter << 1]; while (!(IFG2 & UCB0TXIFG)) ; // TX buffer ready? UCB0TXBUF = 0; while (!(IFG2 & UCB0TXIFG)) ; // TX buffer ready? } } #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A0(void) { P1OUT |= BLANK_PIN; P1OUT |= XLAT_PIN; P1OUT &= ~XLAT_PIN; P1OUT &= ~BLANK_PIN; updateTLC(); } The LEDS are all flickering, what am I doing wrong? Quote Link to post Share on other sites
RobG 1,892 Posted September 6, 2014 Share Posted September 6, 2014 @@EddieM, try this. C1 & C2 should be as close as possible to Vcc pins. C3 is not necessary if you don't do in circuit programming. R2 value is for 10mA current. DCPRG & VPRG is grounded, so if you want to do more with TLC, you will have to connect them to P1.0 & P2.0 If you connect your TLC to LaunchPad, do not use C2, C3, & R3. #include #define SCLK_PIN BIT5 #define MOSI_PIN BIT7 #define GSCLK_PIN BIT4 #define BLANK_PIN BIT2 #define XLAT_PIN BIT1 typedef unsigned char u_char; u_char leds[16] = { 0, }; void updateTLC(); void main(void) { WDTCTL = WDTPW + WDTHOLD; // disable WDT BCSCTL1 = CALBC1_16MHZ; // 16MHz clock DCOCTL = CALDCO_16MHZ; P2OUT &= ~(BLANK_PIN + XLAT_PIN); P2DIR |= BLANK_PIN + XLAT_PIN; P1DIR |= GSCLK_PIN; // port 1.4 configured as SMCLK out P1SEL |= GSCLK_PIN; // setup timer CCR0 = 0xFFF; TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, up mode, 1:1 CCTL0 = CCIE; // CCR0 interrupt enabled // setup UCB0 P1SEL |= SCLK_PIN + MOSI_PIN; P1SEL2 |= SCLK_PIN + MOSI_PIN; UCB0CTL0 = UCCKPH + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master UCB0CTL1 |= UCSSEL_2; // SMCLK UCB0BR0 |= 0x01; // 1:1 UCB0BR1 = 0; UCB0CTL1 &= ~UCSWRST; // clear SW updateTLC(); P2OUT |= XLAT_PIN; P2OUT &= ~XLAT_PIN; _bis_SR_register(GIE); leds[0] = 0x0F; u_char counter = 0; u_char direction = 0; while (1) { _delay_cycles(500000); if (direction) { counter--; leds[counter] = 0x0F; leds[counter + 1] = 0; if (counter == 0) direction = 0; } else { counter++; leds[counter] = 0x0F; leds[counter - 1] = 0; if (counter == 15) direction = 1; } } } void updateTLC() { u_char ledCounter = 8; while (ledCounter-- > 0) { UCB0TXBUF = leds[(ledCounter << 1) + 1] << 4; while (!(IFG2 & UCB0TXIFG)) ; // TX buffer ready? UCB0TXBUF = leds[ledCounter << 1]; while (!(IFG2 & UCB0TXIFG)) ; // TX buffer ready? UCB0TXBUF = 0; while (!(IFG2 & UCB0TXIFG)) ; // TX buffer ready? } } #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A0(void) { P2OUT |= BLANK_PIN; P2OUT |= XLAT_PIN; P2OUT &= ~XLAT_PIN; P2OUT &= ~BLANK_PIN; updateTLC(); } Quote Link to post Share on other sites
EddieM 0 Posted September 6, 2014 Author Share Posted September 6, 2014 Thank you RobG, it is working perfectly now. I appreciate the help! 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.