Page 151 - Making PIC Microcontroller Instruments and Controllers
P. 151
UNDEFSTAI{DII{G THE HANDWANE
AND SOFTWANE NTEiACTIOI{ I43
but once you understand what needs to be done, you can write more compact and
sophisticated code tlat will get thejob done the way you want.
Understandins the Hardware
and Software Interaction
The hardwarc we are considering consists ofan LCD with an integral controller thar is
incorporated in the display by the display manufacrurer In our particular case, rhis is
the Hitachi HD44780U controller Displays are available wirhout this or any other con
tolleri but codrolling displays without a controller is way beyond the scope of this book.
For ourprojects, be surc you buy only those units that have this controllerbuilt in as a
paft of the display. Most do.
Controlling the display consists oftelling this controller what we want ir to do. The
instructions are easy to learn and allow you to control each and every pixel and all
thefunctions thatthe display can periorm, wiih relative ease. You do nothave to read
or understand the rather extensive 40+ page datasheet that Hitachi provides for this
controller, but it is well wonh thc troublero download thc data sheer and srudy it. you
do not rued to download this file eithet but you should know where to iind it if you
need it. We will go over almost everything you need to know to control the display
as a part ofthis exercise. The exercises at lhe end ofthe chaprer will take it to the next
level-
In the LCD display, the imbedded conFoller provides the interface betweer rhe user
andthe display. The controller is the Hilachi HD44780U. This very powedul controller
gives you complete control over the LCD. h allows you to address each and every
pixel on the display. It also has a builtin set of ASCII characters for use by the user
Our task is to learn how to use this controller to Dul what we want. when \r'e want. where
we want, in the display.
The other conmon controller is the Epson SED series confiollcr, whose operation and
instruction set is very similarto that oI lhe Hirachi controller We will rol consider the
EPSON conlroller in this book Ifyou do decide to buy a display wiih ihis controller ro
save a few bucks, you should be able to use ir after only a small amounr of srudy.
You will find that almost all the smaller liquid crystal displays on the market are con-
trolled by the Hitachi controller mentioncd earlier This means that once you learn to
control one display, you can control most of them wjrh rhe code you create. As a mafter
of fact, we will write the code in a way thai will be universal in its application in that
we will define variables like the number of character spaces in the display and the
number of lines in the display as part ofthe program setup. (It is also useful and usu
ally much easier to use the DEFINES created by the PBP compiler to control rhe djs
play. We will le.rn how 1o do this in a later exercise.)
The addresses of the local memory locations (meaning the ones in the LCD) used by
the LCD have already been fixed, as has theinslruclion set we use to write to the LCD.
so we do not have to create any ofthis rather sophisticated code.