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.

MSP430F5529: How to retain data in flash memory while reprogramming

Part Number: MSP430F5529


Hi team,

Here's an issue from the customer may need your help:

The size of the data is close to 2KB and it is stored in Flash.

Our customers want to keep it when reprogramming the MSP430F5529.

If not, is there any other way to retain these data.

Thanks.

Best Regards,

Yale

  • Hi team,

    Here's a follow up question:

    This customer has an error when trying to write data to flash, and the probability of recurrence is 100%.

    He refers to the demo MSP430F55xx_flashwrite_01.c, and below is his code.

    #include <msp430f5529.h>
    
    char value;                                 // 8-bit value to write to seg C
    
    // Function prototypes
    void write_BankA(char value);
    void copy_C2D(void);
    
    int main(void)
    {
      WDTCTL = WDTPW+WDTHOLD;                   // Stop WDT
      value = 1;                                // initialize value
    
        write_BankA(value++);                    // Write Bank A, increment value
    //    copy_C2D();                             // Copy segment C to D
        __no_operation();                       // Loop forever, SET BREAKPOINT HERE
      
      while(1);
    }
    
    //------------------------------------------------------------------------------
    // Input = value, holds value to write to Bank A
    //------------------------------------------------------------------------------
    void write_BankA(char value)
    {
      unsigned int i;
      char * Flash_ptr;                         // Initialize Flash pointer
      Flash_ptr = (char *) 0x4400;            // Bank A address
      FCTL3 = FWKEY;                            // Clear Lock bit
      FCTL1 = FWKEY+ERASE;                      // Set Erase bit
      _DINT();                                  //no interrupt
      *Flash_ptr = 0;                           // Dummy write to erase Flash seg
      FCTL1 = FWKEY+WRT;                        // Set WRT bit for write operation
    
      for (i = 0; i < 128; i++)
      {
        *Flash_ptr++ = value;                   // Write value to flash
      }
      while(FCTL3 & BUSY);
      _EINT();
      FCTL1 = FWKEY;                            // Clear WRT bit
      FCTL3 = FWKEY+LOCK;                       // Set LOCK bit
    }

    Steps to reproduce
    1. Compile the code in IAR
    2. Download and debug
    3. Press Go, then an error is reported

    Error screenshot

    Environment & Platform

    windows10+IAR 7.12.1+MSP-EXP430F5529LP-V1.8

  • Hi Yale

    Sorry for the late response.

    Yes, customer can keep the data if they know where the data located and try to change the memory manage file like cmd for CCS to avoid put code or data in those area.  

  • Have you change the debug driver from Simulator to FET Debugger?

  • Hi Gary

    Thanks for your answer.

    I asked the customer, and he used the eZ-FET lite on the board.

    I just noticed that the 2nd screenshot is not clear, here's the clear one. Sorry for that.

  • Could you upload the project here let me check about the project configuration?

  • Hi Gary

    Here's the project.

    flash_write01

    Flash_Write.zip

  • As you can see the data after memory address 0x443B has not been erased. That is why it will fail to write data there.

    I recommend customer can make some delay after dummy write to erase Flash seg and put a break point there to see if the memory has been erased successfull.

  • Thanks for your help, Gary.

    And sorry for this late confirmation.

**Attention** This is a public forum