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.

Problem in read write operation in MSP430 flash - Information Memory

Other Parts Discussed in Thread: MSP430F5437

Hi ,

            I am trying to write data in flash information memory segment C of MSP430F5437. 

I have followed sample codes for MSP430F543x flash read write operation.

 I am using following function to write data to flash-

main()

{

             write_segment(0x1880,15);

}

void write_segment(unsigned long address, char valveOff)

{

          unsigned long *Flash_ptr; // Flash pointer

          Flash_ptr = (unsigned long *)address; // Initialize Flash pointer to 0x1080

          FCTL3 = FWKEY; // Clear Lock bit

          FCTL1 = FWKEY + WRT; // Set WRT bit for write operation

          *Flash_ptr = valveOff; // Write value to flash
         __no_operation();
         FCTL1 = FWKEY; // Clear WRT bit
         FCTL3 = FWKEY + LOCK; // Set LOCK bit

}

  After execution of this function system is reset.Data is written to specified memory

address ,but I did not get reason for system reset.Can anybody help me out with this?

  

Thank You,

Smita.

  • Hi,

       Have u got Erase_segment() before Write?????????if not try adding this

    Erase_segment(unsigned long address, char valueoff)

    {

      // Erase Flash
      while(BUSY & FCTL3);                      // Check if Flash being used
      FCTL3 = FWKEY;                            // Clear Lock bit
      FCTL1 = FWKEY+ERASE;                      // Set Erase bit
      *Flash_ptr = 0;                           // Dummy write to erase Flash seg
      while(BUSY & FCTL3);                      // Check if Erase is done

    }

    regards,

    Sri.

    --------------------------------------------------------------------------------------------------------------------------

    Please check verify answer if this answers your post.

  • During a flash write operation, interrupts must be blocked. Also, you must not set any breakpoints or single-step through the code when a flash write is ongoing (especially not on the __no_operation(); line)
    When writing to flash from a function that iitself runs in flash, you must not use block write mode.

**Attention** This is a public forum