Positron Compiler Documentation

DelayUs

Positron8 · Revision 4.0.6.5 · PDF page 327

DelayUs Length

Delay execution for Length X microseconds (us). Delays may be up to 65535us (65.535 milliseconds) long.

Length can be a constant, variable, or expression.

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

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 FreqMinimum Delay
4MHz24us
8MHz12us
10MHz8us
16MHz5us
20MHz2us
24MHz2us
25MHz2us
32MHz2us
33MHz2us
40MHz2us
48MHz2us
64MHz2us

See also : Declare, DelayMs, DelayCs, Sleep, Snooze

View original PDF page 327Open page in PDFOriginal PDF page 327