hi this code not work for me but with these change work
void send_byte(unsigned char c)
{
unsigned mask=0x80;
//i2c_write(c);
//return;
do //transmits 8 bits
{
if(c&mask) //set data line accordingly(0 or 1)
SDAHIGH //data high
else
SDALOW //data low
d_us
d_us
SCKHIGH //clock high
d_us
SCKLOW //clock low
d_us
mask/=2; //shift mask
}while(mask>0);
SDAHIGH //release data line for acknowledge
SCKHIGH //send clock for acknowledge
d_us
slave_ack=READ_SDA(); //read data pin for acknowledge
SCKLOW //clock low
d_us
}
Sorry because I am replaying in this instead of its older post but I can not stop myself because I really want solution for my problem.
I have written my code for i2c for 89c51 and DS1307 RTC. which is mostly same as your code.
but I am not getting there output.
from datasheet of ds1307 I have found that it is standard to set 100khz frequency for ds1307 and I2C communication.
so, is that compulsory to give specific delay for SCL and SDA?