Hello,
I'm using :
- MSP430F2232,
- Code Composer Studio v 6.1.1.00022
I want to save a variable in Segment C of information memory (location : 0x1040).
My problem is the value read at @1040 is always 0x00.
Does anyone have any idea of my error?
Below some of my code :
#pragma location=0x1040
unsigned char test_flash;
char cpt;
void WriteDataFlash()
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
FCTL2 = FWKEY + FSSEL0 + FN1; // MCLK/3 for Flash Timing Generator
while(FCTL3 & BUSY) {} // Wait busy
FCTL3 = FWKEY; // Clear Lock bit
FCTL1 = FWKEY + ERASE; // Set Erase bit
while(FCTL3 & BUSY) {} // Wait busy
test_flash = 55; // Dummy write to erase Flash seg
while(FCTL3 & BUSY) {} // Wait busy
FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
while(FCTL3 & BUSY) {} // Wait busy
if(cpt & 0x7F) cpt = 0;
else cpt++;
test_flash = cpt; // Write value to flash
while(FCTL3 & BUSY) {} // Wait busy
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Set LOCK bit
while(FCTL3 & BUSY) {} // Wait busy
WDTCTL = 0x5A08; // re enable watchdog timer
}