Is there a sleep function in dynamic C?

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,

Yes, DelayMS / DelaySec / DelayTicks

(From the Function Reference)
int DelayMs( long delayms );
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.
delayms The number of milliseconds to wait.
1: The specified number of milliseconds have elapsed.
0: The specified number of milliseconds have not elapsed.

1 Like