MPC5777C FLASH ERASE

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

MPC5777C FLASH ERASE

775 Views
PENGHAN
Contributor II

Dear:

  Below is the flash erase program I wrote.

void BlFlash_EraseDone( tFlashParam* flashParam, uint32 eraseValue )

{
BlFlash_RegType * FlashReg;
FlashReg = (BlFlash_RegType *)BLFLASH_REG_BASE_ADDR;
int i = 0;
/* check if flash is operating */
if (((FlashReg->C55FMC_MCR & BLFLASH_MCR_PGM_SET) == 0x00uL) &&
((FlashReg->C55FMC_MCR & BLFLASH_MCR_ERS_SET) == 0x00uL) &&
((FlashReg->C55FMC_MCR & BLFLASH_MCR_EHV_SET) == 0x00uL) )
{

/* set flash erase flag */
FlashReg->C55FMC_MCR |= BLFLASH_MCR_ERS_SET; //置起ERS位
/* unlock blocks */
BlFlash_BlockLock(~eraseValue);
/* select erased blocks */
BlFlash_BlockSelect(eraseValue); //选择FLASH块

/*interlock write*/
*((volatile uint32 *)flashParam->address) = 0xFFFFFFFFuL; //擦除操作写锁定
/* set flash voltage to high */
FlashReg->C55FMC_MCR |= BLFLASH_MCR_EHV_SET;
/* wait flash erase finish */
do{
/* watch dog task */
   if (flashParam->wdTriggerFct != NULLPTR)
   {
    flashParam->wdTriggerFct(); //定时喂狗

    }
}
while ((FlashReg->C55FMC_MCR) & (BLFLASH_MCR_DONE) == 0x0000uL);

/* check if flash operating successful */
if ((FlashReg->C55FMC_MCR & (BLFLASH_MCR_PEG)) == 0x0000uL)
  {
   flashParam->errorCode = kFlashFailed;
  }
/*for(i = 0;i < 5000000; i++)
{

}*/
   FlashReg->C55FMC_MCR &= BLFLASH_MCR_EHV_CLEAR;
   /* lock all blocks */
   BlFlash_BlockLock(0xFFFFFFFFuL);

}
else
{
    flashParam->errorCode = kFlashFailed;
}

/*for(i = 0;i < 5000000; i++)
{

}*/
FlashReg->C55FMC_MCR &= BLFLASH_MCR_ERS_CLEAR;

return;
}

   If there is no added for loop, the flash eraser program cannot complete the operation. If the for loop is added, the flash eraser program can complete the erase task.Can you tell me how to solve this problem?

   Thank you very much.

捕获.PNG

0 Kudos
2 Replies

740 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

it's caused by missing parentheses. Use this:

while (((FlashReg->C55FMC_MCR) & (BLFLASH_MCR_DONE)) == 0x0000uL);

instead of this

while ((FlashReg->C55FMC_MCR) & (BLFLASH_MCR_DONE) == 0x0000uL);

I guess that you are getting also compiler warning about this.

Regards,

Lukas

0 Kudos

703 Views
PENGHAN
Contributor II

hahahaha,My technical level is too low, thank you very much!!!Thank you for your help very much.

0 Kudos