PIC16F887 and DS1307


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    PBP handles the R/W bit for you just like it says in the manual...so...
    Code:
    INCLUDE "modedefs.bas"
    RTC VAR BYTE[8] ' Data byte array
    RTC CON %11010000 'DS1307 RTC ADDRESS SEND...RECEIVE
    SDA var PORTC.4
    SCL var PORTC.3
    pause 1000
    I2CWRITE SDA,SCL,RTC,7,%00010011 'TURN ON SQU WAVE OUT 32k HZ
    main:
    I2CREAD SDA,SCL,RTC,0,[RTC[1],RTC[2],RTC[3],RTC[4],RTC[5],RTC[6],RTC[7]]
    SEROUT PORTC.6,6,[254,1]
    toggle PORTD.7 : pause 1000
    SEROUT PORTC.6,6,[254,128,#RTC[1]]
    pause 1000
    goto main

  2. #2
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    well,
    I can't get any signal on the SWQE output, not by LED or by the logic analyzer of the PICkit2. So I might guess the 1307 is malfunctioning.
    This is what I get when analyzing the SCL vs SDA

    This is what I get when analyzing the SCL vs SWQ

    This is what I get when analyzing the SCl vs SDA
    Last edited by menta; - 28th June 2008 at 11:15.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Here are a few things that 'may' help;

    1. If you're using an oscillator >8MHz, then you'll want to include DEFINE I2C_SLOW 1
    since the 1307 max clock speed is 100kHz.

    2. The SQW output is an open-drain type. I.E. it cannot output a logic 1. Use a 10K
    pull-up on the SQW output. Then you should see a square wave output on your scope.

    3. Use the external pull-ups on SDA and SCL.

    4. Connect a 3V battery to the 1307 Vbat input.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    non of the above really helps.
    Probably the 1307 is dead.

  5. #5
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    I replaced the DS1307 with VS1307 which seems to work.
    Is there any other way to convert the data to dec other than:

    I2CRead SDA, SCL, $D0, $00, [A]
    Sec1=(A.0*1)+(A.1*2)+(A.2*4)+(A.3*8)
    Sec10=(A.4*1)+(A.5*2)+(A.6*4)
    Last edited by menta; - 5th July 2008 at 09:21.

  6. #6
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Now I need to understand how to convert from decimal (which comes from the user setup) to write to the RTC chip.
    Last edited by menta; - 5th July 2008 at 22:11.

  7. #7
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Found it
    ConvertBCD:
    CounterB=CounterA DIG 1
    CounterB=CounterB<<4
    CounterB=CounterB+CounterA DIG 0
    Return

Similar Threads

  1. Pic16f887 vs ds1307
    By larzazral in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th January 2010, 04:12

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