AnsweredAssumed Answered

K64 Internal Flash Erase Error

Question asked by Darshan Shah on Jun 23, 2020
Latest reply on Jul 29, 2020 by Darshan Shah

Hi,

 

I am writing my application data to internal flash for FRDM-K64. My data is 8 byte aligned.

I was getting fault while erasing the sector and later on I find that I should disable all IRQ before flash operation. So I did changes for the same. 

int Internal_FlashErase(uint32_t destAdrss)
{
status_t result; /* Return code from each flash driver function */
uint32_t regPrimask = 0U;
regPrimask = DisableGlobalIRQ();

do
{
result = FLASH_Erase(&s_flashDriver, destAdrss, 4096, kFTFx_ApiEraseKey);
if (kStatus_FTFx_Success != result)
{
PRINTF("Internal Flash Erase Fail, Addr: %x", destAdrss);
result = -1;
break;
}
result = 0;
}while(0);
/* Enable IRQ if previously enabled. */
EnableGlobalIRQ(regPrimask);
return result;
}

Is this correct?

 

After long run, I am getting error now for erase operation. After debugging I found that MGSTAT0 bit is set in FTFE_FSTAT which casue error while erasing. What will be the cause of this?

How many write/erase operations are allowed for a single sector?

Outcomes