Board index » delphi » micro sec?

micro sec?

is it possible in TP7 or ASM to measure micro seconds?

I already know how to measure mili seconds.

 

Re:micro sec?


Quote
Shy Shalom wrote:
> is it possible in TP7 or ASM to measure micro seconds?

Take a look at OpTimer from TurboPower:
ftp://ftp.turbopower.com/pub/oprotpro/optimer.lzh

  /Lars

l...@et-soft.dkX   (remove the X manually before emailing me)

Re:micro sec?


JRS:  In article <7o5dce$l3...@news.inet.tele.dk> of Tue, 3 Aug 1999
02:33:12 in news:comp.lang.pascal.borland, Lars Ladingkaer <larl@et-

Quote
soft.dkX> wrote:
>Shy Shalom wrote:
>> is it possible in TP7 or ASM to measure micro seconds?

>Take a look at OpTimer from TurboPower:
>ftp://ftp.turbopower.com/pub/oprotpro/optimer.lzh

And The Timing FAQ,  ftp://garbo.uwasa.fi/pc/programming/pctim003.zip

--
 ? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
  <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c. FAQqish topics, links.
  Timo's TurboPascal <A HREF="ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip">FAQ</A>.
  <A HREF="http://www.merlyn.demon.co.uk/clpb-faq.txt">Mini-FAQ</A> of c.l.p.b.

Re:micro sec?


Hi Alexander,

I'm quite interested to know how to achieve true millisecond accuracy (or
better I suppose if possible). Unfortunately, I'm not up on register codes
etc. and things tend to go awry when I go to use them. Would you mind
explaining why any special procedures are needed in the first place (timer
ticks?) and further, would you mind embedding solution 1 quoted below into a
simple program that returns the time (accurately) between say two
keypresses? Thanks in advance.

As a bit of an aside, can anyone steer me to a FAQ or any other source for a
beginners guide to register codes in TP?
Robert

Quote
Alexander Sheveraev <go...@aquanet.co.il> wrote in message

news:935527853.664191@cache.aquanet.co.il...
Quote
> In article <7o53qq$d...@news.netvision.net.il>, "Shy Shalom"
<shysa...@netvision.net.il> wrote:
> >is it possible in TP7 or ASM to measure micro seconds?

> >I already know how to measure mili seconds.

> You probably don`t know how to measure milliseconds exactly, but to
> measure timer ticks, which occured 18.2 times per second, right?

> It is possible to achive more accuracy.
> It is possible using a PIT (Programmable Interval Timer).
> There are two ways:
> 1. To read PIT channel 0 counter.

>    PIT counter decreases all the time, when it reaches 0 irq0 (int8)
occurs
> and int8 handler increases time counter in BIOS data area.
> In the same time PIT counter loaded with initial value - usually 65536
> (really 0), and starts to decrease again and so on.

>    Simply store initial values of BIOS timer and PIT counter
> and when you need measure pasted time read current BIOS and counter
values.

> Pasted_time=(current_BIOS_timer - old_BIOS_timer)/18.2 +
(old_PIT_counter -
> current_PIT_counter) / 1193180.

> Note: In timer You substract old from current, and in counter You do vice
> versa because PIT counter is DECREASING.
> 1193180 is decreasing fequency.

>    How to read the values:
> BIOS timer is double word at 40h:6Ch
> Reading PIT is a bit harder.
> use following code:
> asm
>    mov     al,06h     ;select store current counter operation
>    cli                ;not sure if You really need it.
>    out     43h,al     ;PIT control register
>    in      al,40h     ;read low byte
>    mov     ah,al
>    in      al,40h     ;read hi byte
>    sti
>    xchg    al,ah      ;now AX contans counter value
>    mov     counter,ax ;store it
> end;

> 2. To program PIT channel 0 to higher frequency.

> This way is a bit more complicated.
> I hope first way is enough.
> If anyone interested i will explain.

> Sandman4

Re:micro sec?


Quote
Alexander Sheveraev (go...@aquanet.co.il) wrote:

:    PIT counter decreases all the time, when it reaches 0 irq0 (int8) occurs
: and int8 handler increases time counter in BIOS data area.

The PIT counter usually does this in decrements of 2 on most PC's
and does it twice for each of the 18.2 ticks per second,
so you have to check in which of the two runs you are,
or you must reprogram the PIT to an other mode where
it counts down in decrements of one.

Or simply use my htimers unit, it takes care of all this,
it's available for free on my homepage.

Klaus
--
Klaus Hartnegg, Institut fuer Biophysik, Hansa-Strasse 9a, D-79104 Freiburg
hartn...@uni-freiburg.de   http://www.brain.uni-freiburg.de/~klaus/

Other Threads