sst29sf040不是flash吗,为什么我把它当作数据存储器时一掉电数据就会丢失呢? sst29sf040的A0-A7接74ls373的输出,74373集成在CPLD中,没画出来,A8-A14接AT89C52的P20-P26,而A15-A18接地,因为我用不到那么大的空间,而其片选端CE接AT89C52的P27
void ByteProgram(uchar data SrcByte,uint Dst) { XBYTE[0x0555] = 0xAA; XBYTE[0x02AA] = 0x55; XBYTE[0x0555] = 0xA0; XBYTE[Dst] = SrcByte; wait(1,9);//等待25us }
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 */ }
uchar ByteRead(uint addr) { uchar GetData; GetData = XBYTE[addr]; return(GetData); } void sst_save()//用于保存易丢失数据 { uchar i; Erase_One_Sector(128); for(i=0;i<4;i++) { ByteProgram(syn[2*i+1],0x0080+i); syn[2*i+1]=ByteRead(0x0080+i); } } void main() { sst_save();我 在程序中改变syn 的值未写出,为什么我一断电,syn 的值还是原来的赋的初值呢? } |