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.

Variables placed in Flash by linker and therefore become const

Hello,

I am using CCS 4.2.3 to work on a C project for the F2833x MCUs. I have created a RTSC platform and defined the memory map. There, the Flash area is defined as Code/Data Read/Execute, and the SARAM area is defined as Code/Data Read/Write/Execute. I did not create a cmd file.

When compiling my project, global and static variables are placed in Flash and remain uninitialized (0xFFFF) and cannot be changed during runtime (since the memory is Flash and not RAM).

I have read "C28x Compiler - Understanding Linking" and the document recommends to place initalized global and static variables in Flash. How would they still be modified at runtime then?

Thank you,

Cristian

  • That article indicates the .cinit section is placed in flash.  However, the TMS320C28x Optimizing C/C++ Compiler User's Guide (spru514) document indicates the .cinit section holds tables for initializing variables and constants, not the variables and constants themselves.

    Have you observed a particular problem?  If so, it would be useful to see how you have these variables declared to have a better understanding of the issues you are seeing.

  • Well, the particular problem is that the variables are not initialized correctly, and I can't change their contents at runtime (by simple assignment).

    Something like this:

    static int foo1 = 0;

    void main()
    {
         initStuff();

        BIOS_start();
    }

    // this function is called after BIOS_start by, say, a timer Swi

    void some_function ()
    {
        static int foo2 = 0; 
        // foo1 and foo2 are 0xFFFF  and located in Flash  
        foo1 = 1; foo2 = 2;
        // foo1 and foo2 are still 0xFFFF
    }

    The generated .map file shows both .cinit and .data located in Flash.