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.

MSP430 DATA_SECTION to write in C segment issue

Other Parts Discussed in Thread: MSP430F2132

Hi,

I am sorry if this question has already been asked...

I am using CCS6 to program an MSP430F2132 in C language. I use an "eabi (ELF)" output format and I cannot write in the C segment (0x1040). I also tried to do it in a new project in order to avoid an issue due to a wrong setting... but I still have the issue...

Here is my code (I use lnk_msp430f2132.cmd as Linker command file) :

#pragma DATA_SECTION(VARIABLE, ".infoC")

const unsigned int VARIABLE = 0x1234 ;

But I cannot find the value "0x1234" at 0x1040... Does anyone has any idea?

Thank you in advance.

  • Hi C A,

    If you don't use VARIABLE anywhere, it is likely being optimized out. You can resolve this by also using the RETAIN pragma to tell the compiler and linker not to remove it. So your code might now look like:

    #pragma DATA_SECTION(VARIABLE, ".infoC")
    #pragma RETAIN(VARIABLE)
    const unsigned int VARIABLE = 0x1234;

    Now when you look at your .map file you should see that VARIABLE was put in INFOC memory at address 0x1040.

    There is more info on the RETAIN pragma in the compiler guide, www.ti.com/lit/pdf/slau132

    Regards,

    Katie

  • Hi Katie,

    Thank you very much for your response.

    I did what you suggested. Now, I got an error (the same I get when I use the COFF output format without the RETAIN pragma directive). The error is the following:

    MSP430: File Loader: Data verification failed at address 0x00001046 Please verify target memory and memory map.
    MSP430: GEL: FILE:
    .... xxxx.out: a data verification error occurred, file load failed.

    Actually, I declare 5 unsigned int (from 0x1040 to 0x1048). I think I got an error only when the current values in the flash memory are different than the ones I declare in the pragma directive. So in my case, I guess 0x1040, 0x1042, 0x01044 in my MCU flash memory have the "default value" and I guess the 0x1046 is different. Not sure about that but after some tests this afternoon, this is what I noticed.

    Do you have any idea about my new error?

    Thank you again.

    Regards,
  • Hi C A,

    C A said:
    think I got an error only when the current values in the flash memory are different than the ones I declare in the pragma directive

    I think this tells me what your problem is.

    By default, CCS only erases main memory when loading the program. You are trying to now write a value into INFO memory, so INFO memory needs to be erased before the write can occur. You can change this in CCS by going to Project > Properties > Debug > MSP430 Properties and scrolling down to where it has "Erase Options". By default it will be set to "Erase main memory only". You'll want to set it to "Erase main and information memory". With this setting, along with main flash it will also erase INFO B,C,D sections, but not erase the protected INFOA segment (which usually contains calibration data that you want to keep).

    I suspect that if you try this setting, your error will go away, because the INFOC flash will be erased before programming.

    Regards,

    Katie

  • I also tried to use an array instead of 5 variables... I tried without "const"... but I still have the same problem... with values different than the ones currently in flash, I got the error at 0x1040 and not at 0x1046...
  • Arf... I wrote my last message without seeing your response.

    Everything is OK now! Thank you very much Katie! Now, my firmware is done! :D
  • Awesome - so glad I could help! :-)

**Attention** This is a public forum