Name:
pause
Syntax:

PAUSE milliseconds

Milliseconds - is a variable/constant (0-65535) which specifies how many milliseconds to pause (at 8MHz on X2 parts, 4MHz on all other parts)

Description:

Pause for some time.

The duration of the pause is as accurate as the resonator time-base, and presumes a 4MHz resonator (8MHz on X2 parts). The pause command creates a time delay (in milliseconds). The longest time delay possible is just over 65 seconds. To create a longer time delay (e.g. 5 minutes) use a for...next loop

for b1 = 1 to 5 ; 5 loops
pause 60000 ; wait 60 seconds
next b1  

During a pause the only way to react to inputs is via an interrupt (see the setint command for more information). Do not put long pauses within loops that are scanning for changing input conditions. When using time delays longer than 5 seconds it may be necessary to perform a hard reset to download a new program to the microcontroller.

During M2 part multi task programs the accuracy of pause is reduced due to the parallel processing. The minimum resolution is around 20ms in multi task programs. For greater accuracy use single task mode.

Effect of Increased Clock Speed:

The timebase is altered if the default frequency is altered, for instance running 4MHz parts at 8MHz will result in a pause half the expected length.

Applies To:
All
See Also:
Related Create:
    Share:
    Print:

    Flash an LED

    Turn an LED on and off with a 5 second interval

    Code Example:
    main:	high B.1	; switch on output B.1
    	pause 5000	; wait 5 seconds
    	low B.1		; switch off output B.1
    	pause 5000	; wait 5 seconds
    	goto main	; loop back to start
    Copy Code Submit an Example

    Long delays

    Pause for 5 minutes using the pause command

    Code Example:
    	for b1 = 1 to 5	; 5 loops
    	  pause 60000 	; wait 60 seconds
    	next b1
    Copy Code Submit an Example

    Flash a LED at random rates

    The following uses a randomised word variable to determine how long to delay before toggling a LED on output B.1 on and off. The 'w0' will select a random time between zero and 65535 milliseconds (approximately 65 seconds) to toggle the LED.

    Code Example:
    main:	random w0		; note random is repeatedly called within the loop
    	pause w0		; pause for a random amount of time
    	toggle B.1		; toggle the LED
    	goto main
    Copy Code Submit an Example

    Submit Your Own Code!

    You must be logged in to submit code examples. Login now.

    Comments

    • Login to leave a comment.