AnsweredAssumed Answered

Flash Erase Interlock Issue MPC5676R

Question asked by Victor Medina on Dec 9, 2019
Latest reply on Dec 18, 2019 by Lukas Zadrapa

Hello,

 

I am having an issue erasing flash. I am getting a bus error and it is causing a system reset when i perform the interlock write during an erase operation. Here is my code:

 

FLASH_A.LMLR.R = 0xA1A11111; // unlock flash

FLASH_A.LMLR.R = ~0x00010300;


FLASH_A.SLMLR.R = 0xC3C33333;
FLASH_A.SLMLR.R = ~0x00010300;

 

FLASH_A.MCR.B.ERS = 1; // set erase


FLASH_A.LMSR.R = 0x00010300; // select blocks


*(uint32_t*)0x20000 = 0xFFFFFFFF; // interlock write <--- FAILS HERE
FLASH_A.MCR.B.EHV = 1; 


while(FLASH_A.MCR.B.DONE == 0); // wait for erase to signal DONE!

FLASH_A.MCR.B.EHV = 0;
FLASH_A.MCR.B.ERS = 0;

 

Is there anything that could be configured that may interfere with the interlock write such as a watchdog timer or some sort of flash configuration? I ask this because it seems that if this code is the very first thing that executes it works correctly.

 

Thanks,

 

Victor

Outcomes