i have done the interface between ds1307 and 89v51rd2.the output to uart after reading time and date from the rtc ic not correct i am getting like Time=36:32:0D,Date=1F/1C/3F.can any one help me.
unsigned int DS1307_get(unsigned char addr) { unsigned int ret=0; /* shouldn't you issue a start bit before the write ? */ I2C_write(DS1307_ID); /* Connect to DS1307 */ I2C_write(addr); /* Request RAM address on DS1307 */ I2C_start(); /* Start i2c bus */ I2C_write(DS1307_ID+1); /* Connect to DS1307 for Read */ ret = I2C_read(); /* Receive data */ I2C_noack(); I2C_stop(); /* Stop i2c bus */ return ((((ret>>4)&0x0F)*10)+(ret&0x0F));; }