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.

MSP430FR6989: FRAM

Part Number: MSP430FR6989
Other Parts Discussed in Thread: TEST

I'm confused about the use of FRAM read/write. I read the code demo and the programm just define a array like this:

#pragma PERSISTENT(FRAM_write)
unsigned long FRAM_write[WRITE_SIZE] = {0};

The data will be written to FRAM just like this?  how do I know it has been written to FRAM rather than RAM or somewhere else? 

what if I want to read the data existed after trigging a reset? Can you recommand some more manual or demo to me?

  • Hi, 

    The commands you listed above is only for the FRAM_write array initialization. If you want to write the data, please refer to the msp430fr69xx_framwrite.c in MSP430FR6x8x code examples

    For how to confirm the data is written to FRAM, you can use the View->Memory Browser to check the FRAM_write array data and see if it is located in FRAM memory space. 

    For reading the data existed in the FRAM_write[], you can directly define a variable to assign the FRAM_write data to this variable. For example, 

    • unsigned long FRAM_read; 
    • main()
    • {
    • ...
    • FRAM_read = FRAM_write[0]; 
    • FRAM_read = FRAM_write[1]; 
    • ...
    • }

    Thanks, 

    Lixin 

  • Thanks a lot for your reply, chen!!

    In fact, I have read the damo msp430fr69xx_framewrite and  MSP430FR6x8x code examples, what confused me is that there is no definition of FRAM's start location in program C but in program assembly language. Is that mean no definition of start location is needed in C language   and it will write the data to FRAM directly every time rather than RAM or somewhere else? 

    sincerely

  • Hi, 

    When you select the MSP430FRxx device in the CCS or IAR IDE tools, the compiler will define the FRAM start address and space, RAM address and space, register address and space automatically from internal source files. Users don't need to consider this. After compiling the code successfully, you can find the FRAM address in the .map file. The user code, RAM, Stack, variables addresses are assigned by the IDE tools automatically. 

    Thanks, 

    Lixin 

     

  • This is the an example .map file in CCS for your reference. You can also use View -> Expressions to view the variables you defined in the code. 

    Thanks, 

    Lixin 

  • Hi, 

    Do you have any other questions? 

    If my answer helped you for the issue, could you help to click on "this helped me to resolve the issue" button? 

    Thanks, 

    Lixin 

  • hi, chen, your answer is quite clearly and thank you very much!

    But what if I want to get some data already exist in FRAM after resetting or power up ? For example, I detect some temperature data and save to FRAM, and I'm afraid that the device may be power off by accident. So I want to read the data in FRAM at the beginning. How to pragram can achieve this function, is it work like this:

    ...

    unsigned long *fram_address = 0x80;

    unsigned long data;

    data = *fram_address;

    ...

    Is there some other better methods?

    Sorry trouble you so many times, I'm looking forward for your reply sincerely.

     

  • Hi, 

    To read the FRAM variable you saved into the FRAM, it is just like reading the normal variables you defined in RAM. I have showed the example in previous post. 

    There are two methods for FRAM write. In the following code examples, I showed the both write to FRAM and read from FRAM. 

    1. Use the PERSISTENT intrinsic. The compiler will assign FRAM address for the variables (please refer to document slau132)

    // Statically-initialized variable

    #ifdef __TI_COMPILER_VERSION__
    #pragma PERSISTENT(Port_event)
    unsigned long data_FRAM = 0;
    #elif __IAR_SYSTEMS_ICC__
    __persistent unsigned long Port_event = 0;
    #else
    // Port the following variable to an equivalent persistent functionality for the specific compiler being used
    unsigned long Port_event = 0;
    #endif

    unsigned long read_FRAM, read_FRAM2;

    int main(void)
    {
    WDTCTL = WDTPW | WDTHOLD; // Stop WDT

    P1OUT &= ~BIT0; // Clear P1.0 output latch for a defined power-on state
    P1DIR |= BIT0; // Set P1.0 to output directionOUT

    PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode

     

    ....

    read_FRAM = data_FRAM;        // read the data from data_FRAM to read_FRAM

    ...

    // some event to trigger the data_FRAM write. Here is just an example

    data_FRAM = 0x989;

    }

    2. Assign the FRAM address directly. Please check the memory map in the datasheet for the FRAM information memory and code memory address space.

    #define WRITE_SIZE      128

    unsigned long *FRAM_write_ptr;
    unsigned long data;

    #define FRAM_TEST_START 0x1900

    void FRAMWrite(void);


    int main(void)
    {
    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

    P1OUT &= ~BIT0; // Clear P1.0 output latch for a defined power-on state
    P1DIR |= BIT0; // Set P1.0 to output directionOUT

    PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode

    read_FRAM = FRAM_write_ptr[0];   // read FRAM data to check

    ....

    FRAM_write_ptr = (unsigned long *)FRAM_TEST_START;   // assign FRAM write start address

    data += 0x00010001;

    FRAMWrite();  // write FRAM for WRITE_SIZE      

    ...

    }

    void FRAMWrite(void)
    {
    unsigned int i=0;

    for ( i= 0; i< WRITE_SIZE; i++)
    {
    *FRAM_write_ptr++ = data;
    }

    }

    Thanks, 

    Lixin 

  • This quite solve my question! Thank you very much, Li!

**Attention** This is a public forum