uchar idata syn[8]={"24.5 6 0"}; void main(void) { initlcm();//初始化LCD initmcu();//初始化单片机 for(;;) { if(ByteRead(0x0080+7)==3)//这里应该可以证明数据能否写进吧? //检查最后一个数据是否是3,如果是从Flash中读取数据更新syn { sst_read(); } else//否则往sst29sf040写入数据 { sst_write(); } syn_add();//syn增 syn_dec();//syn减 Write595((syn[1]<<4)|(syn[3]&0x0f),(syn[5]<<4)|(syn[7]&0x0f)); sst_write(); } }
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); }
|