void IAP_Page_Erase(unsigned int IAP_Addr,unsigned char Trigger_Check2)
{
#if (Xtal_Freq<=6)
ISPCR=0x03 ;
#elif (Xtal_Freq<=10)
ISPCR=0x02 ;
#elif (Xtal_Freq<=20)
ISPCR=0x01 ;
#elif (Xtal_Freq<=40)
ISPCR=0x00 ;
#endif
ISPCR = ISPCR | 0x80 ;
IFADRH = IAP_Addr >> 8 ; //IAP Flash Address High Byte
IFADRL = IAP_Addr & 0xFF ; //IAP Flash Address Low Byte
IFMT = 0x03 ; //IAP Flash Mode Table (Erase Mode)
if (Trigger_Check1==0x55)
SCMD = 0x46 ;
else
IAP_Fail() ;
if (Trigger_Check2==0xAA)
{ SCMD = 0xB9 ;
}
else
{ SCMD = 0x00 ;
IAP_Fail() ;
}
Trigger_Check2=0x00;
ISPCR = ISPCR & 0x7F ;
} |