AnsweredAssumed Answered

SPC5646C && SPC5646CC B0FA(0x0C0000-0x0DFFFF)Flash erase error

Question asked by 熙民 刘 on Dec 28, 2017
Latest reply on Jan 2, 2018 by Lukas Zadrapa

We found SPC5646C flash erase OK,but erase SPC5646CC error with same code.(B0FA 0x0C0000-0x0DFFFF).I erase flash each 128K space.

The flash different between the SPC5646C and SPC5646CC? 

Code:

StdRetType Flashi_Erase(volatile FLASHI_DATA_INPUT_TYPE InPutData)
{
vuint32_t TempStartAddr = 0;
vuint32_t TempLen = 0;
vuint32_t  StartSector = 0;
vuint32_t  SectorNum = 0;
vuint32_t  i = 0;

 

vuint32_t OutCount = 0;

 

if((InPutData.DataStartAddr < FLI_ADDR_START)||(FLI_ADDR_END < (InPutData.DataStartAddr + InPutData.DataLen)))
{
return STD_RET_NOK;
}

 


TempStartAddr = InPutData.DataStartAddr - FLI_ADDR_START;

 

StartSector = TempStartAddr / FLI_SECTOR_LENGTH;

 

TempLen = InPutData.DataLen + TempStartAddr % FLI_SECTOR_LENGTH;

 

if(TempLen % FLI_SECTOR_LENGTH)
{
SectorNum = TempLen / FLI_SECTOR_LENGTH + 1;
}
else
{
SectorNum = TempLen / FLI_SECTOR_LENGTH;
}

 

for(i=0; i<SectorNum; i++)
{
CFLASH_0.HBL.R = 0xB2B22222;
CFLASH_0.HBL.R = 0x00000000;

 

CFLASH_0.HBS.R = 0x00000001 << (StartSector + i);

 

CFLASH_0.MCR.B.ERS = 1;

 

(*((vint32_t*) (FLI_ADDR_START + ((StartSector + i)*FLI_SECTOR_LENGTH)) )) = InPutData.EraseData;

 

CFLASH_0.MCR.B.EHV = 1;
OutCount = 0;
    while(CFLASH_0.MCR.B.DONE == 0) //wait for DONE
    {
     OutCount++;
     if(OutCount > 0xFFFFFFFE)
     {
         CFLASH_0.MCR.B.EHV = 0;
         CFLASH_0.MCR.B.ERS = 0;
     return 3;
     }
    }

 

    CFLASH_0.MCR.B.EHV = 0;
    CFLASH_0.MCR.B.ERS = 0;
}

 

FlashiData.OutTime1 = OutCount;
return STD_RET_OK;
}

Outcomes