ST AN2687 Application note

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 LCD principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 LCD drive signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1 Quadruplex LCD drive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.1 LCD mean voltage calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1.2 Contrast calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3 Example of a quadruplex LCD driver with STM8 . . . . . . . . . . . . . . . . . 10
3.1 First method: Timer 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2 Second method: Auto-wakeup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4 Consumption considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5 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. LCD RAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Table 2. First method - consumption (Timer 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Table 3. Second method - consumption (AWU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Table 4. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Doc ID 14296 Rev 1 3/22
List of figures AN2687
List of figures
Figure 1. LCD principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 2. Equivalent electrical schematic of an LCD segment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Figure 3. Basic LCD segment connection in quadruplexed mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 4. LCD timing diagram for quadruplex mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figure 5. Hardware connection diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Figure 6. LCD timing diagram with dead & active time (to decrease Vrms). . . . . . . . . . . . . . . . . . . . 15
Figure 7. LCD timing diagram with active and dead time (to increase Vrms) . . . . . . . . . . . . . . . . . . 16
Figure 8. Schematic diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4/22 Doc ID 14296 Rev 1
AN2687 LCD principle
Mean Signal
2


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= ) 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 voltage on an off segment (V V
(rms), the higher the optical contrast. The optical contrast also depends on the level of
OFF
V
versus the LCD threshold voltage. If VON is below or close to the threshold voltage, the
ON
LCD is completely or almost transparent. If V
). The higher the difference between VON(rms) and
OFF
is close or above the threshold voltage, the
OFF
) and the RMS
ON
LCD is completely black.
Doc ID 14296 Rev 1 5/22
LCD principle AN2687
C
R
S
S
COM
ai14758
In this document, contrast is defined as D = VON(rms) / V
OFF
(rms).
The applied LCD voltage must also alternate to give a zero DC value to prevent the electrolytic process and so, ensure a long LCD lifetime.
The higher the multiplexing rates, the lower the contrast. The signal period also has to be short enough to avoid visible flickering on the display.

Figure 2. Equivalent electrical schematic of an LCD segment

Note: The DC value should never be more than 100 mV (refer to the LCD manufacturer’s
datasheet), otherwise the LCD lifetime may be shortened. The frequency range is 30 Hz to 200 Hz typically. If a lower frequency is used, the LCD flickers, if a larger frequency is used, power consumption increases.
6/22 Doc ID 14296 Rev 1
AN2687 LCD drive signals
S11
S1
COM1
ai14762
S2 S3
COM2
S14
COM3
COM4
S12
S13

2 LCD drive signals

2.1 Quadruplex LCD drive

In a quadruplex LCD drive, four backplanes (common lines) are used. Each LCD pin is connected to four LCD segments, whose other side is connected to one of the four backplanes (refer to Figure 3). Thus, only (S/4)+4 MCU pins are necessary to drive an LCD with S segments. For example, to drive an LCD with 128 segments (32 × 4), only 36 I/O ports are required (32 I/O ports to drive the segments, 4 I/O ports to drive the backplanes).
Three different voltage levels have to be generated on the common lines: 0, V The Segment line voltage levels are 0 and V
only. The LCD segment is inactive if the
DD
/2, VDD.
DD
RMS voltage is below the LCD threshold voltage and is active if the LCD RMS voltage is above the threshold.
The intermediate voltage V selected as backplanes are set by software to output mode for 0 or V high-impedance input mode for V
/2 is only required for backplane voltages. The MCU I/O pins
DD
/2. The VDD/2 voltage is determined by two resistors of
DD
levels and to the
DD
equal value, externally connected to the I/O pins as shown in Figure 5. When one backplane or COM is active, the other ones are neutralized by applying V
/2 to them.
DD

Figure 3. Basic LCD segment connection in quadruplexed mode

Doc ID 14296 Rev 1 7/22
Loading...
+ 15 hidden pages