Part Number:TMS320F2800137
void App_FlashUpdate(void) {Fapi_StatusType oReturnCheck;Fapi_FlashStatusType oFlashStatus;Uint16 u16Temp[8] = {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000};DINT;EALLOW;oReturnCheck = Fapi_initializeAPI(FlashTech_CPU0_BASE_ADDRESS,120);if(oReturnCheck != Fapi_Status_Success){App_WaitRestart();}oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);if(oReturnCheck != Fapi_Status_Success){App_WaitRestart();}ClearFSMStatus();Fapi_setupBankSectorEnable(FLASH_WRAPPER_PROGRAM_BASE+FLASH_O_CMDWEPROTA, 0xFFFFFFFF);Fapi_setupBankSectorEnable(FLASH_WRAPPER_PROGRAM_BASE+FLASH_O_CMDWEPROTB, 0x00000000);oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)0x08EFF8,u16Temp,8,0,0,Fapi_AutoEccGeneration);while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);if(oReturnCheck != Fapi_Status_Success){App_WaitRestart();// Check Flash API documentation for possible errors}DEVICE_DELAY_US(100);oFlashStatus = Fapi_getFsmStatus();if (oFlashStatus != 3){App_WaitRestart();}EDIS;App_WaitRestart(); }
目的是将0x8EFF8的值0xbbbb写为0x0000
xiang li:
使用的flash API库
,
xiang li:
出现的问题是,经常写入失败,偶尔能够写入成功
写入失败的时候:oFlashStatus = Fapi_getFsmStatus();返回257
写入成功的时候:oFlashStatus = Fapi_getFsmStatus();返回0
,
xiang li:
我把0xbbbb写为0x0000,并没有将存储的0值程序化为1,为啥会报这个错误
,
xiang li:
找到问题了,u16Temp首地址为奇数,改为偶数就可以了,为啥必须是偶数,哪个文档有介绍吗
,
Ben Qin:
可以参考下下面这个链接的第10条回答:
(+) [FAQ] FAQ on Flash API usage for C2000 devices – C2000 microcontrollers forum – C2000︎ microcontrollers – TI E2E support forums