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/MSP430G2955: Controller gets stuck in memcpy.c when declaring a float[1024] Array

Part Number: MSP430G2955

Tool/software: Code Composer Studio

Hello everyone,

I am Using an MCP430G2955 for a Project. When i Try to declare one or more Float Arrays with more than ~800 variables, the Controller Seems to get stuck in memcpy.c / somewhere along the way.
I need to define two float arrays of size 1024 which should be around 8kB. Thus it should fit in the available FRAM of 56kB.

Example Code with the declaration of one such array:



#include <msp430.h>

void someFunction(float *ptr);

float test;

int main ( void )
{
    WDTCTL = WDTPW | WDTHOLD;   // stop watchdog timer
    float Values[1024]= {0.1,0.2,0.3,0.4,0.5};

    while(1)
    {
        someFunction(Values);
     }
    return (0);
}

void someFunction(float *ptr){
    test = ptr[2];
}



In Livechat i was sent the following link, which did not help me unfortunately:
e2e.ti.com/.../779902 float array
This is because neither RAMGS08 nor .ebss can be found in the .cmd file.

Thanks in advance.


  • The G2955 is a flash memory part and has only 4KB of RAM so your array will not fit. While there is just enough space for that array, that leaves nothing for the stack and your other variables.

  • First off, Thank you very much for your reply.

    Agreed.

    *----EDIT----*

    When i do program the device with an size 1024 array, CCS shows in the console, that the Flash/FRAM usage goes up by about 4kB while RAM usage stays the same. This can be seen in Console as well as in the .map File. Thus it seems that the space is allocated (?).

    On another note, why does CCS not tell me that the space is not sufficient if that is the problem?

    *----END EDIT----*

    Is there a way to store the variable in Flash memory?

    I found this page regarding this specific problem:

    http://processors.wiki.ti.com/index.php/Placing_Variables_in_Specific_Memory_Location_-_MSP430

    But i am not sure how to properly pick a memory location for the variable.

    The shown example uses "information Memory", which is also way to small, is it feasible to use "Code Memory" instead (Which is larger)?


    If i can use Code Memory, are there precautions i need to take to ensure that the saved data does not interfere with the code itself?

    Is there any other way i can store those big volumes of data on this specific Device?

  • The compiler didn't complain because the array is created at runtime on the stack.

    You can store read only data along with code by declaring it as constant: "const float". If the declaration is inside a function you need to add a static to that to get it off the stack.

  • Actually I don't think it is created on the stack. (George Mock corrected me on this.) CCS is smart enough to use the Heap for large auto variables.
  • That is exactly what i needed. (I thought i already tried this but it seems i messed it up somehow last time).

    Is my assumption correct that the controller takes way more time, when it uses data in Flash then in RAM?

    Thank you very much!
  • To some definition of "way more", yes. Though that of course depends on your clock speed. At 32K it probably does not matter.
  • Sure, "way more" is not a to exact statement.
    For curiosity's sake, is there a specific document on the MSP430 where i can read more on this topic?
    (Speed difference of RAM vs Flash when accessing Data ?)

    Thanks to everyone for the fast Help!
  • MCU datasheets provide information about wait states needed by Flash to run at a particular speed.
  • Flash reads are just as fast as reading from RAM.

    I know that the FRAM parts need to add a wait state at higher clock speeds but those include some simple cache hardware to mitigate the slow down.

  • FRAM, not Flash, sorry.
    Only a few bytes of cache.

**Attention** This is a public forum