AN1048
Application note
ST7 software LCD driver
Introduction
This note describes a technique for driving Liquid Crystal Displays (LCD) with any standard
ST7 Microcontroller (MCU) i.e without any specific on-chip LCD driver hardware. This
technique offers a solution for applications which require a display at low cost together with
the versatile capabilities of the standard ST7 MCUs. This note also provides a technique to
control the LCD contrast through software.
After an introduction on LCDs in
Section 1, Section 2
&
3
of this note describes the typical
waveforms required to drive an LCD with a multiplexing rate of 1 or 2 (duplex) and 4
(quadruplex).
Section 3
presents a solution based on a standard ST7 MCU directly driving a
quadruplex LCD. This solution can be implemented with any ST7 MCU as it only requires
the standard I/O ports and one timer, both of which are standard features on all ST7 MCUs.
Section 4
describes how to control the contrast through software. Finally,
Section 5
gives a
brief overview of the LCD demo board including the board schematics. The demo board,
based on a ST72F321B microcontroller, allows the user to develop and test applications
using an LCD device.
The program size (~300 bytes), the CPU load required for controlling the LCD (0.2%), and
the number of external components is kept to the minimum (two external resistors per COM
line). The number of I/O’s is the same as a solution using an on-chip LCD hardware driver or
an external hardware LCD driver. With software contrast control, it is a very flexible solution
that can be adapted easily to a range of applications.
May 2006
Rev 5
1/21
www.st.com
Contents
AN1048
Contents
1
2
LCD requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
LCD drive signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1
2.2
2.3
Single backplane LCD drive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Duplexed LCD drive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Quadruplex LCD drive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3.1
2.3.2
LCD mean voltage calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Contrast calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3
4
Example of a quadruplex LCD with ST72F321B . . . . . . . . . . . . . . . . . . 11
Software contrast control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.1
Contrast calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5
LCD demo board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.1
5.2
5.3
5.4
5.5
Schematic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Power supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Oscillation system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
6
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2/21
AN1048
LCD requirements
1
LCD requirements
With a low Root Mean Square (RMS i.e.:
Mean
(
Signal
)
) voltage applied to it, an LCD is
practically transparent. The LCD segment is inactive(OFF) if the RMS voltage is below the
LCD threshold voltage and is active(ON) if the LCD RMS voltage is above the threshold
voltage. The LCD threshold voltage depends on the quality of the liquid used in the LCD and
the temperature. The optical contrast is defined by the difference in transparency of a LCD
segment ON (dark) and a LCD segment OFF (transparent). The optical contrast depends on
the difference between the RMS voltage on an ON segment (V
ON
) and the RMS voltage on
an OFF segment (V
OFF
). The higher the difference between V
ON
(rms) and V
OFF
(rms), the
higher the optical contrast. The optical contrast also depends on the level of V
ON
versus the
LCD threshold voltage. If V
ON
is below or close to the threshold voltage, the LCD is
completely or almost transparent. If V
OFF
is close or above the threshold voltage, the LCD is
completely dark.
In this document, contrast is defined as D = V
ON
(rms) / V
OFF
(rms).
The applied LCD voltage must alternate to give a zero DC value in order to ensure a long
LCD life time.
The higher the multiplexing rates, the lower the contrast. The signal period has also to be
short enough to avoid visible flickering on the display.
The LCD voltage for each segment is equal to the difference between the S and COM
voltages (see
Figure 1).
Figure 1.
Equivalent Electrical Schematic of an LCD Segment
2
C
S
Rs
COM
Note:
The DC Value should never be more than 100mV (refer to the LCD manufacturer’s
datasheet). Otherwise the life time can be shortened. The frequency range is 30 - 200Hz
typically. If it is less, it flickers; if it is more, the power consumption increases.
3/21
LCD drive signals
AN1048
2
2.1
LCD drive signals
Single backplane LCD drive
In a single backplane drive, each LCD segment is connected to a segment line(Sx) and to
one backplane(common line) common to all the segments. A display using S segments is
driven with S+1 MCU output lines. The backplane is driven with a “COM” signal controlled
between 0 and V
DD
with a duty cycle of 50%.
When switching a segment “ON”, a signal with opposite polarity to “COM” is sent to the
corresponding “Segment” pin. When the non-inverted signal “COM” is sent to the “Segment”
pin, the segment is “OFF”. Using an MCU, the I/O operates in output mode either at logic 0
or 1.
Figure 2.
LCD signals for direct drive
COM
+Vdd
S
+Vdd
S1=COM-S
+Vdd
O
F
F
S
+Vdd
S1=COM-S
+Vdd
O
N
-Vdd
2.2
Duplexed LCD drive
In a duplexed drive, two backplanes are used instead of one. Each LCD segment line(Sx) is
connected to two LCD segments, each one connected on the other side to one of the two
backplanes or common lines(refer to
Figure 3).
Thus, only (S/2)+2 MCU pins are necessary
to drive an LCD with S segments.
Three different voltage levels have to be generated on the backplanes: 0, V
DD
/2 and V
DD
. The
“Segment” voltage levels are 0 and V
DD
only. Figure 4 shows typical Backplane, Segment
and LCD waveforms. The intermediate voltage V
DD
/2 is only required for the Backplane
voltages. The ST7 I/O pins selected as “Backplanes” are set by software to output mode for
4/21
AN1048
LCD drive signals
0 or V
DD
levels and to high impedance input mode for V
DD
/2. When one backplane is active,
the other one is neutralised by applying V
DD
/2 to it. This V
DD
/2 voltage is defined by two
resistors of equal value, externally connected to the I/O pin. By using an MCU with flexible
I/O pin configuration, a duplexed LCD drive can be implemented with only 2 external
resistors bridge (each on two com lines).
Figure 3.
Basic LCD Segment Connection in duplexed mode
S1
S2
S3
S11
COM1
COM2
S12
Figure 4.
LCD signals for duplexed mode (used in the ST7 example)
COM1
+Vdd
+Vdd/2
COM2
+Vdd
+Vdd/2
S1
+Vdd
CASE1
CASE2
CASE3
CASE4
S11=COM1-S1
+Vdd
+Vdd/2
-Vdd/2
-Vdd
SEGMENT1
S12=COM2-S1
+Vdd
+Vdd/2
-Vdd/2
-Vdd
OFF
ON
OFF
ON
SEGMENT2
ON
ON
OFF
OFF
5/21