From: Phil Ehrens Newsgroups: comp.os.msdos.djgpp Subject: Re: High speed timing Date: 29 Jan 1998 19:47:00 -0700 Organization: imbe.foo.bar Lines: 27 Message-ID: <34D141EB.4BEBB1C8@primenet.com> References: <34D11CA2 DOT 79CD AT bellsouth DOT net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Lester Davis wrote: > > What is the best way to get a time value between events. I'm getting > ready to interface a sonar system to a pc and need to measure time of > flight of the sonar. I don't want to use a simple counter. I'm sure > there is a function that does what I need, any ideas? The Linux port programming howto suggests 2 different ways to get a VERY fast loop: 1. use a read from port 0x80, which is unused. I use this with my high speed data-acquisiton programs (which use Allegro for the video, it's VEEERY fast!!) and get about two inp(0x080)'s per microsecond. 2. use an inline assembly line that just executes a NOP. this should take one processor clock cycle, I haven't tried this cuz the port 0x80 loop works fine for me (looping a data-acquisiton and pixel draw at 100 kHz). so see the "ports" howto! (I know I am being a little disingenuous, but all my notes on this are at work, and a quick web search just now makes me think this document was just a part of my overactive imagination!) if you need more help, e-mail me and I will send you a code fragment tomorrow! ( with the port 0x80 code and the inline assembly code). Phil