clock_init(call_ms, call_tenth)
: Initialize the clock, give pointers to your callback functions.
clock_string(buffer)
: Get clock as string. Formats like "22:00:00" (8 chars + zero).
clock_set(string)
: Get clock as string. Format like "22:00:00" (8 chars + zero).
clock_bin_get(string)
: Get binary values for day, hour, minute, second (4 bytes).
clock_bin_set(string)
: Set binary values for day, hour, minute, second (4 bytes).
clock_trim(large, small)
: Set clock trim. large +/- (0.4%), fine +/- (0.1%)
clock_trim(large, small)
function can help you get the system
clock more accurate. The large adjustment changes the TIMER4 counter and
the small (fine) adjustment adds or subtracts milliseconds once every second.
The RC oscillator is pretty good, but the hourly or daily drift can be
very large.
#include "lib_clock.h"
void timer_ms(void); /* millisecond timer call */
void timer_10(void); /* 1/10 second timer call */
char time_tenths; /* tenth second counter */
int main()
{
/* do board setup first */
clock_init(timer_ms, timer_10);
/* rest of main() code */
}
/* Millisecond timer callback */
void timer_ms(void)
{
/* do polling or whatever */
}
/* 1/10 second timer callback */
void timer_10(void)
{
time_tenths++;
}