Connecting DS1307 to PIC16F877A


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2006
    Location
    Iran
    Posts
    94

    Default Connecting DS1307 to PIC16F877A

    Hi,
    I have connected DS1307 to PIC16F877A.sometimes it works.
    sometimes i can see the correct time and calender on lcd and sometimes
    not . when i reset the microcontroller for many times , eventually it works in one of resets.
    could you help me with this problem?

    i use micro code studio picbasic pro2.41

    this is my program:

    define OSC 4
    include"modedefs.bas"
    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTD
    DEFINE LCD_RSBIT 1
    DEFINE LCD_EREG PORTD
    DEFINE LCD_EBIT 0
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    pause 100
    TRISC= %11111111
    SDA var PORTC.0
    SCL var PORTC.1
    DB0 var byte[8]
    CMCON = %00000111 ' Comparators = off
    pause 1000
    gosub write_1307
    read_1307:
    ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
    I2CREAD SDA,SCL,$D1,$00,[STR DB0\8] ' Read 8 bytes from DS1307


    lcdout $fe,1,"Time=",hex2 DB0[2],":",hex2 DB0[1]
    pause 2000
    goto read_1307
    end

    Write_1307:
    ' Set time & date to 21:58:00 Tuesday 6th of July 2004
    I2CWRITE SDA,SCL,$D0,$00,[$00,$58,$21,$2,$6,$7,$4,$90] ' Write to DS1307
    pause 10
    RETURN ' Sec Min Hr Day D M Y Control

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    how about...
    Code:
    Lcdout $fe,1,"Time=",hex2 DB0(2),":",hex2 DB0(1)
    i know i saw that here somewhere... using parenthesis instead of bracket.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Aug 2006
    Location
    Iran
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Hi,
    i did that but i have a same problem.
    what should i do?

  4. #4
    Join Date
    Aug 2005
    Posts
    95


    Did you find this post helpful? Yes | No

    Default

    Do you have a backup battery connected to the DS1307. I used the DS1302 and because I did not have a battery connected to the chip, the battery backup terminal on the DS1302 would just float causing eratic startup problems, according to the data sheet the battery backup terminal needs to be grounded if a backup battery is not used.

    Hope it helps Sphere..

  5. #5
    Join Date
    Aug 2006
    Location
    Iran
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Hi,
    thanks everybody
    by connecting battery my problem is solved

Similar Threads

  1. connecting NH3 and CO sensors to PIC16F877A
    By amindzo in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th September 2008, 22:27
  2. communicating pic18f452 with pic16f877a
    By tamersoss in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th July 2007, 20:54
  3. DS1307 on fire
    By brid0030 in forum General
    Replies: 6
    Last Post: - 25th November 2006, 03:44
  4. connecting pic16F877A to pc via max232
    By zikha in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 12th January 2006, 16:31
  5. PIC16F877A to DS1307
    By miniman in forum Schematics
    Replies: 1
    Last Post: - 31st January 2005, 23:25

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