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.

MSP430FR6043: FRAM

Part Number: MSP430FR6043
Other Parts Discussed in Thread: MSP430FR6041, MSP430WARE, , MSP430FR5043, MSP430FR5041, TEST2

Dear Community,

I want to store 200 bytes of data in my FRAM.  Two 8-byte data and one 32-byte data.

Using driverlib, I am trying to write a FRAM program.

FRAMCtl_write8(uint8_t *dataPtr,uint8_t *framPtr,uint16_t numberOfBytes);

FRAMCtl_write32(uint32_t *dataPtr,uint32_t *framPtr,uint16_t count);

I am not getting any example programs for the above FRAM functions. From where do I get the example code?

Already, 00009562 bytes have been used, and I want to use the last 200 bytes in the remaining unused 00000a1e bytes.

To find out the starting address of the unused data, I used the below formula.

Starting Address of Unused Memory: Origin + Used = 0x00006000 + 0x00009562 = 0x0000F562.

Starting Address of last 200 bytes Memory= end address + 200byte = 0x0000FF80 - 0xC8 = 0x0000FEB8 to start storing your data in the last 200 bytes of FRAM.

  1. First 8-byte data: 0x0000FEB8 to 0x0000FEBF
  2. Second 8-byte data: 0x0000FEC0 to 0x0000FEC7
  3. 32-byte data: 0x0000FEC8 to 0x0000FEE7

Is the above memory calculations are correct?

Please suggestion where can I read the example code for the FRAM implementation?

Regards,

Sarwath

  • Hi Sarwath,

    For an example code for writing directly to FRAM, please see this link to an FRAM write example in our MSPWare SDK. 

    If you've already downloaded MSPWare you can also find this example in the following file path:

    C:\ti\msp430ware_3_80_14_01\examples\devices\MSP430FR5xx_6xx\MSP430FR6043_MSP430FR6041_MSP430FR5043_MSP430FR5041_Code_Examples\C

    For additional information, you should take a look at this E2E post.

    For your second question, I ran the calculations myself and got the same results as you. They look correct.

  • Hi Dylan Obrien,

    I gone through example code for writing and reading from FRAM. I have a doubt on how to point to a different FRAM address in this example code. 

    #define WRITE_SIZE      128

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

    Regards,

    Sarwath

  • Sarwath,

    Please see this page describing the LOCATION pragma. I believe this will allow you to specify the location. Try placing that directive below the line "#pragma PERSISTENT(FRAM_write)". I have not done this myself but looking at past posts I believe this should work.

    Let me know if this works for you, or if you need additional suggestions.

  • Yes, I can access the required portion of FRAM memory by using the LOCATION pragma. But I'm not sure if I'm writing the data correctly in that portion . Would you kindly check my code both read and write function.

    #include <msp430.h>
    #include <stdint.h>
    #define WRITE_SIZE      8
    
    void FRAMWrite(void);
    void FRAMRead(void);
    
    unsigned char count = 0;
    unsigned long data;
    
    
    #pragma PERSISTENT(FRAM_write)
    #pragma LOCATION(FRAM_write,0x0000FEB8)
    uint8_t FRAM_write[WRITE_SIZE] = {0};
    
    unsigned int *pointer;
    unsigned int readData;
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;               // Stop WDT
    
    
        // Disable the GPIO power-on default high-impedance mode to activate
        // previously configured port settings
        PM5CTL0 &= ~LOCKLPM5;
    
        //clear password
        FRCTL0|=NWAITS_0|FRCTLPW;
    
        //enable power
        GCCTL0|=FRPWR;
    
        // Initialize dummy data
        data = 0x00010001;
    
        while(1)
        {
            data += 0x00010001;
            //FRAMWrite();
            FRAMRead();
            count++;
        }
    }
    
    void FRAMWrite(void)
    {
        unsigned int i = 0;
    
        for (i = 0; i < 8; i++)
        {
            FRAM_write[i] = data;
        }
    }
    
    void FRAMRead()
    {
        pointer=(unsigned int *)FRAM_write;
        readData = *pointer;
    }
    

    Regards,

    Sarwath

  • MPUCTL0 = MPUPW;

    //clear password
    FRCTL0=NWAITS_0|FRCTLPW;

    //enable power
    GCCTL0=FRPWR;

    I removed write protection by adding the MPUCTL0 = MPUPW.

    Now I can see some data in the FRAM_Write location. But it is not correct.

    I don't want to write data by using a for loop.

    void FRAMWrite(void)
    {

        FRAM_write = (uint8_t *)0XA;
    }

    Is it possible to write something like the above function?

  • Sarwath,

    I recommend that you run this code on your device and read the memory to see if this behaved as you want it to. When you are checking the value of the variable, you should refresh your memory browser. You may also export the device's memory and read it this way. 

    When you tried the first example code (the one that didn't specify which address to store the data), were you able to see the correct value placed in memory? When you try your new code, are you still able to see it in memory? 

    Please try executing this on your own and return to this thread if you are unable to resolve this.

  • Now I change the data to 10 (0xA). I am not able to understand the readData 2570.

  • Sarwath,

    It based on your expressions window, it looks like your values were saved correctly, right?

    Your memory browser view confuses me. It shows different values than the ones in your expressions window. Are these tow both showing the same thing at the same time? Have you refreshed both of these windows? Have you utilized your pointer correctly?

    It appears that your values were correctly placed in memory so to me this suggests that you need to change your pointer usage.

  • Yes.I can see the FRAM_write data in the expression window. Why is the value 2570 saved in the FRAM location in the Memory Browser? I don't understand the pointer usage. Which pointer are you referring to?

  • Your expression window indicates that the correct information is saved in the correct place. Your memory browser says that different information is saved in the same place. I am asking if you refreshed these windows and took the screenshots at the same time. The pointer that I am referring to is the one you use in your FRAMread() function. The fact that your expressions window showed the correct value made me think that you wrote to FRAM correctly.

    What is stored at address 2570 in memory? Is FRAM_write[] just storing pointers to the correct data? 

    I am unable to run the code that you posted on my device so my ability to help you debug here is limited.

  • I am writing 0XA in FRAM. In Memory browser it is showing the correct value.

    Now I can write the data. but I want to store one bool value, one float value, and a 19-digit number. Instead of For loop, I want to store the data directly on the FRAM address, like 0xFFA=1, 0X1FFA=11.79797, and 0X2FFF=12563846238261816192. Is it possible to write like this?

    I don't want to declare the fram address as an array. could please suggest me another method?

  • The first post that I linked to you shows how to store these values without using an array. You can simply declare multiple areas of FRAM as shown in that link, and assign them values multiple times.

    These are all possible, you just need to consider the size of the value that you are trying to save. A bool is the same size as the FRAM_write indices you already declared, so this will be the same. A float is 4 bytes, so you will need to allocate that amount of memory and write to it accordingly. a 19 digit number will require 10 bytes to save. You will have to split this into pieces and save it as such.

  • Now I declared two pointer and two FRAM memory address.

    uint8_t *FRAM_write1_ptr;
    float *FRAM_write2_ptr;
    uint8_t data1;   // send bool data
    float data2;       // send float data
    #define FRAM_TEST1_START 0xFEB8
    #define FRAM_TEST2_START 0xFEC0

    I am able to store the both value in FRAM at exact location.

    Now I stored the data in FRAM. I created new project to read the data from the same memory locations. But I am not getting the stored values from the both location.

    I am attaching the read program below,

    #include <msp430.h>
    #include <stdint.h>
    
    #define FRAM_TEST1_START 0xFEB8
    #define FRAM_TEST2_START 0xFEC0
    
    uint8_t *FRAM_ptr1_read;
    float *FRAM_ptr2_read;
    
    uint8_t data1;
    float data2;
    
    int main(void) {
    
        WDTCTL = WDTPW | WDTHOLD;               // Stop watchdog timer
    
        MPUCTL0 = MPUPW;
        //clear password
        FRCTL0=NWAITS_0|FRCTLPW;
    
        //enable power
        GCCTL0=FRPWR;
    
        PM5CTL0 &= ~LOCKLPM5;
    
        FRAM_ptr1_read=(uint8_t *)FRAM_TEST1_START;
        FRAM_ptr2_read=(float *)FRAM_TEST2_START;
    
        data1=*FRAM_ptr1_read;
        data2=*FRAM_ptr2_read;
        return (0);
    }
    

    Why am I not getting the stored values from FRAM.

  • If you utilized the default debug settings, you probably erased the contents of your memory when you started a new session. You can stop the debugger from erasing your memory by going to your debug configurations, selecting your target configuration file, going to target, msp430 flash settings, and selecting to replace only written memory locations. In the Program/Memory Load options, you should also make sure the "Reset the target on a connect" and "Reset the target on a program load or restart" are all not selected. Then when you connect you should be able to read the values as long as your new program doesn't overwrite them.

**Attention** This is a public forum