SCL Reference: wait Statement

A wait statement instructs SCL to stop executing instructions from the containing process.

SCL executes statements in a process until it encounters a wait statement. If the end of the process is encountered, SCL simply wraps to the beginning of the process and starts over. So every process must have at least one wait statement. Without it the process will perform an infinite loop and hang the simulator. Fortunately, the SCL parser detects processes without a wait statement, issues the following warning, and refuses to load.

SIM004: Failed to parse SCL SCL022: Process contains neither a wait statement nor a sensitivity list line(#)

There are 4 forms of the wait statement.

wait;                    //unadorned
wait on sensitivity;     //sensitivity wait
wait until condition;    //condition wait
wait for timeout;        //timeout wait

Unadorned Wait

The simplest form of wait is unadorned with no argument. It tells SCL to not only stop executing the process statements, but that the process is complete and is terminating.

process is
      wait;  // terminate the process now!
   end process;

Sensitivity Wait

The sensitivity wait statement waits for a value to change. There can be several types of values.

wait on RD1;          //wait on pin RD1 to change
wait on userVar;      //wait on a user var to change
wait on STATUS;       //wait on the STATUS SFR to change
wait on PORTD.RD0;    //wait on the RD0 bit of PORTD to change

Condition Wait

The condition wait statement waits for an expression to be true.

wait until PORTA == 128;          //wait until SFR PORTA equals 128 (0x80)
wait until RD1 == '1';            //wait until pin RD1 is high
wait until ADCON.ADON == '1';     //wait until field ADON in SFR ADCON is 1
wait until PC == 4;               //wait until PC is 4

Timeout Wait

The timeout wait statement waits for a specified amount of time.

wait for 10 ic;        //wait 10 instruction cycles
wait for 10 ms;        //wait 10 milliseconds

Combined wait

The timeout wait can be combined with either a sensitivity or condition wait. When used this way the timeout becomes a true timeout.

wait on RD1 for 10 ms;            //wait for pin RD1 to change or 10 ms to pass
wait until PC = 20 for 20 ic;     //wait until PC is 20 or for 20 instruction cycles
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.