Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!gatech!udel!rochester!pt!b.gp.cs.cmu.edu!ralf
From: ralf@b.gp.cs.cmu.edu (Ralf Brown)
Newsgroups: comp.sys.ibm.pc
Subject: Re: millisecond timing
Message-ID: <62@b.gp.cs.cmu.edu>
Date: Tue, 14-Jul-87 22:49:06 EDT
Article-I.D.: b.62
Posted: Tue Jul 14 22:49:06 1987
Date-Received: Fri, 17-Jul-87 01:55:21 EDT
References: <4343@jade.BERKELEY.EDU>
Organization: Carnegie-Mellon University, CS/RI
Lines: 35
Summary: Clock-speed-independent timing loops are possible

In article <4343@jade.BERKELEY.EDU> izumi@violet.berkeley.edu () writes:
>Someone recently asked about ways to do timings with 1 millisecond
>accuracy on an XT or compatibles.  Here's what I think is possible.
...
>Now, if you MUST use XT or compatibles, and want to do it without timing
>loops which is affected by the CPU clock frequency, you will have to 
>add an plug in adapter card which has a timer or hardware interrupt 
>circuitry on it. [...]

It is possible to get timing loops which are independent of CPU speed (well,
almost--they can't handle changing clock speed in the middle).  Turbo Pascal
does this to get the DELAY function to work regardless of clock speed, and
be pretty close to exact.  The trick is to run a timing loop for exactly
the interval between two clock ticks, and count the number of times through
the loop.  Divide by 55.nnn to get the number of times through the loop for a 
1-millisecond delay.

In pseudocode,
	take over clock interrupt
	at next clock tick, start timing loop
	at next clock tick, end timing loop
	restore clock interrupt
	see how many times we made it through the loop

Hope this helps!


	
-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
ARPA:  RALF@B.GP.CS.CMU.EDU               USnail: Ralf Brown
AT&T:  (412) 268-3053 (school)                    Computer Science Department
                                                  Carnegie-Mellon University
DISCLAIMER?  Who ever said I claimed anything?    Pittsburgh, PA 15213
"I do not fear computers.  I fear the lack of them..." -- Isaac Asimov