AnsweredAssumed Answered

MPC5777C Flash Erase Issue

Question asked by Victor Medina on Apr 7, 2020
Latest reply on Apr 8, 2020 by Lukas Zadrapa

Hello,

 

I am trying to erase the sector of 0x00980000. Unfortunately I'm unable to successfully erase any flash sector within the RWW partition 6. After failing to flash, the mcu resets when accessing memory within that sector.

 

I have posted my code below. The code works for erasing the sector of 0x00A00000 (which is in RWW partition 7), but doesn't work for the sector 0x00980000. I have not had any success with other sectors in partition 6 either.

 

I have disabled interrupts with the instruction "wrteei 0" prior to this and the code is running from RAM. Any insight would be appreciated.


volatile uint32_t startAddress = 0x00980000;
volatile uint32_t flashSector = 0x40;

C55FMC.LOCK2.R = ~flashSector; // unlock sector for erase: 1 = lock 0 = unlock
C55FMC.MCR.B.ERS = 1;
C55FMC.SEL2.R = flashSector; // select sector for erase: 1 = erasing 0 = not erasing

asm("sync");
*(uint32_t*)startAddress = 0xFFFFFFFF; // interlock write (can be an arbitrary address within the sector being erased)
asm("sync");
C55FMC.MCR.B.EHV = 1; // set high voltage to perform erase method

 

while(C55FMC.MCR.B.DONE == 0);

C55FMC.MCR.B.EHV = 0; // turn off high voltage
C55FMC.MCR.B.ERS = 0; // turn off erase flag

 

*Note: I am not servicing the watchdog as everytime i try to access the register SWT_SR (for SWT_A) I am unable to and the mcu resets. I am unsure of why this would happen as I have not experienced this in other applications. It was not an issue in erasing the block at 0x00A00000.

 

Thanks,

 

Victor

Outcomes