Other Parts Discussed in Thread: CONTROLSUITE
Tool/software: Code Composer Studio
I am having trouble with the FLASH API tools for the F28377S chip. When debugging the read/write to flash bank 0 works flawlessly, when the system is rebooted however, the FLASH API erase command fails to erase the sector in question (any sector) and the only error generated is FMSTAT 0x0C10 which corresponds to erase verify and command fail. If I attempt to program an already clean sector, the Fapi_issueProgrammingCommand call fails save the new data. The error code generated is the generic 500 error both times. All the registers appear to be set correctly as i step through the program line by line leading up to the erase command. I am not using ECC or DCSM in the program. All functions are moved from FLASH to RAM in a SectionCopy.asm prior to executing the actual main program code, and I have verified that this is all being copied to ram correctly with the memory browser. What further steps should i be taking to troubleshooting this issue, as having persistent memory for variable operation settings is a requirement of the system I am developing. I can't provide full blocks of code, but will give a few snippets of what I currently have in the save to flash function as much of it was pulled from the example code in control suite anyway, apart from some diagnostic output code I have added to diagnose where the fail points might be and that has been mostly commented out. I have tried this code on multiple devices and even on a TI-28377s Launchpad but had the same results which each. My main concern is that something is being pre-loaded by the debugger but not effectively making it back to RAM after a power cycle. What should look at now to try and diagnose this failure?
Associated Code Block for this function error:
// Disable ECC. ECC does not have to be disabled to do FSM operations like
// program and erase.
// However, on Sonata Rev. 0 silicon, due to an OTP ECC errata,
// disable ECC to avoid ECC errors while using Flash API functions that
// read TI-OTP
EALLOW;
// DcsmCommonRegs.FLSEM.all = 0x0A503;
Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0x00;
Flash0CtrlRegs.FRDCNTL.bit.RWAIT = 0x3;
Flash0CtrlRegs.FBAC.all = 0x14;
// Flash0CtrlRegs.FRD_INTF_CTRL.all = 0x3;
EDIS;
//
// Bank0 Erase Program
//
EALLOW;
//
//Give pump ownership to FMC0
//
PUMPREQUEST = 0x5A5A0002;
//
// This function is required to initialize the Flash API based on System
// frequency before any other Flash API operation can be performed
// Note that the FMC0 register base address is passed as the parameter
//
oReturnCheck = Fapi_initializeAPI(F021_CPU0_W0_BASE_ADDRESS, 194);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
// UARTprintf("Init err: %x, %x, %x\n",sectorIndex, sectorLength, dataBlockIndex);
return;
}
/// UARTprintf("Init pass: %x, %x, %x\n",sectorIndex, sectorLength, dataBlockIndex);
//
// Fapi_setActiveFlashBank function sets the Flash bank0 and FMC0 for
// further Flash operations to be performed on the bank0.
// Note that the parameter passed is Fapi_FlashBank0 since FMC0 register
// base address is passed to Fapi_initializeAPI()
//
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
// UARTprintf("set act fail: %x, %x, %x\n",sectorIndex, sectorLength, dataBlockIndex);
return;
}
// UARTprintf("set act pass: %x, %x, %x\n",sectorIndex, sectorLength, dataBlockIndex);
//
// Erase Sector
//
// Uint32 * ref;
// for(i=0; i <= sectorLength; i+= 16 )
// {
// ref = (sectorIndex + i);
// UARTprintf("SECTOR pre: 0x%x, 0x%x, 0x%x of 0x%x\n",*ref, ref, i, sectorLength);
// }
oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,
(uint32 *)sectorIndex);
// for(i=0; i <= sectorLength; i+=16)
// {
// ref = (sectorIndex + i);
// UARTprintf("SECTOR post: 0x%x, 0x%x, 0x%x of 0x%x\n",*ref, ref, i, sectorLength);
// }
//
// Wait until FSM is done with erase sector operation
//
while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
// UARTprintf("erase done: %x, %x, %x\n",sectorIndex, sectorLength, dataBlockIndex);
//
// Verify that SectorL is erased. The Erase step itself does a
// verify as it goes. This verify is a 2nd verification that can be done.
//
oReturnCheck = Fapi_doBlankCheck((uint32 *)sectorIndex,
sectorLength,
&oFlashStatusWord);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
// If Erase command fails, use Fapi_getFsmStatus() function to get the
// FMSTAT register contents to see if any of the EV bit, ESUSP bit,
// CSTAT bit or VOLTSTAT bit is set (Refer to API documentation for
// more details)
//
Example_Error(oReturnCheck);
// UARTprintf("erase ver fail: %x, %x, %x\n",sectorIndex, sectorLength, dataBlockIndex);
return;
}
// UARTprintf("erase ver pass: %x, %x, %x\n",sectorIndex, sectorLength, dataBlockIndex);
//
// A data buffer of max 8 words can be supplied to the program function.
// Each word is programmed until the whole buffer is programmed or a
// problem is found. However to program a buffer that has more than 8
// words, program function can be called in a loop to program 8 words for
// each loop iteration until the whole buffer is programmed
//
//
// Example: Program 0xFF bytes in Flash Sector C along with auto-
// generated ECC
//
//
// In this case just fill a buffer with data to program into the flash.
//
// for(i=0; i<=WORDS_IN_FLASH_BUFFER; i++)
// {
// Buffer[i] = i;
// }
for(j=0; j<=blocksize;j+= 256)
{
for(i=0; i<=WORDS_IN_FLASH_BUFFER; i++)
{
if((i+j)<blocksize)
{
Buffer[i] = *(dataBlockIndex+i+j);
}
else
{
Buffer[i] = 0XFFFF;
}
// UARTprintf("buffer loaded: %u, 0x0%x, 0x0%x\n", i, j, Buffer[i]);
}
for(i=0, u32Index = sectorIndex + j;
(u32Index < (sectorIndex + j + WORDS_IN_FLASH_BUFFER)) &&
(oReturnCheck == Fapi_Status_Success); i+= 8, u32Index+= 8)
{
oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index,Buffer+i,
8,0,0,
Fapi_DataOnly);
while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
// UARTprintf("Prog fail: %x, %x, %x\n",sectorIndex, sectorLength, dataBlockIndex);
return;
}
// UARTprintf("Prog pass: %x, %x, %x\n",sectorIndex, sectorLength, dataBlockIndex);
//
// Read FMSTAT register contents to know the status of FSM after
// program command for any debug
//
oFlashStatus = Fapi_getFsmStatus();
//
// Verify the values programmed. The Program step itself does a verify
// as it goes. This verify is a 2nd verification that can be done.
//
oReturnCheck = Fapi_doVerify((uint32 *)u32Index,4,Buffer32+(i/2),
&oFlashStatusWord);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
// UARTprintf("final FAIL: %x, %x, %x\n",sectorIndex, sectorLength, dataBlockIndex);
return;
}
// UARTprintf("final PASS: %x, %x, %x\n",sectorIndex, sectorLength, dataBlockIndex);
}
Thanks in advance,
Will