Start Back Next End
  
ZBasic System Library
217
ZBasic Microcontrollers
Pause
Type
Subroutine
Invocation
Pause(time)
Parameter
Method
Type
Description
time
ByVal
Single or int16
The amount of time to pause, in seconds
(Single) or ticks (int16)
Discussion
This routine suspends execution of the current task for approximately the period of time specified.  When
provided with an Int16 parameter, the units will be will be the period of the rate of change RTC timer
(1/F_RTC_TIMER or 4.34µS for most ZX devices) if the RTC is included in the application.  If the RTC is
not included the units are 1uS intervals.  The maximum pause duration is 65535 units
No other task is allowed to run during the pause period.  Note that the accuracy of the pause may be
affected by the time required for the processor to service interrupts (RTC, serial channel, etc.).  Also note
that the resolution of the pause is similar to the minimum execution time for user instructions.  This means
that timing using Pause() calls of less than 20 to 50 units or so will be affected significantly by the
succeeding instructions.
This routine should be used instead of Sleep() or Delay() when higher resolution timing is required or
you don’t want a task switch to occur.  If you need longer pauses than can be produced by this routine,
you can implement them using Register.RTCStopWatch.
Example
Do
Call PutPin(12, 0)
Call Pause(0.010) 
' a 10 millisecond delay
Call PutPin(12, 1)
Call Pause(2304)  
' a 10 millisecond delay
Loop
This loop produces a square wave signal on pin 12 at approximately 50Hz (with some jitter due to
handling interrupts).
Compatibility
This routine is not available in BasicX compatibility mode.
See Also
Previous page Top Next page