在ST上正常的IAP程序到了APM上发现IAP以后FLASH内的数据不对,经过排查发现是写FLASH之前擦除FLASH没有成功。但是还有个疑问,根据资料介绍APM擦除速度要比ST的快,但为什么还需要加大等待时间。
/* Delay definition */
#define EraseTimeout ((uint32_t)0x000B0000)
加大EraseTimeout解决问题/* Delay definition */
#define EraseTimeout ((uint32_t)0x001B0000)//加大EraseTimeout
/* Wait for last operation to be completed */
status = FLASH_WaitForLastOperation(EraseTimeout);
FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout)
{
FLASH_Status status = FLASH_COMPLETE;
/* Check for the Flash Status */
status = FLASH_GetBank1Status();
/* Wait for a Flash operation to complete or a TIMEOUT to occur */
while((status == FLASH_BUSY) && (Timeout != 0x00))
{
status = FLASH_GetBank1Status();
Timeout--;
}
if(Timeout == 0x00 )
{
status = FLASH_TIMEOUT;
}
/* Return the operation status */
return status;
}
|