Milliseconds - is a variable/constant (0-65535) which specifies how many milliseconds to pause (at 8MHz on X2 parts, 4MHz on all other parts)
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 and setintflags commands 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.
Flash an LED
Turn an LED on and off with a 5 second interval
Pause for 5 minutes using the pause command
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.
Submit Your Own Code!
You must be logged in to submit code examples. Login now.