I'm trying to get a handle on how to use the FLASH on a TI Delfino single core processor.
I started with this:
Fapi_StatusType oReturnCheck;
InitFlash_Bank0();
InitFlash_Bank1();
EALLOW;
PUMPREQUEST = 0x5A5A0002;
oReturnCheck = Fapi_initializeAPI(F021_CPU0_W0_BASE_ADDRESS, 200);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
return -1;
}
//
// Fapi_setActiveFlashBank function sets the Flash bank and FMC for further
// Flash operations to be performed on the bank
//
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
return -2;
}
EDIS;
return oReturnCheck;
Then I tried to write to memory:
Fapi_StatusType ret;
uint32 *addr = (Uint32 *)Bzero_SectorC_start + 8*sel;
uint16 dbuf[2];
dbuf[0] = val & 0xFFFF;
dbuf[1] = (val>>16) & 0xFFFF;
EALLOW;
while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
ret = Fapi_issueProgrammingCommand(addr,dbuf,2,0,0,Fapi_DataOnly);
while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
EDIS;
return (int)ret;
And subsequently read back:
Fapi_FlashStatusWordType status;
uint32 *addr = (Uint32 *)Bzero_SectorC_start + 8*sel;
uint32 rcvBuf = 0;
EALLOW;
if(Fapi_doBlankCheck(addr,1,&status)){
rcvBuf = status.au32StatusWord[1];
}else{
return 0;
}
EDIS;
//Shift down by 16 if onoff==0
rcvBuf = (rcvBuf >>(16 * (!onoff)));
return (Uint16)rcvBuf;
I was hoping that rcvBuf would be equal to the value provided during the write attempt, but instead it shows 0x0001AA00, which is the same value it started with.
However, when debugging, the return value from the Flash Write is always Fapi_Status_Success, implying it wrote correctly. So why doesn't the readback value ever change from 0x0001AA00, no matter how many times I try to write over it?