# 10269 el archivo de salida excede el límite de tamaño de código

0

Al usar Code Composer Studio y MSP430F5438A recibo ese error al compilar, pero si borro aleatoriamente algunas líneas del código, funcionará bien. ¡El problema es que aún no he terminado y hay más por venir! ¿Qué puedo hacer?

EDITAR: El código completo es:

#include <msp430.h>
#include "hal_lcd.h"
#include "string.h"
#include "math.h"
char data;
int brcnfg=0, dbcnfg=0, prtycnfg=0, sbcnfg=0, getfile=0,sendfile=0, print=0, index=0,
    srescnfg=0,trescnfg=0, FrameLength=400, MatrixLength=200;

// Function prototypes
void BaudRateConfig(char data);
void DataBitsConfig(char data);
void ParityBitConfig(char data);
void StopBitConfig(char data);
/////////////////////////////////// Flash
char value;                                 // 8-bit value to write to seg C
void write_SegC(char value);
void read_SegC(char data);
void copy_C2D(void);
void erase();
void sqr();
void circ();
unsigned char * Flash_ptr = (unsigned char *) 0x10000;           // Initialize Flash pointer
long size[]={80000,80000,0,0,0,0,0,0,0};                                 // Files sizes
/////////////////////////////////// end Flash
int main(void)
{   WDTCTL = WDTPW | WDTHOLD;                         // Stop watchdog timer
P5SEL |= 0xC0;                                    // P3.4,5 = USCI_A0 TXD/RXD
UCA1CTL1 |= UCSWRST;
UCA1CTL0 |= UCMODE_0;
UCA1CTL1 = UCSSEL_1;                              // CLK = ACLK

UCA1CTL0 |= UC7BIT;                               // 7-bit characters
UCA1CTL0 &= ~UCSPB;                               // 1 StopBits
UCA1BR0 = 0x03;                                   // 32k/9600=3.41
UCA1BR1 = 0x00;                                   //
UCA1MCTL = UCBRS_3+UCBRF_0;                       // Modulation

UCA1CTL1 &= ~UCSWRST;                             // Release USCI state machine
UCA1IE |= UCRXIE;                                 // Enable USCI_A0 RX interrupt

halLcdInit();
halLcdClearScreen();



//   erase();

// Write the Square Path
sqr();

// Write the Circular Path
circ();

Flash_ptr = (unsigned char *) 0x10000;
FCTL3 = FWKEY;                            // Clear Lock bit

FCTL1 = FWKEY+ERASE;                      // Set Erase bit
*(unsigned int *)Flash_ptr = 0;           // Dummy write to erase Flash seg
while(!(WAIT & FCTL3));

FCTL3 = FWKEY+LOCK;                       // Set LOCK bit


__bis_SR_register(LPM0_bits + GIE);
__no_operation();
}

/*
 * main.c
 */

//=====================================================================================
//                          +++  USCI_A0_Interupt  +++
//=====================================================================================
#pragma vector = USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
if(__even_in_range(UCA1IV,18) == 0x02){          // Vector 2 - RXIFG
    data = UCA1RXBUF;
    // check if command
    if (data == '*')            // BaudRate Config.
        brcnfg=1;
    else if (data == '^')       // DataBits Config.
        dbcnfg=1;
    else if (data == '$')       // ParityBit Config.
        prtycnfg=1;
    else if (data == '#')       // StopBit Config.
        sbcnfg=1;
    else if (data == '%' || data == '{'){       // Get File from PC
        getfile=1;
        if(data=='{')
            print=1;
    }
    else if (data == '@'){      // EOF
        while(!(UCA1IFG & UCTXIFG));
        UCA1TXBUF='@';      // Send Acknowledge that the file has been received
        index++;
        getfile=0;   // Exit the file transfer mode
        print=0;
    }
    else if (data=='&'){ // Send File to PC
        sendfile=1;
    }
    else if(data=='<'){ // Finished sending the file to PC
        while(UCA1STAT & 0x01);
        halLcdPrint("PC: The file has been received",'2');
        halLcdScrollRow(1);
    }
    else if(data=='>') // Change square resolution
        srescnfg=1;
    else if(data=='}') // Change time resolution
        trescnfg=1;
    else{       // implement the command or just do echo
        if(brcnfg){            // BaudRate Config.
            while(UCA1STAT & 0x01);
            UCA1TXBUF='*';  // Send Acknowledge to PC
            while(UCA1STAT & 0x01);
            BaudRateConfig(data);
            brcnfg=0;
        }
        else if(dbcnfg){       // DataBit Config.
            while(UCA1STAT & 0x01);
            UCA1TXBUF='^';  // Send Acknowledge to PC
            while(UCA1STAT & 0x01);
            DataBitsConfig(data);
            dbcnfg=0;
        }
        else if(prtycnfg){     // Parity Bit Config.
            while(UCA1STAT & 0x01);
            UCA1TXBUF='$';  // Send Acknowledge to PC
            while(UCA1STAT & 0x01);
            ParityBitConfig(data);
            prtycnfg=0;
        }
        else if(sbcnfg){       // Stop Bit Config.
            while(UCA1STAT & 0x01);
            UCA1TXBUF='#';  // Send Acknowledge to PC
            while(UCA1STAT & 0x01);
            StopBitConfig(data);
            sbcnfg=0;
        }
        else if (getfile){  // Write to Flash
            /*while(!(UCA1IFG & UCTXIFG));
            UCA1TXBUF=data;
            if(print)
                halLcdPrint(data,'2');*/
            while(UCA1STAT & 0x01);    //   ???????
            write_SegC(data);
        }
        else if (sendfile)
            read_SegC(data);
        else if (srescnfg){  // srescnfg=SquareResolutionConfiguration // TEMPORARLY !!!!!!!!!!!!!!!!!!
            MatrixLength=sqrt(FrameLength*FrameLength/data);
            srescnfg=0;
            while(!(UCA1IFG & UCTXIFG));
            UCA1TXBUF='>'; // Send Ack for changing square resolution
        }
        else if (trescnfg){  // trescnfg=TimeResolutionConfiguration


            while(!(UCA1IFG & UCTXIFG));
            UCA1TXBUF='}'; // Send Ack for changing time resolution
        }
        else{
            /*while(UCA1STAT & 0x01);
            halLcdPrintLine("MCU: ",'2');*/    // Chat
            while(!(UCA1IFG & UCTXIFG));
            UCA1TXBUF=data;
        }
    }
}
}
void BaudRateConfig(char data){
if (data=='9'){  // 9600 BaudRate Configurations
    UCA1BR0 = 3;
    UCA1BR1 = 0;
    UCA1MCTL = UCBRS_3+UCBRF_0;
}
else if (data=='4'){  // 4800 BaudRate Configurations
    UCA1BR0 = 6;
    UCA1BR1 = 0;
    UCA1MCTL = UCBRS_7+UCBRF_0;
}
else if (data=='2'){  // 2400 BaudRate Configurations
    UCA1BR0 = 13;
    UCA1BR1 = 0;
    UCA1MCTL = UCBRS_6+UCBRF_0;
}
else if (data=='1'){  // 1200 BaudRate Configurations
    UCA1BR0 = 27;
    UCA1BR1 = 0;
    UCA1MCTL = UCBRS_2+UCBRF_0;
}
}
void DataBitsConfig(char data){
    if(data=='8')
        UCA1CTL0 &= ~UC7BIT;        //8-bit characters
    else if (data=='7')
        UCA1CTL0 |= UC7BIT;         //7-bit characters
}
void ParityBitConfig(char data){
    if(data=='N')
        UCA1CTL0 &= ~UCPEN;                 // Parity Disable
    else if(data=='E')
        UCA1CTL0 |= UCPEN + UCPAR;         // Parity Enable
    else if(data=='O'){
           UCA1CTL0 |= UCPEN;               // Parity Enable
           UCA1CTL0 &= ~UCPAR;
    }
}
void StopBitConfig(char data){
    if(data=='O')
        UCA1CTL0 &= ~UCSPB;             // 1 StopBits
    else if(data=='T')
        UCA1CTL0 |= UCSPB;              // 2 StopBits
}

//------------------------------------------------------------------------------
// Input = value, holds value to write to Seg C
//------------------------------------------------------------------------------
void write_SegC(char value)
{
  //__disable_interrupt();                  // 5xx Workaround: Disable global
                                            // interrupt while erasing. Re-Enable
                                            // GIE if needed

  FCTL3 = FWKEY;                            // Clear Lock bit

  FCTL1 = FWKEY+WRT;                        // Set WRT bit for write operation
  *Flash_ptr++ = data;                      // Write value to flash
  size[index]++;                            // Calculating the file size
  while(!(WAIT & FCTL3));

  FCTL1 = FWKEY;                            // Clear WRT bit
  FCTL3 = FWKEY+LOCK;                       // Set LOCK bit
}

void read_SegC(char data)
{
    char temp=data;
    unsigned char * Flash_ptrTemp;
    // Square Path
    if(temp==0)
    Flash_ptrTemp = (unsigned char *) 0x10000;
// Circular Path
else if(temp==1)
    Flash_ptrTemp = (unsigned char *) 0x23880;
else{
    Flash_ptrTemp = (unsigned char *) 0x27100;
    // Choose the right file to send to PC
    char k='0';
    while(temp!='2'){
        Flash_ptrTemp = Flash_ptrTemp + size[k-48];
        k++;
        temp--;
    }
}
long i;
// Send the file by sending char-by-char
for(i = 0; i < size[data-48]; i++)
{
    while(!(WAIT & FCTL3));
    while(!(UCA1IFG & UCTXIFG));
    UCA1TXBUF=*Flash_ptrTemp++;
    while(!(WAIT & FCTL3));
}
// Stop sending file mode
sendfile=0;
// Send EOF
while(!(UCA1IFG & UCTXIFG));
UCA1TXBUF='&';
}
void erase(){
    while(Flash_ptr < (unsigned char *)0x40000){
    FCTL3 = FWKEY;                            // Clear Lock bit

    FCTL1 = FWKEY+ERASE;                      // Set Erase bit
    *(unsigned int *)Flash_ptr = 0;           // Dummy write to erase Flash seg
    while(!(WAIT & FCTL3));

    FCTL3 = FWKEY+LOCK;                       // Set LOCK bit
    Flash_ptr += 0x200;
    }
    Flash_ptr = (unsigned char *) 0x10000;
}
void sqr(){
    unsigned char counter='0';
    unsigned char sqrMatrix[MatrixLength][2*MatrixLength];
    // First line
    int j;
    for(j=MatrixLength; j>5;j=j-2){
        sqrMatrix[counter][j]='@'; // 64 Decimal
        sqrMatrix[counter][j+1]=counter;
        counter++;
    }
    // Obstacle
    sqrMatrix[counter][5]='A'; // 65 Decimal
    sqrMatrix[counter][6]=counter;
    counter++;
    // Start the second line ;)
for(j=7;counter<255;j=j+2){
    sqrMatrix[counter][j]='@'; // 64 Decimal
    sqrMatrix[counter][j+1]=counter;
    counter++;
}

// The counter has reached 255->start filling also in the MSB bit.
for(j=0; j<MatrixLength;j=j+2){
    unsigned char MSB=counter/255;
    unsigned char LSB=counter%255;
    sqrMatrix[counter][j]='@'+MSB; // 64 Decimal
    sqrMatrix[counter][j+1]=LSB;
    counter++;
}
unsigned char backCount=counter;
// Obstacle
sqrMatrix[backCount][2*MatrixLength/2]='A'; // 65 Decimal
sqrMatrix[backCount][2*MatrixLength/2]=counter;
counter++;
backCount--;
// draw the 3rd line
for(j=(2*MatrixLength/2)+2;j<2*MatrixLength-5;j=j+2){
    unsigned char MSB=counter/255;
    unsigned char LSB=counter%255;
    sqrMatrix[backCount][j]='@'+MSB; // 64 Decimal
    sqrMatrix[backCount][j+1]=LSB;
    counter++;
    backCount--;
}
// Obstacle
sqrMatrix[backCount][2*MatrixLength/2-6]='A'; // 65 Decimal
sqrMatrix[backCount][2*MatrixLength/2-5]=counter;
backCount--;
// draw the last line
for(j=2*MatrixLength-7;j>2*MatrixLength/2;j=j-2){
    unsigned char MSB=counter/255;
    unsigned char LSB=counter%255;
    sqrMatrix[backCount][j]='@'+MSB; // 64 Decimal
    sqrMatrix[backCount][j+1]=LSB;
    counter++;
    backCount--;
}
int i;
for(i=0;i<MatrixLength;i++)
    for(j=0;j<MatrixLength*2;j++)
        write_SegC(sqrMatrix[i][j]);
}
void circ(){

}
    
pregunta Renya Karasuma

1 respuesta

3

¿Utiliza una versión de tamaño reducido de CCS?

Si no, parece que te estás quedando sin espacio flash en tu unidad de usuario. Existen versiones de su familia MSP que llegan hasta 512kbytes de Flash. Además, es posible que desee comprobar si está utilizando grandes estructuras de datos. No estoy muy familiarizado con CCS pero estoy bastante seguro de que hay alguna manera de ver qué partes de su programa ocupan tanto espacio (cuando se usa GCC, el archivo se llama MAP). Busque el objeto de mayor tamaño e intente reducir su tamaño.

    
respondido por el Tom L.

Lea otras preguntas en las etiquetas