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.

Compiler/MSP430FR2433: Canonical way to declare variables inside Information FRAM

Part Number: MSP430FR2433

Tool/software: TI C/C++ Compiler

Hi there-

This might be a silly question, but the TI examples didn't exactly spell this out.

I know in GCC, if we want to store a variable in a specific segment such as say ".infomem", you can add __attribute__((section(".infomem"))) and voila, you're done.  Just access the variable using normal C operations.

On the FR2433 you'd still have to disable Data FRAM write protection but that's no big deal.

Is there a similar way (when using the TI Optimizing C/C++ compiler instead of GCC) to allow you to declare variables as living inside infomem, so you can read (and, when DFWP is disabled, write) with simple C primitives?

  • Hi Eric,

    The following initialization before main should work:

    #pragma DATA_SECTION(variable, ".infoA")
    unsigned char variable = 0x00;

    Regards,
    Ryan
  • One more question-

    The TI compiler user guide mentions for NOINIT and PERSISTENT-
    "The PERSISTENT pragma is similar to the NOINIT pragma, except that it may only be used with
    statically-initialized variables. Persistent variables disable startup initialization; they are given an initial
    value when the code is loaded, but are never again initialized."

    Is it assumed then, that the use of PERSISTENT also implies the variable will be located inside non-volatile memory? E.g. when the linker knows there is SRAM for data as well as FRAM for code, the use of PERSISTENT implies the variable should live entirely within the FRAM program segment?

    Likewise, when declaring a variable in the Infomem FRAM area, should we use PERSISTENT in conjunction with DATA_SECTION?
  • Nevermind, the linker script answers my questions:

    SECTIONS
    {
        GROUP(ALL_FRAM)
        {
           GROUP(READ_WRITE_MEMORY)
           {
              .TI.persistent : {}                /* For #pragma persistent            */
           }
    
           GROUP(READ_ONLY_MEMORY)
           {
              .cinit      : {}                   /* Initialization tables             */
              .pinit      : {}                   /* C++ constructor tables            */
              .binit      : {}                   /* Boot-time Initialization tables   */
              .init_array : {}                   /* C++ constructor tables            */
              .mspabi.exidx : {}                 /* C++ constructor tables            */
              .mspabi.extab : {}                 /* C++ constructor tables            */
              .const      : {}                   /* Constant data                     */
           }
    
           GROUP(EXECUTABLE_MEMORY)
           {
              .text       : {}                   /* Code                              */
           }
        } > FRAM
    

    Likewise, infoA is NOLOAD:

        .infoA (NOLOAD) : {} > INFOA              /* MSP430 INFO FRAM  Memory segments */

**Attention** This is a public forum