C51编程:请问各位大虾写at29c020的方法?
我在写atmel公司的at29c020时,写入的数据不能稳定的实现
代码如下,请问是什么地方的问题:
不知是时序的问题还是延时方面的问题?
void wFlashUnit(unsigned int Addr,unsigned char dat)
{
setOE_High; //oe=high
setFristCE_High; //ce=high
setWE_High; //we=high
Hdelay(500); //delay 500 cycle
Outport(4,Addr&0xff); //low 8 bits address
Outport(5,(Addr>>8)&0xff); //high 8 bits address
Outport(6,0x00); //disable
//Hdelay(100);
Outport(8,dat); //write flash data port
Hdelay(500); //delay 500 cycle
setFristCE_Low; //ce=low
setWE_Low; //we=low
Hdelay(1000); //delay
setWE_High; //we=high
setFristCE_High; ce=high
Hdelay(500);
}
//****************************************************************
void wFlashSector()
{
unsigned int count;
//write 0xaa to 0x5555;
wFlashUnit(0x5555,0xaa);
//write 0x55 to 0x2aaa;
wFlashUnit(0x2aaa,0x55);
//write 0xa0 to 0x5555;
wFlashUnit(0x5555,0xa0);
Hdelay(1000);
for(count=0x0000;count<=0x00ff;count++)
{
wFlashUnit(count,0xbc); //例如:写0xbc到0x0000-0x00ff
}
}
发表时间:2001年10月27日9:45:00