Eliminating use of PulseOut from AN220 - Parallel LCD

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Eliminating use of PulseOut from AN220 - Parallel LCD

Post by mikep »

Application note AN220 is "Interfacing a Parallel LCD". For native mode devices it is possible to eliminate the use of PulseOut() and therefore remove the dependency on a timer, freeing it up for another use.

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
There is a LockTask()/UnlockTask() pair around the critical timing of the output code in DisplayCharAt and DisplayStrAt. Although not shown in the example code, this should also be added to critical code the InitLCD() subroutine for safety
Mike Perks
Post Reply