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.

MSP430FR5849: Persistent Data and How it Actually Works?

Part Number: MSP430FR5849

Tool/software:

Hello!

I am currently attempting to use the MSP listed in the forum as a data collector and I am trying to store the data into the FRAM by using the "#pragma PERSISTENT". I don't fully understand how this works. The compiler tells me that the variables have to be initialized, but wouldn't that clear the data in the FRAM as well? Is there a way to set the variables up such that it won't be cleared on start up, in case I lose power? Below is how I have the variables set up with in my code, any help would be greatly appreciated!

#pragma PERSISTENT(accel_x)
#pragma PERSISTENT(accel_y)
#pragma PERSISTENT(accel_z)

signed char accel_x[array_length] = {0};
signed char accel_y[array_length] = {0};
signed char accel_z[array_length] = {0};

Thanks!

  • #pragma persistent puts the referenced variables into a section called ".TI.persistent". Since this is neither ".data" nor ".bss", it is not (re-)initialized at program startup. It is however initialized at program download.

    The linker (via the .cmd file) places this section down in low FRAM. At program startup, this area (if non-0 size) is made write-able by configuring the MPU. (This is for the FR5/FR6 series; the FR2 series is different since there's no MPU.)

  • So then anything stored in the persistent variable holds value on a power cycle until the variable is written to again?

  • Yes. You can see how this is done by looking at the linker .cmd file in your project. (Look for ".TI.persistent".)

**Attention** This is a public forum