MPC5644 flash erase of high-address space not working

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPC5644 flash erase of high-address space not working

931 Views
johan_edblad
Contributor I

I am referring to MPC5644a reference manual, chapter 12.4.6 to perform erase operation on a flash block in high-address space. 

Note 1: I have no problem to erase flash blocks L0 and M0 in flash bank B, but for some reason nothing happens when trying to erase block H0 in bank B. HLR.B.HBE is 1 after unlock and MCR.B.PEG is 1 after attempt to erase, but the data is still there.

Note 2: I also have no problem to write to block H0 in bank B. It is just erase in high-address space that doesn't work.

This is the code:

#define FLASH_B (*( volatile struct FLASH_tag *) 0xC3F8C000)
#define FLASH_ADDR 0x00100000

...
volatile struct FLASH_tag *pFlash;
pFlash = &FLASH_B;
//0 - unlock
pFlash->HLR.R = 0xB2B22222; //password
pFlash->HLR.B.HBLOCK = 0x0; //unlock all blocks in high address space

//1
pFlash->MCR.B.ERS = 1;
//2
pFlash->HSR.B.HBSEL = 0x1;//High-address space block H0 (Flash B)
//3
*(unsigned int *)FLASH_ADDR = 0xFFFFFFFF;
//4
pFlash->MCR.B.EHV = 1;
//5
while ((pFlash->MCR.B.DONE == 0));
//6
char peg = pFlash->MCR.B.PEG;
//7
pFlash->MCR.B.EHV = 0;
//8
//no more blocks
//9
pFlash->MCR.B.ERS = 0;

Labels (1)
Tags (1)
0 Kudos
Reply
3 Replies

809 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Hi,

Are you executing this piece of code from RAM? Do you have disabled cache memory?

0 Kudos
Reply

809 Views
johan_edblad
Contributor I

Yes, I am executing from RAM. 

And prior to erase i run the following:

void DCACHE_Disable(void)
{
asm("mfspr r3,1010");
asm("lis r4,0xFFFF");
asm("ori r4,r4,0xFFFE");
asm("and r3,r3,r4");
asm("isync");
asm("mtspr 1010,r3");
}

0 Kudos
Reply

809 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Copy-back or write-through configuration?

0 Kudos
Reply