/* Get the number of the start and end sectors */
StartSector = GetSector(FLASH_USER_START_ADDR);
EndSector = GetSector(FLASH_USER_END_ADDR);
for (SectorCounter = StartSector; SectorCounter <= EndSector; SectorCounter += 8)
{
Iwdog_rst();
/* Device voltage range supposed to be [2.7V to 3.6V], the operation will
be done by word */
if (FLASH_EraseSector(SectorCounter, VoltageRange_3) != FLASH_COMPLETE)
{
/* Error occurred while sector erase.
User can add here some code to deal with this error */
for(i=0;i<0xFFFFFF;i++)
{
Iwdog_rst();
}
}
}
}
----------------------------------------------------------------------------
将 if (FLASH_EraseSector(SectorCounter, VoltageRange_3) != FLASH_COMPLETE)
{
/* Error occurred while sector erase.
User can add here some code to deal with this error */
for(i=0;i<0xFFFFFF;i++)
{
Iwdog_rst();
}
}
改成while (FLASH_EraseSector(SectorCounter, VoltageRange_3) != FLASH_COMPLETE)
{
/* Error occurred while sector erase.
User can add here some code to deal with this error */
//for(i=0;i<0xFFFFFF;i++)
{
Iwdog_rst();
}
}