Pcf8563p Rtc Trouble


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Location
    Bavaria
    Posts
    28


    Did you find this post helpful? Yes | No

    Default

    Hello Dan,

    I had started a project using the PCF8563 a bout a year ago (not yet finished).
    Without deeper analysing your code, I noticed, that you are using different addresses for read and write.
    PBP handles this for you, read/write always to the address $A2.
    You could also shorten your code by using multiple reads/writes like
    I2CRead data_pin,clk_pin,rtc_read,reg_seconds,[seconds, minutes, hours...]

    Regards,

    Ingo

  2. #2
    Join Date
    Jul 2007
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by inse View Post
    Hello Dan,

    I had started a project using the PCF8563 a bout a year ago (not yet finished).
    Without deeper analysing your code, I noticed, that you are using different addresses for read and write.
    PBP handles this for you, read/write always to the address $A2.
    You could also shorten your code by using multiple reads/writes like
    I2CRead data_pin,clk_pin,rtc_read,reg_seconds,[seconds, minutes, hours...]

    Regards,

    Ingo
    hi

    did you get the pcf8563 to work then ?

    in the datasheet it had different addresses for writing and reading so i just used them both in my code to be safe, ive changed a few things now i get 08:08:08 displayed i don't no we re those values come from, because there not the ones i'm writing to the registers

    confuuuuusion!
    Last edited by -Dan-; - 23rd November 2007 at 23:06.

  3. #3
    Join Date
    Jul 2007
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    anyone have any idea's then

    one thing i forgot to do was add pull up resistors on the data and clock lines so i added 10k resistors to them and i get the values 16 for hours minutes and seconds, whether connected to the rtc or not.

    with the data line being bi directional i don't no what to do in means of setting it as an input or an ouput, or do i just not define it as either.

    Thanks

    Dan

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    969


    Did you find this post helpful? Yes | No

    Default

    - Dan -

    I don't have exactly what you want, but I have worked on a PCF8583 from Philips. Perhaps they are similar. You figure it out. Use it as a guideline if you may. Part of init is to set the SDA and SCL lines as outputs via the TRIS command.

    Code:
    '================================================================================
    ' I2C   RTC PCF8583  CODE  using I2C_read and I2C_write routines of compiler
    '================================================================================
    ' RTC registers are defined
    ' 0       -       Command / Status register
    '   .0  timer flag
    '   .1  alarm flag
    '   .2  alarm enable 1 -  enabled
    '   .3  mask flag
    '   .54  function 00 clock 32.768KHz/01 clock 50Hz/10 evt counter/11 test
    '   .6  hold last count flag
    '   .7  stop counting, reset divider
    ' 1       -       1/10 s | 1/100s
    ' 2       -       10s    | 1s       seconds
    ' 3       -       10m    | 1m       minutes
    ' 4       -       10h    | 1h       hours
    '   .3..0 unit hours BCD
    '   .54   10s hours 0..2 binary
    '   .6    1 PM
    '   .7    1 12 hour format
    ' 5       -       10d    | 1day     Day & Year
    '   .3..0 unit days BCD
    '   .54   ten days 0..3 binary
    '   .76   year 0..3 binary (read 0 if mask)
    ' 6       -       10mo   | 1month   month
    '   .3..0 unit months BCD
    '   .4    ten months
    '   .7..5 weekdays 0..6 binary (read 0 if masked)
    ' 
    ' 0x10 to 0xff  RAM
    
    ' If RTC is not running, start it
    TimerOff:
        I2CWRITE SDA, SCL, $A2, ControlReg, [0]
        return
        
    ' Read the time in BCD format
    RTC_GetTime:
        I2Cread SDA, SCL, $A2, SecondsReg+0, [Time[2],Time[1],Time[0]]
        return
    
    ' Set time in BCD format
    RTC_SetTime:
        I2Cwrite  SDA, SCL, $A2, SecondsReg+0, [Time[2],Time[1],Time[0]]
        goto  TimerOff
    Last edited by Jerson; - 24th November 2007 at 14:00.

  5. #5
    Join Date
    Jul 2007
    Location
    Bavaria
    Posts
    28


    Did you find this post helpful? Yes | No

    Default

    Hi Dan,

    i hope you got ahead with your code in the meantime.
    My project is a clock (who could guess it?) with electromechanic seven segment displays.
    The clock is running (1/2 hour behind by now) but the code for setting the time is still missing - as well as the buttons to be used for it.

    You don't have to initialize the pins you use for I2C, it is done by the i2cread/i2cwrite commands.

    I don't see what is causing the communication problems in your code - so i propose you check your hardware wiring.

    Best wishes,

    Ingo

  6. #6
    Join Date
    Jul 2007
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by inse View Post
    Hi Dan,

    i hope you got ahead with your code in the meantime.
    My project is a clock (who could guess it?) with electromechanic seven segment displays.
    The clock is running (1/2 hour behind by now) but the code for setting the time is still missing - as well as the buttons to be used for it.

    You don't have to initialize the pins you use for I2C, it is done by the i2cread/i2cwrite commands.

    I don't see what is causing the communication problems in your code - so i propose you check your hardware wiring.

    Best wishes,

    Ingo
    hey

    yer i got it working in the end, it turned out to be the 32.768 crystal i had, any way i swapped it out and it works ok now, apart from when it gets to say 9 seconds it skips to 16 but thats probably because i have no bcd conversions in my code?

    Dan

Similar Threads

  1. Low battery signal from an RTC
    By ardhuru in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 19th March 2008, 17:13
  2. PIC 16F877 I2C communications
    By sigmoideng in forum General
    Replies: 7
    Last Post: - 13th July 2007, 10:28
  3. Using RTC to generate long time delays
    By schlaray in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd January 2007, 00:31
  4. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07
  5. X1226 RTC - Help
    By charudatt in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th August 2006, 17:54

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts