This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

output of ds1307 to uart using 89v51rd2 is not correct

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.

Parents
  • i'm not familiarize with C just ASM (A51) but i see in your source that
    you wrote
    for example
    min = (DS1307_get(MIN));
    and in the subroutine DS1307_get(MIN) min means the adress on the DS1307
    but in the main prog you made MIN=0 it should be 1
    sec=0 ; min = 1 ; hour = 2 ; day = 4 ; month = 5 ; year = 6

    try to be sure that the voltage in the "pin 3" < 1.25 * Vcc

Reply
  • i'm not familiarize with C just ASM (A51) but i see in your source that
    you wrote
    for example
    min = (DS1307_get(MIN));
    and in the subroutine DS1307_get(MIN) min means the adress on the DS1307
    but in the main prog you made MIN=0 it should be 1
    sec=0 ; min = 1 ; hour = 2 ; day = 4 ; month = 5 ; year = 6

    try to be sure that the voltage in the "pin 3" < 1.25 * Vcc

Children
  • 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));;
    }