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.

How to place const values in msp430 infoflash

Other Parts Discussed in Thread: MSP430F1232

Hello,

I would like to load some pre-defined data in the info flash of a MSP430F1232 when flashing my code. This data is never used directly in the C source code, but it's loaded into a variable after startup using a memcopy. Then the user may change something and with the shutdown, the values are written back to info flash section.

With IAR kickstart, the solution is tricky, but possible if you know how to do this :

#pragma object_attribute=__root
#pragma location="INFOB"
const static dataSet dataSetDefault = {
  14000,
  5,
  1
};

All the work is done by the 2 pragma's. The attribute __root will advise the compile not to optimize it away, because it is never referenced in the source code. The location pragma restricts address to INFOB section of the flash. That works fine with IAR tools.

Now I want to port this project to CCS 5.5.0... but so far I did not find any solution that works. How can I get my data structure automatically flashed in the INFO section of the device ? 

Thanks in advance,

BR,

Mark 

  • Markus Lemke said:
    The attribute __root will advise the compile not to optimize it away

    Use #pragma RETAIN for that.

    Markus Lemke said:
    The location pragma restricts address to INFOB section of the flash. That works fine with IAR tools.

    Use #pragma DATA_SECTION for that.  

    Look up the details on these pragmas in the MSP430 compiler manual.

    Further hints on DATA_SECTION ... I checked through the link command files supplied with CCS for MSP430 devices.  They all seem to adhere to the convention that the section .infoB is allocated to the INFOB  memory range.  I suspect this is what you want.  If that is correct, then this will do ...

    #pragma DATA_SECTION(dataSetDefault, ".infoB:dataSetDefault");

    That tells to the compiler to place that structure in a section of that name.  The name1:name2 form means this is a subsection of the .infoB section.  It is combined with the rest of the .infoB input sections into an output section also named .infoB, and allocated to the INFOB memory range.

    Thanks and regards,

    -George

  • Hello George,

    thank you very much for your hints ! Seems I've searched in the wrong documents so far. The 2 pragmas now doing the job as before with the IAR.

    Additionally, the static keyword had to be removed, otherwise it is not working.

    BR,

    Mark