The below program only i dumped in MPC5644A Evaluation Kit. Here i not used the address of password .*(unsigned int*)0xFFFDD8 = 0xFEEDFACE; // write data within 128bit programming page
*(unsigned int*)0xFFFDDC = 0xCAFEBEEF; // write data within 128bit programming page
Then how it can be erased?
void Flash_Program(void)
{
unsigned int i;
//unlock shadow block
FLASH_A.LMLR.R = 0xA1A11111; //unlock register
FLASH_A.LMLR.R = 0x000303FF; //unlock shadow flash
FLASH_A.SLMLR.R = 0xC3C33333; //unlock register
FLASH_A.SLMLR.R = 0x000303FF; //unlock shadow flash
//erase shadow flash
FLASH_A.MCR.B.ERS = 1;
*(unsigned int*)0x00FFC000 = 0xFFFFFFFF; //interlock write - write any address in shadow block
FLASH_A.MCR.B.EHV = 1;
while(FLASH_A.MCR.B.DONE == 0){};
FLASH_A.MCR.B.EHV = 0;
FLASH_A.MCR.B.ERS = 0;
//confirm the shadow flash is erased
for(i=0x00FFC000;i<0x00FFFFFF; i=i+4)
{
if(*(unsigned int*)i != 0xFFFFFFFF)
while(1){}; //shadow flash not erased!
}
//program shadow flash (restore default password and censoring information)
FLASH_A.MCR.B.PGM = 1;
//program first 128bit page
*(unsigned int*)0x00004000 = 10; // write data within 128bit programming page
// *(unsigned int*)0x00FFC002 = 12; // write data within 128bit programming page
FLASH_A.MCR.B.EHV = 1; // program page (words that were not written above will have default value 0xFFFF)
while(FLASH_A.MCR.B.DONE == 0){};
FLASH_A.MCR.B.EHV = 0;
//program second 128bit page
//*(unsigned int*)0xFFFDE0 = 0x55AA55AA; // this uncensores the device
// *(unsigned int*)0xFFFDE0 = 0xBABABABA; // this censores the device
// FLASH_A.MCR.B.EHV = 1; // program page (words that were not written above will have default value 0xFFFF)
// while(FLASH_A.MCR.B.DONE == 0){};
// FLASH_A.MCR.B.EHV = 0;
//end of program sequence
FLASH_A.MCR.B.PGM = 0;
}
if You want to confirm password erased just check if
*(unsigned int*)0xFFFDD8 == 0xFFFFFFFF and *(unsigned int*)0xFFFDDC == 0xFFFFFFFF
just after successfull erasing procedure