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/MSP-EXP430FR5969: Problems in allocating data in FRAM memory

Part Number: MSP-EXP430FR5969

Tool/software: Code Composer Studio

I use an MSP-EXP430FR5969 board and am trying to write data to FRAM memory.
I searched, and saw that it is necessary to use #pragma NOINIT and #pragma LOCATION. I saw several forms, and I'm not able to save that data to the desired address.
Here's the way I'm trying:
#include "driverlib.h"
#pragma NOINIT(beta)

#pragma LOCATION(beta, 0x8C00)

int beta;

int main(void) {

WDT_A_hold(WDT_A_BASE);
beta = 1;
return (0);
} 

This is .txt file:

@4400
81 00 00 24 B1 13 00 00 B1 13 64 00 0C 43 B1 13 
4C 00 1C 43 B1 13 5E 00 32 D0 10 00 FD 3F 03 43 
@ff80
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
@ffcc
18 44 18 44 18 44 18 44 18 44 18 44 18 44 18 44 
18 44 18 44 18 44 18 44 18 44 18 44 18 44 18 44 
18 44 18 44 18 44 18 44 18 44 18 44 18 44 18 44 
18 44 00 44 B2 40 00 A5 A0 05 3F 40 80 04 82 4F 
A6 05 3F 40 C0 08 82 4F A4 05 3F 40 FF FF 82 4F 
A8 05 3F 40 01 A5 82 4F A0 05 C2 43 A1 05 10 01 
CF 0C 3F 50 0C 00 2F 4F 7F F0 7F 00 7F D0 80 00 
4F 4F 3F 50 00 5A 3C 50 0C 00 8C 4F 00 00 10 01 
3C 40 50 01 B1 13 2C 00 40 18 92 43 00 8C 0C 43 
10 01 03 43 FF 3F 03 43 1C 43 10 01 
q

I did it differently (#pragma PERSISTENT), and it worked. However, the variable is saved "fixed" at program start. That is, I can not save any variables during the program.

Here's the example:

#include "driverlib.h"

#pragma PERSISTENT(beta)

#pragma LOCATION(beta, 0x8C00)

int beta = 10;

int main(void) {

WDT_A_hold(WDT_A_BASE);
beta = 1;
return (0);
} 

This is .txt file:

@4400
81 00 00 24 B1 13 00 00 B1 13 64 00 0C 43 B1 13 
4C 00 1C 43 B1 13 5E 00 32 D0 10 00 FD 3F 03 43 
@8c00
0A 00 
@ff80
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
@ffcc
18 44 18 44 18 44 18 44 18 44 18 44 18 44 18 44 
18 44 18 44 18 44 18 44 18 44 18 44 18 44 18 44 
18 44 18 44 18 44 18 44 18 44 18 44 18 44 18 44 
18 44 00 44 B2 40 00 A5 A0 05 3F 40 80 04 82 4F 
A6 05 3F 40 C0 08 82 4F A4 05 3F 40 FF FF 82 4F 
A8 05 3F 40 01 A5 82 4F A0 05 C2 43 A1 05 10 01 
CF 0C 3F 50 0C 00 2F 4F 7F F0 7F 00 7F D0 80 00 
4F 4F 3F 50 00 5A 3C 50 0C 00 8C 4F 00 00 10 01 
3C 40 50 01 B1 13 2C 00 40 18 92 43 00 8C 0C 43 
10 01 03 43 FF 3F 03 43 1C 43 10 01 
q

What's wrong, I can not use NOINIT? And, using NOINIT, can the variable be saved during the program?

  • Hello,

    user5209019 said:
    #include "driverlib.h"

    #pragma NOINIT(beta)

    #pragma LOCATION(beta, 0x8C00)

    int beta;

    int main(void) {

    WDT_A_hold(WDT_A_BASE);

    beta = 1;

    return (0); }

    This first example is correct.  You can set a location and disable the MPU to write to this FRAM location.  There is a .map file in your debug folder that you can search and see that beta has been allocated at 0x8C00.  

    .TI.bound:beta 
    *          0    00008c00    00000002     UNINITIALIZED
                      00008c00    00000002     msp430fr59xx_framwrite.obj (.TI.bound:beta)

    The reason that you don't see it in .txt file, is because this is a NO_Init variable, meaning that if isn't present with a default value.  Therefore, you won't see it in the .txt output file.  

    When debugging, you can enable the memory browser under the view menu.  Here you can see the pointer beta and the memory location being updated.  

    The PERSISTANT pragma is used to load this location with a pre-defined value.  This is why you see it in the .txt file.  

    Also, I would use caution when manually placing variables/buffers that they don't interfere with your application code.  There are info sections that you can use for some of this data, or you can manually adjust the linker file so that you don't have a collision with the linker. 

    Thanks,

    JD  

  • Thanks for the explanations.
    Another question: If I use #pragma NOINIT, will it be written to the FRAM memory? If so, can I access this value again if uC is turned off? How do I access this data (what method)?
  • Hello,

    No, If you use NOINIT then nothing will be written to the variable when it's declared because its "Not Initialized". So what ever was last written at that location will still be there even after a power cycle.

    In this case, you can just read the variable like normal and see the last saved value.

    Thanks,
    JD

**Attention** This is a public forum