微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 微波和射频技术 > 天线设计和射频技术 > how data can be read and write in I2c and display the data

how data can be read and write in I2c and display the data

时间:04-06 整理:3721RD 点击:
how data can be read and write in I2c and display the data ...and i want interface the I2C with DS1307 RTC....and also attach the DS1307 register for reference...

this is example for I2c read and write data...but i not understand .....


//==========================
// write data one byte to
// DS1307
//==========================
void write_DS1307(byte address, BYTE data)
{
short int status;
i2c_start();
i2c_write(0xd0);
i2c_write(address);
i2c_write(data);
i2c_stop();
i2c_start();
status=i2c_write(0xd0);
while(status==1)
{
i2c_start();
status=i2c_write(0xd0);
}
}
//==========================
// read data one byte from DS1307
//==========================
BYTE read_DS1307(byte address)
{
BYTE data;
i2c_start();
i2c_write(0xd0);
i2c_write(address);
i2c_start();
i2c_write(0xd1);
data=i2c_read(0);
i2c_stop();
return(data);
}


and i attach a pdf file for ds1307 register,,,,,,


pls any help me.......

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top