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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

1,475 次查看
Brad
Contributor I

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() */

标签 (1)
标记 (1)
0 项奖励
回复
1 回复

759 次查看
jej13
Contributor II

Hi,

 

I have exactly the same problem.

 

Did you find the problem?

The program reset after "FLASH.MCR.B.EHV = 1".

 

Thank you.

0 项奖励
回复