int Check_SST_29SF040(){ uchar SST_id1; uchar SST_id2; int ReturnStatus; /* Issue the Software ID code to 29sf040*/ XBYTE[0x0555]= 0xAA;/* set up address to be 555h */ /* write data 0xAA to the address */ XBYTE[0x02AA]= 0x55;/* set up address to be 2AAh */ /* write data 0x55 to the address */ XBYTE[0x0555]= 0x90; wait(61,74); /*delay 10ms*/ /*read the product ID from29sf040*/ /* set up address to be 0000h */ SST_id1 = XBYTE[0x0000] ; /* get first ID byte???????????????*/ SST_id2 = XBYTE[0x0001];/* set up address to be 0001h */ if ((SST_id1 ==SST_ID)&&(SST_id2 == SST_29SF040)){ ReturnStatus = 1; }else{ ReturnStatus = 0; }
/* Issue the Soffware Product ID Exit code thus returning the 29EE020 */ /* to the read operating mode */ /* set up address to be 555h */ XBYTE[0x0555] = 0xAA; /* write data 0xAA to the address */ /* set up address to be 2AAh */ XBYTE[0x02AA] = 0x55; /* write data 0x55 to the address */ /* set up address to be 555h */ XBYTE[0x0555] =0xF0; /* write data 0xF0 to the address */ wait(61,74); /*delay 10ms*/ return(ReturnStatus);
}
int Erase_One_Sector(uint Dst){
/* Issue the Sector Erase command to 39SF040 */
XBYTE[0x0555] = 0xAA; /* set up address to be 555h */ /* write data 0xAA to the address */ XBYTE[0x02AA] = 0x55; /* set up address to be 2AAh */ /* write data 0x55 to the address */ XBYTE[0x0555] = 0x80; /* set up address to be 555h */ /* write data 0x80 to the address */ XBYTE[0x0555] = 0xAA; /* set up address to be 555h */ /* write data 0xAA to the address */ XBYTE[0x02AA] = 0x55; /* set up address to be 2AAh */ /* write data 0x55 to the address */ XBYTE[Dst] = 0x20; /* set up starting address to be erased */ /* write data 0x30 to the address */ wait(85,134); /* check DATABOOK for the most */ /* accurate value -- Tse */ //不建议采用固定的延时(参考字节编程部分) }