Other Parts Discussed in Thread: MSP430F2370
Hello all,
I want to store some of my data in flash memory of MSP430, do any one have sample code available for reading and writing in flash memory of MSP430.
Ashi
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.
Other Parts Discussed in Thread: MSP430F2370
Hello all,
I want to store some of my data in flash memory of MSP430, do any one have sample code available for reading and writing in flash memory of MSP430.
Ashi
I found the sample code given on the TI website for MSP430F2370, there are sample codes available for copying one segment to another and erasing the previous segment. I am doing flash writing first time, so was unable to understand that completely, could u plz help me with some explanation or sudo code for reading and writing cycles of flash.
Ashi
Ashi Gupta said:I am doing flash writing first time, so was unable to understand that completely
Examples and forum conversations contains complete info about everything that anybody have to know about flash access, erase and write so please explain what exactly you do not understand.
Hi Quote,
void erase_segment(int address)
{
int *Flash_ptr; // Flash pointer
Flash_ptr = (int *)address; // Initialize Flash pointer to 0x1080
FCTL1 = FWKEY + ERASE; // Set Erase bit
FCTL3 = FWKEY; // Clear Lock bit
*Flash_ptr = 0; // Dummy write to erase Flash segment
FCTL3 = FWKEY + LOCK; // Set LOCK bit
}
void write_segment(int address, int valveoff, int valveon)
{
int *Flash_ptr; // Flash pointer
Flash_ptr = (int *)address; // Initialize Flash pointer to 0x1080
FCTL3 = FWKEY; // Clear Lock bit
FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
*Flash_ptr = 2; // Write value to flash
Flash_ptr = Flash_ptr + 2; // Increment the flash pointer to next even address
*Flash_ptr = 3; // Write value to flash
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Set LOCK bit
}
This is what i am doing for erasing and writing flag, but flash is not retaining value after restart, please tell me what i am doing wrong in this.
Ashi
Hi,
Problem resolved, this was related to settings of debugger in IAR.
I just have to change the setting of FET Debugger to "Retain unchanged memory" .
Ashi
**Attention** This is a public forum