16. Liquid crystal display controller (LCD)

16.1 Introduction

The STM32WL33xx embeds an LCD controller. LCD control is not available on STM32WL30xx and STM32WL31xx devices.

The LCD controller is a digital controller/driver for monochrome passive liquid crystal display (LCD) with up to 8 common terminals and up to 16 segment terminals to drive 64 (16x4) or 96 (12x8) LCD picture elements (pixels). The exact number of terminals depends on the device pinout as described in the datasheet.

The LCD is made up of several segments (pixels or complete symbols) which can be turned visible or invisible. Each segment consists of a layer of liquid crystal molecules aligned between two electrodes. When a voltage greater than a threshold voltage is applied across the liquid crystal, the segment becomes visible. The segment voltage must be alternated to avoid an electrophoresis effect in the liquid crystal (which degrades the display). The waveform across a segment must then be generated so as to avoid having a direct current (DC).

16.2 LCD main features

Note: 1 When the LCD relies on the internal step-up converter, the VLCD pin should be connected to \(V_{SS}\) with a capacitor. Its typical value is 1 μF (see \(C_{EXT}\) value in the product datasheets for further information).

16.3 Glossary

Bias: Number of voltage levels used when driving an LCD. It is defined as \(1/(\text{number of voltage levels used to drive an LCD display} - 1)\).

Boost circuit: Contrast controller circuit

Common: Electrical connection terminal connected to several segments (16 segments).

Duty ratio: Number defined as \(1/(\text{number of common terminals on a given LCD display})\).

Frame: One period of the waveform written to a segment.

Frame rate: Number of frames per second, that is, the number of times the LCD segments are energized per second.

LCD: (liquid crystal display) a passive display panel with terminals leading directly to a segment.

Segment: The smallest viewing element (a single bar or dot that is used to help create a character on an LCD display).

16.4 LCD functional description

16.4.1 General description

The LCD controller has five main blocks (see Figure 38):

Figure 38. LCD controller block diagram

LCD controller block diagram showing interconnected blocks: Frequency Generator (16-bit Prescaler, Clock MUX, Divide by 16 to 31), LCD RAM (32x16 bits), 8-to-1 MUX, SEG DRIVER, COM DRIVER, Voltage Generator and Contrast Controller within an Analog step-up converter, SEG COM MUX, Analog switch array, and connections to Address Bus, Data Bus, LCD Registers, and I/O Ports (COM0-COM3, SEG0-SEG11, SEG12/COM4-SEG15/COM7).
LCD controller block diagram showing interconnected blocks: Frequency Generator (16-bit Prescaler, Clock MUX, Divide by 16 to 31), LCD RAM (32x16 bits), 8-to-1 MUX, SEG DRIVER, COM DRIVER, Voltage Generator and Contrast Controller within an Analog step-up converter, SEG COM MUX, Analog switch array, and connections to Address Bus, Data Bus, LCD Registers, and I/O Ports (COM0-COM3, SEG0-SEG11, SEG12/COM4-SEG15/COM7).

Note: LCDCLK is the same as RTCCLK. Refer to the RTC/LCD clock description in the RCC section of this manual.

The frequency generator allows you to achieve various LCD frame rates starting from an LCD input clock frequency (LCDCLK) which is 32 kHz.

3 different clock sources can be used to provide the LCD clock (LCDCLK/RTCCLK):

16.4.2 Frequency generator

This clock source must be stable in order to obtain accurate LCD timing and hence minimize DC voltage offset across LCD segments. The input clock LCDCLK can be divided by any value from 1 to 2¹⁵ × 31 (see Section 16.6.2: LCD frame control register (LCD_FCR) on page 326). The frequency generator consists of a prescaler (16-bit ripple counter) and a 16 to 31 clock divider. The PS[3:0] bits, in the LCD_FCR register, select LCDCLK divided by \(2^{\text{PS}[3:0]}\). If a finer resolution rate is required, the DIV[3:0] bits, in the LCD_FCR register, can be used to divide the clock further by 16 to 31. In this way you can roughly scale the frequency, and then fine-tune it by linearly scaling the clock with the counter. The output of the frequency generator block is \(f_{\text{ck\_div}}\) which constitutes the time base for the entire LCD controller. The ck\_div frequency is equivalent to the LCD phase frequency, rather than the frame frequency (they are equal only in case of static duty). The frame frequency (\(f_{\text{frame}}\)) is obtained from \(f_{\text{ck\_div}}\) by dividing it by the number of active common terminals (or by multiplying it for the duty). Thus the relation between the input clock frequency (\(f_{\text{LCDCLK}}\)) of the frequency generator and its output clock frequency \(f_{\text{ck\_div}}\) is:

\[f_{\text{ckdiv}} = \frac{f_{\text{LCDCLK}}}{2^{\text{PS}} \times (16 + \text{DIV})}\]

\[f_{\text{frame}} = f_{\text{ckdiv}} \times \text{duty}\]

This makes the frequency generator very flexible. An example of frame rate calculation is shown in Table 39.

Table 39. Example of frame rate calculation

LCDCLKPS[3:0]DIV[3:0]RatioDuty\(f_{\text{frame}}\)
32.768 kHz311361/830.12 Hz
32.768 kHz412721/430.12 Hz
32.768 kHz463521/331.03 Hz
32.768 kHz515441/230.12 Hz
32.768 kHz611088static30.12 Hz
32.768 kHz14401/8102.40 Hz
32.768 kHz24801/4102.40 Hz
32.768 kHz2111081/3101.14 Hz
32.768 kHz341601/2102.40 Hz
32.768 kHz44320static102.40 Hz

The frame frequency must be selected to be within a range of around ~30 Hz to ~100 Hz and is a compromise between power consumption and the acceptable refresh rate. In addition, a dedicated blink prescaler selects the blink frequency. This frequency is defined as:

\[f_{\text{BLINK}} = f_{\text{ck\_div}} / 2^{(\text{BLINKF} + 3)},\]

ith BLINKF[2:0] = 0,1,2,…,7

The blink frequency achieved is in the range of 0.5 Hz, 1 Hz, 2 Hz or 4 Hz.

16.4.3 Common driver

Common signals are generated by the common driver block(see Figure 38).

COM signal bias

Each COM signal has identical waveforms, but different phases. It has its max amplitude \(V_{LCD}\) or \(V_{SS}\) only in the corresponding phase of a frame cycle, while during the other phases, the signal amplitude is:

Selection between 1/2, 1/3 and 1/4 bias mode can be done through the BIAS bits in the LCD_CR register.

A pixel is activated when both of its corresponding common and segment lines are active during the same phase, it means when the voltage difference between common and segment is maximum during this phase. Common signals are phase inverted in order to reduce EMI. As shown in Figure 39, with phase inversion, there is a mean voltage of \(1/2 V_{LCD}\) at the end of every odd cycle.

Figure 39. 1/3 bias, 1/4 duty

Timing diagram for 1/3 bias, 1/4 duty showing Common and Segment signals over Odd and Even frames.

The diagram illustrates the timing of Common and Segment signals over two frames (Odd Frame and Even Frame), each divided into four phases (Phase 0 to Phase 3). The signals are shown relative to \(V_{LCD}\), \(2/3 V_{LCD}\), \(1/3 V_{LCD}\), and \(V_{SS}\).

Signal TypePhaseState / Voltage Level
CommonPhase 0 (Odd)Active (\(V_{LCD}\))
Phase 1 (Odd)Inactive (\(2/3 V_{LCD}\))
Phase 2 (Odd)Inactive (\(2/3 V_{LCD}\))
Phase 3 (Odd)Inactive (\(2/3 V_{LCD}\))
Phase 0 (Even)Active (\(V_{LCD}\))
Phase 1 (Even)Inactive (\(2/3 V_{LCD}\))
Phase 2 (Even)Inactive (\(2/3 V_{LCD}\))
Phase 3 (Even)Inactive (\(2/3 V_{LCD}\))
SegmentPhase 0 (Odd)Active (\(V_{LCD}\))
Phase 1 (Odd)Active (\(V_{LCD}\))
Phase 2 (Odd)Inactive (\(2/3 V_{LCD}\))
Phase 3 (Odd)Inactive (\(2/3 V_{LCD}\))
Phase 0 (Even)Active (\(V_{LCD}\))
Phase 1 (Even)Active (\(V_{LCD}\))
Phase 2 (Even)Inactive (\(2/3 V_{LCD}\))
Phase 3 (Even)Inactive (\(2/3 V_{LCD}\))
Timing diagram for 1/3 bias, 1/4 duty showing Common and Segment signals over Odd and Even frames.

In case of 1/2 bias (BIAS = 01) the \(V_{LCD}\) pin generates an intermediate voltage equal to \(1/2 V_{LCD}\) for odd and even frames (see Figure 42).

COM signal duty

Depending on the DUTY[2:0] bits in the LCD_CR register, the COM signals are generated with static duty (see Figure 41), 1/2 duty (see Figure 42), 1/3 duty (see Figure 43), 1/4 duty (see Figure 44) or 1/8 duty (see Figure 45).

COM[n] n[0 to 7] is active during phase n in the odd frame, so the COM pin is driven to \(V_{LCD}\),

During phase n of the even frame the COM pin is driven to \(V_{SS}\).

In the case of 1/3 or 1/4 bias:

In the case of 1/2 bias:

When static duty is selected, the segment lines are not multiplexed, which means that each segment output corresponds to one pixel. In this way only up to 4 pixels can be driven. COM[0] is always active while COM[7:1] are not used and are driven to \(V_{SS}\).

When the LCDEN bit in the LCD_CR register is reset, all common lines are pulled down to \(V_{SS}\) and the ENS flag in the LCD_SR register becomes 0. Static duty means that COM[0] is always active and only two voltage levels are used for the segment and common lines: \(V_{LCD}\) and \(V_{SS}\). A pixel is active if the corresponding SEG line has a voltage opposite to that of the COM, and inactive when the voltages are equal. In this way the LCD has maximum contrast (see Figure 40, Figure 41). In the Figure 40 pixel 0 is active while pixel 1 is inactive.

Figure 40. Static duty

Timing diagram for Static duty mode showing COM0, SEG0, and SEG1 signals over four frames (Odd Frame, Even Frame, Odd Frame, Even Frame). COM0 is a square wave between V_LCD and V_SS. SEG0 and SEG1 are square waves between V_LCD and V_SS. COM0-SEG0 and COM0-SEG1 are square waves between 0 and -V_LCD.

The diagram illustrates the timing of signals for static duty mode across four frames (Odd Frame, Even Frame, Odd Frame, Even Frame). The signals shown are:

Timing diagram for Static duty mode showing COM0, SEG0, and SEG1 signals over four frames (Odd Frame, Even Frame, Odd Frame, Even Frame). COM0 is a square wave between V_LCD and V_SS. SEG0 and SEG1 are square waves between V_LCD and V_SS. COM0-SEG0 and COM0-SEG1 are square waves between 0 and -V_LCD.

In each frame there is only one phase, this is why \(f_{frame}\) is equal to \(f_{LCD}\). If 1/4 duty is selected there are four phases in a frame in which COM[0] is active during phase 0, COM[1] is active during phase 1, COM[2] is active during phase 2, and COM[3] is active during phase 3.

Figure 41. Static duty Figure 41. Static duty LCD terminal connections and driving waveforms showing PIN COM0, PIN SEG0, PIN SEG1, COM0 - SEG0 Selected Waveform, and COM0 - SEG1 Non selected waveform across one frame.
Figure 41. Static duty LCD terminal connections and driving waveforms showing PIN COM0, PIN SEG0, PIN SEG1, COM0 - SEG0 Selected Waveform, and COM0 - SEG1 Non selected waveform across one frame.

In this mode, the segment terminals are multiplexed and each of them control four pixels. A pixel is activated only when both of its corresponding SEG and COM lines are active in the same phase. In case of 1/4 duty, to deactivate pixel 0 connected to COM[0] the SEG[0] needs to be inactive during the phase 0 when COM[0] is active. To activate pixel16 connected to COM[1] the SEG[0] needs to be active during phase 1 when COM[1] is active (see Figure 44). To activate pixels from 0 to 15 connected to COM[0], SEG[0:15] need to be active during phase 0 when COM[0] is active. These considerations can be extended to the other pixels.

8 to 1 mux

When COM[0] is active the common driver block, also drives the 8 to 1 mux shown in Figure 38 in order to select the content of first two RAM register locations. When COM[7] is active, the output of the 8 to 1 mux is the content of the last two RAM locations.

Figure 42. 1/2 duty, 1/2 bias

Figure 42: 1/2 duty, 1/2 bias. This figure illustrates the timing and voltage levels for a 1/2 duty, 1/2 bias liquid crystal display (LCD) controller. It includes a schematic of the LCD display and terminal connections, and a series of waveforms for various pins over one frame.

The figure shows a schematic of a 7-segment display with terminals labeled COM0, COM1, SEG0, SEG1, SEG2, and SEG3. To the right, waveforms are shown for the following pins over one frame (indicated by a horizontal double-headed arrow at the bottom):

Figure 42: 1/2 duty, 1/2 bias. This figure illustrates the timing and voltage levels for a 1/2 duty, 1/2 bias liquid crystal display (LCD) controller. It includes a schematic of the LCD display and terminal connections, and a series of waveforms for various pins over one frame.

16.4.4 Segment driver

The segment driver block controls the SEG lines according to the pixel data coming from the 8 to 1 mux driven in each phase by the common driver block.

In the case of 1/4 or 1/8 duty

When COM[0] is active, the pixel information (active/inactive) related to the pixel connected to COM[0] (content of the first two LCD_RAM locations) goes through the 8 to 1 mux.

The SEG[n] pin n [0 to 15] is driven to \(V_{SS}\) (indicating pixel n is active when COM[0] is active) in phase 0 of the odd frame,

The SEG[n] pin is driven to \(V_{LCD}\) in phase 0 of the even frame. If pixel n is inactive then the SEG[n] pin is driven to 2/3 (2/4) \(V_{LCD}\) in the odd frame or 1/3 (2/4) \(V_{LCD}\) in the even frame (current inversion in \(V_{LCD}\) pad). (see Figure 39)

In case of 1/2 bias, if the pixel is inactive the SEG[n] pin is driven to \(V_{LCD}\) in the odd and to \(V_{SS}\) in the even frame.

When the LCD controller is disabled (LCDEN bit cleared in the LCD_CR register) then the SEG lines are pulled down to \(V_{SS}\).

Figure 43. 1/3 duty, 1/3 bias

Figure 43: 1/3 duty, 1/3 bias. This figure illustrates the voltage waveforms for a 1/3 duty, 1/3 bias liquid crystal display (LCD) controller. It includes a schematic of the display and terminal connections, and a timing diagram showing the voltage levels for various pins over one frame.

Liquid Crystal Display and Terminal Connection

The schematic shows a 7-segment display with terminals labeled COM0, COM1, COM2, SEG0, SEG1, and SEG2. COM0 is connected to a common terminal, while COM1 and COM2 are connected to segment terminals. SEG0, SEG1, and SEG2 are connected to the segment terminals.

Timing Diagram

The timing diagram shows the voltage levels for various pins over one frame. The frame is divided into three equal periods by vertical dashed lines. The voltage levels are as follows:

PinPeriod 1Period 2Period 3
PIN COM03/3 V2/3 V1/3 V
PIN COM10/3 V3/3 V2/3 V
PIN COM23/3 V2/3 V1/3 V
PIN SEG03/3 V2/3 V1/3 V
PIN SEG13/3 V2/3 V1/3 V
COM0 - SEG1 Selected Waveform0/3 V-1/3 V-2/3 V
COM0 - SEG0 Non selected waveform1/3 V0/3 V-1/3 V

The diagram also shows the voltage levels for the COM0 - SEG1 Selected Waveform and the COM0 - SEG0 Non selected waveform. The frame duration is indicated by a double-headed arrow labeled "1 frame".

Figure 43: 1/3 duty, 1/3 bias. This figure illustrates the voltage waveforms for a 1/3 duty, 1/3 bias liquid crystal display (LCD) controller. It includes a schematic of the display and terminal connections, and a timing diagram showing the voltage levels for various pins over one frame.

Figure 44. 1/4 duty, 1/3 bias

Figure 44: 1/4 duty, 1/3 bias. This figure illustrates the voltage waveforms for a 1/4 duty, 1/3 bias liquid crystal display (LCD) system. It includes a schematic of the LCD and its terminal connections, and a series of timing diagrams for various pins and waveforms over one frame.

Liquid Crystal Display and Terminal Connection

The schematic shows a 4-digit 7-segment display. The common pins are labeled COM0, COM1, COM2, and COM3. The segment pins are labeled SEG0 and SEG1. The display is shown in two states: one with digits '1234' and another with digits '5678'.

Timing Diagrams

The timing diagrams show the voltage levels for various pins and waveforms over one frame. The frame is divided into four equal time intervals (1/4 duty). The voltage levels are relative to a common reference (0/3 V).

Pin / WaveformInterval 1Interval 2Interval 3Interval 4
PIN COM03/3 V2/3 V1/3 V0/3 V
PIN COM13/3 V2/3 V1/3 V0/3 V
PIN COM23/3 V2/3 V1/3 V0/3 V
PIN COM33/3 V2/3 V1/3 V0/3 V
PIN SEG03/3 V2/3 V1/3 V0/3 V
PIN SEG13/3 V2/3 V1/3 V0/3 V
COM3 - SEG0 Selected Waveform3/3 V2/3 V1/3 V0/3 V
COM0 - SEG0 Non selected waveform1/3 V0/3 V-1/3 V-1/3 V

The diagram also shows the voltage levels for the COM0, COM1, COM2, and COM3 pins, which are 3/3 V, 2/3 V, 1/3 V, and 0/3 V respectively. The voltage levels for the SEG0 and SEG1 pins are 3/3 V, 2/3 V, 1/3 V, and 0/3 V respectively. The voltage levels for the COM3 - SEG0 Selected Waveform are 3/3 V, 2/3 V, 1/3 V, and 0/3 V respectively. The voltage levels for the COM0 - SEG0 Non selected waveform are 1/3 V, 0/3 V, -1/3 V, and -1/3 V respectively.

Figure 44: 1/4 duty, 1/3 bias. This figure illustrates the voltage waveforms for a 1/4 duty, 1/3 bias liquid crystal display (LCD) system. It includes a schematic of the LCD and its terminal connections, and a series of timing diagrams for various pins and waveforms over one frame.

Figure 45. 1/8 duty, 1/4 bias

Figure 45: 1/8 duty, 1/4 bias. This figure illustrates the voltage waveforms for a 7-segment LCD display operating in 1/8 duty and 1/4 bias mode. On the left, a diagram shows the 'Liquid Crystal Display and Terminal Connection' with segments labeled COM0 through COM7 and SEG0. The main part of the figure is a series of eight vertical waveforms, each representing a different pin or segment over one frame. The waveforms are: PIN COM0, PIN COM1, PIN COM2, PIN COM7, PIN SEG0, COM0 - SEG0 Selected Waveform, COM2 - SEG0 Non selected waveform, and a reference scale. The reference scale on the right lists voltage levels from 4/4 V down to 0/4 V, and then from 4/4 V down to -4/4 V. A horizontal double-headed arrow at the bottom indicates the duration of '1 frame'.

Liquid Crystal Display and Terminal Connection

COM7
COM6
COM5
COM4
COM3
COM2
COM0
SEG0

PIN COM0

PIN COM1

PIN COM2

PIN COM7

PIN SEG0

COM0 - SEG0
Selected Waveform

COM2 - SEG0
Non selected waveform

1 frame

4/4 V
3/4 V
2/4 V
1/4 V
0/4 V

4/4 V
3/4 V
2/4 V
1/4 V
0/4 V

4/4 V
3/4 V
2/4 V
1/4 V
0/4 V

4/4 V
3/4 V
2/4 V
1/4 V
0/4 V

4/4 V
3/4 V
2/4 V
1/4 V
0/4 V

4/4 V
3/4 V
2/4 V
1/4 V
0/4 V
-1/4 V
-2/4 V
-3/4 V
-4/4 V

4/4 V
3/4 V
2/4 V
1/4 V
0/4 V
-1/4 V
-2/4 V
-3/4 V
-4/4 V

Figure 45: 1/8 duty, 1/4 bias. This figure illustrates the voltage waveforms for a 7-segment LCD display operating in 1/8 duty and 1/4 bias mode. On the left, a diagram shows the 'Liquid Crystal Display and Terminal Connection' with segments labeled COM0 through COM7 and SEG0. The main part of the figure is a series of eight vertical waveforms, each representing a different pin or segment over one frame. The waveforms are: PIN COM0, PIN COM1, PIN COM2, PIN COM7, PIN SEG0, COM0 - SEG0 Selected Waveform, COM2 - SEG0 Non selected waveform, and a reference scale. The reference scale on the right lists voltage levels from 4/4 V down to 0/4 V, and then from 4/4 V down to -4/4 V. A horizontal double-headed arrow at the bottom indicates the duration of '1 frame'.

The segment driver also implements a programmable blink feature to allow some pixels to continuously switch on at a specific frequency. The blink mode can be configured by the BLINK[1:0] bits in the LCD_FCR register, making possible to blink up to 1, 2, 4, 8 or all pixels (see Section 16.6.2: LCD frame control register (LCD_FCR)). The blink frequency can be selected from eight different values using the BLINKF[2:0] bits in the LCD_FCR register.

Table 40 gives examples of different blink frequencies (as a function of ck_div frequency).

Table 40. Blink frequency

BLINKF[2:0]
bits
ck_div frequency (with LCDCLK frequency of 32.768 kHz)
32 Hz64 Hz128 Hz256 Hz
0004.0 HzN/AN/AN/A
0012.0 Hz4.0 HzN/AN/A
0101.0 Hz2.0 Hz4.0 HzN/A
0110.5 Hz1.0 Hz2.0 Hz4.0 Hz
1000.25 Hz0.5 Hz1.0 Hz2.0 Hz
101N/A0.25 Hz0.5 Hz1.0 Hz
110N/AN/A0.25 Hz0.5 Hz
111N/AN/AN/A0.25 Hz

16.4.5 Voltage generator and contrast control

LCD supply source

The LCD power supply source may come from either the internal step-up converter or from an external voltage applied on the Vlcd pin. Internal or external voltage source can be selected using the VSEL bit in the LCD_CR register. In case of external source selected, the internal boost circuit (step-up converter) is disabled to reduce power consumption.

When the step-up converter is selected as Vlcd source, the \(V_{LCD}\) value can be chosen among a wide set of values from \(V_{LCDmin}\) to \(V_{LCDmax}\) by means of CC[2:0] (Contrast Control) bits inside LCD_FCR (see Section 16.6.2) register. New values of \(V_{LCD}\) takes effect every beginning of a new frame.

When external power source is selected as Vlcd source, the Vlcd voltage must be choosen in the range of Vlcdmin to Vlcdmax (see datasheets). The contrast can then be controlled by programming a dead time between frames (see Deadtime on page 320)

A specific software sequence must be performed to configure the LCD depending on the LCD power supply source to be used. Here we consider the LCD controller is disabled prior to the configuration sequence.

In case the internal step-up converter is used (capacitor \(C_{EXT}\) on VLCD pin is required):

In case of LCD external power source is used:

LCD intermediate voltages

The LCD voltage generator generates up to three intermediate voltage levels (\(1/3 V_{LCD}\), \(2/3 V_{LCD}\) or \(1/4 V_{LCD}\), \(2/4 V_{LCD}\), \(3/4 V_{LCD}\)) between \(V_{SS}\) and \(V_{LCD}\) in case of 1/3 (1/4) bias and only one voltage level (\(1/2 V_{LCD}\)) between \(V_{SS}\) and \(V_{LCD}\) in case of 1/2 bias.

In case of 1/2 bias, one voltage level (\(1/2 V_{LCD}\)) is generated and node b voltage is \(1/2 V_{LCD}\)

In case of 1/3 bias, two intermediate voltage levels (\(1/3 V_{LCD}\), \(2/3 V_{LCD}\)) are generated

In case of 1/4 bias, three intermediate voltage levels (\(1/4 V_{LCD}\), \(1/2 V_{LCD}\) and \(3/4 V_{LCD}\)) are generated

LCD drive selection

1. High drive and low drive resistive network

Internal resistor networks are used to generate all intermediate voltages (see Figure 46). Actually, one with low value resistors (\(R_L\)) and one with high value resistors (\(R_H\)) which are respectively used to increase the current during transitions and to reduce power consumption in static state.

The EN switch allows the following rules :

If LCDEN bit in the LCD_CR register is set, the EN switch is closed.

When clearing the LCDEN bit in the LCD_CR register, the EN switch is open at the end of the even frame in order to avoid a medium voltage level different from 0 considering the entire frame odd plus even.

The PON[2:0] (Pulse ON duration) bits in the LCD_FCR register configure the time during which \(R_L\) is enabled (see Figure 38) through the HD (high drive) switch when the levels of the common and segment lines change. A short drive time leads to lower power consumption, but displays with high internal resistance may need a longer drive time to achieve satisfactory contrast.

Figure 46.\(V_{LCD}\) pin for 1/2 1/3 1/4 bias Schematic diagram of the V_LCD pin circuit for 1/2, 1/3, and 1/4 bias modes. The circuit includes a resistor ladder (R_LN and R_HN) controlled by the HD switch. The ladder is connected to V_LCD and V_SS. The output nodes are connected to buffers (BUFEN) and then to nodes a, b, and c. The diagram shows the internal structure of the bias generator and the connection to the external V_LCD pin.

The diagram illustrates the internal circuitry for generating bias voltages for an LCD. It features a resistor ladder with two main branches, \(R_{LN}^{1)}\) and \(R_{HN}^{1)}\), controlled by a switch labeled HD. The ladder is connected to \(V_{LCD}\) and \(V_{SS}\). The output nodes are connected to buffers (BUFEN) and then to nodes a, b, and c. The diagram shows the internal structure of the bias generator and the connection to the external \(V_{LCD}\) pin.

Schematic diagram of the V_LCD pin circuit for 1/2, 1/3, and 1/4 bias modes. The circuit includes a resistor ladder (R_LN and R_HN) controlled by the HD switch. The ladder is connected to V_LCD and V_SS. The output nodes are connected to buffers (BUFEN) and then to nodes a, b, and c. The diagram shows the internal structure of the bias generator and the connection to the external V_LCD pin.

The \(R_L\) divider can be always switched on using the HD bit in the LCD_FCR configuration register (see Section 16.6.2).

The HD switch follows the rules described below:

2. Buffered mode

When voltage output buffers are enabled by setting BUFEN bit in the LCD_CR register, LCD driving capability is improved as buffers prevent the LCD capacitive loads from loading the resistor bridge unacceptably and interfering with its voltage generation. As a result we obtain more stable intermediate voltage levels thus improving RMS voltage applied to the LCD pixels.

In buffer mode, intermediate voltages are generated by the high value resistor bridge \(R_{hn}\) to reduce power consumption, the low value resistor bridge \(R_{ln}\) is automatically disabled whatever the HD bit or PON bits configuration.

Buffers can be used independently of the \(V_{lcd}\) supply source (internal or external) but can only be enabled or disabled when LCD controller is not activated.

After the LCDEN bit is activated, the RDY bit is set in the LCD_SR register to indicate that voltage levels are stable and the LCD controller can start to work.

Deadtime

In addition to using the CC[2:0] bits, the contrast can be controlled by programming a dead time between each frame. During the dead time the COM and SEG values are put to \(V_{SS}\). The DEAD[2:0] bits in the LCD_FCR register can be used to program a time of up to eight phase periods. This dead time reduces the contrast without modifying the frame rate.

Figure 47. Deadtime

Timing diagram showing the sequence of odd and even frames separated by a dead time period. The diagram illustrates the COM and SEG signals during these periods.

The diagram illustrates the timing of frames and deadtime. It shows a sequence of an odd frame, an even frame, a dead time period, followed by another odd frame and even frame. The odd frames show a high-to-low transition in the COM signal, while the even frames show a low-to-high transition. The dead time period is a gap between frames where both COM and SEG signals are at a low level, representing \(V_{SS}\).

Timing diagram showing the sequence of odd and even frames separated by a dead time period. The diagram illustrates the COM and SEG signals during these periods.

16.4.6 Double buffer memory

Using its double buffer memory the LCD controller ensures the coherency of the displayed information without having to use interrupts to control LCD_RAM modification.

The application software can access the first buffer level (LCD_RAM) through the APB interface. Once it has modified the LCD_RAM, it sets the UDR flag in the LCD_SR register. This UDR flag (update display request) requests the updated information to be moved into the second buffer level (LCD_DISPLAY).

This operation is done synchronously with the frame (at the beginning of the next frame), until the update is completed, the LCD_RAM is write protected and the UDR flag stays high. Once the update is completed another flag (UDD - Update Display Done) is set and generates an interrupt if the UDDIE bit in the LCD_FCR register is set.

The time it takes to update LCD_DISPLAY is, in the worst case, one odd and one even frame.

The update does not occur (UDR = 1 and UDD = 0) until the display is enabled (LCDEN = 1)

16.4.7 LCD controller low power modes

the LCD controller can be displayed in Stop mode or can be fully disabled to reduce power consumption.

Table 41. LCD behavior in low power modes

ModeDescription
DeepThe LCD is still active
ShutdownThe LCD is not active

16.4.8 COM and SEG multiplexing

Output pins versus duty modes

The output pins consists of:

Depending on the duty configuration, the COM and SEG output pins may have different functions:

Summary of COM and SEG functions versus duty and remap

All the possible ways of multiplexing the COM and SEG functions are described in Table 42.

Table 42. Remapping capability

Configuration bitsCapabilityOutput pinFunction
DUTY
1/8012x8SEG[15:12]COM[7:4]
COM[3:0]COM[3:0]
SEG[11:0]SEG[11:0]
1/4016x4COM[3:0]COM[3:0]
SEG[15:0]SEG[15:0]
1/3016x3COM[3]not used
COM[2:0]COM[2:0]
SEG[15:0]SEG[15:0]
1/2016x2COM[3:2]not used
COM[1:0]COM[1:0]
SEG[15:0]SEG[15:0]
STATIC016x1COM[3:1]not used
COM[0]COM[0]
SEG[15:0]SEG[15:0]

16.4.9 Flowchart

Figure 48. Flowchart example

Flowchart example for LCD controller initialization and operation. The flowchart starts with 'START', followed by 'INIT' (enabling GPIO clocks, configuring pins, programming DUTY and BIAS in LCD_CR), loading initial data into LCD_RAM, programming frame rate, contrast, optional features, and interrupts in LCD_FCR. It then enables the display (LCDEN bit in LCD_CR). The main loop includes decisions for 'Adjust contrast?', 'Modify data?', 'Change Blink?', and 'Disable LCD?'. If 'Adjust contrast?' is Yes, it changes parameters in LCD_FCR. If 'Modify data?' is Yes, it checks 'UDR = 1?'; if No, it modifies LCD_RAM and sets UDR bit in LCD_SR. If 'Change Blink?' is Yes, it changes BLINK or BLINKF in LCD_FCR. If 'Disable LCD?' is Yes, it disables the display and checks 'ENS = 0?'. If ENS is 0, it ends; otherwise, it loops back. If any decision is No, it loops back to the start of the main loop.
graph TD
    START([START]) --> INIT[INIT
- Enable the GPIO port clocks
- Configure the LCD GPIO pins as alternate functions
Configure LCD controller according to the Display to be driven:
- Program desired DUTY in LCD_CR
- Program desired BIAS in LCD_CR] INIT --> LOAD_DATA[Load the initial data to be displayed into LCD_RAM and set the UDR bit in the LCD_SR register] LOAD_DATA --> PROGRAM_FCR["- Program the desired frame rate (PS and DIV bits in LCD_FCR)
- Program the contrast (CC bits in LCD_FCR register)
- Program optional features (BLINK, BLINKF, PON, DEAD, HD)
- Program the required interrupts"] PROGRAM_FCR --> ENABLE_DISP[Enable the display (LCDEN bit in LCD_CR register)] ENABLE_DISP --> LOOP_JOIN(( )) LOOP_JOIN --> ADJUST_CONTRAST{Adjust contrast?} ADJUST_CONTRAST -- Yes --> CHANGE_PARAM[Change PS, DIV, CC, PON, DEAD or HD in LCD_FCR] CHANGE_PARAM --> LOOP_JOIN ADJUST_CONTRAST -- No --> MODIFY_DATA{Modify data?} MODIFY_DATA -- Yes --> UDR_CHECK{UDR = 1?} UDR_CHECK -- No --> MODIFY_RAM[Modify the LCD_RAM] MODIFY_RAM --> SET_UDR[Set UDR bit in LCD_SR] SET_UDR --> LOOP_JOIN UDR_CHECK -- Yes --> LOOP_JOIN MODIFY_DATA -- No --> CHANGE_BLINK{Change Blink?} CHANGE_BLINK -- Yes --> CHANGE_BLINKF[Change BLINK or BLINKF in LCD_FCR] CHANGE_BLINKF --> LOOP_JOIN CHANGE_BLINK -- No --> DISABLE_LCD{Disable LCD?} DISABLE_LCD -- Yes --> DISABLE_DISP[Disable the display (LCDEN bit in LCD_CR register)] DISABLE_DISP --> ENS_CHECK{ENS = 0?} ENS_CHECK -- Yes --> END([END]) ENS_CHECK -- No --> LOOP_JOIN DISABLE_LCD -- No --> LOOP_JOIN
Flowchart example for LCD controller initialization and operation. The flowchart starts with 'START', followed by 'INIT' (enabling GPIO clocks, configuring pins, programming DUTY and BIAS in LCD_CR), loading initial data into LCD_RAM, programming frame rate, contrast, optional features, and interrupts in LCD_FCR. It then enables the display (LCDEN bit in LCD_CR). The main loop includes decisions for 'Adjust contrast?', 'Modify data?', 'Change Blink?', and 'Disable LCD?'. If 'Adjust contrast?' is Yes, it changes parameters in LCD_FCR. If 'Modify data?' is Yes, it checks 'UDR = 1?'; if No, it modifies LCD_RAM and sets UDR bit in LCD_SR. If 'Change Blink?' is Yes, it changes BLINK or BLINKF in LCD_FCR. If 'Disable LCD?' is Yes, it disables the display and checks 'ENS = 0?'. If ENS is 0, it ends; otherwise, it loops back. If any decision is No, it loops back to the start of the main loop.

16.5 LCD interrupts

Table 43 gives the list of LCD interrupt requests.

Table 43. LCD interrupt requests

Interrupt eventEvent flagEvent flag/Interrupt clearing methodInterrupt enable control bit
Start Of Frame (SOF)SOFWrite SOFC =1SOFIE
Update Display Done (UDD)UDDWrite UDDC = 1UDDIE

Start of frame (SOF)

The LCD start of frame interrupt is executed if the SOFIE (start of frame interrupt enable) bit is set (see Section 16.6.2: LCD frame control register (LCD_FCR)). SOF is cleared by writing the SOFC bit to 1 in the LCD_CLR register when executing the corresponding interrupt handling vector.

Update display done (UDD)

The LCD update display interrupt is executed if the UDDIE (update display done interrupt enable) bit is set (see Section 16.6.2: LCD frame control register (LCD_FCR)). UDD is cleared by writing the UDDC bit to 1 in the LCD_CLR register when executing the corresponding interrupt handling vector.

Depending on the product implementation, all these interrupts events can either share the same interrupt vector (LCD global interrupt), or be grouped into 2 interrupt vectors (LCD SOF interrupt and LCD UDD interrupt). Refer to the Vector table in the Interrupts and events section for details.

In order to enable the LCD interrupts, the following sequence is required:

  1. 1. Configure and enable the LCD IRQ channel in the NVIC
  2. 2. Configure the LCD to generate interrupts

16.6 LCD registers

The peripheral registers have to be accessed by words (32-bit).

16.6.1 LCD control register (LCD_CR)

Address offset: 0x00

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.BUFENRes.BIAS[1:0]DUTY[2:0]VSELLCDEN
rwrwrwrwrwrwrwrw

Bits 31:9 Reserved, must be kept at reset value

Bit 8 BUFEN : Voltage output buffer enable

This bit is used to enable/disable the voltage output buffer for higher driving capability.

0: Output buffer disabled

1: Output buffer enabled

Bit 7 Reserved, must be kept at reset value

Bits 6:5 BIAS[1:0]: Bias selector

These bits determine the bias used. Value 11 is forbidden.

00: Bias 1/4

01: Bias 1/2

10: Bias 1/3

11: Reserved

Bits 4:2 DUTY[2:0]: Duty selection

These bits determine the duty cycle. Values 101, 110 and 111 are forbidden.

000: Static duty

001: 1/2 duty

010: 1/3 duty

011: 1/4 duty

100: 1/8 duty

101: Reserved

110: Reserved

111: Reserved

Bit 1 VSEL: Voltage source selection

The VSEL bit determines the voltage source for the LCD.

0: Internal source (voltage step-up converter)

1: External source (VLCD pin)

Bit 0 LCDEN: LCD controller enable

This bit is set by software to enable the LCD Controller/Driver. It is cleared by software to turn off the LCD at the beginning of the next frame. When the LCD is disabled all COM and SEG pins are driven to VSS.

0: LCD Controller disabled

1: LCD Controller enabled

Note: The VSEL, MUX_SEG, BIAS, DUTY and BUFEN bits are write protected when the LCD is enabled (ENS bit in LCD_SR to 1).

16.6.2 LCD frame control register (LCD_FCR)

Address offset: 0x04

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.PS[3:0]DIV[3:0]BLINK[1:0]
rwrwrwrwrwrwrwrwrwrw
1514131211109876543210
BLINKF[2:0]CC[2:0]DEAD[2:0]PON[2:0]UDDIERes.SOFIEHD
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:26 Reserved, must be kept at reset value

Bits 25:22 PS[3:0]: PS 16-bit prescaler

These bits are written by software to define the division factor of the PS 16-bit prescaler.
ck_ps = LCDCLK/(2). See Section 16.4.2.

0000: ck_ps = LCDCLK

0001: ck_ps = LCDCLK/2

0010: ck_ps = LCDCLK/4

...

1111: ck_ps = LCDCLK/32768

Bits 21:18 DIV[3:0]: DIV clock divider

These bits are written by software to define the division factor of the DIV divider. See Section 16.4.2.

0000: ck_div = ck_ps/16

0001: ck_div = ck_ps/17

0010: ck_div = ck_ps/18

...

1111: ck_div = ck_ps/31

Bits 17:16 BLINK[1:0]: Blink mode selection

00: Blink disabled

01: Blink enabled on SEG[0], COM[0] (1 pixel)

10: Blink enabled on SEG[0], all COMs (up to 8 pixels depending on the programmed duty)

11: Blink enabled on all SEGs and all COMs (all pixels)

Bits 15:13 BLINKF[2:0]: Blink frequency selection

000: \(f_{LCD}/8\)

100: \(f_{LCD}/128\)

001: \(f_{LCD}/16\)

101: \(f_{LCD}/256\)

010: \(f_{LCD}/32\)

110: \(f_{LCD}/512\)

011: \(f_{LCD}/64\)

111: \(f_{LCD}/1024\)

Bits 12:10 CC[2:0]: Contrast control

These bits specify one of the \(V_{LCD}\) maximum voltages (independent of \(V_{DD}\)). It ranges from 2.60 V to 3.51 V.

000: \(V_{LCD0}\)

100: \(V_{LCD4}\)

001: \(V_{LCD1}\)

101: \(V_{LCD5}\)

010: \(V_{LCD2}\)

110: \(V_{LCD6}\)

011: \(V_{LCD3}\)

111: \(V_{LCD7}\)

Note: Refer to the product datasheet for the \(V_{LCDx}\) values.

Bits 9:7 DEAD[2:0]: Dead time duration

These bits are written by software to configure the length of the dead time between frames. During the dead time the COM and SEG voltage levels are held at 0 V to reduce the contrast without modifying the frame rate.

000: No dead time

001: 1 phase period dead time

010: 2 phase period dead time

.....

111: 7 phase period dead time

Bits 6:4 PON[2:0]: Pulse ON duration

These bits are written by software to define the pulse duration in terms of ck_ps pulses. A short pulse leads to lower power consumption, but displays with high internal resistance may need a longer pulse to achieve satisfactory contrast. Note that the pulse is never longer than one half prescaled LCD clock period.

000: 0

100: 4/ck_ps

001: 1/ck_ps

101: 5/ck_ps

010: 2/ck_ps

110: 6/ck_ps

011: 3/ck_ps

111: 7/ck_ps

PON duration example with LCDCLK = 32.768 kHz and PS=0x03:

000: 0 μs

100: 976 μs

001: 244 μs

101: 1.22 ms

010: 488 μs

110: 1.46 ms

011: 782 μs

111: 1.71 ms

Bit 3 UDDIE: Update display done interrupt enable

This bit is set and cleared by software.

0: LCD Update Display Done interrupt disabled

1: LCD Update Display Done interrupt enabled

Bit 2 Reserved, must be kept at reset value

Bit 1 SOFIE: Start of frame interrupt enable

This bit is set and cleared by software.

0: LCD Start of Frame interrupt disabled

1: LCD Start of Frame interrupt enabled

Bit 0 HD: High drive enable

This bit is written by software to enable a low resistance divider. Displays with high internal resistance may need a longer drive time to achieve satisfactory contrast. This bit is useful in this case if some additional power consumption can be tolerated.

0: Permanent high drive disabled

1: Permanent high drive enabled. When HD=1, then the PON bits have to be programmed to 001.

Note: The data in this register can be updated any time, however the new values are applied only at the beginning of the next frame (except for UDDIE, SOFIE that affect the device behavior immediately).

The new value of CC[2:0] bits is also applied immediately but its effect on device is delayed at the beginning of next frame by the voltage generator.

Reading this register obtains the last value written in the register and not the configuration used to display the current frame.

Note: 1 When BUFEN bit is set in the LCD_CR register, low resistor divider network is automatically disabled whatever the HD or PON[2:0] bits configuration.

16.6.3 LCD status register (LCD_SR)

Address offset: 0x08

Reset value: 0x0000 0020

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.FCRSFRDYUDDUDRSOFENS
rrrrsrr

Bits 31:6 Reserved, must be kept at reset value

Bit 5 FCRSF: LCD Frame Control Register Synchronization flag

This bit is set by hardware each time the LCD_FCR register is updated in the LCDCLK domain. It is cleared by hardware when writing to the LCD_FCR register.

Bit 4 RDY: Ready flag

This bit is set and cleared by hardware. It indicates the status of the step-up converter.

Bit 3 UDD: Update Display Done

This bit is set by hardware. It is cleared by writing 1 to the UDDC bit in the LCD_CLR register. The bit set has priority over the clear.

Note: If the device is in STOP mode (PCLK not provided) UDD does not generate an interrupt even if UDDIE = 1.
If the display is not enabled the UDD interrupt never occurs.

Bit 2 UDR: Update display request

Each time software modifies the LCD_RAM it must set the UDR bit to transfer the updated data to the second level buffer. The UDR bit stays set until the end of the update and during this time the LCD_RAM is write protected.

Note: When the display is disabled, the update is performed for all LCD_DISPLAY locations. When the display is enabled, the update is performed only for locations for which commons are active (depending on DUTY). For example if DUTY = 1/2, only the LCD_DISPLAY of COM0 and COM1 is updated.

Note: Writing 0 on this bit or writing 1 when it is already 1 has no effect. This bit can be cleared by hardware only. It can be cleared only when LCDEN = 1

Bit 1 SOF: Start of frame flag

This bit is set by hardware at the beginning of a new frame, at the same time as the display data is updated. It is cleared by writing a 1 to the SOFC bit in the LCD_CLR register. The bit clear has priority over the set.

0: No event

1: Start of Frame event occurred. An LCD Start of Frame Interrupt is generated if the SOFIE bit is set.

Bit 0 ENS: LCD enabled status

This bit is set and cleared by hardware. It indicates the LCD controller status.

0: LCD Controller disabled.

1: LCD Controller enabled

Note: The ENS bit is set immediately when the LCDEN bit in the LCD_CR goes from 0 to 1. On deactivation it reflects the real status of LCD so it becomes 0 at the end of the last displayed frame.

16.6.4 LCD clear register (LCD_CLR)

Address offset: 0x0C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.UDDCRes.SOFCRes.
ww

Bit 31:2 Reserved, must be kept at reset value

Bit 3 UDDC: Update display done clear

This bit is written by software to clear the UDD flag in the LCD_SR register.

0: No effect

1: Clear UDD flag

Bit 2 Reserved, must be kept at reset value

Bit 1 SOFC: Start of frame flag clear

This bit is written by software to clear the SOF flag in the LCD_SR register.

0: No effect

1: Clear SOF flag

Bit 0 Reserved, must be kept at reset value

16.6.5 LCD display memory (LCD_RAM)

Address offset: 0x14-0x50

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
SEGMENT_DATA[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 SEGMENT_DATA[31:0]

Each bit corresponds to one pixel of the LCD display.

0: Pixel inactive

1: Pixel active

16.7 LCD register map

The following table summarizes the LCD registers.

Table 44. LCD register map and reset values

OffsetRegister313029282726252423222120191817161514131211109876543210
0x00LCD_CRReservedBUFENRes.BIAS[1:0]DUTY[2:0]VSELLCDEN
Reset value00000000
0x04LCD_FCRReservedPS[3:0]DIV[3:0]BLINK[1:0]BLINKF[2:0]CC[2:0]DEAD[2:0]PON[2:0]UDDIERes.SOFIEHD
Reset value0000000000000000000000000
0x08LCD_SRReservedFCRSFRDYUDDUDRSOFENS
Reset value1000000
0x0CLCD_CLRReservedUDDCRes.SOFCRes.
Reset value000000
0x14LCD_RAM (COM0)ReservedS15S14S13S12S11S10S09S08S07S06S05S04S03S02S01S00
0000000000000000
0x18LCD_RAM (COM0)Reserved
0x1CLCD_RAM (COM1)ReservedS15S14S13S12S11S10S09S08S07S06S05S04S03S02S01S00
0000000000000000
0x20LCD_RAM (COM1)Reserved
0x24LCD_RAM (COM2)ReservedS15S14S13S12S11S10S09S08S07S06S05S04S03S02S01S00
0000000000000000
0x28LCD_RAM (COM2)Reserved
0x2CLCD_RAM (COM3)ReservedS15S14S13S12S11S10S09S08S07S06S05S04S03S02S01S00
0000000000000000
0x30LCD_RAM (COM3)Reserved
0x34LCD_RAM (COM4)ReservedS11S10S09S08S07S06S05S04S03S02S01S00
000000000000
0x38LCD_RAM (COM4)Reserved

Table 44. LCD register map and reset values (continued)

OffsetRegister313029282726252423222120191817161514131211109876543210
0x3CLCD_RAM
(COM5)
ReservedS11S10S09S08S07S06S05S04S03S02S01S00
000000000000
0x40Reserved
0x44LCD_RAM
(COM6)
ReservedS11S10S09S08S07S06S05S04S03S02S01S00
000000000000
0x48Reserved
0x4CLCD_RAM
(COM7)
ReservedS11S10S09S08S07S06S05S04S03S02S01S00
000000000000
0x50Reserved

Refer to Section 2.2.2: Memory map and register boundary addresses for the Register boundary addresses table.