IapEraseSector(IAP_ADDRESS); //扇区擦除
for (i=0; i<512; i++) //检测是否擦除成功(全FF检测)
{
if (SendData(IapReadByte(IAP_ADDRESS+i)) != 0xff)
goto Error; //如果出错,则退出
}
P1 = 0xfc; //1111,1100 擦除成功
Delay(10); //延时
for (i=0; i<512; i++) //编程512字节
{
IapProgramByte(IAP_ADDRESS+i, (BYTE)i);
}
P1 = 0xf8; //1111,1000 编程完成
Delay(10); //延时
for (i=0; i<512; i++) //校验512字节
{
if (SendData(IapReadByte(IAP_ADDRESS+i)) != (BYTE)i)
goto Error; //如果校验错误,则退出
}
为啥我看的都有检测 ?