PAUSEUS |
PAUSEUS Value
PAUSEUS ByteVal1 {[, | *] ByteVal2}
Function
Pause the program (do nothing) for a number of microseconds.
† Note: Fractional values (0.01 to 65535.99) are allowed when a single constant parameter is used. SX clock speed will affect the accuracy of fractional timing.
Explanation
PAUSE delays the execution of the next program instruction for a
number of microseconds based on Value, or ByteVal1 and
ByteVal2. For example:
Tone: RC.0 = ~RC.0 PAUSEUS 500 IF RB.0 = 1 THEN Tone
This code toggles the state of RC.0 every 500 microseconds, creating a 1 kHz tone until pin RB.0 goes low. Note that a PAUSEUS duration of up to 65535 microseconds is possible when a single constant parameter is used.
Some projects may require sub- or fractional-microsecond delays. When using a single parameter, a fractional PAUSEUS value may be specified:
Tone440: DO RC.0 = ~RC.0 PAUSEUS 1136.36 LOOP
PAUSEUS can take a single byte or word parameter, or two byte parameters. When using two byte parameters, two forms are allowed. Here's an example of the first form:
PAUSEUS 238, 2
Using this form, the PAUSEUS duration is ByteVal1 + (ByteVal2 * 256). In the example above the program will pause for 750 microseconds. Note that this form is typically used with variables, but will also work with constants up to 255. Note that as of SX/B version 1.5 using a single word variable or constant is easier to code and understand.
The third form of PAUSEUS is demonstrated below:
idx = 3 PAUSEUS idx * 250
Using this form, the PAUSEUS duration is ByteVal1 * ByteVal2. In the example above the program will pause for 750 microseconds. Note that this form is typically used with variables, but will also work with constants up to 255.
Related instruction: PAUSE