Interfacing The Densitron LCD To The 8051: February 1996

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

AB-39

APPLICATION
BRIEF

Interfacing the Densitron LCD


to the 8051

RICK SCHUE
REGIONAL APPLICATIONS SPECIALIST
INDIANAPOLIS, INDIANA

February 1996

Order Number: 270529-003


Information in this document is provided in connection with Intel products. Intel assumes no liability whatsoev-
er, including infringement of any patent or copyright, for sale and use of Intel products except as provided in
Intel’s Terms and Conditions of Sale for such products.

Intel retains the right to make changes to these specifications at any time, without notice. Microcomputer
Products may have minor variations to this specification known as errata.

*Other brands and names are the property of their respective owners.

² Since publication of documents referenced in this document, registration of the Pentium, OverDrive and
iCOMP trademarks has been issued to Intel Corporation.

Contact your local Intel sales office or your distributor to obtain the latest specifications before placing your
product order.

Copies of documents which have an ordering number and are referenced in this document, or other Intel
literature, may be obtained from:

Intel Corporation
P.O. Box 7641
Mt. Prospect, IL 60056-7641
or call 1-800-879-4683
COPYRIGHT © INTEL CORPORATION, 1996
INTERFACING THE CONTENTS PAGE
DENSITRON LCD TO THE INTRODUCTION ÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀ 1
8051 HARDWARE DESIGN ÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀ 1

TIMING REQUIREMENTS ÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀ 1

SOFTWARE ÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀ 1

REFERENCES ÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀÀ 1
AB-39

INTRODUCTION Undefined results may occur if the software attempts to


read address 8000H or 8001H, or write to address
This application note details the interface between an 8002H or 8003H.
80C31 and a Densitron two row by 24 character
LM23A2C24CBW display. This combination provides
a very flexible display format (2x24) and a cost effec- TIMING REQUIREMENTS
tive, low power consumption microcontroller suitable
for many industrial control and monitoring functions. The timing requirements of the Densitron LCD are a
little slow for a full speed 80C31. The critical timing
Although this applications brief concentrates on the parameters are the enable pulse width (PW E) of
80C31, the same software and hardware techniques are 450 ns, and the data delay time during read cycles
equally valid on other members of the 8051 family, in- (tDDR) of 320 ns. The 80C31 is available at clock
cluding the 8031, 8751, and the 8044. speeds up to 16 MHz, but at this speed these parame-
ters are violated. Since the 80C31 lacks a READY pin,
the only way to satisfy the LCD timing requirements is
HARDWARE DESIGN to slow the clock down to 10 MHz or lower. A conve-
nient crystal frequency is 7.3728 MHz since it allows all
The LCD is mapped into external data memory, and standard baud rates to be generated with the internal
looks to the 80C31 just like ordinary RAM. The regis- timers.
ter select (RS) and the read/write (R/W) pins are con-
nected to the low order address lines A0 and A1. Con-
necting the R/W pin to an address line is a little unor- SOFTWARE
thodox, but since the R/W line has the same set-up
time requirements as the RS line, treating the R/W pin The code consists of a main module and a set of utility
as an address kept this pin from causing any timing procedures that talk directly to the LCD. This way the
problems. application code does not have to be concerned with
where the LCD is mapped, or the exact bit patterns
The enable (E) pin of the LCD is used to select the needed to control it. The mainline consists of a call to
device, and is driven by the logical OR of the 80C31’s initialize the LCD, and then it writes a message to the
RD and WR signals AND’ed with the MSB of the ad- screen, waits, and then erases it. It repeats this indefi-
dress bus. This maps the LCD into the upper half of the nitely.
64 KB external data space. If this seems a little waste-
ful, feel free to use a more elaborate address decoding The utility procedures include functions to initialize the
scheme. display, send data and address to the LCD, home the
cursor, clear the display, set the cursor to a given row
With the address decoding shown in the example, the and column, turn the cursor on and off, and print a
LCD is mapped as follows: string of characters to the display. Not all the functions
are used in the software example.
Address Function Read/Write?
8000H Write Command to LCD Write Only REFERENCES
8001H Write Data to LCD Write Only
8002H Read Status from LCD Read Only INTEL Embedded Controller Handbook, 210918
8003H Read Data from LCD Read Only
INTEL PL/M-51 User’s Guide, 121966
8004H
to No Access DENSITRON Catalog LCDMD-C
FFFFH

1
AB-39

270529– 1

Figure 1.

2
AB-39

Main module: DO;

Delay: PROCEDURE (count) EXTERNAL;


DECLARE count WORD;
END Delay;

Initialize LCD: PROCEDURE EXTERNAL;


END Initialize LCD;

Clear display: PROCEDURE EXTERNAL;


END Clear display;

LCD print: PROCEDURE EXTERNAL;


END LCD print;

DECLARE LCD buffer (48) BYTE PUBLIC,


sign on message (*) BYTE CONSTANT
(’INTEL 8051 DRIVES LCD - ’
’2 ROWS BY 24 CHARACTERS ’),
i BYTE;

/* This is the start of the program */

/* Initialize the LCD */


CALL Initialize LCD;
CALL Clear display;

/* Now enter an endless loop to display the message */


DO WHILE 1;

/* Copy the message to the buffer */


DO i 4 0 to 47;
LCD buffer(i) 4 sign on message(i);
END;

/* Now print out the buffer to the LCD */


CALL LCD print;

/* wait a while */
CALL Delay(2000);

/* now clear the screen */


CALL Clear display;

END; /* of DO WHILE */

END Main module;

Main Module

3
AB-39

LCD IO MODULE: DO;

DECLARE LCD buffer (48) BYTE EXTERNAL,


LCD command BYTE AT (08000H) AUXILIARY,
LCD data BYTE AT (08001H) AUXILIARY,
LCD status BYTE AT (08002H) AUXILIARY,
LCD busy LITERALLY ’1000$0000B’,
i BYTE;

Delay: PROCEDURE (msec) PUBLIC;

/* This procedure causes a delay of n msec */

DECLARE msec WORD,


i WORD;

IF msec l 0 THEN DO;


DO i 4 0 to msec 1 1;
CALL Time(5); /* .2 msec delay */
END;

END Delay;

LCD out: PROCEDURE (char) PUBLIC;

DECLARE char BYTE;

/* wait for LCD to indicate NOT busy */


DO WHILE (LCD status AND LCD busy) kl 0;
END;

/* now send the data to the LCD */


LCD data 4 char;

END LCD out;

LCD Driver Module

4
AB-39

LCD command out: PROCEDURE (char) PUBLIC;

DECLARE char BYTE;

/* wait for LCD to indicate NOT busy */


DO WHILE (LCD status AND LCD busy) kl 0;
END;

/* now send the command to the LCD */


LCD command 4 char;

END LCD command out;

Home cursor: PROCEDURE PUBLIC;

CALL LCD command out(0000$0010B);

END Home cursor;

Clear display: PROCEDURE PUBLIC;

CALL LCD command out (0000$0001B);

END Clear display;

Set cursor: PROCEDURE (position) PUBLIC;

DECLARE position BYTE;

IF position l 47 THEN position 4 47;


IF position k 24 THEN CALL LCD command out(080H 0 position);
ELSE CALL LCD command out(0COH 0 (position 1 24));

END Set cursor;

Cursor on: PROCEDURE PUBLIC;

CALL LCD command out(0000$1111B);

END Cursor on;

Cursor off: PROCEDURE PUBLIC;

CALL LCD command out(0000$1100B);

END Cursor off;

LCD Driver Module (Continued)

5
AB-39

LCD print: PROCEDURE PUBLIC;

/* This procedure copies the contents of the LCD buffer


to the display */

CALL Set cursor(0) ;


DO i 4 0 to 23;
CALL LCD out(LCD buffer(i));
END;
CALL Set cursor(24);
DO i 4 24 to 47;
CALL LCD out(LCD buffer(i));
END;

END LCD print;

Initialize LCD: PROCEDURE PUBLIC;

CALL Delay(100);
CALL LCD command out(38H); /* Function Set */
CALL LCD command out(38H);
CALL LCD command out(06H); /* entry mode set */
CALL Clear display;
CALL Home cursor;
CALL Cursor off;
CALL Set cursor(0);

END Initialize LCD;

END LCD IO Module;

LCD Driver Module (Continued)

You might also like