DS1307 sample Program


Closed Thread
Results 1 to 3 of 3
  1. #1
    Mark's Avatar
    Mark Guest

    Question DS1307 sample Program

    I am working on a timer that will turn on at high tide.

    I'm just getting started with this RTC and have been experimenting with Melanie's MN1307 -- It is very helpful & explains alot - but I am having some problems & I hope some one who has use this sample program may be able to shed some light.

    I have wired this up & compiled the program with additional I2C write line to get the 1307 initialised. SetupPreset now looks like this:

    SetupPreset:
    RTCSec=$00 ' Seconds preset to 00
    RTCMin=$15 ' Minutes preset to 15
    RTCHour=$13 ' Hours preset to 13'00
    RTCWDay=$01 ' Weekday preset to 01
    RTCDay=$12 ' Day preset 12
    RTCMonth=$06 ' Months preset to June
    RTCYear=$02 ' Year preset to 2002
    RTCCtrl=$10 ' Control preset to output 1 second 'Tick' on SQWpin
    I2CWrite SDApin,SCLpin,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCY ear,RTCCtrl]
    Pause 1000

    Return


    The display shows the 12 June 2002 defalut time OK

    I'm having a problem with the setup loop - I can't get it to advance from the 12 24 hour set mode screen

    all three buttons toggle between the 12 & 24

    after the 20 secs delay it goes back to the time display as it should.

    I'm not sure if I have a hardware or software problem - All three switches seem to be OK

    Any suggestions will be appreciated.

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    Oh my Gawd... it's two years already since I wrote that!

    Assuming you've connected the buttons as per the text... the SET Button...

    SetButton var PORTB.5 ' Press to Set/memorise Button

    ... will save the current Set-Up and advance to the next option. The first option is the setting for 12/24 hour mode... if you're stuck in it, then it looks like you might have miss-wired the Buttons - especially the SET Button.

    With no Buttons pressed, PortB.4, 5 and 6 should all be High. Check them with a DVM or scope. Then with SET only pressed, only PortB.5 should go LOW (0v), the others remain High.

    You might have a short between SET and one of the adjacent pins. In the software, the code for Increment and Decrement is executed before SET, therefore if one of those pins are going Low (as it looks might be the case), all that happens is you end up toggling between 12/24 hour mode and never getting any further.

    I really must update that one day for something more sophisticated... it's embarassing looking at it...

  3. #3
    Mark's Avatar
    Mark Guest


    Did you find this post helpful? Yes | No

    Talking MN1307 working

    Thanks Melanie.

    The switches were fine but there is a short on the proto18 PCB I used to build this between B5 and B6

    I gave up looking for it after a while just moved the reset to B7.

    Works fine now. Thanks for the great example & the fantastic troubleshooting -

Similar Threads

  1. Presetting Configuration Fuses (PIC Defines) into your Program
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 82
    Last Post: - 15th December 2013, 09:54
  2. CTCSS Tone Decoder Sample Program
    By sozkarabacak in forum General
    Replies: 0
    Last Post: - 20th October 2009, 06:15
  3. Replies: 1
    Last Post: - 23rd May 2009, 09:22
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. PIC16F684 Program question
    By Nicholas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th December 2006, 14:30

Members who have read this thread : 1

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