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.

MSP-EXP430FR5994: std::vector not working for my c++ program

Part Number: MSP-EXP430FR5994

Tool/software:

Hi,

I would like to know if c++ vector works with MSP430 as the push_back function for my std::vector does now work but inputs garbage to the vector list.  The project is generated to run on the above launch pad.

I would like to know what I have left undone that is making it not to work.

A snapshot of my programme and the memroy browser in debug mode is below:

The num_c counts from 0 - 5 and I expect to see these values in the debug window but I did not.

The programme I am using is below

blink.cpp

The code is a simple code I generated from the CCS.

I shall be grateful if you could spot the problem for me, as I have checked all around the code and could not find the problem.

Thanks

  • Hi Abayomi Babatola

    May I know if you can develop the code using C intead of C++ because C is more commonly used

    Please refer to code example https://www.ti.com/tool/download/SLAC710 on the quick development

    msp430fr599x_1.c is the blinking LED based on the software delay

    Thanks!

  • I don't know exactly what a std::vector object looks like in Memory, but I don't expect it to look like a C array, since there's more functionality associated with a std::vector.

    When I tried this, the Expressions View showed me a bit more about what my_vector looked like, and I found the data at *__begin_= 0x4034 (=16436 in your Memory display).

    This might or might not continue to be true as you add/remove items. What I finally did was extract the vector contents into a C array with something like:

    uint16_t c_array[6];
    for (i = 0 ; i < my_vector.size() ; ++i)
    {
        c_array[i] = my_vector[i];
    }

    [Edit: On re-reading I noticed you actually added 6 items to my_vector, so I repaired the c_array[] declaration ([5]->[6]).]

  • Hi Li,

    Thanks for your reply.

    Yes and No.  Yes because most c++ code and syntax can be implemented in c but with more effort.  No, our implementation is more efficient, optimal and with reduced effort, when it is implemented as C++.

    I would like to know if this is possible.  The compiler is a c++ 14 compiler and the usage of std:: vector is basic to C++.

    Where you able to run the attached code?

    I would be grateful for your reply and help.  

    Thanks

  • Hi Abayomi Babatola

    I am not familiar Syntax for C++ on MSP430. 

    Please check the MSP430 Optimizing C/C++ Compiler v18.1.0.LTS User's Guide (Rev. R) page 160

    I think  std:: vector can 't be used on Syntax for C++ on MSP430

    Thanks!

  • As near as I can tell, std::vector works just fine [see above]. I was able to put items in, take them out (with additional code) and show them in memory. The Memory View in the Original Post doesn't show the data since it isn't looking at the correct location (0x4034).

    It could be said that the CCS debugger isn't very C++ friendly, but I don't know whether IAR/GDB do any better. (It's in general a hard problem.)

**Attention** This is a public forum