Jump to content

Search the Community

Showing results for tags 'TLC5940'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks

Calendars

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Location


Interests


Sparkfun


Github

Found 8 results

  1. I am working on a breakout / test board for a TLC5940 that I got in one of those HTSSOP-28 packages, with the little metal back that you're supposed to attach to a copper area using thermal vias and use as heat sink. My question is: is there a way for me to "hand solder" that part without reflowing the board? Will it work if I try to heat it from the back of the board with a soldering iron, or is the copper area too large and it will never heat up to a point where the solder melts? Would some flux maybe help? Should I just wack some thermal paste between board and component and not even bother trying to solder it? I do not plan on using high currents, but thought it would be nice to have it properly done. I will get the boards made by Elecrow, and will use HASL finishing as I guess that would make it easier to solder that part, am I right? I am using the new Altium Circuit Maker, therefore you can check the project here (still work in progress): https://workspace.circuitmaker.com/Projects/148E0C7D-1CA4-472C-8BE4-44C2DBD13361 (I guess, never shared a project, hope the link will take you there). If you have any tips on the board itself also feel free to comment. My first board using Circuit Maker and well, haven't done many elsewhere, so I'm open to suggestions!
  2. RobG

    TLC5940 driver for Tiva

    TLC5940 driver for Tiva / Stellaris. Uses 2 Timers, SSI, and DMA. SPI runs @ 20MHz, GSCLK @ 8MHz, update occurs every ~0.5ms Up to 16 TLC5940s can be daisy chained (in theory, I tested only 2.) main.cstartup_ccs.c
  3. 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!
  4. Hello everyone! I'm continuing my project of creating an RGB LED matrix capable of displaying live images being transmitted from a laptop via a serial cable to the MSP430G2553. At the moment, I'm coding four 8x8 Common Anode RGB LED matrices joined together to create a 16x16 display. Hardware I'm using: - 3 * TLC5940s (one for each colour) - 2 * 74HC595 shift registers (drives the columns/anodes) I'm using code provided by RobG from this link <http://forum.43oh.com/topic/2315-tlc5940-examples/> and this one <http://forum.43oh.com/topic/3328-rgb-to-hsv-conversion-with-msp430g2231-help/#entry29106> in order to drive the LEDs with PWM enabled. BUT, the problem I'm having is that I'm trying to allow every pixel to have different colours, but when running, the microcontroller isn't refreshing the pixels fast enough so there is MASSIVE flickering - which isn't ideal.... Here is the code from which I am working : feel free to insult :-P #include <msp430g2553.h> #include <msp430.h> // Need to sort hsv2rgb because yellow is pish... // u_long is 32 bits so 2^32 - 1 is max value. Need more for 32x32 matrix // TLC inputs #define VPRG_PIN BIT0 // TIE TO GND? #define GSCLK_PIN BIT4 #define SCLK_PIN BIT5 #define DATA BIT6 // DS -> 1.6 | 595 DATA PIN #define MOSI_PIN BIT7 #define MOSI595 BIT2 // 595 data pin ? THIS ISNT DOING ANYTHING #define DCPRG_PIN BIT0 // TIE IT TO GND? #define XLAT_PIN BIT1 #define BLANK_PIN BIT2 #define CLOCK BIT3 // SH 11 -> 2.3 // 595 OUTPUTS #define LATCH BIT4 // ST 12 -> 2.4t typedef unsigned char u_char; typedef unsigned int u_int; typedef unsigned short u_short; typedef unsigned long u_long; // ================================// // Prototypes // // ================================// void init( void ); void SPI_setup( void ); void updateTLC( void ); void shiftOut( u_long ); void HSV2RGB( u_short*, u_short*, u_short*, short, u_char); void set_row_char_hue (u_char, u_long, short, u_char); void row_refresh(u_char,short,short,short,short,short,short,short,short,short,short,short,short,short,short,short,short); #define NUMBER_OF_OUTS 48 // TLC OUTPUTS #define NUMBER_OF_ROWS 8 #define NUMBER_OF_COLUMNS 16 #define max_COLUMN NUMBER_OF_COLUMNS-1 #define max_ROW NUMBER_OF_ROWS-1 #define OFF 0 u_short leds[NUMBER_OF_OUTS]; // 0 - 15 Red Rows, 16 - 31 Blue Rows, 32 - 47 Green Rows {0, } u_char timerCounter = 0; void init(void) { WDTCTL = WDTPW + WDTHOLD; // disable WDT BCSCTL1 = CALBC1_16MHZ; // 16MHz clock DCOCTL = CALDCO_16MHZ; BCSCTL2 |= DIVS_0; // divide clock by 1 P1OUT &= ~(VPRG_PIN); P1DIR |= (VPRG_PIN + GSCLK_PIN + DATA); // port 1.4 configured as SMCLK out P1SEL |= GSCLK_PIN; P2DIR |= (BLANK_PIN + XLAT_PIN + CLOCK + LATCH + DCPRG_PIN); P2OUT &= ~(BLANK_PIN + XLAT_PIN); P2OUT &= ~DCPRG_PIN; // setup timer CCR0 = 0xFFF; TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, up mode, 1:1 CCTL0 = CCIE; // CCR0 interrupt enabled } void SPI_setup(void) { // setup UCA0 ----UCA0 ISNT DOING ANYTHING YET! SHOULD I CONFIGURE THE 595's TO BE CONTROLLED BY SPI? P1SEL |= MOSI595; // p1.2 P1SEL2 |= MOSI595; // UCA0SIMO UCA0CTL0 = UCCKPH + UCMSB + UCMST + UCSYNC; // data captured on 1st UCLK edge/changed on follwing edge, MSB first, master, 3-pin SPI,synchronous UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 |= 0x01; // 1:1 UCA0BR1 = 0; UCA0CTL1 &= ~UCSWRST; // clear SW // setup UCB0 P1SEL |= SCLK_PIN + MOSI_PIN; // pins 5 + 7 P1SEL2 |= SCLK_PIN + MOSI_PIN; // UCB0CLK + UCB0SIMO UCB0CTL0 = UCCKPH + UCMSB + UCMST + UCSYNC; // data captured on 1st UCLK edge/changed on follwing edge, MSB first, master, 3-pin SPI,synchronous UCB0CTL1 |= UCSSEL_2; // SMCLK UCB0BR0 |= 0x01; // 1:1 UCB0BR1 = 0; UCB0CTL1 &= ~UCSWRST; // clear SW } void main(void) { init(); SPI_setup(); updateTLC(); P2OUT |= (XLAT_PIN); P2OUT &= ~(XLAT_PIN); short o = 240; short y = 60; // yellow short b = 240; // blue short hue = 0; _bis_SR_register(GIE); for(; { // creates box image row_refresh(0, b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,; row_refresh(1, b,y,y,y,y,y,y,y,y,y,y,y,y,y,y,; row_refresh(2, b,y,b,b,b,b,b,b,b,b,b,b,b,b,y,; row_refresh(3, b,y,b,y,y,y,y,y,y,y,y,y,y,b,y,; row_refresh(4, b,y,b,y,b,b,b,b,b,b,b,b,y,b,y,; row_refresh(5, b,y,b,y,b,y,y,y,y,y,y,b,y,b,y,; row_refresh(6, b,y,b,y,b,y,b,b,b,b,y,b,y,b,y,; row_refresh(7, b,y,b,y,b,y,b,y,y,b,y,b,y,b,y,; row_refresh(8, b,y,b,y,b,y,b,y,y,b,y,b,y,b,y,; row_refresh(9, b,y,b,y,b,y,b,b,b,b,y,b,y,b,y,; row_refresh(10, b,y,b,y,b,y,y,y,y,y,y,b,y,b,y,; row_refresh(11, b,y,b,y,b,b,b,b,b,b,b,b,y,b,y,; row_refresh(12, b,y,b,y,y,y,y,y,y,y,y,y,y,b,y,; row_refresh(13, b,y,b,b,b,b,b,b,b,b,b,b,b,b,y,; row_refresh(14, b,y,y,y,y,y,y,y,y,y,y,y,y,y,y,; row_refresh(15, b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,; _bis_SR_register(LPM0_bits); // go to sleep } // end of for(; loop } void updateTLC(void) // RobG's code { u_char ledCounter = NUMBER_OF_OUTS >> 1; while (ledCounter-- > 0) { u_char i = ledCounter << 1; UCB0TXBUF = leds[i + 1] >> 4; while (!(IFG2 & UCB0TXIFG)); // TX buffer ready? u_char unib = leds[i + 1] << 4; u_char lnib = (leds[i] >> 8) & 0x0F; UCB0TXBUF = unib | lnib; while (!(IFG2 & UCB0TXIFG)) ; // TX buffer ready? UCB0TXBUF = leds[i]; while (!(IFG2 & UCB0TXIFG)); // TX buffer ready? } } void row_refresh(u_char row,short a,short b,short c,short d,short e,short f,short g,short h,short i,short j,short k,short l,short m,short n,short o,short p) { // this function checks if led is supposed to be ON // for example, if row = 0, and a = 360 then the top left led is OFF // if a = 120, then the led will be ON, and will be assigned the appropriate hue (green) u_long col_data = 0x0000; if(a < 360){col_data = 0x8000; set_row_char_hue(row,col_data,a,1);} // 0 if(b < 360){col_data = 0x4000; set_row_char_hue(row,col_data,b,1);} // 1 if(c < 360){col_data = 0x2000; set_row_char_hue(row,col_data,c,1);} // 2 if(d < 360){col_data = 0x1000; set_row_char_hue(row,col_data,d,1);} // 3 if(e < 360){col_data = 0x0800; set_row_char_hue(row,col_data,e,1);} // 4 if(f < 360){col_data = 0x0400; set_row_char_hue(row,col_data,f,1);} // 5 if(g < 360){col_data = 0x0200; set_row_char_hue(row,col_data,g,1);} // 6 if(h < 360){col_data = 0x0100; set_row_char_hue(row,col_data,h,1);} // 7 if(i < 360){col_data = 0x0080; set_row_char_hue(row,col_data,i,1);} // 8 if(j < 360){col_data = 0x0040; set_row_char_hue(row,col_data,j,1);} // 9 if(k < 360){col_data = 0x0020; set_row_char_hue(row,col_data,k,1);} // 10 if(l < 360){col_data = 0x0010; set_row_char_hue(row,col_data,l,1);} // 11 if(m < 360){col_data = 0x0008; set_row_char_hue(row,col_data,m,1);} // 12 if(n < 360){col_data = 0x0004; set_row_char_hue(row,col_data,n,1);} // 13 if(o < 360){col_data = 0x0002; set_row_char_hue(row,col_data,o,1);} // 14 if(p < 360){col_data = 0x0001; set_row_char_hue(row,col_data,p,1);} // 15 } void set_row_char_hue (u_char row, u_long col_data, short hue, u_char bool) { u_char led = 0; u_long byte; for(led = 0 ; led < 16 ; led++ ) { byte = (col_data>>led)&(0x01); if( byte ) { HSV2RGB( &leds[row], &leds[row + 32], &leds[row + 16], hue, bool); //on; shiftOut( col_data ); } } // turn off leds leds[row] = OFF; leds[row+32] = OFF; leds[row+16] = OFF; } void HSV2RGB(u_short* r, u_short* g, u_short* b, short h, u_char bool) { const u_char s = 255; u_char v = 255; u_char i, p, q, t; u_short fs; if (h < 60 ) i = 0; else if (h < 120) i = 1; else if (h < 180) i = 2; else if (h < 240) i = 3; else if (h < 300) i = 4; else if (h < 360) i = 5; else return; fs = ((h - i * 60) * s)/ 60; p = 255 - s; q = 255 - fs; t = 255 - s + fs; switch(i) { case 0: *r = 255;*g = t;*b = p;break; case 1: *r = q;*g = 255;*b = p;break; case 2: *r = p;*g = 255;*b = t;break; case 3: *r = p;*g = q;*b = 255;break; case 4: *r = t;*g = p;*b = 255;break; case 5: *r = 255;*g = p;*b = q;break; } if ( bool == 1 ) { *r *= v/16; *g *= v/16; *b *= v/16; } else { *r *= 0; *g *= 0; *b *= 0; } } #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A0(void) { // 4096 GS clock cycles have been generated, time to restart PWM P2OUT |= (BLANK_PIN); P2OUT |= (XLAT_PIN); P2OUT &= ~(XLAT_PIN); P2OUT &= ~(BLANK_PIN); // increase timer counter timerCounter++; if (timerCounter == 1) // this is also from RobG, except updateTLC is every interrupt because otherwise it is far too slow { // is it time to for next frame? updateTLC(); // data was already prepared by main loop when it was awake last time timerCounter = 0; _bic_SR_register_on_exit(LPM0_bits); // wake up main loop so that it can prepare data for the next frame } } void shiftOut(u_long val) { P2OUT &= ~LATCH; int i; for (i = 0; i < 16; i++) // iterate over each bit 16 { if(val & (1 << i)) { P1OUT |= DATA; } else { P1OUT &= ~DATA; } P2OUT |= CLOCK; // PULSE CLOCK P2OUT ^= CLOCK; } // } P2OUT |= LATCH; // PULSE LATCH P2OUT &= ~LATCH; } If anyone has any suggestions on how to improve this code, it will be greatly appreciated, because I've really hit a wall with it. I did think that using SPI P1.2 for UCA0SIMO instead of the shiftOut() function might be a solution but I don't know how to go about doing that. Keep in mind that soon I'll be using P1.1 for RXD. Cheers!
  5. Hello! I know I've been posting loads of problems which you have all been very helpful with and I appreciate it. I'm at the last stage in my project where I have to send an image as a byte array (values from 0-255) via serial communication, use H/W UART to receive bytes and map them onto my RGB LED display to create the image. I've configured the UART at 115200 BAUD, clock at 18MHz, I'm using the UCA0 ISR routine to map the received bytes into a 3D array "image[8][8][3]" where the 1st, 2nd, and 3rd terms are row, column, RGB component, respectively. I am seeing results on the display when sending individual bytes, but not the correct results. I'll post a video/screenshots to go with the code. #include <msp430f5438a.h> // TLC INPUTS #define GSCLK BIT6 // P1.6 (SMCLK OUT pin 9 RF3) #define MOSI BIT1 // P3.1 (UCB0MOSI pin 18 RF3) #define SCLK BIT3 // P3.3 (UCB0CLK pin 16 RF3) #define BLANK BIT2 // P1.2 (GPIO pin 5 RF3) #define XLAT BIT5 // P1.5 (GPIO PIN 7 RF3) // SERIAL COMMS #define RX_PIN BIT5 // P3.5 (UCA0RXD bottom header) // 74HC595 #define DATA BIT7 // P3.7 (UCB1MOSI) #define CLOCK BIT5 // P5.5 (UCB1CLK) #define LATCH BIT0 // P4.0 (GPIO) //============================================================== typedef unsigned char u_char; typedef unsigned int u_int; typedef unsigned short u_short; typedef unsigned long u_long; //============================================================= // PROTOTYPES void init(void); // put clock and GPIO pin directions etc void init595(void); void SPI_TLC(void); // for GSCLK + MOSI + DATA + CLOCK void SPI_595(void); void UART_init(void); // for RX void updateTLC(void); void SPI_shift(u_short); void shiftOut(u_long); void HSV2RGB(u_short*, u_short*, u_short*, short, u_char); void SetVcoreUp (unsigned int level); void calibrateClock(void); //===================================================================== // GLOBAL DEFINES //====================================================================== #define NUMBER_OF_OUTS 48 #define NUMBER_OF_COLUMNS 16 #define UPDATE {P1OUT |= BLANK;P1OUT |= XLAT;P1OUT &= ~XLAT;P1OUT &= ~BLANK; updateTLC();} #define OFF 0 #define SAT 255 u_short leds[NUMBER_OF_OUTS] = {0,}; // 0 - 15 Red Rows, 16 - 31 Blue Rows, 32 - 47 Green Rows {0, } const u_long column16Array[NUMBER_OF_COLUMNS] = {0x8000,0x4000,0x2000,0x1000,0x0800,0x0400,0x0200,0x0100,0x0080,0x0040,0x0020,0x0010,0x0008,0x0004,0x0002,0x0001}; const u_long column8Array[8] = {0x0080,0x0040,0x0020,0x0010,0x0008,0x0004,0x0002,0x0001}; const u_char rowArray[NUMBER_OF_COLUMNS] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; //------------------------------------ // SERIAL GLOBAL VARIABLES u_char image[8][8][3] = {0,}; u_char rowCnt = 0, colCnt = 0, rgb = 0; volatile u_short x = 0,y; u_char clear = 0; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Kill watchdog timer init(); updateTLC(); P1OUT |= (XLAT); P1OUT &= ~(XLAT); _bis_SR_register(GIE); for(; { for(x=0;x<8;x++) // rows { for(y=0;y<8;y++) // columns { leds[x] = image[x][y][0]*16; // Red leds[x+32] = image[x][y][1]*16; // Green leds[x+16] = image[x][y][2]*16; // Blue UPDATE; // this line pulses TLC XLAT and then updates the TLC5940 shiftOut(column8Array[y]); // controls columns (74HC595 shift register) leds[x]=0; leds[x+32]=0; leds[x+16]=0; UPDATE; } } _bis_SR_register(LPM0_bits); // Enter LPM0, interrupts enabled } } void calibrateClock(void) { SetVcoreUp (PMMCOREV_2); // Set VCore = 1.8V for 18MHz clock UCSCTL3 |= SELREF_2; // Set DCO FLL reference = REFO UCSCTL4 |= SELA_2; // Set ACLK = REFO __bis_SR_register(SCG0); // Disable the FLL control loop UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx UCSCTL1 = DCORSEL_6; // Select DCO range 24MHz operation UCSCTL2 = FLLD_1 + 547; //547 // Set DCO Multiplier for 18MHz __bic_SR_register(SCG0); // (N + 1) * FLLRef = Fdco __delay_cycles(562500); // (547 + 1) * 32768 = 18MHz do{ // Loop until XT1,XT2 & DCO fault flag is cleared UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG); // Clear XT2,XT1,DCO fault flags SFRIFG1 &= ~OFIFG; // Clear fault flags } while (SFRIFG1&OFIFG); // Test oscillator fault flag // Set FLL Div = fDCOCLK/2 // Enable the FLL control loop // Worst-case settling time for the DCO when the DCO range bits have been // changed is n x 32 x 32 x f_MCLK / f_FLL_reference. // 32 x 32 x 18 MHz / 32,768 Hz = 562500 = MCLK cycles for DCO to settle } void init(void) { calibrateClock(); // SETUP GPIO PINS AS OUTPUTS P1DIR |= (GSCLK + BLANK + XLAT + BIT0); P1SEL |= GSCLK; // P1.6 AS SMCLK OUT P1OUT &= ~(BLANK + XLAT); TA0CCR0 = 0xFFF; TA0CTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, up mode, 1:1 TA0CCTL0 = CCIE; // CCR0 interrupt enabled init595(); // only if SPI isnt used. SPI_TLC(); UART_init(); } void init595(void) { P4DIR |= LATCH; P4OUT &= ~LATCH; P3DIR |= DATA; P3OUT &= ~DATA; P5DIR |= CLOCK; P5OUT &= ~CLOCK; } void SPI_TLC(void) { // TLC: SPI setup UCB0 P3SEL |= MOSI + SCLK; // P3.1 + P3.3, UCB0SIMO + UCB0CLK UCB0CTL0 = UCCKPH + UCMSB + UCMST + UCSYNC; // data captured on 1st UCLK edge/changed on follwing edge, MSB first, master, 3-pin SPI,synchronous UCB0CTL1 |= UCSSEL_2; // SMCLK UCB0BR0 |= 0x01; // 1:1 UCB0BR1 = 0; UCB0CTL1 &= ~UCSWRST; // clear SW } void UART_init(void) { // UART Setup UCA0 P3SEL |= 0x30; // P3.4,5 = USCI_A0 TXD/RXD UCA0CTL1 |= UCSWRST; // **Put state machine in reset** UCA0CTL1 |= UCSSEL_2; //SMCLK UCA0BR0 |= 9; //115200 at 18MHz UCA0BR1 = 0; //115200 at 18MHz UCA0MCTL = UCOS16 + UCBRF3 + UCBRF2; //Modulation UCA0CTL1 &= ~UCSWRST; //Start USCI UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt } void updateTLC(void) { u_char ledCounter = NUMBER_OF_OUTS >> 1; while (ledCounter-- > 0) { u_char i = ledCounter << 1; UCB0TXBUF = leds[i + 1] >> 4; while (!(UCB0IFG & UCTXIFG)); // TX buffer ready? ????????? NEED TO CHECK THIS u_char unib = leds[i + 1] << 4; u_char lnib = (leds[i] >> 8) & 0x0F; UCB0TXBUF = unib | lnib; while (!(UCB0IFG & UCTXIFG)); // TX buffer ready? ????????? NEED TO CHECK THIS UCB0TXBUF = leds[i]; while (!(UCB0IFG & UCTXIFG)); // TX buffer ready? ????????? NEED TO CHECK THIS } } void shiftOut(u_long val) { P4OUT &= ~LATCH; int i; for (i = 0; i < 16; i++) // iterate over each bit 16 { if(val & (1 << i)) { P3OUT |= DATA; } else { P3OUT &= ~DATA; } P5OUT |= CLOCK; // PULSE CLOCK P5OUT ^= CLOCK; } P4OUT |= LATCH; // PULSE LATCH P4OUT &= ~LATCH; } void SetVcoreUp (unsigned int level) // only used to calibrate clock at 18MHz { // Open PMM registers for write PMMCTL0_H = PMMPW_H; // Set SVS/SVM high side new level SVSMHCTL = SVSHE + SVSHRVL0 * level + SVMHE + SVSMHRRL0 * level; // Set SVM low side to new level SVSMLCTL = SVSLE + SVMLE + SVSMLRRL0 * level; // Wait till SVM is settled while ((PMMIFG & SVSMLDLYIFG) == 0); // Clear already set flags PMMIFG &= ~(SVMLVLRIFG + SVMLIFG); // Set VCore to new level PMMCTL0_L = PMMCOREV0 * level; // Wait till new level reached if ((PMMIFG & SVMLIFG)) while ((PMMIFG & SVMLVLRIFG) == 0); // Set SVS/SVM low side to new level SVSMLCTL = SVSLE + SVSLRVL0 * level + SVMLE + SVSMLRRL0 * level; // Lock PMM registers for write access PMMCTL0_H = 0x00; } #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A0(void) {_bic_SR_register_on_exit(LPM0_bits);} #pragma vector = USCI_A0_VECTOR __interrupt void USCI0RX_ISR(void) { if(UCA0RXBUF < 256) { if(rowCnt < 8) //if(rowCnt < 16) { if(colCnt < 8) //if(colCnt < 16) { if( rgb == 0 ) { image[rowCnt][colCnt][rgb] = UCA0RXBUF; // R } else if ( rgb == 1 ) { image[rowCnt][colCnt][rgb] = UCA0RXBUF; // G } else if( rgb == 2 ) { image[rowCnt][colCnt][rgb] = UCA0RXBUF; // B } else if( rgb == 3) { colCnt++; rgb = 0; } rgb++; } else { colCnt = 0; rowCnt++; } } } } The way I want the code to work is as follows: 1. row, column and rgb are initialised to 0. 2. byte received? is it less than 256? if yes then go to step 3, else wait for a new byte. 3. Then check the values of row and column so see if they are less than 8. 4. if rgb = 0, then assign the value of RXBUF to red component of current pixel (for row = 0, column = 0 & rgb = 0, then "image[0][0][0] = RXBUF" ) 5. In "main()" each component of the 3D array is assigned to the corresponding value in the "leds[]" array, and the correct column is lit. 6. Increment rgb by one 7. Repeat for green and blue (rgb = 1, rgb = 2). 8. If rgb reaches 3, then rgb is reset to 0 and column is incremented by one 9. Repeat.. 10. If column = 8, then row is incremented by one 11. Repeat until all spaces in array have been filled. That is how I want it to work, but below is a video of what is actually happening: BTW, I'm using this for the serial connection. If you could just have a look at the video/program and if anything pops out that is obviously wrong then give me a shout, cos it is driving me insane trying to get this to work. Thanks good people of 43oh!
  6. Gareeeesh

    Memory issue with G2553

    Hi people! Basically I'm writing a function to control a 16x16 RGB LED matrix with serial communication. The function I'm writing requires an array of size 16x16 ( hueBuffer[16][16] ) and of type 'short' since the max value of hue is 359. However, I keep getting an error: "program will not fit into available memory. run placement with alignment fails for section "DATA_GROUP" size 0x23d" but there is plenty of memory on the G2553. I need the values of hue to go up to 360 so i cant use unsigned chars. Anyone know of a solution to this problem? I'll post the code if you want. Cheers!
  7. rickysinho

    TLC5940

    I can not do msp430g2553, working with a TLC5940, is there any library for it?
  8. Hi all! I was wondering if anyone has used this algorithm with the G2231 before? I'm trying to use it but I keep getting an error message saying: "program will not fit into available memory. placement with alignment fails for section ".text" size 0x142e ." The reason I am trying to implement this is so I can represent exact colours for RGB LEDS in a large-ish matrix. Does anyone know a method to decrease the amount of memory being consumed by this algorithm, or increase the amount of memory allocated to ".text"? Any advice would be greatly appreciated. Here is the code I am using: #include <msp430g2231.h> #include <math.h> // TLC inputs #define SCLK_PIN BIT5 #define MOSI_PIN BIT7 #define GSCLK_PIN BIT4 #define BLANK_PIN BIT2 #define XLAT_PIN BIT1 #define VPRG_PIN BIT0 // 595 Inputs #define DATA BIT6 // DS -> P2.6 #define LATCH BIT6 // ST_CP -> 1.6 #define CLOCK BIT7 // 11 -> 2.7 // -------------- MACROS ------------------------------------------// #define setHigh(n) ( P1OUT |= n ) // Only for TLC! #define setLow(n) ( P1OUT &= ~n ) // TLC!! #define pulse(n) do { setHigh(n); setLow(n); } while(0) // ---------------------------------------------------------------------// typedef unsigned char u_char; typedef unsigned int u_int; typedef unsigned short int us_int; // Prototypes void init(void); void updateTLC(); void sendMOSI(u_int data); void pulseClock ( void ); void pinWrite ( unsigned int, int ); void shiftOut(unsigned char); void shift(unsigned int); void allrowsON(void); void allrowsOFF(void); void allcolsON(void); void delay (unsigned int); void bounce (int); void knight(int); void HSV2RGB(u_char *r, u_char *g, u_char *b, signed int h, u_char s, u_char v); #define NUMBER_OF_LEDS 24 #define NUMBER_OF_COLUMNS 8 #define NUMBER_OF_ROWS 8 u_int leds[NUMBER_OF_LEDS] = { 0, }; // 0 - 7 Red Rows, 8 - 15 Green Rows, 16 - 23 Blue Rows u_int rows[NUMBER_OF_ROWS] = { 0, }; u_char timerCounter = 0; short int icount = 0; void init(void) { WDTCTL = WDTPW + WDTHOLD; // disable WDT DCOCTL |= DCO0 + DCO1; // DCO = 15.25MHz BCSCTL1 |= RSEL0 + RSEL1 + RSEL2 + RSEL3; // as above BCSCTL2 |= DIVS_2; // divide clock by 8 P1OUT &= ~(VPRG_PIN + BLANK_PIN + XLAT_PIN + SCLK_PIN + MOSI_PIN ); P1DIR |= VPRG_PIN + BLANK_PIN + XLAT_PIN + SCLK_PIN + MOSI_PIN; // 595 P2SEL &= ~(CLOCK + LATCH); P1DIR |= DATA; // Setup pins as outputs P2DIR |= (CLOCK + LATCH); 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 } void main(void) { init(); updateTLC(); pulse(XLAT_PIN); _bis_SR_register(GIE); bounce(300); knight(300); int loopCounter = 0; int p,hue; for(; { // this loop will be executed every 16.384ms, ~61Hz //leds[0-7] = Red //leds[8-15] = Green //leds[16-23] = Blue for( hue = 0 ; hue < 360 ; hue ++) // this is where the problem lies! { HSV2RGB(0,0,0,hue,1,1); } allcolsON(); if (loopCounter < 512) {//512 for( p = 0 ; p < 8 ; p++) // R (0-7) { leds[p]++; } } else if (loopCounter < 1024) { // G (8-15) for( p = 8 ; p < 16 ; p++) { leds[p]++; } } else if (loopCounter < 1536) { //dim R (0-7) for( p = 0 ; p < 8 ; p++) { leds[p]--; } } else if (loopCounter < 2048) { // B (16 - 23) for( p = 16 ; p < 24 ; p++) { leds[p]++; } } else if (loopCounter < 2560) { //dim G (8-15) for( p = 8 ; p < 16 ; p++) { leds[p]--; } } else if (loopCounter < 3072) { // R (0-7) for( p = 0 ; p < 8 ; p++) { leds[p]++; } } else if (loopCounter < 3584) { //dim B (16-23) for( p = 16 ; p < 24 ; p++) { leds[p]--; } } else if (loopCounter < 4096) { //dim R (0-7) for( p = 0 ; p < 8 ; p++) { leds[p]--; } } else { loopCounter = 0; } // do not edit below loopCounter++; // sleep _bis_SR_register(LPM0_bits); } } void updateTLC() { u_char ledCounter = NUMBER_OF_LEDS >> 1; while (ledCounter-- > 0) { u_char i = ledCounter << 1; sendMOSI(leds[i + 1]); sendMOSI(leds[i]); } } // the HSV algorithm void HSV2RGB(u_char *r, u_char *g, u_char *b, signed int h, u_char s, u_char v) { int i,z; float f, p, q, t, hf, sf, vf; hf=(float)h; sf=(float)s; vf=(float)v; sf /=255; if( sf == 0 ) { // achromatic (grey) *r = *g = *b = vf; return; } hf /= 60; // sector 0 to 5 i = floor( hf ); f = hf - i; // factorial part of h p = (u_char)(v * ( 1 - sf )); q = (u_char)(v * ( 1 - sf * f )); t = (u_char)(v * ( 1 - sf * ( 1 - f ) )); switch( i ) { case 0: *r = v; *g = t; *b = p; break; case 1: *r = q; *g = v; *b = p; break; case 2: *r = p; *g = v; *b = t; break; case 3: *r = p; *g = q; *b = v; break; case 4: *r = t; *g = p; *b = v; break; default: // case 5: *r = v; *g = p; *b = q; break; } for( z = 0 ; z < 8 ; z++) { leds[z] = *r; // red pins leds[z+8] = *g; // green pins leds[z+16] = *b; // blue pins } } void allcolsON(void) { for( icount = 0; icount < NUMBER_OF_COLUMNS ; icount++ ) { shiftOut(1 << icount); //1 << } for( icount = NUMBER_OF_COLUMNS-1; icount >= 0 ; icount-- ) { shiftOut(1 << icount); //1 << } } void allrowsON(void) { int x; for( x = 0; x < 8 ; x++ ) { leds[x] = 4095; } for( x = 7; x >= 0 ; x-- ) { leds[x] = 4095; } } void allrowsOFF(void) { int x; for( x = 0; x < 8 ; x++ ) { leds[x] = 0; } for( x = 7; x >= 0 ; x-- ) { leds[x] = 0; } } void delay(unsigned int ms) { while (ms--) { __delay_cycles(2000); // set for 16Mhz change it to 1000 for 1 Mhz } } void bounce (int time) { int a; allcolsON(); for( a = 0; a < 8 ; a++) // red { leds[a] = 4095; delay(time); leds[a] = 0; } for( a = 7 ; a >= 0 ; a--) { leds[a] = 4095; delay(time); leds[a] = 0; } for( a = 0; a < 8 ; a++) // yellow { leds[a] = 4095; leds[a+8] = 3500; delay(time); leds[a] = 0; leds[a+8] = 0; } for( a = 7 ; a >= 0 ; a--) { leds[a] = 4095; leds[a+8] = 3500; delay(time); leds[a] = 0; leds[a + 8] = 0; } for( a = 0; a < 8 ; a++) // green { leds[a+8] = 4095; delay(time); leds[a+8] = 0; } for( a = 7 ; a >= 0 ; a--) { leds[a+8] = 4095; delay(time); leds[a+8] = 0; } for( a = 0; a < 8 ; a++) // cyan { leds[a+8] = 4095; leds[a+16] = 4095; delay(time); leds[a+8] = 0; leds[a+16] = 0; } for( a = 7 ; a >= 0 ; a--) { leds[a+8] = 4095; leds[a+16] = 4095; delay(time); leds[a+8] = 0; leds[a+16] = 0; } for( a = 0; a < 8 ; a++) // blue { leds[a+16] = 4095; delay(time); leds[a+16] = 0; } for( a = 7 ; a >= 0 ; a--) { leds[a+16] = 4095; delay(time); leds[a+16] = 0; } for( a = 0; a < 8 ; a++) // magenta { leds[a] = 4095; leds[a+16] = 4095; delay(time); leds[a] = 0; leds[a+16] = 0; } for( a = 7 ; a >= 0 ; a--) { leds[a] = 4095; leds[a+16] = 4095; delay(time); leds[a] = 0; leds[a+16] = 0; } for( a = 0; a < 8 ; a++) // white { leds[a] = 4095; leds[a+8] = 4095; leds[a+16] = 4095; delay(time); leds[a] = 0; leds[a+8] = 0; leds[a+16] = 0; } for( a = 7 ; a >= 0 ; a--) { leds[a] = 4095; leds[a+8] =4095; leds[a+16] = 4095; delay(time); leds[a] = 0; leds[a+8] = 0; leds[a+16] = 0; } } void knight(int time) { int x; allrowsON(); for( x = 0 ; x < 8 ; x++) { shift(1 << x); delay(time); } for( x = 7 ; x >= 0 ; x--) { shift(1 << x); delay(time); } allrowsOFF(); } #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A0(void) { setHigh(BLANK_PIN); pulse(XLAT_PIN); setLow(BLANK_PIN); timerCounter++; if (timerCounter == 8) { // 0x08 - 2ms * 8 = 16.384ms, ~61Hz updateTLC(); timerCounter = 0; _bic_SR_register_on_exit(LPM0_bits); } } void sendMOSI(u_int mosi) { u_char c = 0; while (c < 12) { (mosi & 0x0800) ? (P1OUT |= MOSI_PIN) : (P1OUT &= ~MOSI_PIN); pulse(SCLK_PIN); mosi <<= 1; c++; } } void shiftOut(unsigned char val) { P2OUT &= ~LATCH; pinWrite(DATA, val); pulseClock(); P2OUT |= LATCH; P2OUT &= ~LATCH; } void shift(unsigned int val) { P2OUT &= ~LATCH; int i; for (i = 0; i < 8; i++) { pinWrite(DATA, (val & (1 << i))); pulseClock(); } P2OUT |= LATCH; P2OUT &= ~LATCH; } void pinWrite( unsigned int bit, int val ) { if (val){ P1OUT |= bit; } else { P1OUT &= ~bit; } } // Pulse the clock pin void pulseClock( void ) { P2OUT |= CLOCK; P2OUT ^= CLOCK; }
×