User’s Manual
245
Two library functions are provided to read and write the real-time clock:
unsigned long int read_rtc(void) ; // read bits 15-46 rtc
void write_rtc(unsigned long int time) ; // write bits 15-46
// note: bits 0-14 and bit 47 are zeroed
However, it is not intended that the real-time clock be read and written frequently. The
procedure to read it is lengthy and has an uncertain execution time. The procedure for
writing the clock is even more complicated. Instead, Dynamic C software maintains a long
variable
SEC_TIMER
in memory.
SEC_TIMER
is synchronized with the real-time clock
when the Virtual Driver starts, and updated every second by the periodic interrupt. It may
be read or written directly by the user’s programs. Since
SEC_TIMER
is driven by the
same oscillator as the real-time clock there is no relative gain or loss of time between the
two. A millisecond timer variable,
MS_TIMER
, is also maintained by the Virtual Driver.
Two utility routines are provided that can be used to convert times between the traditional
format (10-Jan-2000 17:34:12) and the seconds since 1-Jan-1980 format.
// converts time structure to seconds
unsigned long mktime(struct tm *timeptr);
// seconds to structure
unsigned int mktm(struct tm *timeptr, unsigned long time);
The format of the structure used is the following
struct tm {
char tm_sec; // seconds 0-59
char tm_min; // 0-59
char tm_hour; // 0-59
char tm_mday; // 1-31
char tm_mon; // 1-12
char tm_year; // 00-150 (1900-2050)
char tm_wday; // 0-6 0==sunday
};
The day of the week is not used to compute the long seconds, but it is generated when
computing from long seconds to the structure. A utility program,
setclock.c
, is avail-
able to set the date and time in the real-time clock from the Dynamic C
STDIO
console.
Summary of Contents for Rabbit 2000
Page 2: ...Rabbit 3000 Microprocessor User s Manual 019 0108 040731 O ...
Page 9: ...Rabbit 3000 Microprocessor ...
Page 29: ...20 Rabbit 3000 Microprocessor ...
Page 64: ...User s Manual 55 5 PIN ASSIGNMENTS AND FUNCTIONS ...
Page 79: ...70 Rabbit 3000 Microprocessor ...
Page 80: ...User s Manual 71 6 RABBIT INTERNAL I O REGISTERS ...
Page 123: ...114 Rabbit 3000 Microprocessor ...
Page 137: ...128 Rabbit 3000 Microprocessor ...
Page 157: ...148 Rabbit 3000 Microprocessor ...
Page 207: ...198 Rabbit 3000 Microprocessor ...
Page 249: ...240 Rabbit 3000 Microprocessor ...
Page 255: ...246 Rabbit 3000 Microprocessor ...
Page 277: ...268 Rabbit 3000 Microprocessor ...
Page 343: ...334 Rabbit 3000 Microprocessor ...
Page 345: ......