how do i write on a i2c bus as well as read data from a I2C. i want to read and write data from the ds1307 ic. and i want to know how do i code it in c to interface it.
Just read the datasheet of DS1307. There will be details given about the i2c read and write cycles along with timing details. Just write code for those.
Eg: write individual functions for i2c_ack, i2c_start, i2c_stop etc... Then according to the flow given in the datasheet make a different function which will call all these functions in that order with the appropriate data being passed.
how do i write on a i2c bus as well as read data from a I2C. i want to read and write data from the ds1307 IC. and i want to know how do i code it in c to interface it.
First you have to write I2C routines like I2c start, I2c Stop, I2C_Acknowledge_wait, I2C_Byte_Read, I2C_Byte_Write,
these are sub functions of I2C and deals with your SDA and SCL line.
Then try to write the Peripheral IC sub routine function using the I2C sub functions. e.g. Read_DS1307, Write_Ds1307,
Which will write and read the data from DS1307.
how do i write on a i2c bus as well as read data from a I2C. i want to read and write data from the ds1307 ic. and i want to know how do i code it in c to interface it.