WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

RTC

Adds support for various real time clocks (RTC) as of Version 2.07.
Note: if you are using your clock and getting a value back but it's not changing then try setting the clock to a new value. This will often make it wake up !
Although your board has lots of timers they can normally only measure time relative to the moment that the board was powered up.
A real time clock adds the ability to track the calendar date and time. Normally they use a small lithium battery so that whilst your board is turned off they can continue to track the date and time. The date and time can be changed via software and you would certainly want to write a 'one-off' program to set the clock to an initial date and time.
All RTCs allow you to get the current date and time as follows (assuming you have called it myRTC):-
const DATE_TIME* t = rtcRead(&myRTC);
if(t){
    // This shows you how to access each field
    // PRINTF(stdout,"%02u/%02u/%04u %02u:%02u:%02u\r\n",
    //    t->date,    /* day of month 1-31 */
    //    t->month,   /* month number 1-23 */
    //    t->year,    /* year number */
    //    t->hours,   /* hour 0 - 23 */
    //    t->minutes, /* minutes 0-59 */
    //    t->seconds  /* seconds 0-59 */
    // );
    // Can be done more easily by just dumping....
    rtcDumpTo(stdout,myRTC);
}else{
    PRINTF(stdout,"Is your RTC plugged in?\r\n");
}
Of course, at some stage, you will need to program the RTC with the actual date and time. This can be done, assuming your device is called myRTC, using:
rtcSet(&myRTC, 2011,7,24, 21,02,00);  // Set time to 9:02:00pm on 24 July 2011
The following real time clocks are supported:-

 

File

 

Valid XHTML 1.0 Transitional