real time clock


Closed Thread
Results 1 to 40 of 45

Thread: real time clock

Hybrid View

  1. #1
    bahattinkor's Avatar
    bahattinkor Guest


    Did you find this post helpful? Yes | No

    Unhappy Still not working

    yes, I checked connections. voltages are normal but when I measured the cyrstal of Ds1302 with ossiloscope, I did not see any frequency. The ossilator does not ossilates. then I change DS1302 and 32.768Khz cyrstal with new ones but they are still not working. Can it be related with the Vcc that I used. I use 5V for Vcc for DS1302. Or Should I use any resistor or capacitor plus for the DS1302.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Probably your Clock Halt flag is set..... it's undetermined when you put power on the RTC. Just clear this bit and you'll see oscillation on your scope.
    The problem is the same on many RTC. See the secondes register for the CH bit.

    Many cheaper probe will screw the signal coming from an Crystal. Place it on 10X and this will help a bit in many case.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Cool RTC - DS1302 with User Interface

    Here is a modified version of the code posted by CocaColaKid above.

    In the code above, the clock can only be set during the programming of PIC.

    With the modification here, the user can set the time, date etc. at any given time.

    Advise/post any additions, recommendations, modifications etc if any.
    Attached Images Attached Images  
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Cool Shorther HEX convertion sub routine

    As members are asking;

    Attached is the updated version with more space.
    (HEX Conversion is shorter)

    ------------------------------------------------------
    Attached Files Attached Files
    Last edited by sayzer; - 24th February 2006 at 19:01.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    Join Date
    Jun 2006
    Location
    Bangalore, India
    Posts
    136


    Did you find this post helpful? Yes | No

    Exclamation

    Hey CocaColaKid,
    Your code for the DS1302 is really good and efficient...
    I got a few questions,
    how should i enable the trickle charge option ?
    and how should i clear or set the clock halt flag???

  6. #6
    Join Date
    Jan 2006
    Location
    New Hampshire, USA
    Posts
    107


    Did you find this post helpful? Yes | No

    Default

    I am a neophyte at programming, but have been writing BASIC code for 40 years. This is how I would do the conversion:

    DECX VAR BYTE(59)
    A VAR BYTE
    B VAR BYTE
    C VAR BYTE

    FOR B = 0 TO 59
    FOR A = $0 TO $59
    IF C = B THEN DECX(C) = A
    C = C+1
    NEXT A

    NEXT B
    ' THIS ROUTINE GENERATES AN ARRAY WHERE
    ' DECX(0) = $0
    ' DECX (1) = $1
    ' ETC.
    I didn't do it correctly the first time, this is better.
    Last edited by Russ Kincaid; - 6th July 2006 at 02:31.

  7. #7
    blainecf's Avatar
    blainecf Guest


    Did you find this post helpful? Yes | No

    Talking Straight-forward RTC bits conversion algorithm

    For all you old timers, here's an alternate way of calculating Human Date/Time from the RTC bits:

    (Also, because all info is read in one shot, there is less liklihood that the seconds won't match the minutes.)

    I2CREAD DPIN,CPIN,RTC,I2C_Adr_B,[Rd_seconds, rd_minutes, rd_hours, Rd_DOW, Rd_DAy, RD_month, Rd_Year] ' in bcd code

    Seconds = Rd_Seconds.0 + (Rd_Seconds.1 * 2) + (rd_seconds.2 * 4) + (rd_Seconds.3 * 8) + (rd_seconds.4 * 10) + (rd_seconds.5 * 20) + (Rd_Seconds.6 * 40)

    Minutes = Rd_Minutes.0 + (Rd_Minutes.1 * 2) + (rd_Minutes.2 * 4) + (rd_Minutes.3 * 8) + (rd_Minutes.4 * 10) + (rd_Minutes.5 * 20) + (Rd_Minutes.6 * 40)

    Hours = RD_Hours.0 + (Rd_hours.1 * 2) + (rd_hours.2 * 4) + (rd_hours.3 * 8) + (rd_hours.4 * 10)

    am_pm = rd_hours.5
    dow = rd_dow

    day = rd_day.0 + (rd_day.1 * 2) + (rd_day.2 * 4) + (rd_day.3 * 8) + (rd_day.4 * 10) + (rd_day.5 * 20)

    Month = rd_month.0 + (rd_month.1 * 2) + (rd_month.2 * 4) + (rd_month.3 * 8) + (rd_month.4 * 10)

    Year = rd_year.0 + (rd_year.1 * 2) + (rd_year.2 * 4) + (rd_year.3 * 8) + (rd_year.4 * 10) + (rd_year.5 * 20) + (rd_year.6 * 40) + (rd_year.7 * 80)

Similar Threads

  1. Real Time Clock
    By in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd June 2012, 04:52
  2. real time clock - PCF8583
    By maria in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 15th April 2010, 15:41
  3. Real time clock ICs
    By Eng4444 in forum mel PIC BASIC Pro
    Replies: 66
    Last Post: - 20th October 2008, 16:05
  4. Real Time Clock
    By savnik in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th December 2006, 02:02
  5. Real time clock... what a headache!
    By Eng4444 in forum mel PIC BASIC
    Replies: 2
    Last Post: - 8th June 2006, 21:56

Members who have read this thread : 3

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