Professional Documents
Culture Documents
Interfacing Example - 16 Character X 2 Line LCD: Description
Interfacing Example - 16 Character X 2 Line LCD: Description
Interfacing Example - 16 Character X 2 Line LCD: Description
Description.
This is the first interfacing example for the Parallel Port. We will
start with something simple. This example doesn't use the Bi-
directional feature found on newer ports, thus it should work with
most, if no all Parallel Ports. It however doesn't show the use of
the Status Port as an input. So what are we interfacing? A 16
Character x 2 Line LCD Module to the Parallel Port. These LCD
Modules are very common these days, and are quite simple to
work with, as all the logic required to run them is on board.
Schematic
Circuit Description
#include <dos.h>
#include <string.h>
void main(void)
{
char string[] = {"Testing 1,2,3
"
"It' Works ! "};
char init[10];
int count;
int len;
init[0] = 0x0F; /* Init Display */
init[1] = 0x01; /* Clear Display */
init[2] = 0x38; /* Dual Line / 8 Bits */
len = strlen(string);
Above is the source code to get this example running. It's been
written for Borland C, so if you are using a Microsoft compiler, then
you will have to change theoutportb() function
to outp() and inportb() to inp().
After we place a data byte on the data lines, we must then signal
to the LCD module to read the data. This is done using
the Enable line. Data is clocked into the LCD module on the high
to low transition. The Strobe is hardware inverted, thus by setting
bit 0 of the Control Register we get a high to low transition on
the Strobeline. We then wait for a delay, and return the line to a
high state ready for the next byte.
The delays should be suitable for most machines. If the LCD panel
is not initializing properly, you can try increasing the delays.
Likewise if the panel is skipping characters, e.g. Tst ,2. On the
other hand, If the LCD module is repeating characters
e.g. TTTeessttiinngg then you may have a
faulting Enable connection. Check
your Enable to Strobe connection.