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.

CCS/MSP430F6638: Can't resolve #171: expected a declaration error with ccsstudio

Part Number: MSP430F6638
Other Parts Discussed in Thread: MSP-FET

Tool/software: Code Composer Studio

Hello, 

I am using MSP430F6638 and I am trying to run a really simple code with ccs studio. Here is the code below :

int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer

UCSCTL4|=SELA__XT1CLK|SELS__XT2CLK; 
UCSCTL6|=XT2DRIVE_0|XCAP_0; 
UCSCTL6&=~XT2OFF; // turn on XT2
UCSCTL6&=~XT1OFF; // turn on XT1

P3SEL&=~BIT7;
P3DIR&=~BIT7;
P4SEL&=~BIT1;
P4DIR|=BIT1;

return 0;


}

while (1)  // line 26

{
if ((P3IN>>7) & (0x01) == 1)
{
P4OUT|=BIT1;
}
else
{

}

}

But while building I have this "../main.c", line 26: error #171: expected a declaration error (line 26 is the while line).

I don't see any error of "} "  or ";" here so I am really confused about that. I have searched a lot about this error on TI forum and on the net and tried many things such as adding verbose diagnstics option but nothing has changed. Here is below the diagnostics options :

You will also find attached the zip folder of the project.

MAPA_BPM.zip

Can someone help please ?

Thank you very much,

Best regards, 

Mike

  • Move the "return 0" and the subsequent right-brace to below the while() loop, so the while() is inside the main() function.

    Unsolicited: 

    > if ((P3IN>>7) & (0x01) == 1)
    This works only by accident, in spite of the operator precedence. Try:

    > if (((P3IN>>7) & (0x01)) == 1)
    or even better:

    > if ((P3IN & BIT7) == BIT7)   // P3.7 high?

    [Edit: Fixed typo]

  • Hi Bruce,

    Thank you very much for your answer and advices. I don't have the #171 error anymore. The program is successfully build. But now there is another main problem which is when I am trying to debug the program the MSP-FET can't be find : MSP430: Error initializing emulator: No USB FET was found. I am using the 4-Wire JTAG Communication and I am powering the MCU from an external supply so I made the J1 connection :

    I also checked the power supply and I do have the right voltage. So I don't if there is  some drivers or some tools that I should install or check if they are installed but I really don't know why the FET isn't found. Here is below my JTAG connections : Since C1 should not exceed 2.2 nF I used a 2 nF cap.

    Thank you,

    Regards,

    Mike

  • I have very little experience with the MSP-FET, and haven't used 4-wire JTAG in some time. 

    There are people here who know quite a lot, but they might not look at this post due to the Subject: line.

    Since this is a new question, I suggest you create a new post for it.

  • Bruce McKenney47378 said:

    There are people here who know quite a lot, but they might not look at this post due to the Subject: line.

    Since this is a new question, I suggest you create a new post for it.

    Agreed. 

    Mike - please start a new post in the MSP forum.

    Thanks

    ki

  • Hi Bruce,

    I will do that. 

    Thank you for your help.

    Mike