Jorge, thank you for your quick reply. My search had not turned up either of the links you cited, so thank you for pointing those out. I will adapt my code to never rewrite any phrase.
I certainly did not infer this phrase boundary restriction from the text I cited in the data sheets (and, obviously, neither did the people on those other two threads!), so I would suggest that the data sheet text for the FTFE module be updated to clarify this rule. (How does one feed a suggestion back to the Freescale documentation team?)
And I need to point out that the Flash code generated by Processor Expert shares my reading of the data sheet, believing that it is legal to write to an erased byte within a not-fully-erased phrase (and going to the extra trouble of merging the existing content of the phrase with the requested write data). The hard faults mentioned by me (and both threads you cited) are being allowed by the code produced by Processor Expert. I should think that Processor Expert should be corrected as well. Here is the relevant code from Flash1_Main:
FlashPrgUnitAddr = DeviceDataPrv->CurrentFlashAddress - DstAddrOffset;
CurrentFlashPrgUnitData[0] = ((uint32_t *)FlashPrgUnitAddr)[0];
CurrentFlashPrgUnitData[1] = ((uint32_t *)FlashPrgUnitAddr)[1];
if(((DataToPrg[0] & DataToPrgMask[0]) & (~CurrentFlashPrgUnitData[0])) > 0U) {
DeviceDataPrv->CurrentErrorFlags |= LDD_FLASH_MULTIPLE_WRITE_ERROR;
return;
}
if(((DataToPrg[1] & DataToPrgMask[1]) & (~CurrentFlashPrgUnitData[1])) > 0U) {
DeviceDataPrv->CurrentErrorFlags |= LDD_FLASH_MULTIPLE_WRITE_ERROR;
return;
}
My example of having a byte written at 0x70003, then trying to flash a byte at 0x70001, breezes right through these checks. Based upon the rule you stated, the tests should be rewritten as:
if((~CurrentFlashPrgUnitData[0]) || (~CurrentFlashPrgUnitData[1])) {
DeviceDataPrv->CurrentErrorFlags |= LDD_FLASH_MULTIPLE_WRITE_ERROR;
return;
}
That would have rejected my attempt to modify an already programmed phrase, and then the hard fault would not have occurred... and I could have answered my own question of what is legal to do on the K64 Flash! (So, how does one feed a suggestion back to the Processor Expert team?)
Again, thank you for the prompt answer. Now I'm just asking how to make this problem not hit the next developer!