Sei sulla pagina 1di 8

UNIVERSITY MALAYSIA SABAH

SCHOOL OF ENGINEERING & INFORMATION TECHNOLOGY

DESIGN PROJECT
[KE30602]
APPLICATION NOTE

PREPARED BY : ALEX SIM KHIM SONG


MATRIX NO : HK2006-3529
LECTURER : MR.LIAU CHUNG FAN
DATE : 25 MARCH 2009
LCD INTERFACING WITH PIC16F876A

LCDs
Liquid crystal displays (LCDs) are thin, flat display devices made up of any number of
color or monochrome pixels arranged in front of a light source or reflector. These
displays have become an indispensable part of most of electronic devices. Some
features that have made LCDs popular are:

• LCDs provide applications with a useful interface that allows debugging


capabilities and provides the application with a more professional look.
• LCDs use very small amounts of electric power; they are very suitable for battery
powered devices.
• LCDs are slim and used small amounts of space compared to other display types.

Most LCD modules are equipped with a generic interface, on-board controllers, and on-
board driver. Thus, using an LCD to enhance the visual appeal of any application has
become a lot simpler. Some devices that use LCD displays are wrist watches, calculators,
laptops, PDAs, cellular phones, home electronics, and in our project (digital clock with
remote control).

Executive Summary
Many times a Liquid Crystal Display (LCD) interface is needed to display information.
There are multiple common protocols that are used for LCDs.This application note will
show how to interface a typical parallel protocol LCD and a Programmable Integrated
Circuit (PIC).

Objective
This application note will explain how to control the LCD 16*2BL with a Microchip
PIC16F876A.
Introduction
This document details the implementation of an LCD controller in a PIC16F876A.The
example display uses an 16*2 Dot Matrix LCD module, such as the popular SC1602D
device. The controller receives its into commands that are understood by the LCD
module. Togather, the devices can be used to created a simple and inexpensive
information display for a wide range of projects.

Signal Descriptions for the LCD Controller


Signal Description
DB0-DB7 8 bit bi-directional bus that carries data and commands to
and from the LCD module
RW Read and write signal to distinguish between a read and a
write operation.
• RW = 0 : Write Operation
• RW = 1 : Read Operation
RS Register select signal. This is used to choose between the
data and the command registers of the LCD module.
• RS = 0 : Command Register
• RS = 1 : Data Register
E Enable strobe signal. A negative edge on this signal latches
the data on the bi-directional bus into the data or command
register, and vice versa.
DATA 0 –DATA 7 8-bit bus coming from the processor and controller that
carries the ASCII value of the character to be displayed on
the LCD

Hardware System Description


The LCD 16*2 is an 16 character, 2-line display. This display utilizes a parallel interface
for communications. The parallel interface 16 data lines and also separate lines for
Register Select (RS), Read/Write (R/W), and Enable (E). This means that 11 connections
will have to be made between the LCD and the PIC. For this interface to function, all the
bits are set correctly except the enable bit, which is kept high. When the other bits are
set, the enable bits is toggled low so that the LCD knows it is time to read the bits.
The PIC16F876A has 28 I/O pins. This makes it sufficient for communications with the
LCD still allows for 9 more connections to be made with other possible devices in a
project.
Figure 1 outlines the connections that will need to be made between the LCD and the
PIC.
LCD Pin LCD Symbol PIC Pin PIC Symbol
4 RS 2 RA0/AN0
5 R/W 8 Vss
6 E 3 RA1/AN1
7 DB0 21 RB0/INT
8 DB1 22 RB1
9 DB2 23 RB2
10 DB3 24 RB3
11 DB4 25 RB4
12 DB5 26 RB5
13 DB6 27 RB6
14 DB7 28 RB7
Figure 1 : PIC and LCD interconnections

LCD Controller
You can easily integrate this controller design into any application to provide a suitable
display unit. It meets the timing constraints of the LCD by generating the necessary
timing signals and simultaneously off loads the microprocessor and controller from
details of the LCD, thereby allowing the processor and the controller to carry out their
other operations efficiently.

Initializing the LCD Module and the PIC16F876A


The PIC is made of eight different states. It is used to initialize the LCD, display a
message after initialization is complete, and to write to and read from the LCD. The
initialization steps for the LCD module are shown in Figure 2.
Software System Description

Recommendations
Although this code was built to work on a certain model of LCD, and use the Microchip
PIC16F876A, the techniques can be adapted to any parallel LCD or PIC that has similar
characteristics. The pins chosen in Figure 1 were recommended pins and are not in any
particular order. Any of the 28 I/O oins that PIC provides are sufficient to control the
LCD. For a particular project, use the pins that make the most sense for board design
and implementation.
The full circuit of PIC16F876A interface with LCD 16*2

Conclusion
This application note demonstrates how to control a parallel LCD with a PIC. Using the
same techniques, other parallel interfaces can be controlled via a PIC. Furthermore, this
application note demonstrated how to take existing libraries and manipulate them into
operating different hardware and running on different hardware than the library was
intended. By using this technique, the developer can save time and reduce bugs using
software that has already been used by other people.
References
1 . Microchip Technology, Inc. (2006). 16-bit Development Boards, Tools, and Libraries.
Retrieved March 29, 2007, from

http://www.microchip.com/stellent/idcService=SS_GET_PAGE&nodeId=2035

2 . Microchip Technology, Inc. (2007). In DsPIC16F876A Data Sheet

Potrebbero piacerti anche