Page 160 - Making PIC Microcontroller Instruments and Controllers
P. 160
I32 USI G LIOUID CRYSTAL DISPLAY$ AN EXTE DED II{FON AIIOTI RESOURCE
Busycheck:
Read busybyte
Isolate busybit
If it is busy then goto Busycheck
Retum
We isolate the bit and if it is not loq we read the flag byte again We do this again
and again till the bit goes low. As soon as it does, we can write to the LCD and go on
with the program.
We also have an interest in having our display be compatible with code generated by
the PICB ASIC PRO Compiler I-ooking at the instructions for the LCDOUT conrmand'
we lind that the compiler would prefer thal the hardware be set up for the following
conditionsl
r Four data bits DB4 to DB7 connected to PORTA.0 to PORTA.3
I Chip emble at PORTA.3
I Register select at PORTA.4
t Two lines ofdisptay are assumed, but we should specify that
lf we cannot meet the preceding requirement! we musl set the addresses out as
DEFINES in each and every program we write (or we can use an "INCLUDE ' state-
ment that includes a program that does this for us). It's only a few lines of code, but
we will have to add the code every time, and it compromises compatibility with other
systems that willno doubt be set up to meet the compiler standad.It may tum out tnat
the micrccontroller you choose will need to have this done in any case, but ifit can be
avoided, it should be done at this stage ofour leaming process.
The next thing we need to decide is whether we are gojng to use lhe soliware as
'where
an integral part ofa prcgram that is ronning on a larger microcontroller we can
use all ten address lines for the display, or do we want the software to run on a smaller
aledicated microconfollo thatwill need only one serial line to controlthe disp]ay but
will have to be added to the total project as a part of hardware we design. For now'
let's agrce that we will go with a dedicated conlroller just to run the displ ay The soft
ware for tunning on a larger controller will be a subset of what we develop so no work
is lost here.
The task on the input side is to design lhc software ihat will take the serial informa-
tion rcceived on one pin and output it as 4 bit characters to the LCD with the select,
js
rcaavwnte, and enable lines. The work needed to do read the data in done by the com-
piler with the SERIN instruclion.
Program 9.1 does just this, and is provided by microEngineering Labs on their
Web site.