Part Number:TMS320F28075Other Parts Discussed in Thread:C2000WARE
FLASH编程正常,擦除总是报错,每次擦除会进入非法中断:Interrupt_illegalOperationHandler,然后就卡死了。
核心代码如下:
const Uint32 flashSectorStart[14] =
{
0x080000, 0x082000, 0x084000, 0x086000,
0x088000, 0x090000, 0x098000, 0x0A0000, 0x0A8000, 0x0B0000,
0x0B8000, 0x0BA000, 0x0BC000, 0x0BE000
};
const Uint32 flashSectorSize[14] =
{
0x2000, 0x2000, 0x2000, 0x2000,
0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
0x2000, 0x2000, 0x2000, 0x2000,
};
// sector = a-n
#pragma CODE_SECTION(eraseFlashSector,".TI.ramfunc");
Uint32 eraseFlashSector(Uint16 sector)
{
Uint32 addr = 0;
Fapi_StatusType oReturnCheck;
Fapi_FlashStatusTypeoFlashStatus;
if(sector < 'a' || sector > 'n')
{
return 0;
}
addr = flashSectorStart[sector - 'a'];
#if 1
DINT;
EALLOW;
oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32*)addr);
while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
if(oReturnCheck != Fapi_Status_Success)
{
printx("oReturnCheck = 0x__\r\n", oReturnCheck);
}
oFlashStatus = Fapi_getFsmStatus();
if(oFlashStatus != 0)
{
printx("oFlashStatus = 0x__\r\n", oFlashStatus);
}
EDIS;
EINT;
#endif
return addr;
}
PLL输出120M,使用内部INTOSC2和外部16M晶振都试过,现象一样。
cmd文件中通过-lF021_API_F2837xD_FPU32.lib(.text)将F021库放入SRAM,并且通过map文件检查,相关代码都在SRAM中。
F021库版本为1.54,F28075和F2837x使用相同的F021固件库没错吧?是否有需要特别注意的地方?
Xiao Dong:
自己搞定了,公布答案:在等待扇区擦除完成的while循环中,一定要踢狗。官方例程
C2000Ware_4_00_00_00\device_support\f2807x\examples\cpu1\flash_programming\cpu01\flash_programming_cpu01.c里面等待擦除完毕是这样写的:
while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
没有踢狗,因为2k扇区擦除时间典型值为35ms,而默认看门狗配置大约13ms就会复位,所以一定要踢狗。正确代码是这样:
while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){SysCtl_serviceWatchdog();}
这是一个非常隐蔽的坑,我查了一整天才查出来,希望TI能修改一下例程,不要给用户挖这种高级而又隐蔽的坑。
TI中文支持网


