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.

CCSv6 - MSP430 - GCC 4.8 - #include <msp430.h> does not work

Other Parts Discussed in Thread: MSP430FR5969

Hi folks,

Using the new CCSv6 release edition, I'm trying a Wolverine test program I wrote during the Beta phase.

It no longer compiles, as it can't find the various SFRs (e.g. P4OUT).  My program uses:

#include <msp430.h>

up top, which worked before.  Now I have to use #include <msp430fr5969.h> for it to compile correctly.

I'm puzzled how/why, because according to the CDT build console, CCS is using -D__MSP430FR969__ in the build command and msp430.h checks for that define before including msp430fr5969.h on its own.  Can't figure out why that's not working right...

Judging by the fact that it does compile with "#include <msp430fr5969.h>" I have to assume it has its search pattern correct for the include files.

This is CCSv6 on Windows 7 (32-bit) FYI.

Code:

/*
 * main.c
 */
#include <msp430.h>

int main(void) {
	WDTCTL = WDTPW | WDTHOLD;

	// GPIO Setup
	P1OUT = 0;
	P1DIR = 0xFF;

	P2OUT = 0;
	P2DIR = 0xFF;

	P3OUT = 0;
	P3DIR = 0xFF;

	P4OUT = 0;
	P4DIR = 0xFF;
	
	PJOUT = 0;
	PJSEL0 = BIT4 | BIT5;                     // For XT1
	PJDIR = 0xFFFF;


	// Disable the GPIO power-on default high-impedance mode to activate
	// previously configured port settings
	PM5CTL0 &= ~LOCKLPM5;

	// Clock System Setup
	CSCTL0_H = CSKEY >> 8;                    // Unlock CS registers
	CSCTL1 = DCOFSEL_6;                       // Set DCO to 8MHz
	CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK;
	CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers
	CSCTL4 &= ~LFXTOFF;                       // Enable LFXT1
	do
	{
		CSCTL5 &= ~LFXTOFFG;                    // Clear XT1 fault flag
		SFRIFG1 &= ~OFIFG;
	} while (SFRIFG1&OFIFG);                  // Test oscillator fault flag
	CSCTL0_H = 0;                             // Lock CS registers

	WDTCTL = WDT_ADLY_16;
	SFRIE1 |= WDTIE;
	_EINT();
	while (1) {
		__delay_cycles(4000000);
	}

	return 0;
}

void __attribute__((interrupt(WDT_VECTOR))) wdtisr()
{
	P4OUT ^= BIT6;
	__bic_SR_register_on_exit(LPM3_bits);
}

  • CDT console messages:

    **** Build of configuration Debug for project wolvgcctest ****
    
    "c:\\ti\\ccsv6\\utils\\bin\\gmake" -k all 
    'Building file: ../main.c'
    'Invoking: GNU Compiler'
    "c:/ti/ccsv6/tools/compiler/gcc_msp430_4.8.371/bin/msp430-elf-gcc.exe" -c -mmcu=msp430X -D__MSP430FR5969__ -I"c:/ti/ccsv6/tools/compiler/gcc_msp430_4.8.371/msp430-elf/include" -I"c:/ti/ccsv6/ccs_base/msp430/include_gcc" -Os -g -gstrict-dwarf -Wall -MMD -MP -MF"main.d" -MT"main.d" -o"main.o"  "../main.c"
    ../main.c: In function 'main':
    ../main.c:7:2: error: 'WDTCTL' undeclared (first use in this function)
      WDTCTL = WDTPW | WDTHOLD;
      ^
    ../main.c:7:2: note: each undeclared identifier is reported only once for each function it appears in
    ../main.c:7:11: error: 'WDTPW' undeclared (first use in this function)
      WDTCTL = WDTPW | WDTHOLD;
               ^
    ../main.c:7:19: error: 'WDTHOLD' undeclared (first use in this function)
      WDTCTL = WDTPW | WDTHOLD;
                       ^
    ../main.c:10:2: error: 'P1OUT' undeclared (first use in this function)
      P1OUT = 0;
      ^
    ../main.c:11:2: error: 'P1DIR' undeclared (first use in this function)
      P1DIR = 0xFF;
      ^
    ../main.c:13:2: error: 'P2OUT' undeclared (first use in this function)
      P2OUT = 0;
      ^
    ../main.c:14:2: error: 'P2DIR' undeclared (first use in this function)
      P2DIR = 0xFF;
      ^
    ../main.c:16:2: error: 'P3OUT' undeclared (first use in this function)
      P3OUT = 0;
      ^
    ../main.c:17:2: error: 'P3DIR' undeclared (first use in this function)
      P3DIR = 0xFF;
      ^
    ../main.c:19:2: error: 'P4OUT' undeclared (first use in this function)
      P4OUT = 0;
      ^
    ../main.c:20:2: error: 'P4DIR' undeclared (first use in this function)
      P4DIR = 0xFF;
      ^
    ../main.c:22:2: error: 'PJOUT' undeclared (first use in this function)
      PJOUT = 0;
      ^
    ../main.c:23:2: error: 'PJSEL0' undeclared (first use in this function)
      PJSEL0 = BIT4 | BIT5;                     // For XT1
      ^
    ../main.c:24:2: error: 'PJDIR' undeclared (first use in this function)
      PJDIR = 0xFFFF;
      ^
    ../main.c:29:2: error: 'PM5CTL0' undeclared (first use in this function)
      PM5CTL0 &= ~LOCKLPM5;
      ^
    ../main.c:29:14: error: 'LOCKLPM5' undeclared (first use in this function)
      PM5CTL0 &= ~LOCKLPM5;
                  ^
    ../main.c:32:2: error: 'CSCTL0_H' undeclared (first use in this function)
      CSCTL0_H = CSKEY >> 8;                    // Unlock CS registers
      ^
    ../main.c:32:13: error: 'CSKEY' undeclared (first use in this function)
      CSCTL0_H = CSKEY >> 8;                    // Unlock CS registers
                 ^
    ../main.c:33:2: error: 'CSCTL1' undeclared (first use in this function)
      CSCTL1 = DCOFSEL_6;                       // Set DCO to 8MHz
      ^
    ../main.c:33:11: error: 'DCOFSEL_6' undeclared (first use in this function)
      CSCTL1 = DCOFSEL_6;                       // Set DCO to 8MHz
               ^
    ../main.c:34:2: error: 'CSCTL2' undeclared (first use in this function)
      CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK;
      ^
    ../main.c:34:11: error: 'SELA__LFXTCLK' undeclared (first use in this function)
      CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK;
               ^
    ../main.c:34:27: error: 'SELS__DCOCLK' undeclared (first use in this function)
      CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK;
                               ^
    ../main.c:34:42: error: 'SELM__DCOCLK' undeclared (first use in this function)
      CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK;
                                              ^
    ../main.c:35:2: error: 'CSCTL3' undeclared (first use in this function)
      CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers
      ^
    ../main.c:35:11: error: 'DIVA__1' undeclared (first use in this function)
      CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers
               ^
    ../main.c:35:21: error: 'DIVS__1' undeclared (first use in this function)
      CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers
                         ^
    ../main.c:35:31: error: 'DIVM__1' undeclared (first use in this function)
      CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers
                                   ^
    ../main.c:36:2: error: 'CSCTL4' undeclared (first use in this function)
      CSCTL4 &= ~LFXTOFF;                       // Enable LFXT1
      ^
    ../main.c:36:13: error: 'LFXTOFF' undeclared (first use in this function)
      CSCTL4 &= ~LFXTOFF;                       // Enable LFXT1
                 ^
    ../main.c:39:3: error: 'CSCTL5' undeclared (first use in this function)
       CSCTL5 &= ~LFXTOFFG;                    // Clear XT1 fault flag
       ^
    ../main.c:39:14: error: 'LFXTOFFG' undeclared (first use in this function)
       CSCTL5 &= ~LFXTOFFG;                    // Clear XT1 fault flag
                  ^
    ../main.c:40:3: error: 'SFRIFG1' undeclared (first use in this function)
       SFRIFG1 &= ~OFIFG;
       ^
    ../main.c:40:15: error: 'OFIFG' undeclared (first use in this function)
       SFRIFG1 &= ~OFIFG;
                   ^
    ../main.c:44:11: error: 'WDT_ADLY_16' undeclared (first use in this function)
      WDTCTL = WDT_ADLY_16;
               ^
    ../main.c:45:2: error: 'SFRIE1' undeclared (first use in this function)
      SFRIE1 |= WDTIE;
      ^
    ../main.c:45:12: error: 'WDTIE' undeclared (first use in this function)
      SFRIE1 |= WDTIE;
                ^
    ../main.c: At top level:
    ../main.c:55:1: warning: argument of 'interrupt' attribute is not a string constant or number [-Wattributes]
     {
     ^
    ../main.c: In function 'wdtisr':
    ../main.c:56:2: error: 'P4OUT' undeclared (first use in this function)
      P4OUT ^= BIT6;
      ^
    gmake: *** [main.o] Error 1
    gmake: Target `all' not remade because of errors.
    
    **** Build Finished ****

  • FYI, setting the -mmcu parameter in properties to "msp430fr5969" instead of "msp430X" clears this up.  I'm a bit puzzled still, since -D__MSP430FR5969__ should take care of this, and why does CCS use "-mmcu=msp430X" by default?

  • Ok I figured it out.

    msp430.h has a few __MSP430xxxxx__ type macros that are tested "in the middle" of the file, before the FR5xxx series and a bunch of others are tested.

    #elif defined (__MSP430F6659__)
    #include "msp430f6659.h"
    
    #elif defined (__MSP430L092__)
    #include "msp430l092.h"
    
    #elif defined (__MSP430C091__)
    #include "msp430c091.h"
    
    #elif defined (__MSP430C092__)
    #include "msp430c092.h"
    
    #elif defined (__MSP430XGENERIC__)
    #include "msp430xgeneric.h"
    
    #elif defined (__MSP430F5XX_6XXGENERIC__)
    #include "msp430f5xx_6xxgeneric.h"
    
    #elif defined (__MSP430FR5XX_6XXGENERIC__)
    #include "msp430fr5xx_6xxgeneric.h"
    
    #elif defined (__MSP430FR57XXGENERIC__)
    #include "msp430fr57xxgeneric.h"
    
    #elif defined (__MSP430F5131__)
    #include "msp430f5131.h"
    
    #elif defined (__MSP430F5151__)
    #include "msp430f5151.h"
    
    #elif defined (__MSP430F5171__)
    #include "msp430f5171.h"
    
    #elif defined (__MSP430F5132__)
    #include "msp430f5132.h"

    Those "generic" defines should probably be tested at the end, not in the middle.  With -mmcu=msp430X it does indeed match __MSP430XGENERIC__ which then causes it to include "msp430xgeneric.h" instead of "msp430fr5969.h" as I would expect.

    Adding some #warning's to various parts of that file to identify it, I do get:

    **** Build of configuration Debug for project wolvgcctest ****
    
    "c:\\ti\\ccsv6\\utils\\bin\\gmake" -k all 
    'Building file: ../main.c'
    'Invoking: GNU Compiler'
    "c:/ti/ccsv6/tools/compiler/gcc_msp430_4.8.371/bin/msp430-elf-gcc.exe" -c -mmcu=msp430X -D__MSP430FR5969__ -I"c:/ti/ccsv6/tools/compiler/gcc_msp430_4.8.371/msp430-elf/include" -I"c:/ti/ccsv6/ccs_base/msp430/include_gcc" -Os -ffunction-sections -fdata-sections -g -gstrict-dwarf -Wall -MMD -MP -MF"main.d" -MT"main.d" -o"main.o"  "../main.c"
    In file included from ../main.c:4:0:
    c:/ti/ccsv6/ccs_base/msp430/include_gcc/msp430.h:8:2: warning: #warning "Pre-check __msp430" [-Wcpp]
     #warning "Pre-check __msp430"
      ^
    c:/ti/ccsv6/ccs_base/msp430/include_gcc/msp430.h:11:2: warning: #warning "Post-check __msp430" [-Wcpp]
     #warning "Post-check __msp430"
      ^
    c:/ti/ccsv6/ccs_base/msp430/include_gcc/msp430.h:941:2: warning: #warning "Using __MSP430XGENERIC__" [-Wcpp]
     #warning "Using __MSP430XGENERIC__"
      ^
    ../main.c: In function 'main':
    ../main.c:7:2: error: 'WDTCTL' undeclared (first use in this function)
      WDTCTL = WDTPW | WDTHOLD;
      ^
    ../main.c:7:2: note: each undeclared identifier is reported only once for each function it appears in
    ../main.c:7:11: error: 'WDTPW' undeclared (first use in this function)
      WDTCTL = WDTPW | WDTHOLD;
    (etc etc etc)

    I'd consider this a bug in the release.  For now I'm nuking those generic entries from my msp430.h file.

  • Hi Eric,

    Thanks so much for the very detailed feedback - sorry that you had to run into this issue. I'll report this as an improvement that needs to be made on the header files.

    Regards,

    Katie

  • Hi Eric,

    Before filing this as a bug, I was trying to reproduce the issue, but I haven't been able to get it to fail. Here is what I did - please tell me if I'm missing something needed to reproduce the error:

    CCS version 6.0.0.00190 (the release version, not beta)

    • Project > New CCS project , select MSP430FR5969, set compiler version to GNU v4.8.0 (Red Hat) and create an empty project
    • In the empty project, I simply used this as my code:
    • /*
       * main.c
       */
      #include <msp430.h>
      
      int main(void) {
      	
          P4OUT = 0;
      	P4DIR = 0xFF;
      
      	while(1)
      	{
      		__no_operation();
      	}
      
      	return 0;
      }
    • Then I build. It builds with no errors. If I go right click on something like P4OUT and go to Open Declaration, it opens up the msp430fr5969.h file, so I can tell that was correctly included.

    Is there a setting or step that you think I have missed here? Here is my CDT Build Console so you can see some of the settings used - it looks like it matches:

    **** Build of configuration Debug for project gnu_test ****
    
    "C:\\ti_6_0\\ccsv6\\utils\\bin\\gmake" -k all 
    'Building file: ../main.c'
    'Invoking: GNU Compiler'
    "C:/ti_6_0/ccsv6/tools/compiler/gcc_msp430_4.8/bin/msp430-elf-gcc.exe" -c -mmcu=msp430X -D__MSP430FR5969__ -I"C:/ti_6_0/ccsv6/tools/compiler/gcc_msp430_4.8/msp430-elf/include" -I"C:/ti_6_0/ccsv6/ccs_base/msp430/include_gcc" -Os -g -gstrict-dwarf -Wall -MMD -MP -MF"main.d" -MT"main.d" -o"main.o"  "../main.c"
    'Finished building: ../main.c'
    ' '
    'Building target: gnu_test.out'
    'Invoking: GNU Linker'
    "C:/ti_6_0/ccsv6/tools/compiler/gcc_msp430_4.8/bin/msp430-elf-gcc.exe" -mmcu=msp430X -D__MSP430FR5969__ -Os -g -gstrict-dwarf -Wall -Wl,-Map,"gnu_test.map" -o"gnu_test.out" "./main.o" -T"../msp430fr5969.ld"  -Wl,--start-group -l"c" -l"gcc" -Wl,--end-group 
    'Finished building target: gnu_test.out'
    ' '
    
    **** Build Finished ****

    Can you reproduce when making a fresh project like this, or only on the one that you imported from an older CCSv6 beta version?

    Regards,

    Katie

  • Same example as yours, mine failed:

    **** Build of configuration Debug for project wolv_hdrtest ****
    
    "c:\\ti\\ccsv6\\utils\\bin\\gmake" -k all 
    'Building file: ../main.c'
    'Invoking: GNU Compiler'
    "c:/ti/ccsv6/tools/compiler/gcc_msp430_4.8.371/bin/msp430-elf-gcc.exe" -c -mmcu=msp430X -D__MSP430FR5969__ -I"c:/ti/ccsv6/tools/compiler/gcc_msp430_4.8.371/msp430-elf/include" -I"c:/ti/ccsv6/ccs_base/msp430/include_gcc" -Os -g -gstrict-dwarf -Wall -MMD -MP -MF"main.d" -MT"main.d" -o"main.o"  "../main.c"
    ../main.c: In function 'main':
    ../main.c:7:2: error: 'P4OUT' undeclared (first use in this function)
      P4OUT = 0;
      ^
    ../main.c:7:2: note: each undeclared identifier is reported only once for each function it appears in
    ../main.c:8:2: error: 'P4DIR' undeclared (first use in this function)
      P4DIR = 0xFF;
      ^
    gmake: *** [main.o] Error 1
    gmake: Target `all' not remade because of errors.
    
    **** Build Finished ****
    

    Can you zip up a copy of your "C:\ti\ccsv6\ccs_base\msp430\include_gcc\msp430.h" header file and post it here?  I want to see if it's different.  In the meantime I am going to blow away my current CCSv6 install and reinstall it.

  • Another option instead of uninstalling, is to simply make a new folder so you can have a parallel install - I do this a lot to maintain different CCS versions since I need the old ones sometimes: make a new folder like C:\ti_6_0 and point to that instead of C:\ti in the CCS installer. Then you don't have to lose your old version if you don't want to.

    My msp430.h file from inside the include_gcc folder: 5123.msp430.h

  • Okay I am puzzled now, yours looks similar to mine.  I'll see how it performs after a reinstall.

  • Okay, full uninstall of CCSv6, full reinstall.

    Program:

    /*
     * main.c
     */
    #include <msp430.h>
    
    int main(void) {
    	P4OUT = 0;
    	P4DIR = 0xFF;
    
    	while (1)
    	{
    		__no_operation();
    	}
    	
    	return 0;
    }

    Error:

    **** Build of configuration Debug for project wolv_hdrtest2 ****
    
    "c:\\ti\\ccsv6\\utils\\bin\\gmake" -k all 
    'Building file: ../main.c'
    'Invoking: GNU Compiler'
    "c:/ti/ccsv6/tools/compiler/gcc_msp430_4.8.371/bin/msp430-elf-gcc.exe" -c -mmcu=msp430X -D__MSP430FR5969__ -I"c:/ti/ccsv6/tools/compiler/gcc_msp430_4.8.371/msp430-elf/include" -I"c:/ti/ccsv6/ccs_base/msp430/include_gcc" -Os -g -gstrict-dwarf -Wall -MMD -MP -MF"main.d" -MT"main.d" -o"main.o"  "../main.c"
    ../main.c: In function 'main':
    ../main.c:7:2: error: 'P4OUT' undeclared (first use in this function)
      P4OUT = 0;
      ^
    ../main.c:7:2: note: each undeclared identifier is reported only once for each function it appears in
    ../main.c:8:2: error: 'P4DIR' undeclared (first use in this function)
      P4DIR = 0xFF;
      ^
    gmake: *** [main.o] Error 1
    gmake: Target `all' not remade because of errors.
    
    **** Build Finished ****

    Project in a .zip file:

    4073.wolv_hdrtest2.zip

  • Ok, we might have a breakthrough now.

    When I first imported and built your project, I still had no error. But I noticed from your build console output, that it was using "gcc_msp430_4.8.371", whereas mine was using gcc_msp430_4.8. I opened up CCS app center and there it showed that my MSP430 GCC Beta had updates available, so I let it update. Now when I clean and rebuild the project with the updated GCC to 4.8.371, now I get the same error that you did.

    So it seems that something changed between these versions. I'll see if I can find the right people to work on this - we should figure out what changed between the versions to cause this, and what is the best course of action to fix it.

    -Katie

  • That's interesting.  I'm guessing the previous release you had didn't set __MSP430XGENERIC__ internally by the compiler when -mmcu=msp430X was delivered to the command, while the new version does.  Anyway the ideal solution I think is to have those "generic" tests moved to the end (in fact at the very end there is a duplicate test for __MSP430XGENERIC__)

    Thanks again Katie!

  • During one of the recent CCS updates, the location information of the processor registers has been moved from the header files to the linker scripts.
    However, new compiler versions come with new header files while old projects keep the old linker scripts. And suddenly none of the two offers the info.

    When you change the code/data model or the target device, the IDE will replace the linker script with the proper one form the compiler database, and suddenly things work again. (but custom modifications to the script are lost).

**Attention** This is a public forum