Re: need a prog to pause



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."
.



Relevant Pages

  • Re: Need help in converting YUV to RGB using OV7620
    ... PCLK at 5Mhz. ... Firstly you have NOT checked that your microcontroller can accept data ... ONE clock edge, whilst UV is clocked out at 10MHz by using the rising ... work either on BOTH edges of the PCLK signal or to two ports that can ...
    (comp.arch.embedded)
  • Re: Help me solve this design problem PLEEEZ
    ... any single chip microcontroller could handle the job - the ... >> clock the microcontroller at 32.768kHz. ... which added with some logic gates allows the first timer to work ...
    (sci.electronics.design)
  • Re: async reset model too optimistic?
    ... module AsyncResetFlop(flopout, flopin, clr_bar, clock); ... assign flopout = temp; ... an undefined value should return 1'bx which is false and the reset ...
    (comp.lang.verilog)
  • Re: Help me solve this design problem PLEEEZ
    ... > that needs a 24-bit counter, for which you could use the LSI LS7166 ... any single chip microcontroller could handle the job - the ... > clock the microcontroller at 32.768kHz. ... which added with some logic gates allows the first timer to work ...
    (sci.electronics.design)
  • Re: Outdoor temperature sensor . . .`
    ... The clock has an "inside" temperature as well. ... somewhere else for the outside temp, and the sensor must be inside a house. ...
    (comp.home.automation)