The trick is to use the new library functions recently introduced named DelayMicroseconds() and DelayMilliseconds(). This works because a LockTask is used so any busy loops would occur in any case. The functions PinHigh() and PinLow() can also be used to improve performance a little when outside the timing delay. The attached code shows the before and after for each code snippet. The actual changes are left as an exercise to the reader (!).
Code: Select all
'Before
Private Const ePulseWidth as Single = 5.0e-5
'After
Private Const ePulseWidth as Integer = 50 '50 microseconds
Code: Select all
'Before
Call PulseOut(pinE, ePulseWidth, 1)
'After
Call PinHigh(pinE)
Call DelayMicroseconds(ePulseWidth)
Call PinLow(pinE)
Code: Select all
'Before
Call PulseOut(0, 5.0e-3, 0)
'After
Call DelayMilliseconds(5)
Code: Select all
'Before
Call PulseOut(0, 0.2e-3, 0) ' 200uS delay
'After
Call DelayMicroseconds(200) ' 200us delay