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.

MSP430FR57XX #pragma persistent not working in CCS

Other Parts Discussed in Thread: MSP430FR5738

Hi

I imported a working project (written in texteditor, compiled by a makefile before) into CCS. My command to store an array in FRAM was

__attribute__((section(".text"))) uint8_t f_variable[256];

Now CCS told me that it doesn't unterstand the command, so I begun reading about all the pragmas and FRAM best practices. I tried it with different combinations of 

#pragma persistent(f_variable)
#pragma DATA_SECTION(".text")
uint8_t f_variable[256];

but it didn't work. 

For #pragma persistent I get the following warning: #163-D unrecognized #pragma, for #pragma DATA_SECTION(".text") I get #830-D error processing pragma DATA_SECTION, verify format and when I try #pragma DATA_SECTION(f_variable, ".text") I get the following compile error [E0300] Cannot redefine this section name.

Do I have to import some files to enable the persistent pragma or what can I do to make my array persistent?

  • Hi,

    For #pragma DATA_SECTION(f_variable, ".text"), you can only place constants in ".text"; typically, you don't need to declare a data section to place your array in FRAM, the linker will take care of that.

    #pragma persistent(f_variable)
    uint8_t f_variable[256];

    If you really need to put the array within a specific section, I suggest the ".data" section.

    Sincerely,

    Sean

  • Hi Sean

    Thank you for your answer! 

    Unfortunately, the command #pragma persistent(f_variable) doesn't work. It produces a warning #163-D unrecognized pragma. 

    My CCS version should be up to date, 6.1.1.00022

    On a sidenote, .data resides in RAM (at least on my chip).

    Best regards

    Gian-Peider

  • Hi,

    It sounds like you did not declare the FRAM section in your linker file when you ported it, refer to section 3.4.1 of the following guide to modify the linker file
    www.ti.com/.../slaa628.pdf

    Notice the declarations below in the linker file:
    .TI.noinit : {} > FRAM /* For #pragma NOINIT */
    .TI.persistent : {} > FRAM /* For #pragma PERSISTENT */


    Sincerely,
    Sean
  • In the project's properties, I use lnk_msp430fr5738.cmd from CCS. It has this section in it which looks okay to me:

    GROUP(ALL_FRAM)
        {
           GROUP(READ_WRITE_MEMORY)
           {
              .TI.persistent : {}                /* For #pragma persistent            */
              .cio        : {}                   /* C I/O buffer                      */
              .sysmem     : {}                   /* Dynamic memory allocation area    */
           } ALIGN(0x0200), RUN_START(fram_rw_start)
    
           GROUP(READ_ONLY_MEMORY)
           {
              .cinit      : {}                   /* Initialization tables             */
              .pinit      : {}                   /* C++ constructor tables            */
              .init_array : {}                   /* C++ constructor tables            */
              .mspabi.exidx : {}                 /* C++ constructor tables            */
              .mspabi.extab : {}                 /* C++ constructor tables            */
              .const      : {}                   /* Constant data                     */
           } ALIGN(0x0200), RUN_START(fram_ro_start)
    
           GROUP(EXECUTABLE_MEMORY)
           {
              .text       : {}                   /* Code                              */
           } ALIGN(0x0200), RUN_START(fram_rx_start)
        } > FRAM

    I think there is somethink like a library missing where the #pragma persistent is defined, because else the IDE should know it.

  • Hi Gian-Peider,

    I pulled up some sample code in CCS for FR5738 and found out that PERSISTENT should be in upper case, it should build.

    #pragma PERSISTENT(f_variable)
    uint8_t f_variable[256];

    Sincerely,

    Sean

  • That's almost a bit embarassing.. Thank you very much!
  • No problem, glad it's working now! :D

**Attention** This is a public forum