DS1307 not running?


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: DS1307 not running?

    Richard,

    The control and Address are wrong in the I2C instructions. Control should be $0 if not using the SQWO. The address should be $D0 for write and $D1 for read. Or that is the way I interpret the data sheet.

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: DS1307 not running?

    the ds1307 has 8 registers for the rtc function addressed from 0 to 0x07
    the control reg address is 0x07 bits 7 and 4 control the sqwe , if you only use the time keeping function the control reg can be ignored
    to set the time you start at register address 0 (sec min hours ......)
    to read just minutes start from address 1 etc
    pbp will set bit 0 of the device address ($d0 in this case) as required (at least pbp3 will not sure about pbp2xx)

    the ram goes from 0x08 to 0x3f trying to write or read from regs $d0 or $d1 will not have meaning full results
    Last edited by richard; - 30th May 2014 at 13:44. Reason: added ram info

  3. #3
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: DS1307 not running?

    Richard,

    Now I understand the datasheet refers to the control as address, how confusing. I did not realise that the eighth bit is added automatically.

    Thanks for that.

  4. #4
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: DS1307 not running?

    Having read the data sheet again I found this near the end

    Name:  Capture.PNG
Views: 342
Size:  21.4 KB

    How confusing that makes us both wrong. I must learn to read the whole data sheet in future.

  5. #5
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: DS1307 not running?


  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: DS1307 not running?

    I will say again pbp will set bit 0 of the i2c device address as required
    by running :-
    I2CRead SDA, SCL, $D0, 0, [RTCSec, RTCMin, RTCHour, RTCDay, RTCDate, RTCMonth, RTCYear]

    it will write 0 to the control address logic of the 1307 and then read 7 bytes
    try it !

  7. #7
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: DS1307 not running?

    Quote Originally Posted by richard View Post
    I will say again pbp will set bit 0 of the i2c device address as required
    by running :-
    I2CRead SDA, SCL, $D0, 0, [RTCSec, RTCMin, RTCHour, RTCDay, RTCDate, RTCMonth, RTCYear]

    it will write 0 to the control address logic of the 1307 and then read 7 bytes
    try it !
    $D0 is write

    I2CRead SDA, SCL, $D1, 0, [RTCSec, RTCMin, RTCHour, RTCDay, RTCDate, RTCMonth, RTCYear]

    Is read according to the data sheet and the example in #9.

    Interestingly the data sheet extract shown in #8 says to do

    I2CWrite SDA, SCL, $D0, 0

    reset the write pointer then

    I2CRead SDA, SCL, $D1, [RTCSec, RTCMin, RTCHour, RTCDay, RTCDate, RTCMonth, RTCYear]

    to read the time.

    But the example code in #9 works by using

    I2CRead SDA, SCL, $D1, 0, [RTCSec, RTCMin, RTCHour, RTCDay, RTCDate, RTCMonth, RTCYear]

    So I am curious to find out from Sabahan what works in his case.

Similar Threads

  1. Replies: 8
    Last Post: - 28th January 2014, 14:21
  2. using DS1307
    By Scampy in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 2nd December 2013, 10:01
  3. 18F4550 not running
    By comwarrior in forum General
    Replies: 6
    Last Post: - 1st January 2011, 01:07
  4. Cant get my PIC running
    By Viberer in forum Off Topic
    Replies: 13
    Last Post: - 29th August 2008, 20:07

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