Interface of DS1307 with PIC16F876A


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    Eng4444's Avatar
    Eng4444 Guest


    Did you find this post helpful? Yes | No

    Default One more thing..

    i think you didn't understand me well because you provided me a program to read from DS1307 and i am thankful.

    But still, i dunno how to prgram it ( i mean how to set hours, minutes, seconds, month, day ,year for the first time).

    So as i said, i just bought a DS1307 and i have a PIC16F876A. what are the next steps?....


    I'll appear an idiot i know but really... this is not my field at all.. i got stuck with it and not way to step back because of lack of time...

    thank you all for your understanding.

  2. #2
    Eng4444's Avatar
    Eng4444 Guest


    Did you find this post helpful? Yes | No

    Lightbulb Melanie

    Would you be able to help me?

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    The following may prove useful.

    Remember that the DS1307 stores all data in BCD format, so you will have
    to convert your ASCII input into binary BCD before writing, and will have to
    convert back from BCD when reading.


    ClockAddr CON %11010000 ' RTC device address (byte addressing)
    Offset CON 0
    Cntrl CON %00010000 ' sets the SQW/OUT to 1Hz pulse, logic level low

    I2CRead SDA_PIN, SCL_PIN,ClockAddr,Offset,[sec,mins,hr,day,date,mon,yr],ErrorTrap


    I2CWrite SDA_PIN,SCL_PIN,ClockAddr,Offset,[sec,mins,hr,day,date,mon,yr,cntrl],ErrorTrap
    Charles Linquist

  4. #4
    Join Date
    Feb 2006
    Posts
    89


    Did you find this post helpful? Yes | No

    Default Rtc

    If you can buy a ds1302 RTC I can provide you with a working program and a schematic. I know it isn't a 1307, but those are the options I can provide.

    Travin

  5. #5
    Eng4444's Avatar
    Eng4444 Guest


    Did you find this post helpful? Yes | No

    Lightbulb Dear Travin

    Quote Originally Posted by Travin77
    If you can buy a ds1302 RTC I can provide you with a working program and a schematic. I know it isn't a 1307, but those are the options I can provide.

    Travin
    ++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++

    I do not care about the IC, i can buy DS1302 as long as it gives the same result.
    i just need to deal with time in a certain way (multiply, divide...etc) so the IC will not cause a prob at all... do you have a program for PIC16F876A? i'll be more than thankful!!!

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Eng4444 please understand that folks don't sit next to their terminals all day long waiting to answer your questions. I might glance at it once a day if I'm at my desk - sometimes more, or I might not for several days at a time... Time may be of the essence for you but I also have other priorities in my life...

    If you are calculating Energy = Power . Time, then you are about to open up a whole heap of time calculation problems if you are going to read the time and date, because as you move through midnight into the next day, or increment through into the next month, you have to take into account a whole new set of figures...

    Example... What is the elapsed time between 14:37:31 on 25/02/06 and 17:11:09 on 26/05/06? That's a whole heap of code to do that. You have to work out how much time elapsed until midnight on one day, and how much time elapsed since midnight on the next. Then a month goes by... and you have to take account how many days have elaspsed. And was this year a Leap Year? If you get it wrong you're a day out... So unless you convert everything to Linear Time (there was a long thread on Julian Date calculation some time ago) you have a headache with a PIC full of lots of code doing no more than calculating an elapsed period.

    The DS1307 however provides you with an easier solution that saves you having to do these Time and Date calculations... just count Seconds. Set up the DS1307 to output a Second Pulse to your PIC, and your program sits there doing whatever you want it to do and just simply incrementing a counter every time a Second ticks by.

    Melanie

  7. #7
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Isn't there a different chip in the DSxx series that just records the launch date and then counts elapsed seconds? - can't recall the part # off-hand.

    Arch

Similar Threads

  1. LCDOUT w/custom interface?
    By Mike, K8LH in forum PBP Extensions
    Replies: 4
    Last Post: - 3rd March 2015, 03:54
  2. Replies: 33
    Last Post: - 19th March 2010, 03:02
  3. DS1307 on fire
    By brid0030 in forum General
    Replies: 6
    Last Post: - 25th November 2006, 02:44
  4. 'SCI' interface
    By ecua64 in forum Off Topic
    Replies: 0
    Last Post: - 29th September 2005, 16:02
  5. User Configuration Interface in PBP
    By Radiance in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 7th February 2004, 08:00

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