I use either a costate or a blocking function, depending on the circumstance, for millisecond (ms) delays. Preferably the multitasking costate so that other processing can happen during the wait:
Code:
costate progress_Task always_on {
while (updating) { // update the bar graph until the update reboots
waitfor (DelayMs(100));
hBar (3, 0, 159, 0.0, 10000.0, (float) progress);
}
}
Code:
/* START FUNCTION DESCRIPTION **************************************************
delay_ms <DCS2_IO.LIB>
SYNTAX: void delay_ms (long dur);
DESCRIPTION: Delay loop
PARAMETER1: long dur - number of milliseconds to delay
RETURN VALUE: None
END DESCRIPTION ***************************************************************/
__nodebug void delay_ms (long dur) {
int i;
int n =0;
while (dur--)
for (i=0; i<200; i++)
n ^= i;
}
The loop length is already tuned for the clock speed of an RCM6750.