Home/Support/Support Forum/Is there a sleep function in dynamic C?
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Is there a sleep function in dynamic C?

0 votes
I used the below loop to do a blocking delay for a couple of hundred milliseconds. Is there a single function (like "sleep") that can do this?

delay = 200;
start_time = MS_TIMER;
while (MS_TIMER - start_time < delay);
// Continue

Thank you,
David
asked May 31, 2016 in Rabbit Software by phungd New to the Community (3 points)

Please log in or register to answer this question.

1 Answer

+1 vote
Yes, DelayMS / DelaySec / DelayTicks

(From the Function Reference)
DelayMs
int DelayMs( long delayms );
DESCRIPTION
Millisecond time mechanism for the costatement waitfor constructs. The initial call to this
function starts the timing. The function returns zero and continues to return zero until the number
of milliseconds specified has passed.
Note that milliseconds timing starts immediately, without waiting for the current millisecond to
elapse. In the case that the current millisecond is just about to end, the perceived elapsed time may
be as much as 1 millisecond shorter than the requested delay.
PARAMETERS
delayms The number of milliseconds to wait.
RETURN VALUE
1: The specified number of milliseconds have elapsed.
0: The specified number of milliseconds have not elapsed.
LIBRARY
COSTATE.LIB
answered Jun 1, 2016 by Martin.work New to the Community (4 points)
...