Hi all:
In my project, I find that when I erase the flash and then use api "Fapi_doBlankCheck()", the return result is always error;
The code below:
Fapi_StatusType FlashSectorErase(U32 SectorAddress,U16 SectorLen)
{
U16 nRetrys = 0;
Fapi_StatusType oReturnCheck = Fapi_Error_Fail;
Fapi_FlashStatusWordType oFlashStatusWord;
uint16 repeat;
SeizeFlashPump();
watchdogDisable();
//
// Grab flash semaphore for Zone1 to enable access to flash registers.
//
EALLOW;
DcsmCommonRegs.FLSEM.all = 0xA501;
Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0x0;
Flash0CtrlRegs.FRD_INTF_CTRL.bit.DATA_CACHE_EN = 0;
Flash0CtrlRegs.FRD_INTF_CTRL.bit.PREFETCH_EN = 0;
EDIS;
DINT;
oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,(uint32 *)SectorAddress);
EINT;
uart_len = sprintf(uart_buff, "Fapi_issueAsyncCommandWithAddress: 0x%08lx\n", SectorAddress);
uartSendText(uart_buff, uart_len);
if(oReturnCheck == Fapi_Status_Success)
{
#if 1
do
{
// Wait until FSM is done with erase sector operation
while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady)
{
}
if(SectorAddress != SECTOR_E_ADDR)
{
// the oReturnCheck is alwyas Fapi_Error_Fail
oReturnCheck = Fapi_doBlankCheck((uint32 *)SectorAddress,SectorLen,&oFlashStatusWord);
uart_len = sprintf(uart_buff, "Fapi_doBlankCheck: 0x%08lx\n", SectorAddress);
uartSendText(uart_buff, uart_len);
}
if (Fapi_Error_Fail == oReturnCheck)
{
uart_len = sprintf(uart_buff, "Fapi_doBlankCheck NOk \n");
uartSendText(uart_buff, uart_len);
Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,(uint32 *)SectorAddress);
uart_len = sprintf(uart_buff, "Fapi_issueAsyncCommandWithAddress: 0x%08lx\n", SectorAddress);
uartSendText(uart_buff, uart_len);
nRetrys ++;
}
}while((nRetrys < 5)&&(Fapi_Error_Fail == oReturnCheck));
#endif
}
Fapi_flushPipeline();
watchdogSet(WDT_4ms);
ReleaseFlashPump();
return oReturnCheck;
}
Could anyone help me out? Do I miss something?
Best Wish
Li
