void write_add(unsigned char address,unsigned char date) { start(); write_byte(0xa0); respons(); write_byte(address); respons(); write_byte(date); respons(); stop(); }
void write_add(uchar address,uchar date) { start(); write_byte(0xa0);//a表示器件地址,0表示接收数据 respons();//应答 write_byte(address);//写数据的地址 respons();//应答 write_byte(date);//写数据 respons();//应答 stop();//停止信号 }
void write_add(unsigned char address,unsigned char date)//向地址写一个字节数据 { start(); writebyte(0xa0);//A0,A1,A2接地,AT24C02芯片地址为1010,送控制字为1010A2A1A0R/~W respons(); writebyte(address); respons(); writebyte(date); respons(); stop(); }
char read_add(unsigned char address) { unsigned char date; start(); write_byte(0xa0); respons(); write_byte(address); respons(); start(); write_byte(0xa1); respons(); date=read_byte(); stop(); return date; }
uchar read_add(uchar address) { uchar date; start(); write_byte(0xa0);//a表示器件地址,0表示接收数据 respons();//应答 write_byte(address);//读数据的地址 respons();//应答 start(); write_byte(0xa1);//1表示读数据 respons(); date=read_byte(); stop(); return date; }void timer0() interrupt 1
unsigned char read_add(unsigned char address)//向地址读一个字节数据 { unsigned char date; start(); writebyte(0xa0);//A0,A1,A2接地,AT24C02芯片地址为1010,送控制字为1010A2A1A0R/~W respons(); writebyte(address); respons(); start(); writebyte(0xa1);//A0,A1,A2接地,AT24C02芯片地址为1010,送控制字为1010A2A1A0R/~W respons(); date = readbyte(); stop(); return date; }