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.

MSP430FR2111: Persistent data is not being allocated to FRAM

Part Number: MSP430FR2111
Other Parts Discussed in Thread: MSP430FR2311

I have a project using the MSP430FR2311 which has both RAM and FRAM. I'm trying to put an array into FRAM using the #pragma persistent directive as such:

#pragma PERSISTENT
uint16_t persistent_array[128];

When I compile I get a warning message:

..., line 228 (col. 10): warning #1519-D: variable "persistent_array" was declared persistent and should be explicitly initialized

This warning message is as expected, and seems to indicate the compiler understands the directive. However, the map file shows this array is still put into the .bss segment which gets placed into RAM and not FRAM:

.TI.persistent
* 0 0000f100 00000000 UNINITIALIZED

...

.bss 0 00002000 00000322 UNINITIALIZED
...
0000229e 00000080 (.common:persistent_array)

If I remove the "#pragma PERSISTENT," there is absolutely no change to the map file, but the warning does disappear.

I am using the standard unmodified linker file as generated by CCS. ".TI.persistent" is sent to FRAM and ".bss" is sent to RAM.

I also noticed a bunch of posts which give suggest a slightly different syntax:

#pragma PERSISTENT(persistent_array)
uint16_t persistent_array[128];

However, this leads to an error during compiling:

..., line 224: error #18: expected a ")"

I'm using the TI compiler.

Similar post but solution does not work:

e2e.ti.com/.../3353885

How can I get the #pragma PERSISTENT directive to work as expected?

  • Did you try giving it an initializer (as recommended in the warning)? When I added an initializer the compiler then didn't ignore the PERSISTENT attribute, and put it in FRAM.

    What version of the TI compiler? My copy of v18.1.2.LTS requires "#pragma PERSISTENT(persistent_array)"

    [Edit: Missed a bit of the original post]

  • > Did you try giving it an initializer (as recommended in the warning)? When I added an initializer the compiler then didn't ignore the PERSISTENT attribute, and put it in FRAM.

    I did not. I was initializing it within main(). Setting an initializer does seem to get it to behave as expected, thank you.

    Perhaps without the initializer the compiler things it's just dumb uninitialized memory and dumps it in .bss regardless? I don't think that's the correct behavior, but that is what happens.

    > Are you using the TI compiler?

    I am using the default TI compiler (C:/ti/ccs1010/ccs/tools/compiler/ti-cgt-msp430_20.2.4.LTS/bin/cl430)

    > My copy of v18.1.2.LTS doesn't accept that pragma, rather it requires "#pragma PERSISTENT(persistent_array)"

    I figured out this part, sort of. My file main.cpp is a C++ file and only accepts the "#pragma PERSISTENT" format.

    If I change it to main.c, it only accepts the "#pragma PERSISTENT (persistent_array)" format.

    I have no idea why the #pragma format would be different between the two, but it is.

    So problem solved, although it doesn't seem like the expected behavior.

**Attention** This is a public forum