Other Parts Discussed in Thread: C2000WARE
调用Fapi_issueProgrammingCommand(),不报错,但是数据没有存储进去,之后Fapi_getFsmStatus(),报0x30错误,但是flash区域我看过全是0xffff,没有数据
用Fapi_doBlankCheck()函数也校验过这片区域全是0xffff,不应该写入不进去
#ifdef __cplusplus
#pragma CODE_SECTION(".TI.ramfunc");
#else
#pragma CODE_SECTION(FLASH_Write_NoCheck, ".TI.ramfunc");
#endif
uint16_t FLASH_Write_NoCheck(uint32_t WriteAddr,uint16_t *pBuffer,uint16_t NumToWrite)
{
Fapi_StatusType oReturnCheck =0;
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,
DEVICE_SYSCLK_FREQ/1000000U);
if(oReturnCheck != Fapi_Status_Success)
{
#ifdef flashdebug
FlashError9++;
#endif
return 1;
}
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank2);
if(oReturnCheck != Fapi_Status_Success)
{
#ifdef flashdebug
FlashError10++;
#endif
return 2;
}
// Fapi_StatusType oReturnCheck;
uint32 u32Index = 0;
uint16 i = 0;
Fapi_FlashStatusType oFlashStatus;
//Fapi_FlashStatusWordType oFlashStatusWord;
//
// A data buffer of max 8 16-bit 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.
//
// Remember that the main array flash programming must be aligned to
// 64-bit address boundaries and each 64 bit word may only be programmed
// once per write/erase cycle. Meaning the length of the data buffer
// (3rd parameter for Fapi_issueProgrammingCommand() function) passed
// to the program function can only be either 4 or 8.
//
// Program data in Flash using "AutoEccGeneration" option.
// When AutoEccGeneration option is used, Flash API calculates ECC for the
// given 64-bit data and programs it along with the 64-bit main array data.
// Note that any unprovided data with in a 64-bit data slice
// will be assumed as 1s for calculating ECC and will be programmed.
//
// Note that data buffer (Buffer) is aligned on 64-bit boundary for verify
// reasons.
//
// Monitor ECC address for Sector6 while programming with AutoEcc mode.
//
// In this example, 0x100 bytes are programmed in Flash Sector6
// along with auto-generated ECC.
//
for(i=0, u32Index = WriteAddr; (u32Index < (WriteAddr+NumToWrite));i+= 8, u32Index+= 8)
{
oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index,(uint16_t *)&pBuffer[i],
8, 0, 0, Fapi_AutoEccGeneration);
//
// 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
//
//Example_Error(oReturnCheck);
#ifdef flashdebug
FlashError3++;
#endif
return 3;
}
//
// 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(oFlashStatus != 0)
{
//
//Check FMSTAT and debug accordingly
//
//FMSTAT_Fail();
#ifdef flashdebug
FlashError4++;
#endif
return 4;
}
#if 0
//
// Verify the programmed values. Check for any ECC errors.
//
oReturnCheck = Fapi_doVerify((uint32 *)u32Index,
0x4, (UInt32 *)&pBuffer[i],
&oFlashStatusWord);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
// Example_Error(oReturnCheck);
#ifdef flashdebug
FlashError5++;
#endif
return 5;
}
#endif
}
return 0;
}
WriteAddr地址为0xAFFE0 NumToWrite 为16