Jump to content

Search the Community

Showing results for tags 'RGB LED'.



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 4 results

  1. Some time ago, I wrote about WS2812D, an 8mm RGB LED with built-in controller (WS2811.) However, that LED was killed off after very short run. Since then, APA Electronics came out with it's own version, APA-106, which is compatible with WS2811. I have 2 versions available in my store right now, 5mm and 8mm. They are perfect for any breadboarding or through hole project. I will be using them in updated versions of my clocks (Geek & Gear.)
  2. 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!
  3. Gareeeesh

    Sending Image as RGB Array to G2553

    Hi everybody, Hopefully someone will be able to help. The aim of this project is to send an image from my laptop over a serial port to the MSP430G2553 where the data will be processed and then the image will be shown on my RGB LED display. At present I'm looking at methods of converting an image into an RGB array. I found that using GIMP, a file can be exported as a ".c" source code file which converts the image into an array. - Although the syntax is unlike any I have seen before. Anyways, i am using a program I found on the web to do the sending of the data over the serial port (http://batchloaf.wordpress.com/2013/02/13/writing-bytes-to-a-serial-port-in-c/) then I am simply changing the "bytes_to_send" array to the image array. On the receiving end of the transmission, I am unsure how to process the data - should I do it in the "USCI0RX_ISR" ? Here's the code from which I am working: #include <msp430g2553.h> #include <msp430.h> // TLC inputs #define VPRG_PIN BIT0 // TIE TO GND? #define RX_PIN BIT1 #define TX_PIN BIT2 #define GSCLK_PIN BIT4 #define SCLK_PIN BIT5 #define DATA BIT6 // DS -> 1.6 | 595 DATA PIN #define MOSI_PIN BIT7 #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( void ); void UART(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); void clearArray(void); void serialSnake(void); void extractRGB(); // ===================================================================================== #define UPDATE {P2OUT |= (BLANK_PIN);P2OUT |= (XLAT_PIN);P2OUT &= ~(XLAT_PIN);P2OUT &= ~(BLANK_PIN);updateTLC();} #define NUMBER_OF_OUTS 48 // TLC OUTPUTS #define NUMBER_OF_ROWS 16 #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, } short columnArray[16] = {0x8000,0x4000,0x2000,0x1000,0x0800,0x0400,0x0200,0x0100,0x0080,0x0040,0x0020,0x0010,0x0008,0x0004,0x0002,0x0001}; u_char rowArray[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; u_char cnt = 0; u_char SAT = 255; // full colour // ========== SERIAL GLOBAL VARIABLES =================================== u_char rxRow = 0; u_char rxCol = 0; u_char image[16][16]; u_char colour[3]; u_char Count = 0; u_char cCount = 0; u_char rCount = 0; // ====================================================================== void init(void) { WDTCTL = WDTPW + WDTHOLD; // disable WDT BCSCTL1 = CALBC1_16MHZ; // 16MHz clock DCOCTL = CALDCO_16MHZ; BCSCTL2 |= DIVS_0; // divide clock by 1 // Setup TLC and 595 outputs P1DIR |= (VPRG_PIN + GSCLK_PIN + DATA); P1SEL |= GSCLK_PIN; // port 1.4 configured as SMCLK out P2DIR |= (BLANK_PIN + XLAT_PIN + CLOCK + LATCH + DCPRG_PIN); P1OUT &= ~(VPRG_PIN); P2OUT &= ~(BLANK_PIN + XLAT_PIN); P2OUT &= ~DCPRG_PIN; // setup timer TA0CCR0 = 0xFFF; TA0CTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, up mode, 1:1 TA0CCTL0 = CCIE; // CCR0 interrupt enabled // // setup FrameBuffer Timer // TA1CCR0 = 0xFFF; // TA1CTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, up mode, 1:1 // TA1CCTL0 = CCIE; // CCR0 interrupt enabled } void SPI(void) { // SPI 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 UART(void) { // UART Setup UCA0 P1SEL |= RX_PIN + TX_PIN; //Set P1.1 and P1.2 to RX and TX P1SEL2 |= RX_PIN + TX_PIN; UCA0CTL1 |= UCSSEL_2; //SMCLK UCA0BR0 = 138; //115200 @[member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""][member=""] 16MHz UCA0BR1 = 0; //115200 UCA0MCTL = UCBRS_1; //Modulation UCA0CTL1 &= ~UCSWRST; //Start USCI IE2 |= UCA0RXIE; //Enable RX interrupt } void main(void) { u_char z; init(); SPI(); UART(); updateTLC(); P2OUT |= (XLAT_PIN); P2OUT &= ~(XLAT_PIN); _bis_SR_register(GIE); for(; { // extractRGB(); while (!(IFG2 & UCA0RXIFG)); for(z = 0; z < 16; z++) { leds[z] = colour[0] * 16; //r leds[z+32] = colour[1] * 16; // g leds[z+16] = colour[2] * 16; // b shiftOut(columnArray[rxCol]); } _bis_SR_register(LPM0_bits); } } 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 extractRGB(void) //{ // u_char i; // for(i=0;i<16;i++) // { // leds[i] = image[3*i][rxCol]; // leds[i+16] = image[(3*i)+1][rxCol]; // leds[i+32] = image[(3*i)+2][rxCol]; // shiftOut(columnArray[rxCol]); // } //} void shiftOut(u_long val) { P2OUT &= ~LATCH; int i; for (i = 0; i < 32; 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; } #pragma vector=USCIAB0RX_VECTOR __interrupt void USCI0RX_ISR(void) { while(UCA0RXBUF) { if(Count < 3) { colour[Count] = UCA0RXBUF; Count++; } else { Count = 0; } if( rCount == 48 ) { rxRow++; rCount = 0; } else { rCount++; } if( cCount == 16 ) { cCount = 0; } else { rxCol++; cCount = 0; } } } #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A0(void) { _bic_SR_register_on_exit(LPM0_bits); // wake up main loop so that it can prepare data for the next frame } #pragma vector = TIMER0_A1_VECTOR __interrupt void Timer_A1(void) {} I've taken out a bunch of functions which won't be used for this part of the project, so there are some variables etc. which arent used. Below is the modified version of the TX code I am using with the GIMP image array included: // serial.c / serial.cpp // A simple serial port writing example // Written by Ted Burke - last updated 13-2-2013 // // To compile with MinGW: // // gcc -o serial.exe serial.c // // To compile with cl, the Microsoft compiler: // // cl serial.cpp // // To run: // // serial.exe // #include <windows.h> #include <stdio.h> /* GIMP RGB C-Source image dump (TEST.c) */ // export opacity 68 #define GIMP_IMAGE_WIDTH (16) #define GIMP_IMAGE_HEIGHT (16) #define GIMP_IMAGE_BYTES_PER_PIXEL (3) /* 3:RGB, 4:RGBA */ #define GIMP_IMAGE_PIXEL_DATA ((unsigned char*) GIMP_IMAGE_pixel_data) static const unsigned char bytes_to_send[16 * 16 * 3 + 1] = ("\255\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255\0\255\255" "\255\0\0\255\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\0\255\255\255\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\0\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\0\255\255" "\0\255\255\255\255\255\255\0\255\0\0\255\0\255\255\255\255\255\255\255\255" "\0\255\255\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\0\255\255\0\255\255\255\255\255\255\0\255\0\0\255\0\255\255" "\255\255\255\255\255\255\0\255\255\0\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\0\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\0\255\255" "\255\0\0\255\255\255\255\255\255\0\255\0\0\255\0\255\255\255\255\255\255\0" "\0\255\0\0\255\255\255\255\255\255\255\0\255\0\0\255\0\255\255\255\255\255" "\255\255\0\0\255\0\0\255\255\255\255\255\255\0\255\0\0\255\0\255\255\255\255" "\255\255\0\0\255\0\0\255\255\255\255\255\255\255\0\255\0\0\255\0\255\255\255" "\255\255\255\255\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\0\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\0\255" "\255\0\255\255\255\255\255\255\0\255\0\0\255\0\255\255\255\255\255\255\255" "\255\0\255\255\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\0\255\255\0\255\255\255\255\255\255\0\255\0\0\255\0\255" "\255\255\255\255\255\255\255\0\255\255\0\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\0\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\0\255" "\255\255\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255\0\255" "\255\255\0\0\255\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\255" "\255\0\255\255\255\0\0"); int main() { // Define the five bytes to send ("hello") // char bytes_to_send[5]; // bytes_to_send[0] = 104; // bytes_to_send[1] = 101; // bytes_to_send[2] = 108; // bytes_to_send[3] = 108; // bytes_to_send[4] = 111; // Declare variables and structures HANDLE hSerial; DCB dcbSerialParams = {0}; COMMTIMEOUTS timeouts = {0}; // Open the highest available serial port number fprintf(stderr, "Opening serial port..."); hSerial = CreateFile( "\\\\.\\COM5", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if (hSerial == INVALID_HANDLE_VALUE) { fprintf(stderr, "Error\n"); return 1; } else fprintf(stderr, "OK\n"); // Set device parameters (115200 baud, 1 start bit, // 1 stop bit, no parity) dcbSerialParams.DCBlength = sizeof(dcbSerialParams); if (GetCommState(hSerial, &dcbSerialParams) == 0) { fprintf(stderr, "Error getting device state\n"); CloseHandle(hSerial); return 1; } dcbSerialParams.BaudRate = CBR_115200; dcbSerialParams.ByteSize = 8; dcbSerialParams.StopBits = ONESTOPBIT; dcbSerialParams.Parity = NOPARITY; if(SetCommState(hSerial, &dcbSerialParams) == 0) { fprintf(stderr, "Error setting device parameters\n"); CloseHandle(hSerial); return 1; } // Set COM port timeout settings timeouts.ReadIntervalTimeout = 50; timeouts.ReadTotalTimeoutConstant = 50; timeouts.ReadTotalTimeoutMultiplier = 10; timeouts.WriteTotalTimeoutConstant = 50; timeouts.WriteTotalTimeoutMultiplier = 10; if(SetCommTimeouts(hSerial, &timeouts) == 0) { fprintf(stderr, "Error setting timeouts\n"); CloseHandle(hSerial); return 1; } // Send specified text (remaining command line arguments) DWORD bytes_written, total_bytes_written = 0; fprintf(stderr, "Sending bytes..."); if(!WriteFile(hSerial, bytes_to_send, 769, &bytes_written, NULL)) { fprintf(stderr, "Error\n"); CloseHandle(hSerial); return 1; } fprintf(stderr, "%d bytes written\n", bytes_written); // Close serial port fprintf(stderr, "Closing serial port..."); if (CloseHandle(hSerial) == 0) { fprintf(stderr, "Error\n"); return 1; } fprintf(stderr, "OK\n"); // exit normally return 0; } If anyone could help that would be much appreciated since this is the last part of my project! Cheers
  4. 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!
×