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.

HOW TO ? Non Volatile and Persistent Variables on FRAM Devices

Other Parts Discussed in Thread: MSP-EXP430FR5739, MSP430FR5739

Hello,

I'd like to take advantage of the FRAM on my FR5739 to store some arrays that would be initialized during the debug session but then would be unitialized whatever happens to the MCU (Reset or else ...)

I've read on the wiki and in the CCS Help that this can be achieved through modifying the linker file :

  • So I've mapped my memory as follow :
 RAM : origin = 0x1C00, length = 0x0400
INFOA : origin = 0x1880, length = 0x0080
INFOB : origin = 0x1800, length = 0x0080
FRAM : origin = 0xC200, length = 0x1FFF
FRAM_DATA : origin = 0xE1FF, length = 0x1D80
SIGNATURE : origin = 0xFF88, length = 0x0008

  • And then I allocated a section :

.fram_data : {} > FRAM_DATA type=NOINIT

  • And finally in my main source file I declare the variables between two #pragma :

#pragma SET_DATA_SECTION(".fram_data")
unsigned int buffer[5][10];
#pragma SET_DATA_SECTION()

But all this is not working, to test it I declared a variable in the section , write to it. Unplug the Dev Board (MSP-EXP430FR5739) run debug again witht the same code, and I expect my memory to be as when I unplugged it, but when I place a breakpoint on the first instruction in the main, go check the value in the memory there all my available memory is initialized with '1' for every bit...

Source :

http://processors.wiki.ti.com/index.php/Creating_MSP430_FRAM_Variables_Using_CCS

  • Hi Freedo,

    i was the one who originally wrote the wiki page.

    have you chosen the EABI output format? As far as i remember this is really necessary since it won't work with the old COFF format output.

  • Hey thanks,

    Yes I did check that I was using EABI but I couldn't get my variables to be Persistent and they are always initialized ...

  • Fredoo.net said:
    But all this is not working, to test it I declared a variable in the section , write to it. Unplug the Dev Board (MSP-EXP430FR5739) run debug again witht the same code, and I expect my memory to be as when I unplugged it, but when I place a breakpoint on the first instruction in the main, go check the value in the memory there all my available memory is initialized with '1' for every bit...

    What option do you have under CCS Project Properties -> Debug -> MSP430 Properties -> Download Options -> Erase Options?

    The default for a new project is "Erase main memory only". This erases all of FRAM when the program is downloaded by the debugger, which for a variable in FRAM marked as "NOINIT" causes the NOINIT variables to be initialised to all '1's on starting a debug session.

    I found that the erase option is changed to "Erase and download necessary segements only (Differential Download)" then a NOINIT variable in FRAM preserved its contents in a MSP430FR5739 on starting a debug session.

  • Great, I think you make a point here ! It does work now ...

    I read these erase options when troubleshooting this issue but it wasn't very explicit about what it was actually doing ... 

  • Leo Hendrawan said:
    i just made a small test example and put it on the wiki.

    The problem was the erase option of the debug mode, by default they are set to erase all memory therefore clearing all FRAM each time you launch a debug session ...

    In the project properties I checked the highlighted box and it enabled FRAM to not be initialized ...

  • I'm getting desperate ...

    It does work on some variables but when I put all my variables into FRAM and want some to be Initialized (cleared at Start-up) and some to be Persistent (keep their value forever) then it is all not working ..

    Instead of what I expect, my variables are indeed stored into FRAM but each time I even use the Restart button all my variables that I watch in the "Expression" panel get cleared...

    I've tried the other method using the

    #pragma PERSISTENT(xyz)
    int xyz=25;
    but this doesn't work either ...
    
    
    So to summarize what I've got :
    A Var_FRAM.h file with all my Variables I wanna store in FRAM:
    This file is like this :

    #pragma SET_DATA_SECTION(".fram_data_init")

    Some variables

    ..........

    #pragma SET_DATA_SECTION()

    #pragma SET_DATA_SECTION(".fram_data_noinit")

    Some other variables

    ..........

    #pragma SET_DATA_SECTION()

    the section .fram_data_init is defined in the linker file :
    .fram_data_init : {} > FRAM_DATA_INIT 
    .fram_data_noinit : {} > FRAM_DATA_NOINIT type=NOINIT

    And the memory is mapped :

    FRAM_DATA_INIT : origin = 0xF380, length = 0x0980 // Variable INIT length 0x980 (2400 byte)

    FRAM_DATA_NOINIT : origin = 0xFD00, length = 0x0280 // Variable NOINIT length 0x280 (640 byte)

    I've also changed the debug dowmload options (as described in the earlier post) 
    But I can't figure out why these variables would still be cleared/reset each time while on some projects it does work... 

    Thanks for having a try at solving this conundrum with me !

    Then I'll be able to add lots of good tips to the wiki for others to get it working much faster than myself !

  • Hi Freedo,

    did you checked your settings in theproject properties under Debug->MSP430 Properties->Erase Options ?

  • Thanks Leo,

    It does work for a variable. But how can I make it works even for a variable with a fix address inside this memory segment? what I want to achieve is the same: "...give initialization value only at load/compile time. This initialization value will appear in the binary file which will be downloaded into the FRAM device, but it will not be initialized during C startup." Thanks.

     

    MEMORY
    {
        .............
        FRAM_VARS               : origin = 0xC200, length = 0x0080
        .............
    }
    SECTIONS
    {
        .............
        .fram_vars : {} > FRAM_VARS type=NOINIT
        .............
    }


    in the main.h
    #define fram_var_char =(unsigned char *) (0xC210)

    in the main.c

    #pragma SET_DATA_SECTION(".fram_vars")

    * char fram_var_char = 2;

    #pragma SET_DATA_SECTION()

    it doesn't work. the compiler reports incompatible error.

  • Hi,

    Did you ever resolve this issue? I am trying to do something similar I think

    e2e.ti.com/.../546426

    Thanks!

    David