This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

error #29: expected an expression how to fix it?

Other Parts Discussed in Thread: MSP430G2553

Hi,

I am trying to send or recieve multiple bytes in uart,so iI defined uart.h and there put all the declarations.

Code-

-------main.c------

#include "msp430g2553.h"
#include "uart.h"

void string_init()

{
m[]="Hello Ma'am...!!!";
i=0;
a[]=" ";
p[]="Please enter valid command";

return;
}

int main(void)

{

WDTCTL = WDTPW + WDTHOLD; //Stop WDT

if (CALBC1_16MHZ ==0xFF || CALDCO_16MHZ == 0xFF)
{
while(1); // If cal constants erased,
} // trap CPU!!

BCSCTL1 = CALBC1_16MHZ; //Set DCO to 16Mhz+

DCOCTL = CALDCO_16MHZ; //Set DCO to 16Mhz

string_init();


uart_init(); //Initialize the UART connection

__enable_interrupt(); //Interrupts Enabled

__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled


}

------uart.h------


#ifndef UART_H
#define UART_H


extern volatile unsigned int i;
extern volatile char m[20];
//extern volatile unsigned char gate=0;
extern volatile char a[20];
extern volatile char p[20];


void uart_init(); //Initialize the UART connection


#endif

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Build Logs...---


**** Build of configuration Debug for project nms_test_string_hello_mam ****

"C:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
'Building file: ../main.c'
'Invoking: MSP430 Compiler'
"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/bin/cl430" -vmsp --abi=eabi --use_hw_mpy=none --include_path="C:/ti/ccsv6/ccs_base/msp430/include" --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/include" --advice:power=all -g --embedded_cpp --define=__MSP430G2553__ --diag_warning=225 --diag_wrap=off --display_error_number --printf_support=minimal --preproc_with_compile --preproc_dependency="main.pp" "../main.c"
"../main.c", line 16: error #29: expected an expression
"../main.c", line 18: error #29: expected an expression
"../main.c", line 19: error #29: expected an expression
"../main.c", line 34: remark #1527-D: (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead
3 errors detected in the compilation of "../main.c".

>> Compilation failure
gmake: *** [main.obj] Error 1
'Building file: ../uart.c'
'Invoking: MSP430 Compiler'
"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/bin/cl430" -vmsp --abi=eabi --use_hw_mpy=none --include_path="C:/ti/ccsv6/ccs_base/msp430/include" --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/include" --advice:power=all -g --embedded_cpp --define=__MSP430G2553__ --diag_warning=225 --diag_wrap=off --display_error_number --printf_support=minimal --preproc_with_compile --preproc_dependency="uart.pp" "../uart.c"
"../uart.c", line 68: remark #1528-D: (ULP 3.1) Detected flag polling using IFG2. Recommend using an interrupt combined with enter LPMx and ISR
"../uart.c", line 107: remark #1528-D: (ULP 3.1) Detected flag polling using IFG2. Recommend using an interrupt combined with enter LPMx and ISR
"../uart.c", line 86: remark #1544-D: (ULP 13.1) Detected loop counting up. Recommend loops count down as detecting zeros is easier
"../uart.c", line 91: remark #1544-D: (ULP 13.1) Detected loop counting up. Recommend loops count down as detecting zeros is easier
'Finished building: ../uart.c'
' '
gmake: Target `all' not remade because of errors.

**** Build Finished ****

After compilation I am getting error  #29 in lines 29,38 & 31.

If you could help me a little I would be very pleased. 

Regards,

Vivek Agrawal

 

  • You should always mark the lines the errors are about. If you use the syntax highlighter in rich formatting, then your code gets line numbers you can refer to. I guess line 16, 18 and 19 are the following

    16: m[]="Hello Ma'am...!!!";
    
    18: a[]=" ";
    19: p[]="Please enter valid command";

    ?

  • Yes you are correct I am facing errors in the very same line.

  • Well, you cannot assign a string to the array in this way. You can do it when creating the variable like

    char s[] = "New string";

    In your case you can use functions like strcpy or memcpy to fill your array.

    Dennis

  • Ok sir,but when I tried to implement your suggestion in my uart.h I got the new error--

    Modified Code--(uart.h)


    #ifndef UART_H
    #define UART_H


    extern volatile unsigned int i;
    extern volatile char m[]="Hello Ma'am....!!!! ";
    //extern volatile unsigned char gate=0;
    extern volatile char a[20];
    extern volatile char p[]="Please enter a valid command";


    void uart_init(); //Initialize the UART connection


    #endif

    Error encountered-

    error #10056: symbol "p" redefined: first defined in "./main.obj"; redefined in "./uart.obj"
    error #10056: symbol "m" redefined: first defined in "./main.obj"; redefined in "./uart.obj"

    undefined first referenced
    symbol in file
    --------- ----------------
    a ./uart.obj
    i ./uart.obj

    Build Logs--


    **** Build of configuration Debug for project nms_test_string_hello_mam ****

    "C:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
    'Building file: ../main.c'
    'Invoking: MSP430 Compiler'
    "C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/bin/cl430" -vmsp --abi=eabi --use_hw_mpy=none --include_path="C:/ti/ccsv6/ccs_base/msp430/include" --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/include" --advice:power=all -g --embedded_cpp --define=__MSP430G2553__ --diag_warning=225 --diag_wrap=off --display_error_number --printf_support=minimal --preproc_with_compile --preproc_dependency="main.pp" "../main.c"
    "../main.c", line 20: remark #1527-D: (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead
    'Finished building: ../main.c'
    ' '
    'Building file: ../uart.c'
    'Invoking: MSP430 Compiler'
    "C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/bin/cl430" -vmsp --abi=eabi --use_hw_mpy=none --include_path="C:/ti/ccsv6/ccs_base/msp430/include" --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/include" --advice:power=all -g --embedded_cpp --define=__MSP430G2553__ --diag_warning=225 --diag_wrap=off --display_error_number --printf_support=minimal --preproc_with_compile --preproc_dependency="uart.pp" "../uart.c"
    "../uart.c", line 68: remark #1528-D: (ULP 3.1) Detected flag polling using IFG2. Recommend using an interrupt combined with enter LPMx and ISR
    "../uart.c", line 107: remark #1528-D: (ULP 3.1) Detected flag polling using IFG2. Recommend using an interrupt combined with enter LPMx and ISR
    "../uart.c", line 86: remark #1544-D: (ULP 13.1) Detected loop counting up. Recommend loops count down as detecting zeros is easier
    "../uart.c", line 91: remark #1544-D: (ULP 13.1) Detected loop counting up. Recommend loops count down as detecting zeros is easier
    'Finished building: ../uart.c'
    ' '
    'Building target: nms_test_string_hello_mam.out'
    'Invoking: MSP430 Linker'
    "C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/bin/cl430" -vmsp --abi=eabi --use_hw_mpy=none --advice:power=all -g --embedded_cpp --define=__MSP430G2553__ --diag_warning=225 --diag_wrap=off --display_error_number --printf_support=minimal -z -m"nms_test_string_hello_mam.map" --heap_size=80 --stack_size=80 -i"C:/ti/ccsv6/ccs_base/msp430/include" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/lib" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/include" --reread_libs --warn_sections --diag_wrap=off --display_error_number --xml_link_info="nms_test_string_hello_mam_linkInfo.xml" --use_hw_mpy=none --rom_model -o "nms_test_string_hello_mam.out" "./main.obj" "./uart.obj" "../lnk_msp430g2553.cmd" -l"libc.a"
    <Linking>
    remark #10372-D: (ULP 4.1) Detected uninitialized Port 2 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    remark #10372-D: (ULP 4.1) Detected uninitialized Port 3 in this project. Recommend initializing all unused ports to eliminate wasted current consumption on unused pins.
    error #10056: symbol "p" redefined: first defined in "./main.obj"; redefined in "./uart.obj"
    error #10056: symbol "m" redefined: first defined in "./main.obj"; redefined in "./uart.obj"

    undefined first referenced
    symbol in file
    --------- ----------------
    a ./uart.obj
    i ./uart.obj


    >> Compilation failure
    error #10234-D: unresolved symbols remain
    error #10010: errors encountered during linking; "nms_test_string_hello_mam.out" not built
    gmake: *** [nms_test_string_hello_mam.out] Error 1
    gmake: Target `all' not remade because of errors.

    **** Build Finished ****

  • uart.c

    volatile char p[] = "Please enter a valid command";

    uart.h

    extern volatile char p[];

  • Thank you for help.This worked.

**Attention** This is a public forum