Pages: [1]   Go Down
Author Topic: ds3234 routine walkthrough and eeprom store  (Read 797 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First post so sorry for the ignorance.   smiley-sweat

I have a couple projects where I'm using the ds3234 for a RTC.  I can set the time and display it fine using the sparkfun code.
I have modified it slightly so I can manipulate the data individually.  This function, I would call to simply get the "minutes" data.

Code:
String ReadMin(){
        String tempTime;       // I added these
        String mn_time;         // minutes data returned to caller

// this is the original source routine for getting all the time/date info
int TimeDate [7]; //second,minute,hour,null,day,month,year
for(int i=0; i<=6;i++){
if(i==3)
i++;
digitalWrite(cs, LOW);
SPI.transfer(i+0x00);
unsigned int n = SPI.transfer(0x00);       
digitalWrite(cs, HIGH);
int a=n & B00001111;   
if(i==2){
int b=(n & B00110000)>>4; //24 hour mode
if(b==B00000010)
b=20;       
else if(b==B00000001)
b=10;
TimeDate[i]=a+b;
}
else if(i==4){
int b=(n & B00110000)>>4;
TimeDate[i]=a+b*10;
}
else if(i==5){
int b=(n & B00010000)>>4;
TimeDate[i]=a+b*10;
}
else if(i==6){
int b=(n & B11110000)>>4;
TimeDate[i]=a+b*10;
}
else{
int b=(n & B01110000)>>4;
TimeDate[i]=a+b*10;
}
}
        tempTime.concat(TimeDate[2]);
        tempTime.concat(":");
        tempTime.concat(TimeDate[1]);
        tempTime.concat(":");
        tempTime.concat(TimeDate[0]);

        mn_time = TimeDate[1]; 
        return(mn_time); 
}

The troubles I'm having  are:
1.)  I don't really understand what the routine is actually "doing".  I can tell it's some bitwise work but I don't follow it.  For simple displaying of date/time, it doesn't matter.  I just know that (mn_time) and (tempTime) will be the strings I need. 
2.)  I'd like to write this info to EEPROM on my UNO but the strings are all larger than 1 byte, so how is the best way to write this data to eeprom?  Break it into multiples and just keep track of what info went to which address? or is there some simple routine for handling such conversions?

Thanks for the help.   smiley
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also, I'm interested in having an interval timer.  Something like, interrupt every 5 minutes, etc.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 221
Posts: 13848
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


check - http://arduino.cc/playground/Main/MsTimer2 -
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 632
Posts: 50182
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And ditch those Strings. You KNOW how much space is needed to hold a date or time in the format you want. Use a char array of that size, instead.
Logged

Pages: [1]   Go Up
Jump to: