1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

strange RTC 8563

Discussion in 'Oshonsoft' started by gold94, Jun 10, 2014.

  1. gold94

    gold94 New Member

    Joined:
    Jun 10, 2014
    Messages:
    11
    Likes:
    0
    Location:
    Paris
    Hello, my name is thierry

    I try to do a real time clock with PCF8563, the clock works fine but a strange thing produit.a every 20 seconds the LCD add me numbers, like this:
    LCD
    time: 6:30:00
    Date: 01/01/2014 (no problem)
    LCD
    time: 6:30:20
    Date: 01/21/2014 (oups. ..!).
    LCD
    time: 6:30:40 -> time: 46:30:41 (oups ...)
    Date: 41/41/2014 (oups ..)
    strange and I can not find the problem
    my code or the clock

    thank you

    PS: sorry for my bad English (google) :))
     

    Attached Files:

  2. revave

    revave Member

    Joined:
    Oct 11, 2011
    Messages:
    48
    Likes:
    1
    Location:
    Netherlands
    Please try in your code for conversion from bcd to dec the code like written below:

    'convert RTC packed bcd to a bin number for inc/dec usage
    'enter with temp1 holding the packed BCD byte
    'exit with temp1 holding the decimal byte
    bcd2dec:
    units = temp1 Mod 16
    tens = (temp1 / 16) * 10
    temp1 = tens + units
    Return

    When this is working you have to modify the bin2bcd code too.

    'convert the bin number to packed bcd for RTC write
    'enter with temp1 holding the decimal byte
    'exit with temp1 holding the packed BCD byte
    dec2bcd:
    tens = (temp1 / 10) * 16
    units = temp1 Mod 10
    temp1 = tens + units
    Return


    Note 1: maybe it's needed to mask the 7th bit, because it is unused or reserved for other functionality.

    Note 2: Remember that the high nibble is used for the tens and the low nibble is used for the units.

    Regards,
    Reijnko
     
    Last edited: Jul 9, 2014
    • Like Like x 1
  3. gold94

    gold94 New Member

    Joined:
    Jun 10, 2014
    Messages:
    11
    Likes:
    0
    Location:
    Paris
    hello

    thank you for the answer
    I am currently holiday
    I change my code on my return

    thank you

    PS: sorry for my bad English (google) :))
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. pe1riv

    pe1riv New Member

    Joined:
    Dec 26, 2012
    Messages:
    6
    Likes:
    0

    the pcf8563 needs a strage way to read out or to write, read manual (pdf) of the rtc.

    you use directly this code: I2CRead sda, scl, rtcr, addr, sec but the chip first has to be set to slave you can do this by ad the following lines:

    I2CStart
    I2CSend 0xa2
    --than your code ---
    I2CRead sda, scl, rtcr, addr, sec

    I got same problem by using this rtc and some wierd read out...
     

Share This Page