Page 63 - Making PIC Microcontroller Instruments and Controllers
P. 63
LCD DISPLAY 53
I.CD Display
These notes descdbe the use of, and interactions with, exisring hardware coonections 10
the liquid crystal display as it comes wired on the LAB-XI module. Thesc connections
are defined in the program with DEFINE staiemenrs. Define thcm as necessary in your
designs, keepi ng in mind thal designs that follow the connections lbr LAB-X I will allow
you to use the LAB Xl as the test platform. (Even il your design is subsrantially dif
ferent from the LAB Xl circuitry, this willrenain auseful feature for resring the LCD
and certain I/O lhat may be the same.)
On the LAB X1, the LCD data is fed from PORTD, and all 8 birs ofthis port are con
necled to the LCD. It is controlled trom the 3 bits of PORTD. You theretbrc have the
choice ofusing onlythe4 highbits or PORTD as a 4-bir dara paih for rhe LCD orusing
all S bits. The entire port is also connected to eighr ofthe LEDS on the ten-light LED
bargraph. (The two leitmost LEDS in the bargraph arc uscd 10 indicate that the power
js
to the LAB-X I ON and the poldrity of the bargraph.) The 4 high bits, birs D4 ro D7,
cannot be used fbr any ofier puryose ifthe LCD is being used. The sofrwarc does nor
release these 4 bits aufomatically after using them to fansfer information to rhe LCD
but you do have the option ofsaving the value of PORTD before using rhe LCD. and
then restoring lhis value after the LCD has been written to. The complication, ofcourse,
being that there will be a short glitch when rhe LCD is written to and the use you make
of PORTD has to tolerate this discontinuity.
PORTE, which has only lfuee extemal lines, is dedicated to conlrolling the information
transfer to the LCD. These lines can be used for other puryoses ifthe LCD is nor being
used. PORTE is made digilal when controlling the LCD and can be used for analog inputs
when its pins arc specified as analog inputs. This is done with theADCONl register
as described carlier and in Chapter 9.
The LCD provided on the LAB-XI allows us to display two lines of 20 characrcrs
each. Its connections to the microcontroller are shown in Figure 5.3.
Since this is important,let's take anotlerlook.In Figure 5.3. we see that the LCD
uses all the lines available on PORTD and PORTE. All of PORTD is used as the port
tiie data will be put on, while PORTE, which has only three lines, is used ro con-
trol data transfer to the LCD. We also know from looking at the full schematics pro-
vided with the LAB Xl that all of PORTD is also connecred to ihe LED bargraph.
This does not alfect our programming of the LCD and we will ignore this for now.
You will. however, see the LEDS in the bargraph flicker ON and OFF as programs
run, because we willbe manipulating the data on ihe lines (D0 to D7).Itis also pos-
sible to feed the LCD wirh jnsr the 4 high bits ofPORTD. Sce t]ie PBP marual on
how to do this. It takes siightly longer to refresh the LCD when you are using orly
4 bits, and writing to the LCD is one of the most time consuming lasks in most
programs.
"HelloWorld"
Let's write the ubiquitous program ior the LCD as our firsr exercise
in programming lhe LCD (see Program 5.4). Once we know how to do that, we can
basically w te whatever we want, when wc wan1, to the LCD display.