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.

CCS/MSP430FR6820: MSP430FR6820: FRAM variable definition

Part Number: MSP430FR6820
Other Parts Discussed in Thread: MSP430FR2311

Tool/software: Code Composer Studio

I can create and use a FRAM variable. It is not difficult. But I need to
create a variable (an array of bytes about 1kB) with a constant address.
The address must be the same even if we modify the program code. I
suppose it is not a good solution to define only a variable with an constant
address in FRAM like char *myFRAMvariable = 0x08000 because somewhere of
the occupied place could be start of program code. I expect I need to also
modify the .cmd file to create a new section for  FRAM variables and
decrease the section of program code. But I do not know how to do it.

Thank you in advance for your reply.
  • Hi,

    You can refer to this file:

    And give you some code example (For MSP430FR2311) about this :

    The function of defining variables in the specified memory area can be realized by modifying the linker file.
    The following steps and example outline how to achieve this function.

    1. Allocate a new memory block(MY_SECTION).
    2. Define a segment(.Image) that store in this memory block(MY_SECTION).
    3. Use #pragma DATA_SECTION in program to define variables in this segment.

    RAM : origin = 0x2000, length = 0x400
    RAM2 : origin = 0xF100, length = 0x100
    MY_SECTION : origin = 0xF200, length = 0x100
    FRAM : origin = 0xF300, length = 0xC80
    .Image : {} > MY_SECTION
    #pragma DATA_SECTION(a,".Image")
    unsigned char a;

    NOTE: The write function of FRAM must be enable in program if there are some write operation
    within the allocated FRAM memory.

    Best Regards


  • Thank you,

    however I am getting the "program will not fit into available memory.  run placement with alignment fails for section "RW_IPE" size 0x9be". I watched the similar topics here but they have not resolved my issue.

    Here is a snippet of my original(working) .cmd file:

    FRAM                    : origin = 0x8000, length = 0x7F80

    here is the edited:

        FRAM_DATA               : origin = 0x8000, length = 0x0320
        FRAM_STATUS             : origin = 0x8320, length = 0x0010
        FRAM                    : origin = 0x8330, length = 0x7C50

    another part where I added my sections:

               .TI.persistent : {}              /* For #pragma persistent            */
               .cio           : {}              /* C I/O Buffer                      */
               .sysmem        : {}              /* Dynamic memory allocation area    */
            } PALIGN(0x0400), RUN_START(fram_rw_start)
               .ipestruct     : {}              /* IPE Data structure                */
               .ipe           : {}              /* IPE                               */
               .ipe_const     : {}              /* IPE Protected constants           */
               .ipe:_isr      : {}              /* IPE ISRs                          */
               .ipe_vars      : type = NOINIT{} /* IPE variables                     */
            } PALIGN(0x0400), RUN_START(fram_ipe_start) RUN_END(fram_ipe_end) RUN_END(fram_rx_start)
        } > 0x8000
        .my_data_fram	  : {}  > FRAM_DATA		/* Saved my data in FRAM			 */
        .my_status_fram	  : {}  > FRAM_STATUS	/* Saved status of data in FRAM		 */
        .cinit            : {}  > FRAM          /* Initialization tables             */
        .pinit            : {}  > FRAM          /* C++ Constructor tables            */
        .binit            : {}  > FRAM          /* Boot-time Initialization tables   */
        .init_array       : {}  > FRAM          /* C++ Constructor tables            */
        .mspabi.exidx     : {}  > FRAM          /* C++ Constructor tables            */
        .mspabi.extab     : {}  > FRAM          /* C++ Constructor tables            */
        .const            : {}  > FRAM          /* Constant data                     */
        .text:_isr        : {}  > FRAM          /* Code ISRs                         */
        .text             : {}  > FRAM          /* Code                              */

    I define variables like:

    #pragma DATA_SECTION(framData,".my_data_fram")
    char framData[800] = {0};
    #pragma DATA_SECTION(framStatus,".my_status_fram")
    char framStatus[8] = {0};

    EDIT: I also tried using sizes of FRAM blocks aligned to 32 bytes.

    And here is my .map file:

     FRAM_DATA             00008000   00000320  00000320  00000000  RWIX
     FRAM_STATUS           00008320   00000010  00000008  00000008  RWIX
     FRAM                  00008330   00007c50  0000261a  00005636  RWIX

    It seems that everything fits into blocks even it does not work.

  • Hi lgi,

    I don't encounter any problem about your code : 

    You can check if there are other errors in the cmd file.

    Best Regards


  • Hi Johnson,

    that is strange the same code works in your ccs.

    I changed few things and now it seems that works.

    I changed the last value in this part in cmd file:

    } PALIGN(0x0400), RUN_START(fram_ipe_start) RUN_END(fram_ipe_end) RUN_END(fram_rx_start)
        } > 0x8400

    Then I got a message that there should be 1024 bytes blocks. I am not sure whether I can change the


    to my custom value.

    Therefore I changed also in cmd file alignment to start the program will be 1024 bytes shifted(it was required by an error message):

        FRAM_DATA               : origin = 0x8000, length = 0x03F6
        FRAM_STATUS             : origin = 0x83F6, length = 0x000A
        FRAM                    : origin = 0x8400, length = 0x7920

    Now I can build the project. My last question:

    As you know I use one variable in both FRAM segment. If the variable in one segment is smaller than maximum size of this part will be the address of variable always the start of the segment?

  • Hi lgi,

    Yes, the compiler places them in order by default, so as you described, this variable will be placed at the first address of this segment.

    Best Regards


  • Hi Johnson,

    I just found out that the values in my FRAM variables do not remain there after power off. I checked if the addresses of variables are really in the FRAM and they are. I tried delete initialization the variables but it did not help.

    Do you have any idea where could be a problem?

**Attention** This is a public forum