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.

MSP430FR2355: #pragma LOCATION and DATA_SECTION hangup

Part Number: MSP430FR2355

I have the following in some working code:

#pragma DATA_SECTION (default_Info,".info")
char default_Info[4] = {'1', '2', '3', '4'};
char permanent_Info[5] = {0xFF};
#pragma LOCATION (permanent_Info, 0x1810);
#pragma DATA_SECTION (fw_version, ".info");
char fw_version[] = {"V_1.0_F"};

If I look at the map file after a build the sections default_Info, fw_version, etc are there in the file.

I cut and paste this into a new project that I have been working on and build it but I cannot see these in the new map file nor can I see them in the debug Memory browser.  I must be missing a setting in the project settings....Can someone tell me what I am doing wrong?

Thanks

  • As I recall the linker tosses out any unreferenced variables (even if they're in other sections). Are there references to all of these?

  • No there is not however fw_version has no link whatsoever in the working code either yet it still shows up in mem browser and map file of working prj

  • All the same, what happens if you set "Build Settings->Build->Linker->Miscellaneous->Eliminate sections not needed" to "off"? (I got a warning about _nop, which I'm pretty sure is harmless.)

    [Edit: That option probably keeps more than you're interested in. A slightly more "surgical" method would be to use "#pragma RETAIN(permanent_Info)". [Ref CC User Guide (SLAU132S) Sec 5.12.28]]

    [Edit: Fixed UG name]

  • Bruce...

    That worked....At least on the following

    #pragma SET_DATA_SECTION (".info")
    char fw_ver[] = {"V_6.0_A"};
    #pragma SET_DATA_SECTION (".info")
    

    Can you explain what the setting did??  I looked at the working project and I did not have that setting set.....

    Thanks

  • That flag turns off the linker's "garbage collection" that throws away unused variables. [Ref CCS Assembler User Guide (SLAU131V) Sec 8.4.8]

    It's a global flag, so it's also keeping some other things that you don't know about and  probably don't want. That "_nop" warning referred to a library symbol whose reference is removed if you don't use its feature. 

    That led me to discover the RETAIN feature (I sneaked in an "Edit:" above while you weren't looking).

  • Not gonna lie....This was a lesson in patience....I got something that works but WOW, very finicky....

    #pragma DATA_SECTION (default_Info,".info")
    char default_Info[4] = {'1', '2', '3', '4'};
    #pragma RETAIN (default_Info)  //this works with DATA_SECTION NOT LOCATION
    
    #pragma DATA_SECTION (fw_version, ".info")
    char fw_version[] = {"V_1.0_M"};
    #pragma RETAIN (fw_version)
    
    #pragma DATA_SECTION (permanent_Info, ".info")
    char permanent_Info[5] = { [0 ... 3] = 0xFF, 0x5A}; //does not work
    #pragma RETAIN (permanent_Info)
    

    For instance....If you replace DATA_SECTION with LOCATION the RETAIN will make a space in the MEMORY WINDOW for the name 'default_Info' but will not populate the data into the space.  

    Thanks for the help

**Attention** This is a public forum