working RTC. Only set once then just use get.

Dependents:   finalV1 finalv2 finalv3

Fork of DS1307 by Philip Smith

Files at this revision

API Documentation at this revision

Comitter:
seedteam20
Date:
Wed Apr 22 16:37:51 2015 +0000
Parent:
0:c3e4da8feb10
Commit message:
asd

Changed in this revision

ds1307.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r c3e4da8feb10 -r 9702e2e4aef9 ds1307.cpp
--- a/ds1307.cpp	Sun Jun 24 22:09:35 2012 +0000
+++ b/ds1307.cpp	Wed Apr 22 16:37:51 2015 +0000
@@ -19,9 +19,9 @@
     if (quantity > DS1307_lastreg) return (1);  // fail because quantity greater then what can be read
     if ((addr + quantity) > DS1307_lastreg ) return (1);    // fail because cant read past reg 63
     if ( quantity == 0 ) return (1);    // fail because zero quantity wanted
-    temp_data[0] = DS1307_lastreg ;  // note this ram location is used to set the addressing pointer in DS1307
+    temp_data[0] =  0 ; //DS1307_lastreg ;  // note this ram location is used to set the addressing pointer in DS1307
     temp_data[1] = 0;    // just junk to clober this address with
-    test = ds1307i2c.write(DS1307_addr,temp_data,2);
+    test = ds1307i2c.write(DS1307_addr,temp_data,1);
     if (test == 1) return (1);  // the write operation failed
     ds1307i2c.stop();   // now the DS1307 is pointing to the first register
     if ( addr != 0 ) test = ds1307i2c.read(DS1307_addr,temp_data,addr);  // now the DS1307 address pointer is pointing to correct address
@@ -218,12 +218,17 @@
     // sec = 0 to 59, min = 0 to 59, hours = 0 to 23 ( 24 hour mode only ), day = 1 to 7 ( day of week ), date = 1 to 31, month = 1 to 12, year 0 to 99 ( this is for 2000 to 2099)
     if (1 == DS1307::read(DS1307_sec,sec)) return(1);       // failed to read for some reason
     *sec = (*sec & 0x7F );                                  // drop the clock start stop bit
-    *sec = DS1307::bcdtodec( *sec);                         // bcd is now dec value
-
+    *sec = DS1307::bcdtodec( *sec);                         // bcd is now dec value*/
+    
+    
+    
+    
     if (1 == DS1307::read(DS1307_min,min)) return(1);       // failed to read for some reason
     *min = (*min & 0x7F );                                  // drop bit 7 because it should be 0 anyways
     *min = DS1307::bcdtodec( *min);                         // bcd is now dec value
+    
 
+    
     if (1 == DS1307::read(DS1307_hour,hour)) return(1);     // failed to read for some reason
     if ((*hour & 0x40) == 0x40) {                           // if true then 12 hour mode is set currently  so change to 24 hour, read value, and return to 12 hour mode
         if (1 == DS1307::twentyfour_hour()) return(1);          // failed to set 24 hour mode for some reason