Show Posts
Pages: [1]
1  International / Scandinavia / Re: Söker Arduino användare i Södermanland on: March 03, 2012, 10:09:32 am
Fortfarande i behov av hjälp?
Jag kanske kan hjälpa till.
2  Forum 2005-2010 (read only) / Development / Issue with DS1307RTC.h - library for DS1307 RTC on: April 08, 2010, 10:29:13 am
I'm fairly new to the whole Arduino scene but i have done progamming before.

I seem to be having an issue with the DS1307RTC library.

I always like to check for things to make sure they worked so i started everything up without attaching the RTC and i noticed this fault where the time library thinks that it is synced ok even though there is no RTC connected.

If i'm understanding everything correctly the following occur.

in DS1307RTC.cpp
  • RTC.get is called from time.
It declares tm as a tmElements_t
read(tm) is called
a transmission is started to the wire for the RTC chip
the RTC pointer is set at 0x00
the transmission ends
a request is made for 7 bytes of data (i haven't fount where the 7 comes from yet smiley
then the data is recived and put into the supplied tm
read(tm) ends and we return to get()
get sends tm trough makeTime() and the result is returned.

The issue is that expects the data to be returned without actually checking if any data has been returned.
tm is returned full with zeroes and since makeTime() makes the unixtime based on jan 1st 1970 ? witch is more than 0 the function to check if time has been set fails in the below bold code.

 if(nextSyncTime <= sysTime){
      if(getTimePtr != 0){
        time_t t = getTimePtr();
      if( t != 0) // <== Fail here :)
        Status = (Status == timeNotSet) ?  timeNotSet : timeNeedsSync;        

I haven't gotten around to fully understand everything of the coding so i apologize if i have this all wrong.

The two solutions i can think of is either
1. make sure the notices that the rtc is not connected and make RTC.get return 0
2. only accept time set bigger than makeTime() return from a call with tm full of only zeros
2. see no 1 ? :-[ ( I noticed y2kYearToTm() is used in, this adds 30 to the year, so it is not all 0's being passed to makeTime() )
Pages: [1]