DS1307 returns incorrect data ???


Results 1 to 18 of 18

Threaded View

  1. #11
    sinoteq's Avatar
    sinoteq Guest


    Did you find this post helpful? Yes | No

    Default

    Sure is.
    But in your first example you did not write hex and then you only get 15 and not 21.

    I would start by just writing 0 to all locations and from there start to read the DS once every second. I would do this to make sure I have a routine that can read and display the data in a correct way. When I am sure this is working I would set the DS to a specific time and date and test again.

    You need the # in the serout function to convert the data in the variable to ASCII numbers. Without this you do not get nothing, you get a ASCII character that is difficult to detect but you do get something. Yes unless you send NUL

    Code:
    DS_CHECK:				I2C_Adr_B=0
    						I2CREAD SDA,SCL,RTC,I2C_Adr_B,[Seconds,Minutes,Hours]
    						t=Seconds &%00001111
    						Seconds.7=0
    						n=Seconds>>4
    						Seconds=(n*10)+t
    						I2C_Adr_B=0
    						t=Minutes &%00001111
    						n=Minutes>>4
    						Minutes=(n*10)+t
    						Hours=Hours &%00001111
    						System_Time=(Hours*3600)+(Minutes*60)+Seconds
    						DS_COUNT=0
    						RETURN
    This is one way to use the DS, maybe not the best and most code efficient but it works. Please note that it is only working to 9hours 59min 59 sec because I have not implemented the "10-hour" bit from the Hours register. The equipment I am using will never be on for more than a few hours and I am using the DS as a timer and not as a real RTC. I reset the RTC to 0 at startup.
    Last edited by sinoteq; - 6th October 2009 at 08:12.

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

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