AN2687
Application note
STM8S20xxx
LCD software driver
Introduction
This application note describes two different methods for driving liquid crystal displays
(LCD) with any standard STM8S20xxx microcontroller (MCU), without any specific on-chip
LCD driver hardware:
●
●
the first method uses the timer 2 channel resource and also allows LCD contrast
control through software
the second method uses the Auto-wakeup mode only
This application note starts with an introduction on LCDs in
Section 1: LCD principle
and
Section 2: LCD drive signals.
Section 3
then presents a solution based on a standard STM8S20xxx MCU directly driving a
quadruplex LCD. This solution can be implemented with any MCU as it only requires the
standard I/O ports and some timings.
Section 4
gives consumption considerations.
Section 5
describes how to control contrast
through software: for this purpose, two push-buttons connected to two standard I/Os are
used. Finally,
Section 6
gives an overview of the LCD demo board based on an
STM8S20xxx microcontroller, and provides the board schematics.
For more information on the LCD drive theory, please refer also to AN1048.
The number of external components is kept to a minimum of two external resistors per COM
line. The number of I/Os depends on the number of LCD segments used. Software contrast
control is a very flexible solution that can be easily adapted to a wide range of applications.
April 2009
Doc ID 14296 Rev 1
1/22
Contents
AN2687
Contents
1
2
LCD principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
LCD drive signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1
Quadruplex LCD drive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.1
2.1.2
LCD mean voltage calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Contrast calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3
Example of a quadruplex LCD driver with STM8 . . . . . . . . . . . . . . . . . 10
3.1
3.2
First method: Timer 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Second method: Auto-wakeup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4
5
Consumption considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Software contrast control with the first method . . . . . . . . . . . . . . . . . 17
5.1
Contrast calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6
LCD demo board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
6.1
Board information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2/22
Doc ID 14296 Rev 1
AN2687
List of tables
List of tables
Table 1.
Table 2.
Table 3.
Table 4.
LCD RAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
First method - consumption (Timer 2). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Second method - consumption (AWU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Doc ID 14296 Rev 1
3/22
List of figures
AN2687
List of figures
Figure 1.
Figure 2.
Figure 3.
Figure 4.
Figure 5.
Figure 6.
Figure 7.
Figure 8.
LCD principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Equivalent electrical schematic of an LCD segment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Basic LCD segment connection in quadruplexed mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
LCD timing diagram for quadruplex mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Hardware connection diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
LCD timing diagram with dead & active time (to decrease Vrms). . . . . . . . . . . . . . . . . . . . 15
LCD timing diagram with active and dead time (to increase Vrms) . . . . . . . . . . . . . . . . . . 16
Schematic diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4/22
Doc ID 14296 Rev 1
AN2687
LCD principle
1
LCD principle
Figure 1.
LCD principle
An LCD panel is composed of many layers. A liquid crystal is filled between two of them
(glass plates), which are separated by thin spacers coated with transparent electrodes that
contain orientation layers. The orientation layer usually consists of a polymer (e.g.
polyimide) which has been unidirectionally rubbed using, for instance, a soft tissue. As a
result, the liquid crystal molecules are fixed with their alignment more or less parallel to the
plates, in the direction of rubbing. The crystal alignment directions at the surface of the two
plates are perpendicular so that the molecules between the two plates undergo a
homogeneous twist deformation in alignment to form a helix.
If no electric field is applied, the birefringent liquid crystal molecules keep their helical
structure and rotate linearly polarized light waves passing through the plates. The
transmitted light wave is then allowed through a crossed exit polarizer. As a result, the
modulator has a bright appearance.
On the other hand, if an AC voltage of a few volts is applied, the resulting electric field forces
the liquid crystal molecules to align themselves along the field direction and the twist
deformation (the helix) is unwound. In this case, the polarization of the incident light is not
rotated by the crystal molecules and the crossed exit polarizer blocks the light wave. As a
result, the modulator appears dark.
The inverse switching behavior can be obtained with parallel polarizers. It must also be
noted that gray scale modulation is easily achieved by varying the voltage between the
crystal molecule reorientation threshold (reorientation is resisted by the elastic properties of
liquid crystals) and the saturation field.
LCDs are sensitive to root mean square voltage (Vrms=
Mean
Signal
) levels. With a low
root mean square voltage applied to it, an LCD is practically transparent (the LCD segment
is then inactive or off). To turn an LCD segment on, causing the segment to turn dark (from
light gray to opaque black), an LCD RMS voltage greater than the LCD threshold voltage is
applied to the LCD. The LCD RMS voltage is the RMS voltage across the capacitor C in
Figure 2,
which is equal to the potential difference between the SEG and COM values.
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 an LCD
segment that is on (dark) and an LCD segment that is 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 black.
2
Doc ID 14296 Rev 1
5/22