PIC16F887 and DS1307


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Posts
    84

    Default PIC16F887 and DS1307

    I've been reading all posts here regarding the DS1307 RTC, but I really can't get it to work.
    I just get the value '0' when trying to read it.
    Is soething in my code is wrong ?

    Code:
    	RTCSec var byte		' Seconds
    	RTCMin var byte		' Minutes
    	RTCHour var byte	' Hours
    	RTCWDay var byte	' Weekday
    	RTCDay var byte		' Day
    	RTCMonth var byte	' Months
    	RTCYear var byte	' Year
    	RTCCtrl var byte	' Control 
    	SetTime var byte	' 12/24 Hour Clock
    	SetSec var byte		' Seconds
    	SetMin var byte		' Minutes
    	SetHour var byte	' Hours
    	SetDay var byte		' Day
    	SetMonth var byte	' Months
    	SetYear var byte	' Year
    	TimeOut var word	' Variable for SetUp Menu Time-Out
    RTCSec=1
    RTCMin=4
    
    I2CWRITE PORTC.4,PORTC.3,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCYear,RTCCtrl]
    pause 100
    main:
    I2CRead PORTC.4,PORTC.3,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCYear,RTCCtrl]
    SEROUT PORTC.6,6,[254,1]
    toggle PORTD.7 : pause 1000
    SEROUT PORTC.6,6,[254,128,#RTCSec]
    pause 1000
    goto main

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by menta View Post
    I've been reading all posts here regarding the DS1307 RTC, but I really can't get it to work.
    I just get the value '0' when trying to read it.
    Is soething in my code is wrong ?
    A quick search on DS1307 will get you a long way. But since your SEARCH function seems to be broken, I'll show you use mine.
    http://rentron.com/PicBasic/SERLED.htm
    No, this code isn't 100% perfect for what you need, but I'll bet ANYTHING that you can easily modify for your purposes.

    And besides, why are you trying to set the same time that you're trying to read?
    If the set time is zero and the read time is zero, then it seems to me that your program, if that is the whole program, is working correctly.

    Got any pullups on the I2C lines?
    Last edited by skimask; - 26th June 2008 at 20:02.

  3. #3
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Well, i write the time, then I keep reading it, isn't it suppose to be chance every second when I keep reading it ?
    pullups, you mean resistors ? I tried, then I only got 16 or 32 instead of 0

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by menta View Post
    Well, i write the time, then I keep reading it, isn't it suppose to be chance every second when I keep reading it ?
    I don't know if it's supposed to chance every second, but if the clock is running, it may change every second.

    pullups, you mean resistors ? I tried, then I only got 16 or 32 instead of 0
    Complete this sentence:
    The value of my resistors connected to +5v and to the I2C clock and data line is __________."

  5. #5
    Join Date
    Jun 2008
    Posts
    84


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    The value of my resistors connected to +5v and to the I2C clock and data line is ____10k____."
    ..........

  6. #6


    Did you find this post helpful? Yes | No

    Default rtc

    control register may need to be set

    alsoooooo....
    the I2c read and write address/control string have to be different, I just used binary 00011110 (just an example) to make sure the read write is correctly coded.

    don
    Last edited by amgen; - 28th June 2008 at 00:07.

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