Other Parts Discussed in Thread: C2000WARE
Tool/software: Code Composer Studio
Hey,
I have a device that utilizes the flash API on the TMS320F28379S. However, whenever I call a these two lines to reset the microprocessor:
WdRegs.WDCR.all = 0x28;
WdRegs.WDCR.all = 0x00;
The device eventually ends up frozen in the NMI ISR routine.
There are several errors in the Flash0EccRegs after attempting to overwrite the flash, as an example, ERR_STATUS reads 0x00060002. SINGLE_ERR_ADDR_LOW reads 0x00088008. SINGLE_ERR_ADDR_HIGH reads 0x00088004. The code to write the flash is listed below, it is largely taken from the example in control suite.
void Program_FlashAPI(void)
{
Fapi_StatusType oReturnCheck;
volatile Fapi_FlashStatusType oFlashStatus;
Fapi_FlashStatusWordType oFlashStatusWord;
uint32 u32Index = 0;
uint16 i = 0;
EALLOW;
PUMPREQUEST = 0x5A5A0002; // Give pump ownership to FMC0(Bank0)
oReturnCheck = Fapi_initializeAPI(F021_CPU0_W0_BASE_ADDRESS, 194);
if(oReturnCheck != Fapi_Status_Success)
{Example_Error(oReturnCheck);}
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
if(oReturnCheck != Fapi_Status_Success)
{Example_Error(oReturnCheck);}
oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32 *)FLASH_SectorE_start);
while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
oReturnCheck = Fapi_doBlankCheck((uint32 *)FLASH_SectorE_start, FLASH_64KSectorE_u32length, &oFlashStatusWord);
if(oReturnCheck != Fapi_Status_Success)
{Example_Error(oReturnCheck);}
// Program Sector E
for(i=0, u32Index = FLASH_SectorE_start; (u32Index < (FLASH_SectorE_start + WORDS_IN_FLASH_BUFFER)) &&
(oReturnCheck == Fapi_Status_Success); i+= 8, u32Index+=8)
{
//
// Issue program command
//
oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index, (uint16 *)EEPROM_52.Buffer+i, 8, 0, 0, Fapi_DataOnly);
//
// Wait until the Flash program operation is over
//
while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
if(oReturnCheck != Fapi_Status_Success)
{Example_Error (oReturnCheck);}
oFlashStatus = Fapi_getFsmStatus();
if(oFlashStatus != 0)
{
//
//Check FMSTAT and debug accordingly
//
//FMSTAT_Fail();
}
//
// Verify the programmed values
//
// oReturnCheck = Fapi_doVerify((uint32 *)u32Index, 4, FLASH_SectorE_start + i, &oFlashStatusWord);
// if(oReturnCheck != Fapi_Status_Success)
// {
//
// Check Flash API documentation for possible errors
//
// Example_Error(oReturnCheck);
// }
}
PUMPREQUEST = 0x5A5A0000;
EDIS;
//
// Example is done here
//
///Example_Done();
}
There also appears to be several errors reading the flash, where a location will have 0x0000 stored, will be read as 0x0200. While reading the flash, I simply have this subroutine to read the information that is pointed to:
void Load_Flash_Buffer(void)
{
Uint16 i;
Uint16 *Flash_ptr; // Pointer to a location in flash
Flash_ptr = (Uint16*)EEPROM_Copy;
for (i=0; i < 256; i++)
{
EEPROM_52.Buffer[i] = (((unsigned char)*Flash_ptr) & 0xFF);
Flash_ptr++;
}
}
Is there any particular reason why these errors are being thrown, and is there a standard code I should follow besides the control suite example for writing and reading to a certain location in flash?