Re: need a prog to pause
- From: pete@xxxxxxxxxxxxxxxxxx
- Date: Fri, 31 Mar 2006 05:47:04 +0000 (UTC)
In article <1143760671.529096.172690@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
opster81@xxxxxxxxxxx "bob" writes:
I need a C prog. made with MS C/C++ 7.0 running on DOS to sleep for
about 0.25s. How can I do this in the C code? I don't want to use
scripts. I couldn't find any functions to do what I want in the
reference manual that came with MS C/C++ 7.0. Any ideas.
C knows nothing of the underlying timekeeping system, so you have
to roll your own. Assuming you are running under pure DOS (all
bets are off if you're running under Windows) the simplest way
that comes to mind is to count about 5 clock ticks of the timer
that lives at address 0000:046Ch in the BDA (which updates approx
18 times a second). Something like this (untested):
#define CLOCK *(unsigned short far *)0x46Ch
void pause (unsigned short ticks)
{
unsigned short temp = CLOCK;
++ticks; // allow for partial tick on first read
while (ticks)
{
if (temp != CLOCK)
{
--ticks;
temp = CLOCK;
}
}
}
So pause(4) or pause(5) should delay around a quarter of a second.
The problem I'm having is that a new PC is reading values from a
microcontroller via a serial port. It reads as fast as the
microcontroller can in a never ending loop to update a monitor display.
However in about an hour the PC overwrites some values on the
microcontroller. I'm hoping by putting a pause in the loop, I might
avoid this overwrite.
Hang on. you're *reading* from the microcontroller yet the PC is
*overwriting* values there? Something wrong there, or you
haven't described fully what you're doing. And it seems to me
rather unlikely that programming a "dead" pause in the receiver
will do what you want (unless your serial I/O is interrupt driven
that is).
Do tell us more...
Pete
--
"We have not inherited the earth from our ancestors,
we have borrowed it from our descendants."
.
- Follow-Ups:
- Re: need a prog to pause
- From: bob
- Re: need a prog to pause
- References:
- need a prog to pause
- From: bob
- need a prog to pause
- Prev by Date: need a prog to pause
- Next by Date: Reading old backup
- Previous by thread: need a prog to pause
- Next by thread: Re: need a prog to pause
- Index(es):
Relevant Pages
|