Using real-time timers

Nathan Fiedler (nfiedler@aol.com)
Tue, 04 Jun 1996 07:20:23 -0700

Here is a question I had asked on CompuServe and Ed Ballot asnwered it
for me. Thought others might want to know:

Q: How do I set a real-time alarm using TimerStart?

A: TIMER_EVENT_REAL_TIME starts a real-time clock on the device that
will send a message at some particular date and time. You pass the date
that the event should happen in the "ticks" parameter and the time of
day in the "interval" parameter of TimerStart.

The date is stored in a compressed format that is word-sized. The year
(since 1980) is in the high 7 bits; the month is in the next 4 bits; and
the day is in the low 5-bits.

The hour is stored in the high byte of "interval" and the minute is
stored in the low byte of "interval.

For example, if I wanted to have a wakeup notification sent on March 5,
1996 at 8:05am, I would set up the "ticks" and "interval" parameter as
follows:

ticks = 0x2065;
(year = 1996-1980 = 16 = 0x10, 0x10 << 9 = 0x2000;
month = 3, 0x03 << 5 = 0x0060;
day = 5, 0x05 << 0 = 0x0005)

interval = 0x0805;

Hope that helps.

Answered by Ed Ballot