Pic16f887 vs ds1307


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2010
    Posts
    14

    Default Pic16f887 vs ds1307

    IM USING SERIAL LCD TO DISPLAY ONLY SECOND...WHY MY LCD ALWAYS DISPLAY 20 IN HEX....

    INCLUDE "modedefs.bas"
    DEFINE OSC 20
    DEFINE I2C_SLOW 1


    TRISC = %00000000
    TRISD = 0
    SDA var PORTC.5
    SCL var PORTC.3

    Hours var Byte
    Minutes var Byte
    Seconds var Byte
    RTC var Byte
    I2C_Adr_B var byte


    RTC = %11010000 ' Device adress on I2C bus
    I2C_Adr_B=0

    I2CWRITE SDA,SCL,RTC,I2C_Adr_B,[128,0,0,0,0,0,0,128] 'Reset time to 0 and stopped, 12 hour setting
    PAUSE 100
    gOSUB Start_RTC
    PAUSE 900
    SEROUT PORTD.1,N2400,[27,"1"]
    PAUSE 50
    SEROUT PORTD.1,N2400,[27,"P",$80,"TIME :"]
    MAIN:
    PORTD.2 = 1
    GOSUB RTC_Read
    PAUSE 100
    sEROUT PORTD.1,N2400,[27,"P",$C5]
    SEROUT PORTD.1,N2400,[27,"M",Seconds]
    GOTO MAIN

    Start_RTC:
    I2C_Adr_B=0
    I2CWRITE SDA,SCL,RTC,I2C_Adr_B,[0,0,0,0,0,0,0,16] 'Start RTC if you put a resistor and LED between the "SEC" pin and 5V it should start flash 1/s
    return

    RTC_Read:
    I2C_Adr_B=0
    I2CREAD SDA,SCL,RTC,I2C_Adr_B,[seconds,minutes, hours] ' in bcd code
    return
    END

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Maybe this will work?
    After you read the RTC.
    Code:
    SEC_T = seconds & $70
    SEC_T = SEC_T>>4
    Serout2 PORTC.6, 16572,["SEC_T  ",DEC SEC_T, $d, $a]
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default

    Good pickup there is no decoding the RTC output.
    The value displayed as it is shouldn't be the same every second though.

  4. #4
    Join Date
    Jan 2010
    Posts
    14


    Did you find this post helpful? Yes | No

    Question

    I don't why my second not counting...????.

  5. #5
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default

    There might be a hardware problem.

    I would try turning on the square wave output on the RTC chip (if it has one),
    Then you can see with an LED or scope that the chip is working at least.
    You'll have had to talk to it correctly to set the pulse as well.

Similar Threads

  1. PIC16F887 and DS1307
    By menta in forum General
    Replies: 21
    Last Post: - 29th September 2008, 17:05
  2. DS1307 12-hour mode with AM/PM divisor
    By JNOR07 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 30th August 2007, 13:26
  3. DS1307 on fire
    By brid0030 in forum General
    Replies: 6
    Last Post: - 25th November 2006, 02:44
  4. Connecting DS1307 to PIC16F877A
    By amindzo in forum General
    Replies: 4
    Last Post: - 8th September 2006, 14:11
  5. ds1307 from f877 to f452 not work
    By microkam in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th July 2005, 00:02

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