SPRADE8A November 2023 – April 2024 F29H850TU , F29H859TU-Q1 , TMS320F28P650DH , TMS320F28P650DK , TMS320F28P650SH , TMS320F28P650SK , TMS320F28P659DH-Q1 , TMS320F28P659DK-Q1 , TMS320F28P659SH-Q1
The EEPROM_CheckStatus function provides functionality to check the Flash API status and check the Flash State Machine status after each program/erase to Flash. There is also an additional check to confirm the flash is blank following an erase operation. If any unexpected statuses are detected, the program stops. Error handling is not implemented in this project.
Fapi_FlashStatusType oFlashStatus;
Fapi_FlashStatusWordType oFlashStatusWord;
uint32_t sectorAddress = FLASH_BANK_SELECT + FIRST_AND_LAST_SECTOR[EEPROM_ACTIVE_UNIT^1][0] * FLASH_SECTOR_SIZE;
uint16_t sectorSize = (FIRST_AND_LAST_SECTOR[EEPROM_ACTIVE_UNIT^1][1] - FIRST_AND_LAST_SECTOR[EEPROM_ACTIVE_UNIT^1][0] + 1) * (FLASH_SECTOR_SIZE / 2);
// Wait until the Flash program operation is over
while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
if(*oReturnCheck != Fapi_Status_Success)
{
// Check Flash API documentation for possible errors
Sample_Error();
}
// Read FMSTAT register contents to know the status of FSM after
// program command to see if there are any program operation related
// errors
oFlashStatus = Fapi_getFsmStatus();
if (Erase_Inactive_Unit && Erase_Blank_Check){
*oReturnCheck = Fapi_doBlankCheck((uint32_t *) sectorAddress,
sectorSize, &oFlashStatusWord);
Erase_Blank_Check = 0;
}
if(*oReturnCheck != Fapi_Status_Success || oFlashStatus != 3)
{
//Check FMSTAT and debug accordingly
Sample_Error();
}