Brad Holeman

MPC5554 - Erasing Internal Flash while running from internal RAM doesn't work.

Discussion created by Brad Holeman on Nov 4, 2010
Latest reply on Apr 1, 2011 by Roux David

The program goes into the weeds when I attempt to erase a block of intenal flash.

 

 

 

#pragma

section RX ".driver" ".driver"
INT_FLASHER
void vIntFlashEraseCalledFromRam( )
/*******************************************************************************
Description: Erases a block of internal flash.
Inputs: NONE
Outputs: NONE
Globals: NONE
*******************************************************************************/

{
BYTE bStatus;

/* FLASH ERASE Sequence - Page 13-30 of manual. */
/* STEP 1: Set up the internal flash configuration register to erase. */
FLASH
.MCR.B.ERS = 1;
/* STEP 2: Select Block L3 for erase. */
FLASH
.LMSR.B.LSEL = INT_FLASH_L3;
/* STEP 3: Perform erase interlock write (write to any address in flash). */
*((VULONG *)0x0001C000L) = 0xFFFFFFFF;
/* STEP 4: Start internal erase sequence by writing 1 to EHV register. */
FLASH
.MCR.B.EHV = 1;
/* STEP 5: Wait for done bit to be set. */
while( !FLASH.MCR.B.DONE )
{
}
/* STEP 6: Operation complete, check erase status. */
bStatus
= FLASH.MCR.B.PEG;
/* Step 7: End interal erase sequence. */
FLASH
.MCR.B.EHV = 0;
FLASH
.MCR.B.ERS = 0;

}/* vIntFlashEraseCalledFromRam() */

Outcomes