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 on MacOS-X and C++

Hello!

I just discovered that CCS is now available on MacOS-X and I wanted to have a test
run. I did a minimal program using a brand new launchpad (5529) that I just bought.
CCS has updated the FET firmware, everyhing is fine in C, I can blink the red LED
on P1 bit 0.

Now I wanted to do the same thing in C++. I made a LED class which does basically
nothing. The Init function is P1DIR = 0x01; P1OUT = 0;
The Set function is P1OUT = 0x01, the Reset function is P1OUT = 0;
It compiles fine. When I start it, it steps over the first line. However, stepping
over MyRedLed.Init() causes the program getting lost. If I pause the debugger, the
program is in an abort function in exit.c.

Anybody knows how to use C++ in CCS on mac?
NB: I can use it on PC after enabling C++ in the preferences. On Mac, if I open the
project properties -> Build -> MSP430 compiler -> Advanced options -> Language options,
I have chosen C++ dialect as C++03 mode (whatever it is), but the other option doesn't
work either.

By the way, is C++ supported in this beta? (I should have asked that first...)

Thanks,

Pascal

#include <msp430.h>
#include "Led.h"

/*
 * main.c
 */
Led    MyRedLed;

int main(void) {
    WDTCTL = WDTPW | WDTHOLD;    // Stop watchdog timer
    MyRedLed.Init();
    MyRedLed.Set();
    return 0;
}

  • Hi Pascal,

     The MAC OS X version comes with the MSP430 compiler v4.4.1, therefore C++ should be supported (but maybe there is a problem with the Beta IDE/Debug session). It works for me using the windows version  (v4.41 and CCS v6.1.x) and the following code:

    #include <msp430.h>
    #include <stdint.h>
    #include <stdbool.h>
    
    class testLED
    {
    public:
    	uint16_t dutyCycles;
    //	testLED(void);
    	void initLED();
    	void toggleLED();
    };
    
    
    /*testLED::testLED(void)
    {
    	dutyCycles=10;
    }*/
    
    void testLED::initLED(void)
    {
    	P1DIR |= 0x01;					// Set P1.0 to output direction
    }
    
    void testLED::toggleLED(void)
    {
    	P1OUT ^= 0x01;				// Toggle P1.0 using exclusive-OR
    }
    
    int main(void) {
    	testLED myLED;
    
    	WDTCTL = WDTPW | WDTHOLD;		// Stop watchdog timer
    
    	myLED.initLED();
    
    	for(;;) {
    		volatile unsigned int i;	// volatile to prevent optimization
    
    		myLED.toggleLED();
    
    		i = 40000;					// SW Delay
    		do i--;
    		while(i != 0);
    	}
    	
    	return 0;
    }

    Could you please try that code and let us know if you see the same problem. At the same could please try the CCS could version

      Thanks,

        David

  • Hello David!

    Thanks for your reply.
    I have tried your code, and no surprise, it works the same way (i.e. it doesn't).
    If I step over the line just after main, it works (i.e. the LED blinks with a period
    of approximately 0.5 second), but it doesn't step.
    I have already used C++ on Windows and the debugger works.

    By the way, when creating it would be great with a "c++ project" option, which would
    configure the right way. To be frank, I'm not sure of which option I should choose.
    Is it automatically chosen when the file name is .cpp?
    As for the C++ options:
    Enable exception handling: even without, it should be possible to work in C++. Same with
    support C++ runtime type information...

    And last thing, when adding a file to a directory, Eclipse uses it directly and compiles
    it. I have a collection of driver files (for various sensors, LCDs, etc...) that are
    kept together. With IAR, I add the path to this directory. If I add the path to eclipse,
    it will add all the files, most of which are unrelated.
    I know that I can opt out by "exclude from build", but the best solution would be to
    opt in every file.

    Thanks,

    Pascal


  • Hi Pascal,

     In regards to your question:

    Pascal4275 said:
    Is it automatically chosen when the file name is .cpp?

    Please take a look at this UG www.ti.com/lit/slau132 Sections "changing How the Compiler Interprets Filenames" and "Changing How the Compiler Processes C Files".

    As the same time I'm moving your post to the CCS Forum as I believe they should be able to provide you with the information/help that you need.

      Best regards,

       David

  • Pascal,

    Per your description it seems to be a bug in the current public beta for Mac OS X. I tested David's code on a newer internal build (yet unreleased) and the Step operations worked just fine.

    Unfortunately at this time I am not 100% sure when a new CCS for Mac OS X will be released, but given the newer release for Windows and Linux are scheduled to be released next week, I am pretty sure that Mac OS X will be close.

    I apologize for the inconvenience,
    Rafael
  • Hello!

    Thanks for the replies. Well, I'm not really in a hurry, so I'll wait for a more stable version. As it's a beta,

    I wasn't expecting a perfect release.

    Pascal

  • Pascal,

    The updated CCS for Mac OS X was released today. Check the post below:

    e2e.ti.com/.../1633531

    Cheers,
    Rafael
  • Hello Rafael!


    Thanks for the info! That was quick!

    Pascal

  • Hello Rafael!

    I have another issue today.
    I made a class that used to work on MSP432. Today, it doesn't. The compiler keeps saying
    identifier "class" is undefined.
    And it points to a header file, so it's not a .cpp extension issue. Anyway all the cpp file have the proper
    extension. Any hint?

    Thanks,

    Pascal