void ClearDataflash(void)
{
u32 i;
FLASH_Unlock();
Iwdog_rst();
/* Clear pending flags (if any) */
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |
FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR);
/* 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();
}
}
}
}
----------------------------------------------------------------------------
这样吗?还是没有用啊
|