DelayUs
Positron8 · Revision 4.0.6.5 · PDF page 327
Syntax
DelayUs Length
Overview
Delay execution for Length X microseconds (us). Delays may be up to 65535us (65.535 milliseconds) long.
Parameters
Length can be a constant, variable, or expression.
Example
Device = 18F25K20
Declare Xtal = 16
Dim MyByte as Byte = 50
Dim MyWord as Word = 1000
DelayUs 1 ' Delay for 1us
DelayUs 100 ' Delay for 100us
DelayUs MyByte ' Delay for 50us
DelayUs MyWord ' Delay for 1000us
DelayUs MyWord + 10 ' Delay for 1010us
Notes
DelayUs is oscillator independent, as long as you inform the compiler of the crystal frequency to use, using the Xtal directive.
If a constant is used as Length, then delays down to 1us can be achieved, however, if a Variable is used as the Length parameter, then there's a minimum delay time depending on the frequency of the crystal used: -
| Crystal Freq | Minimum Delay |
| 4MHz | 24us |
| 8MHz | 12us |
| 10MHz | 8us |
| 16MHz | 5us |
| 20MHz | 2us |
| 24MHz | 2us |
| 25MHz | 2us |
| 32MHz | 2us |
| 33MHz | 2us |
| 40MHz | 2us |
| 48MHz | 2us |
| 64MHz | 2us |
