I also checked the address through memory window, it shows 0xFF.
This is my complete program
#include "MPC5604B_M27V.h"
void initPeriClkGen(void) {
CGM.SC_DC[0].R = 0x80;
CGM.SC_DC[2].R = 0x80;
}
void initModesAndClock(void) {
ME.MER.R = 0x0000001D;
CGM.FMPLL_CR.R = 0x02400100;
ME.RUN[0].R = 0x001F0074;
ME.RUNPC[1].R = 0x00000010;
ME.PCTL[68].R = 0x01;
ME.MCTL.R = 0x40005AF0;
ME.MCTL.R = 0x4000A50F;
while (ME.GS.B.S_MTRANS) {}
while(ME.GS.B.S_CURRENTMODE != 4) {}
}
void disableWatchdog(void) {
SWT.SR.R = 0x0000c520;
SWT.SR.R = 0x0000d928;
SWT.CR.R = 0x8000010A;
}
int main(void) {
volatile int i = 0;
uint8_t a1;
uint8_t a2;
uint8_t a3;
uint8_t a4;
uint8_t a5;
uint8_t a6;
uint8_t a7;
uint8_t a8;
initPeriClkGen();
initPeriClkGen();
disableWatchdog();
DFLASH.LML.R = 0xA1A11111; // write password
DFLASH.LML.R = 0x00100000; // unlock low and mid blocks primary
DFLASH.SLL.R = 0xC3C33333; // write password
DFLASH.SLL.R = 0x00100000; // unlock low and mid blocks secondary
DFLASH.HBL.R = 0xB2B22222; // write password
DFLASH.HBL.R = 0x00000000; // unlock high blocks
// erase block B0F3 (0x00010000 - 0x00017FFF)
DFLASH.MCR.B.ERS = 1;
DFLASH.LMS.R = 0x00000008; /* select B0F3 */
*(unsigned int *)0x00010000 = 0xFFFFFFFF; /* interlock write - write to any address in selected memory */
DFLASH.MCR.B.EHV = 1;
while(DFLASH.MCR.B.DONE != 1){}
DFLASH.MCR.B.EHV = 0;
DFLASH.MCR.B.ERS = 0;
/* program double word to B0F3 */
DFLASH.MCR.B.PGM = 1;
*(unsigned int *)0x00010000 = 0xAABBCCDD; /* interlock write */
*(unsigned int *)0x00010004 = 0x11223344; /* program data write */
DFLASH.MCR.B.EHV = 1;
while(DFLASH.MCR.B.DONE != 1){}
if(DFLASH.MCR.B.PEG==1) // check if PEG in MCR is 1
{
i=1;
//switch ON Led
}
DFLASH.MCR.B.EHV = 0;
DFLASH.MCR.B.PGM = 0;
a1=*(unsigned int *)(0x00010000);
a2=*(unsigned int *)(0x00010001);
a3=*(unsigned int *)(0x00010002);
a4=*(unsigned int *)(0x00010003);
a5=*(unsigned int *)(0x00010004);
a6=*(unsigned int *)(0x00010005);
a7=*(unsigned int *)(0x00010006);
a8=*(unsigned int *)(0x00010007);
while(1) {}
}