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.

Compiler/MSP430G2553: Information memory Segments C,D debug on IAR workbench IDE

Part Number: MSP430G2553

Tool/software: TI C/C++ Compiler

Hi,

We have implemented the example code to check the storage onto the MSP430 information memory.
The below is the code for it

#include <msp430g2553.h>

void WriteCharToFlash(char* Flashptr, char val);
void WriteLongToFlash(long* Flashptr, long val);
void ReadCharFromFlash(char* address, char* val);
void ReadLongFromFlash(long* address, long* val);
void ClearAllFlash();
void EraseSegment(char *flash_ptr);

int main(void) {
	WDTCTL = WDTPW + WDTHOLD;
	BCSCTL1 = CALBC1_1MHZ;                    // Set DCO to 1MHz
	DCOCTL = CALDCO_1MHZ;
	FCTL2 = FWKEY + FSSEL_3 + FN1;

	char val;
	char val2;
	char val3;
        //ClearAllFlash();
        EraseSegment((char*) 0x1000);
	
	WriteCharToFlash((char *) 0x01000, '1');
	WriteCharToFlash((char *) 0x01004, '3');
	WriteCharToFlash((char *) 0x01008, '5');

	ReadCharFromFlash((char *) 0x01000, &val2);
	ReadCharFromFlash((char *) 0x01004, &val);
	ReadCharFromFlash((char *) 0x01008, &val3);

	return 0;
}


void WriteLongToFlash(long* address, long val)
{
	long* flash_ptr;
	flash_ptr = address; // Initialize Flash pointer
	while(FCTL3 & BUSY);
	FCTL1 = FWKEY + WRT;
	*flash_ptr = val;
	while(FCTL3 & BUSY);
	FCTL1 = FWKEY;                            // Clear WRT bit
	FCTL3 = FWKEY + LOCK;                     // Set LOCK bit
}

void ReadLongFromFlash(long* address, long* val)
{
	while(FCTL3 & BUSY);
	long* flash_ptr;
	flash_ptr = address;
	*val = *flash_ptr;
}

void WriteCharToFlash(char* address, char val)
{
	char* flash_ptr;
	flash_ptr = address; // Initialize Flash pointer
	while(FCTL3 & BUSY);
	FCTL1 = FWKEY + WRT;
	*flash_ptr = val;
	while(FCTL3 & BUSY);
	FCTL1 = FWKEY;                            // Clear WRT bit
	FCTL3 = FWKEY + LOCK;                     // Set LOCK bit
}

void ReadCharFromFlash(char* address, char* val)
{
	while(FCTL3 & BUSY);
	char* flash_ptr;
	flash_ptr = address;
	*val = *flash_ptr;
}

/*void ClearAllFlash()
{
	char *flash_ptr;                         // Segment D pointer
	flash_ptr = (char *) 0x1000;             // Initialize Flash segment D pointer
	FCTL1 = FWKEY + MERAS;                    // Set Mass Erase bit
	FCTL3 = FWKEY;                            // Clear Lock bit
	*flash_ptr = 0;                          // Dummy write to erase Flash segment D
	FCTL1 = FWKEY + WRT;                      // Set WRT bit for write operation
	FCTL1 = FWKEY;                            // Clear WRT bit
	FCTL3 = FWKEY + LOCK;
}*/

void EraseSegment(char *flash_ptr)
{
	FCTL3 = FWKEY;                            // Clear Lock bit
	FCTL1 = FWKEY + ERASE;                    // Set Erase bit
	*flash_ptr = 0;
	FCTL1 = FWKEY;                            // Clear WRT bit
	FCTL3 = FWKEY + LOCK;                     // Set LOCK bit
}

While debugging the above code i am not able to see any change on the Information memory.Find the below picture.

**Attention** This is a public forum