I am attempting to write to the CODE memory amidst my program, and the writes seem to be having no effect on the data stored in the flash, here is my code for writing:
uint8 writePairID(uint16 pairID)
{
uint8 datas[2];
//Break input down into bytes for fast transfer to FWDATA
datas[0] = (uint8)(pairID & 0xFF);
datas[1] = (uint8)((pairID >> 8) & 0xFF);
//Disable interrupts
EA = 0;
//Erase Block 14 (starts @ 0x7000)
FADDRH = (uint8)(14 << 1);
FCTL |= ERASE;
while(FCTL & BUSY);
//Load address to write first byte of word to (0x7000)
FADDRH = 0x70;
FADDRL = 0x00;
//Perform write of pair ID
FCTL |= WRITE;
FWDATA = datas[0];
FWDATA = datas[1];
FWDATA = 0x00;
FWDATA = 0x00;
//Wait for operation to finish
while(FCTL & FULL);
while(FCTL & WRITE);
//Re-enable interrupts
EA = 1;
//Return 0 if operation fail
if(FCTL & ABORT)
return 0;
else
return 1;
}
I know the block is erased properly and when I attempt to read out the value I am attempting to store I read 0xFF, which is the "reset value"
Any helpful hints?