Uint16 ChipErase(void)
{
Uint16 Data;
Uint32 TimeOut,i;
*(FlashStart + 0x5555) = 0xAAAA;
*(FlashStart + 0x2AAA) = 0x5555;
*(FlashStart + 0x5555) = 0x8080;
*(FlashStart + 0x5555) = 0xAAAA;
*(FlashStart + 0x2AAA) = 0x5555;
*(FlashStart + 0x5555) = 0x1010;
i = 0;
TimeOut = 0;
while(i<5)
{
Data = *(FlashStart + 0x3FFFF);
if (Data == 0xFFFF) i++;
else i=0;
if ( ++TimeOut>0x1000000) //0x1000000地址值1M容量
return (TimeOutErr);
}
for (i=0;i<0x40000;i++)
{
Data = *(FlashStart + i);
if (Data !=0xFFFF) return (EraseErr);
}
return (EraseOK);
} |