From: Rob Sacks (editor_at_realization.org)
Date: 2001-08-09 09:45:19
Hi Joerg,
> That will not be needed since I redesigend
> the hardware so that the timer is triggered
> by the PC software.
Great idea. Does your clock still control
the time when the measurement is taken (as
opposed to when the pulse is generated)?
(Maybe this is a good idea because the
intervals will be more accurate with your
clock than the PC -- see timing results below.)
> With the above mentioned trigger technic,
> the first 0.8usec inaccuracy could be eliminated.
> So the total resolution would be 0.8 usec.
> That would be enough for 10 bit.
If the polling loop is eliminated, could you
expand the length of the pulse duration?
Doubling the length to a maximum of 2 ms
would add a bit to the resolution, wouldn't it?
> > The timer for scheduling (invoking code) uses
> > intervals that are integral numbers of milliseconds:
> > 1 ms, 2 ms, 3 ms, etc. = 1000 Hz, 500 Hz, etc.
> > The max resolution is 1 ms. I posted test results
> > yesterday showing the accuracy of it.
>
> Where did you post the results ?
Here they are again. The timer was set to
invoke my code at intervals of 8 ms. Here are
the actual intervals as measured by the .8 ms
counter:
> 7.99125 ms
> 7.96946 ms
> 7.97616 ms
> 8.00634 ms
> 7.99125 ms
> 7.99712 ms
> 8.00717 ms
> 7.99293 ms
> 8.00634 ms
> 7.98874 ms
> 7.99796 ms
> 8.03316 ms
> 7.96695 ms
> 8.03148 ms
> 7.96527 ms
> 7.99796 ms
> etc.
>
> > There's also a "counter" for measuring intervals.
> > On Intel CPUs the resolution is .8 usec.
>
> That is the old PIT timer counter.
> On Pentium class machines (and Athlon ) something much
> better exists:
> A 64 bit counter clocked with the internal CPU speed.
> This counter can be read with the
> RDTSC opcode (see appendix).
I mistakenly believed the .8 usec Windows timer has the
same resolution as the CPU counter. Thanks for
correcting me.
But I think, actually, the .8 usec Windows timer is built on
the RDTSC instruction. Maybe Windows reports the
result with partial resolution so the units will be uniform
on all x86 systems? (Windows reports the result as
a 64-bit number.) If I remember correctly, the old timer
chip has a maximum resolution of 1/64k second (but I haven't
done that kind of programming in 15 years so my memory
is suspect).
One comment about the code you attached -- I just
checked the Intel documentation about RDTSC (I didn't
know anything about it until you told me). Intel says
this kind of code should contain a CPUID instruction
before the RDTSC to force all preceding instructions
to complete. Otherwise the code can execute out-of-order
and spoil the timing results.
Regards,
Rob
This archive was generated by hypermail 2.1.4 : 2002-07-27 12:28:32 BST