[net.micro.pc] "Real-time" clock on IBM PC

pls@ncsu.UUCP (Phillip L. Shaffer) (09/24/84)

Some time ago I tried to make use of the "unused" counter of the
Intel 8253 programmable interval timer as a real-time clock to
time operation of some programs on an IBM PC XT.  This is Channel 2
of the 8253, which is used for speaker tone generation (but the speaker
can be disabled).  I wanted times more accurate than the 18.2 ticks per
second given by the DOS time-of-day call.  I got a routine nearly
working that would give times to ~ 1 microsecond.  I say "nearly"
because occasionally an interrupt appeared to be lost (i.e. was not
responded to correctly), and the software part of the clock was
not incremented when the hardware counter rolled over.  I had done
similar programs on other computers, so I thought I knew what I was
doing, but could not get the thing to work - it was very erratic as
to how often an interrupt was lost.  I finally gave up and used an
outboard real-time clock (not having the funds to buy a plug-in board
for the PC).  I saw some mention on the net that some PC's have flakey
interrupts, and figured that might be the cause of my problems.

I have recently been running these programs, which are very computationally-
intensive, and use the 8087 co-processor, and find that during a program
run, the system clock is losing a tremendous amount of time.  For
example, a program recently took about 12.3 minutes to run; during that
time, the system clock lost about 4.5 minutes: the clock ran 36% slow!
Flakey interrupts are one thing, but that's wholesale desertion!

Has anyone had similar experiences?  Is this a correctable defect, or
something I have to live with?  Has anyone written a reliable RTC
routine using 8253 channel 2?  Please reply by mail - I'll summarize
any interesting contributions to the net.  Many thanks.

Phil Shaffer (pls@ecsvax) {decvax!mcnc!ecsvax!pls}
North Carolina State University