How to do timing in a VC++ windows program??
Roman Black email (remove spam text)
Alan B. Pearce wrote:
> >Does anyone have suggestions for references on timing methods, or
> >possibly switching over to doing a DLL, or does someone have any quick
> >advice on how to get through this brief emergency.
> I have programmed in VB3 on Win3.1 and know from bitter experience that the
> timer resolution is 55mS - despite being able to specify the time in 1mS steps.
> I assume VC is the same fort the same reason - it uses the standard tier
> hardware without reprogramming it.
> To do better than this you will need to have some sort of hardware timer card
> that will generate an interrupt at the time or rate you need. However do also be
> aware that if the time is too short (rate too fast) your program will not get
> anything useful done (unless you run on a very fast processor) because of the
> windows overhead.
Not so, the PC has a PIT (programmable interrupt timer
chip) that has ticks at 1.194MHz or abouts, this is
readable by accessing one port, and can be programmed
to give fine timing interrupts. And you don't even have
to program it, just read it's current tick value.
For my high res timing in my PC programs I just
read (and poll) the PIT ticks, this is non invasive
and with one simple port read and subtract you get
exact time delay. I did 3 years as a PC games graphics
programmer and lived by the PIT chip.
I still live by the PIT chip now in my C programs
that use the high res timing to control/measure data
from the parallel port. :o)
Just do a web search for "8086 PIT programming" or
something, should bring up some data.
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics
See also: www.piclist.com/techref/language/index.htm?key=c%2B%2B
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the