Time delay loop less than 1ms

C

Craig Williamson

I'm trying to write a time delay loop in Borland C 3.1 (for legacy
code) which has an accuracy of about 0.1ms. This change is due to a
hardware change and the software is now running too fast to take
proper readings. I have been using delay(1) in the past but it does
not have the accuracy that I need for this situation. Does anyone
know of a useful C function which can be used to create the time
delay? If anyone could help that would be greatly appreciated.
Cheers and good luck :).
 
W

Walter Roberson

I'm trying to write a time delay loop in Borland C 3.1 (for legacy
code) which has an accuracy of about 0.1ms. This change is due to a
hardware change and the software is now running too fast to take
proper readings. I have been using delay(1) in the past but it does
not have the accuracy that I need for this situation. Does anyone
know of a useful C function which can be used to create the time
delay? If anyone could help that would be greatly appreciated.

Sorry, no portable way. See

http://c-faq.com/osdep/subsecond.html
 
J

jacob navia

Craig said:
I'm trying to write a time delay loop in Borland C 3.1 (for legacy
code) which has an accuracy of about 0.1ms. This change is due to a
hardware change and the software is now running too fast to take
proper readings. I have been using delay(1) in the past but it does
not have the accuracy that I need for this situation. Does anyone
know of a useful C function which can be used to create the time
delay? If anyone could help that would be greatly appreciated.
Cheers and good luck :).

Use some of the timing functions in windows. I do not remember if
GetTickCount() was already there in 16 bits windows but you could
try that one.
 
B

Bartc

jacob navia said:
Use some of the timing functions in windows. I do not remember if
GetTickCount() was already there in 16 bits windows but you could
try that one.

Gettickcount returns milliseconds, and may have an accuracy coarser than
that.

But if the OP is trying to slow down software, there are plenty of ways!
Although getting a delay consistent across machines, and with different
machine loading, is not so easy.
 
J

jacob navia

Bartc said:
Gettickcount returns milliseconds, and may have an accuracy coarser than
that.

But if the OP is trying to slow down software, there are plenty of ways!
Although getting a delay consistent across machines, and with different
machine loading, is not so easy.

There is Sleep(int miliseconds) too.
 
K

Keith Thompson

CBFalconer said:
Where? I don't find it in the C standard. Could you be making a
mistake and recommending functions that are not available, and thus
off-topic here? Give us the appropriate section and I will
apologize.

You could save yourself some typing, and the rest of us some boredom,
by just mentioning that Sleep is non-standard. The shtick about
challenging people to find things in the standard that obviously
aren't there is getting old, don't you think?
 
K

Keith Thompson

CBFalconer said:
The aim of that post (but probably hopeless) is to get Jacob to
realize what is and is not on-topic here.

Understood. My statement above stands.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top