Part Number:TMS320F280049
我的程序中在擦除Sector前先检查其状态,如果已经是擦除状态,则不需要擦除。
程序中检查Bank0的Sector4~Sector14都没有问题,但是当对Bank0Sector15执行检查时,程序跳转到ROM代码中
以下是擦除单个扇区的代码:
#pragma CODE_SECTION(EraseSingleSector, ".TI.ramfunc"); //Erase single sector at address Fapi_StatusType EraseSingleSector(Uint32 u32StartAddress) {Fapi_StatusType oReturnCheck;Fapi_FlashStatusWordType oFlashStatusWord;//before erase ,check blank statusoReturnCheck = Fapi_doBlankCheck((Uint32 *)u32StartAddress,Sector8KB_u32length,&oFlashStatusWord);if(oReturnCheck == Fapi_Status_Success) //this sector is blank,no need to erasereturn Fapi_Status_Success;oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,(Uint32 *)u32StartAddress);//wait uintil FSM is done with erase sector operationwhile (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){ServiceDog();}if(oReturnCheck != Fapi_Status_Success) return oReturnCheck;//verify the sector is erasedoReturnCheck = Fapi_doBlankCheck((Uint32 *)u32StartAddress,Sector8KB_u32length,&oFlashStatusWord);return oReturnCheck; }
以下是连续擦除多个扇区时调用的代码:
if(Fapi_Status_Success != EraseSingleSector(Bzero_Sector4_start)) return false;if(Fapi_Status_Success != EraseSingleSector(Bzero_Sector5_start)) return false;if(Fapi_Status_Success != EraseSingleSector(Bzero_Sector6_start)) return false;if(Fapi_Status_Success != EraseSingleSector(Bzero_Sector7_start)) return false;if(Fapi_Status_Success != EraseSingleSector(Bzero_Sector8_start)) return false;if(Fapi_Status_Success != EraseSingleSector(Bzero_Sector9_start)) return false;if(Fapi_Status_Success != EraseSingleSector(Bzero_Sector10_start)) return false;if(Fapi_Status_Success != EraseSingleSector(Bzero_Sector11_start)) return false;if(Fapi_Status_Success != EraseSingleSector(Bzero_Sector12_start)) return false;if(Fapi_Status_Success != EraseSingleSector(Bzero_Sector13_start)) return false;if(Fapi_Status_Success != EraseSingleSector(Bzero_Sector14_start)) return false;if(Fapi_Status_Success != EraseSingleSector(Bzero_Sector15_start)) return false;
确认过所有操作FLASH的函数都在RAM中运行。
在线debug发现,当对Bank0Sector15执行Fapi_doBlankCheck时,程序异常
Fapi_doBlankCheck(0x8F000,0x800,&oFlashStatus)
Flash API参考手册中禁止调用此函数时给出的地址区间跨越bank边界,但是程序中并没有违反此规定:0x8F000 + 0x800 *2 = 0x90000
程序异常后跳转到地址 0x003F C7A5 处
根据参考手册中的(4.6.5.1 Boot ROM Memory Map)描述,此处代码位于Boot区域(0x003F AA00 ~ 0x3FE9CF)
请问是哪里出现了问题呢?
Barbecue:
当前没有找到合适的处理办法,只能先不使用这个扇区。
屏蔽该扇区后可以正常擦写FLASH,并完成程序升级功能
但是后面随着项目的进行,代码的扩充,可能会出现FLASH不够用的情况