Example

  PAUSE Value
  PAUSE ByteVal1 {[, | *] ByteVal2}

Function
Pause the program (do nothing) for a number of milliseconds.

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 milliseconds based on Value, or ByteVal1 and ByteVal2. For example:

Flash:
  DO
    LOW RC.0
    PAUSE 1000
    HIGH RC.0
    PAUSE 1000
  LOOP

This code causes pin RC.0 to go low for 1000 milliseconds, then high for 1000 milliseconds. Note that a PAUSE duration of up to 65535 milliseconds is possible with a 16-bit variable or constant.

Some projects may require sub- or fractional-millisecond delays, and in some cases PAUSEUS may not be practical or desired. When using a single parameter, a fractional PAUSE value may be specified:

Flash:
  DO
    LOW RC.0
    PAUSE 12.5
    HIGH RC.0
    PAUSE 12.5
  LOOP

PAUSE 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:

  PAUSE 238, 2

Using this form, the PAUSE duration is ByteVal1 + (ByteVal2 * 256). In the example above the program will pause for 750 milliseconds. 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 PAUSE is demonstrated below:

  idx = 3
  PAUSE idx * 250

Using this form, the PAUSE duration is ByteVal1 * ByteVal2. In the example above the program will pause for 750 milliseconds. Note that this form is typically used with variables, but will also work with constants up to 255.


Related instruction: PAUSEUS