R-Engine-D
Chapter 4: Software
4-11
4.3.7
Other library functions
On-board supervisor MAX691 or LTC691
The watchdog timer offered by the MAX691 or LTC691 offers an excellent way to monitor improper
program execution. If the watchdog timer (
J9
) jumper is set, the function
hitwd()
must be called every 1.6
seconds of program execution. If this is not executed because of a run-time error, such as an infinite loop
or stalled interrupt service routine, a hardware reset will occur.
void hitwd
Arguments:
none
Return value:
none
Resets the supervisor timer for another 1.6 seconds.
void led
Arguments:
int ledd
Return value:
none
Turns the on-board LED on or off according to the value of
ledd
.
Real-Time Clock
The real-time clock can be used to keep track of real time. Backed up by a lithium-coin battery, the real
time clock can be accessed and programmed using two interface functions.
There is a common data structure used to access and use both interfaces.
typedef struct{
unsigned char sec1;
One second digit.
unsigned char sec10;
Ten second digit.
unsigned char min1;
One minute digit.
unsigned char min10;
Ten minute digit.
unsigned char hour1;
One hour digit.
unsigned char hour10;
Ten hour digit.
unsigned char day1;
One day digit.
unsigned char day10;
Ten day digit.
unsigned char mon1;
One month digit.
unsigned char mon10;
Ten month digit.
unsigned char year1;
One year digit.
unsigned char year10;
Ten year digit.
unsigned char wk;
Day of the week.
} TIM;
int rtc_rd
Arguments:
TIM *r
Return value:
int error_code
This function places the current value of the real time clock within the argument
r
structure. The structure
should be allocated by the user. This function returns 0 on success and returns 1 in case of error, such as
the clock failing to respond.
int rtc_rds
Arguments: char* realTime
Return value:
int error_code