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.

MSP430FR5989: saving array in FRAM and retrieve it after the power failure

Part Number: MSP430FR5989
Other Parts Discussed in Thread: CC1101

Hello there,

I'm trying to save test wrtng to FRAM by saving a dummy arry to FRAM in case if the power went off  and send it through  cc1101 radio.  I used TI example code.

uint8_t __attribute__((persistent)) FRAM_buffer1[2]={0};

int main(void)
{
for(;;)
 {
......
  FRAM_buffer1[0] = 21 ;     /* write  to FRAM */
  FRAM_buffer1[1] = 10 ;      /*write  to FRAM */
........

send what is in FRAM through the radio } return 0; }

I got the follwing warning when I compiled the file (i'm uding GNU complier) :

variable 'FRAM_buffer1' was declared persistent and should be explicitly initialized [-Wattributes]

 uint8_t __attribute__((persistent)) FRAM_buffer1[61]={0};

and did not recive 21 and 10 values.  I recived a garbage values instead. 

What did i do wrong ? 

  • Hi,

    Did you set the MPU module in properties -> general -> MPU?

    If you enable memory protection, you need to divide some FRAM place in order to enable FRAM write.

    Best Regards

    Johnson 

  • Thanks, Johnson for your response.

    I'm not using Code Composer Studio. Is the MPU module enabled by default? because I'm not enabling it in my code. 

  • If I increased the array size to 16 bytes, I got the values of the 4 first elements of the array correct and the rest are garbage.  Is there anything I have to consider such as the FRAM address?

  • Hi,

    The MPU module is enabled memory protection by default for FR5989, could you tell me your development software? IAR?

    The protection of FRAM memory can be divided into several segments, which can protect a specific address segment.

    so the problem you describe may be caused by unreasonable MPU settings.

    You can view the address of the FRAM_buffer1 array variable in debug mode and compare it with the MPU module's memory protection settings to make it easier to find the root cause.

    Best Regards

    Johnson

  • I'm using msp430 GCC toolchain. I tried to specify the array address after looking at the linker script and know where "HIFRAM" starts.  So, I found that "HIFRAM" starts at 0x00010000.  Also, I'm not configuring MPU. 

    Here is the new code :

    uint8_t *FRAM_write_ptr;
    
    int main(void)
    {
    set up a timer to wake up every 5 seconds from lmp3
    FRAM_write_ptr = (uint8_t *)FRAM_TEST_START; // Sets start address for FRAM pointer at 0x00010000 for(;;) { go to lmp3 till timer interupt fired for (i=0; i<16; i++) { FRAM_write_ptr[i]= 100; } send FRAM_write_ptr array through radio } }

    I'm receiving garbage values for all 16 elements. 

    I'm really stuck on this issue for two weeks.  Any help is highly appreciated. 

  • Hi ,

    This code as your reference, that test pass in our lanuchpad (development in CCS software) :

    This code disable MPU module by clear MPUENA bit.

    #include <msp430.h>
    
    #define FRAM_TEST_START 0x00010000
    unsigned char *FRAM_write_ptr;
    char i;
    
    int main(void)
    {
    
      WDTCTL = WDTPW | WDTHOLD;                 // Stop WDT
      PM5CTL0 &= ~LOCKLPM5;
    
      MPUCTL0 = MPUPW;
      FRAM_write_ptr = (unsigned char *)FRAM_TEST_START; // Sets start address for FRAM pointer at 0x00010000
      while(1)
       {
         for(i=0; i<16; i++)
            {
             FRAM_write_ptr[i]= 100;
            }
      }
    }
    

    Attach some test data (result and MPUENA value) :

    Best Regards

    Johnson

  • using "persistent" to write to FRAM works for me. It turned to be radio was sending a corrupted packet!

**Attention** This is a public forum