|
by Jamie
Pollock
Start ý Problem
Solving ý EEPROM Programming ý Some
Assemblyý ý Interfacing the LCD ý Sources
and PDF
INTERFACING THE LCD
Interfacing the LCD can pose certain
challenges. With the Optrex display, the technical manual for the
LCD controller is needed. The manual for the Hitachi HD44780 can be
found on the Internet. Complete descriptions of all LCD functions
are explained in the manual, but a good understanding of the LCD is
necessary for reliable operation.
At the beginning of the program, the
LCD is initialized. This consists of placing data on the LCD bus and
toggling the E pin on the LCD. The code sets up the LCD for an 8-bit
data bus, then chooses two lines and a 5 ý 7 font. Next, the display
is turned on (in software), then auto-increment and cursor are picked.
After these control commands are accepted, the busy flag is in operation.
The busy flag enables the LCD to receive
data as quickly as possible. The use of delay loops as opposed to
busy-flag checking reduces the efficiency of the code. Busy-flag checking
allows the LCD to be updated inside the TOC1 ISR.
Listing
3 is the routine that writes
characters to the LCD. This code receives the RAM location for the
character in register Y and continues to send characters until the
RAM location contains a 0. This arrangement has multiple uses. First,
a string of text can be sent, or the result of a Hex to Decimal conversion
(derived from the Motorola 6811 manual) can be sent. The routine first
sends the data to Port C then toggles the E pin.
Next, Port C is changed to an input port
and the busy flag bit is monitored until it clears. Once the busy
flag has cleared, the LCD autoincrements its display address. A small
delay loop of 120 cycles (by trial and error) allows the LCD to update.
This routine can send the seconds, a decimal point, the milliseconds,
and a space, five times. The HOME command, which returns the cursor
to position 1 without clearing the display, is then sent.
Control commands require more time to
complete so the DLY1 delay subroutine is called after a Control command
has been sent. This allows the character-write loop to operate at
its fastest speed.
 |
| Photo
1Under the LCD is asocketed 68HC11F1, and the other supporting
components. The dial is a contrast control which came mounted
to the LCD. |
Photo 1shows
the completed project. Now all that is left is to build a case to
protect the components.
With the use of the Internet and freeware,
many obstacles for developing microcontroller solutions are eliminated.
Wire wrapping prototype boards with few components can allow experimentation
on the smallest of budgets. Realistically, $20 and a little time can
produce stand-alone single chip products for many different applications.
PREVIOUS
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ýCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |