Article View: comp.sys.ibm.pc.programmer
Article #379Re: programming timer 0
From: Thuan-Tit Ewe
Date: Thu, 03 May 1990 15:38
Date: Thu, 03 May 1990 15:38
37 lines
2121 bytes
2121 bytes
In article <90122.132954UNIVREL@AUVM.BITNET> UNIVREL@AUVM.BITNET writes:
>I am trying to time a function that executes in better than '1/100' of a
>second. I know how to program PC's timer 2, but i don't need its
>very high resolution. I understand there is a way of programming
>PC's timer 0 to obtain a resolution higher than that provided by the
>BIOS clock tick.
>
>I would appreciate any adivce from anyone with experience in programming
>IBM PC/XT/AT's timer 0.
>
>Sajjad Ahrabi`
Timer 0 is currenly programed to mode 3, (Square wave mode). You pretty
well can't read the counter and make use of it. The thing to do is to
reprogram the counter to mode 2, (Rate generator); this way when you
read the counter, you'll get a downward count from 64K. Along with
the BIOS counter in low memory, you'll get a very high resolution
timer.
Since you didn't mention what you wanted to do with the timer, I'll assume
that you may want to speed up the clock interrupt. To do this, program the
chip to a lower startup count, but make sure that it is multiple of 2,
therefore the chip will interrupt in multiples of 18.2 times a second. At this
point, keep an internal counter of the number of times the chip
interrupts before chaining to the original interrupt, thereby keeping the
correct time and everything else will be dandy.
Get the Intel Microsystem Components Handbook and read up on 8254, and
good luck. Thanks goes to Roger Cross of HyperWare for explaining the
subtleties of the chip to me when I was writing a profiler.
-thuan
---
Thuan-Tit Ewe MetaWare Inc
tte@metaware.com (408) 429-6382
{uunet|ucscc|acad}!metaware!tte
Technical Details
Message-ID:
<423@metaware.metaware.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!samsung!uunet!metaware!tteReferences:
<90122.132954UNIVREL@AUVM.BITNET>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!samsung!uunet!metaware!tte From: tte@metaware.metaware.com (Thuan-Tit Ewe) Newsgroups: comp.sys.ibm.pc.programmer Subject: Re: programming timer 0 Message-ID: <423@metaware.metaware.com> Date: 3 May 90 15:38:43 GMT References: <90122.132954UNIVREL@AUVM.BITNET> Reply-To: tte@metaware.UUCP (Thuan-Tit Ewe) Organization: Metaware Lines: 37