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.

const struct array in FLASH instead of RAM

Other Parts Discussed in Thread: MSP430F4250, CODECOMPOSER

Hello,

I am using Code Composer Version: 4.2.3.00004, a MSP-FETU430IF and a MSP430F4250

I got a struct defined:

struct s_Test
{
volatile unsigned char* MemoryCell;
int16_t* PointerToValue; 
int16_t Minimum;
int16_t Maximum;
char* MenueText;
};

then I want to have a Table of more entries of this struct globally available:

const struct s_ Test  const Data[_e_DataLength] =
{
     {NULL, &(DataMemory.Value), -1999, 9999, MenueTexte[0]},
     ...
}

now the whole thing is put into RAM not into FLASH, so using const or not makes no difference at all.

when i explicitly put #pragma DATA_SECTION(".const")  before the definition, the RAM seems to be free, but the whole table is not initialized with the data.

 

How can i create a table in flash that is initialized with data?

 

Thank you,

Martin

 

  • Probably you did, but to be sure, am I assuming right that you actually wrote something like:

    #pragma DATA_SECTION(Data, ".const")

    Additionally, as far as I understand this mechanism, somewhere it has to be declared which memory type shall be used for the different data sections.Did you?

    Concerning "flash" (until shortly before now I didn't think that this memory might be bound to a data section, so thanks for your hint to that) maybe this thread post will be helpful for you...

    Regards,
    Joern.

  • Hello,

    I used the parameter for deleting the complete flash before programming.
    I used the default cmd-File of CodeComposer for my chip, this says for the memory mapping:

    /****************************************************************************/
    /* SPECIFY THE SYSTEM MEMORY MAP */
    /****************************************************************************/

    MEMORY
    {
    SFR : origin = 0x0000, length = 0x0010
      ...
    FLASH : origin = 0xC000, length = 0x3FE0
    ...

     ****************************************************************************/
    /* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */
    /****************************************************************************/

    SECTIONS
    {
    .bss : {} > RAM /* GLOBAL & STATIC VARS */
    .sysmem : {} > RAM /* DYNAMIC MEMORY ALLOCATION AREA */
    .stack : {} > RAM (HIGH) /* SOFTWARE SYSTEM STACK */
    ...
      .const : {} > FLASH /* CONSTANT DATA */
    ...

     

    Another thing is, when I declare:

    char* const MenueTexte[100]
    {
    ...
    }

    this is put into flash as I expected.

    But this is always put into ram:

    struct s_Data[100]
    {
    ...
    }

     

    Thank you