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/MSP430FR2155: Float variable read-write in Flash memory

Part Number: MSP430FR2155


Tool/software: Code Composer Studio

Hi all,

I want to write and read the float variable in flash memory in my controller MSP430FR2155. Please sugeest.

Thanks Sandhya Yadav

  • Hi, Sandhya, 

    CCS MSP430 compiler and IAR MSP430 compiler support 32bits "float" data type. You can define the variable as float data type directly. 

    For the flash memory variable, I think you are going to write and read variable in FRAM non-volatile memory, right? For this, there is a code example "msp430fr235x_framwrite_persistent.c" in MSP430FR235x, MSP430FR215x Code Examples (Rev. B)  You can refer to it for the FRAM variables definition and read/write. For quick definition for the float variable in FRAM memory, I have an example: 

    // Statically-initialized variable
    #ifdef __TI_COMPILER_VERSION__
    #pragma PERSISTENT(Variable_Name)
    float long Variable_Name = 0.0;                              // Note: Persistent variable needs a initial value
    #elif __IAR_SYSTEMS_ICC__
    __persistent float Variable_Name = 0.0;                 // Note: Persistent variable needs a initial value
    #else
    // Port the following variable to an equivalent persistent functionality for the specific compiler being used
    float Variable_Name = 0.0;
    #endif

    Then you can use the defined variable Variable_Name to read and write in your code. 

    If my post helped to solve your issue, please click on the  This resolved my issue    button. 

     

    Best Regards, 

    Lixin 

  • Thanks for reply Lixin,

    I have tried my code with your referred code and Now I can read and write float value in FRAM.

    Thanks,

    Sandhya Yadav

  • Hi, Sandhya, 

    It is nice my comments can help you to resolve the question. 

    Could you please click on the  This resolved my issue  button? 

    Best Regards, 

    Lixin 

**Attention** This is a public forum