RTC date problem


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    10

    Default RTC date problem

    Hi, I am working with a PCF 8583 real time clock. I can read and write to the device correctly, but as soon as the time changes to 00:00:00, the day and month gets incremented by the RTC automatically. I have tried changing the RTC, but the same thing happens.

    Can anyone help me?

    Thanks

  2. #2
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Are you sure you are masking off the unused bits in the month and date registers while reading/writing?

    You can expect bizarre things if you are simply reading (or writingto) the whole register(s).

    Regards,

    Anand

  3. #3
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    Yes, I have masked it ( I2CWrite DPIN,CPIN, RTC,$00,[ $09 ] ).

    Could it be because I'm reading the RTC every second, it is confuses the RTC when it wants to update the date the same time as I'm trying to read it?

  4. #4
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Hi Peder,

    I dont think reading the chip every second should be an issue; I have used a PCF 8563 in a propeller clock that gets polled far more frequently, and there is no problem.

    I am attaching a snippet using PBP with the PCF8583 that I had downloaded some time ago; this might lead you in the right direction.

    Regards,

    Anand
    Attached Images Attached Images  

  5. #5
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    Thanks man, by checking your code and comparing it to mine, I realised that I made my "DAY" variable WORD instead of BYTE. It works perfectly now...

    Thank you for your help and time.

    Cheers

  6. #6
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi ardhuru,

    Would it be possible for you to post the rest of the code for the RTC including time setting? I think many people on this forum would be interested as there have been some posts requesting specifically this chip.

    Thank you very much!

    BobK

  7. #7
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default RTC read and RTC write

    Hi Bob,

    Actually, I used the PCF8563, which is virtually identical to the PCF8583 except for a few features.

    Anyway, here are the RTC read and RTC write segments that I use. Since my RTC works on a battery (a CR2032, now in its second year, expected to go on for at least a year more!), I have also extracted the low battery indiactor bit.

    'READ FRESH VALUES FROM THE RTC and convert BCD to decimal

    I2CREAD SDA,SCL,$A2,2,[S,m,h,D,W,MN,Y] 'Read all parameters from the RTC

    LOBATT = S & %10000000 ' Mask off all bits unimplemented in RTC registers
    S = S & %01111111 '
    M = M & %01111111 '
    h = H & %00111111 '
    D = D & %00111111 '
    Mn = Mn & %00011111 '

    TMP=S ' Convert BCD to decimal
    S=((tmp>>4)*10)+(tmp & $0F) '
    tmp=M '
    M=((tmp>>4)*10)+(tmp & $0F) '
    tmp=H '
    H=((tmp>>4)*10)+(tmp & $0F) '
    tmp=D '
    D=((tmp>>4)*10)+(tmp & $0F) '
    tmp=MN '
    MN=((tmp>>4)*10)+(tmp & $0F) '
    tmp=Y '
    Y=((tmp>>4)*10)+(tmp & $0F) '


    'Convert Decimal Seconds,Minutes & Hours values to BCD equivalents and write to RTC

    tmp=S
    S=(tmp dig 1<<4)+(tmp dig 0)
    tmp=M
    M=(tmp dig 1<<4)+(tmp dig 0)
    tmp=H
    H=(tmp dig 1<<4)+(tmp dig 0)
    tmp=D
    D=(tmp dig 1<<4)+(tmp dig 0)
    tmp=MN
    MN=(tmp dig 1<<4)+(tmp dig 0)
    tmp=Y
    Y=(tmp dig 1<<4)+(tmp dig 0)

    I2CWRITE SDA,SCL,$A2,2,[S,M,H,D,W,MN,Y] 'Write parameters to RTC

    Hope this helps!

    Regards,

    Anand

  8. #8
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Anand,

    Thank you!

    BobK

Similar Threads

  1. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  2. PIC 16F877 I2C communications
    By sigmoideng in forum General
    Replies: 7
    Last Post: - 13th July 2007, 10:28
  3. 8583 rtc date problem
    By crazyhellos in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th February 2007, 15:28
  4. X1226 RTC - Help
    By charudatt in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th August 2006, 17:54
  5. RTC Problem
    By Travin77 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th March 2006, 05:13

Members who have read this thread : 2

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