AN2687 Application note

Similar documents
Obsolete Product(s) - Obsolete Product(s)

STEVAL-ILL031V1. Digital constant-current controller for LED driving based on the STM8S208x. Features. Description

STEVAL-IHM043V1. 6-step BLDC sensorless driver board based on the STM32F051 and L6234. Features. Description

STEVAL-ILH004V1. 70 W electronic ballast for metal halide lamp (HID) based on the L6382D5 and ST7FLITE49K2. Features. Description

STEVAL-ILL029V1. Front panel demonstration board based on the STLED325 and STM8S. Features. Description

STEVAL-ICB004V1. Advanced resistive touchscreen controller demonstration board based on the STMPE811. Features. Description

STEVAL-IHM021V W, 3-phase inverter based on the L6390 and UltraFASTmesh MOSFET for speed FOC of 3-phase PMSM motor drives. Features.

ROBOT-M24LR16E-A. Evaluation board for the M24LR16E-R dual interface EEPROM. Features. Description

STEVAL-CCH002V2. HDMI and video switches demonstration board. Features. Description

STEVAL-ILL015V1. High brightness RGB LED array with LED error detection based on the STP24DP05 and STM32. Features. Description

STEVAL-SPBT2ATV2. USB Dongle for the Bluetooth class 2 SPBT2532C2.AT module. Features. Description

EVALPM8803-FWD. EVALPM8803-FWD: IEEE802.3at compliant demonstration kit with synchronous active clamp forward PoE converter. Features.

STEVAL-IHM024V W 3-phase inverter using the L6390 and STGDL6NC60DI for vector control. Features. Applications. Description

Multi-channel LED driver with integrated boost controller for medium, large LCD panel backlight based on LED7708 and STM32F103C6T6A

Obsolete Product(s) - Obsolete Product(s)

STEVAL-ILH005V W electronic ballast for HID lamps based on the L6562A and ST7LITE39F2. Features. Description

IEC compliant smart meter system for AMI applications based on STM32, ST7570 PLM, and STPMC1/STPMS1 chipset

STEVAL-IME002V1. Multi-lead electrocardiogram (ECG) and body impedance demonstration board. Features. Description

STEVAL-ILL037V1. Demonstration board for the HVLED805 IC for LED power supply. Features. Description

Obsolete Product(s) - Obsolete Product(s)

UM0534 User manual. STEVAL-MKI014V1 demonstration kit for the LIS344ALH. Introduction

Obsolete Product(s) - Obsolete Product(s)

L7208. Portable consumer electronics spindle and VCM motor controller. General features. Spindle driver. Description. VCM driver.

March 2012 Doc ID Rev 1 1/4

STEVAL-ILL043V1. High end, 75 W high power factor flyback LED driver based on the L6562A with two dimmable strings. Features.

AN3075 Application note

STEVAL-ISB008V1. Standalone USB Li-Ion battery charger demonstration board based on the STw4102 and STM32F103C6. Features.

PRODUCT INFORMATION LETTER

Obsolete Product(s) - Obsolete Product(s)

STEVAL-ISA121V1. Wide range single-output demonstration board based on the VIPER37LE. Features. Description

Obsolete Product(s) - Obsolete Product(s)

STEVAL-CCM003V1. Graphic panel with ZigBee features based on the STM32 and SPZBE260 module. Features. Description

STEVAL-IHM025V1. 1 kw 3-phase motor control demonstration board featuring the IGBT SLLIMM STGIPL14K60. Features. Description

SPC564A80CAL176 SPC564A70CAL176

STEVAL-IFN003V1. PMSM FOC motor driver based on the L6230 and STM32F103. Features. Description

EVAL-RHF1009A. EVAL-RHF1009A product evaluation board. Description. Features

STEVAL-ILL019V1. 32 W offline RGGB LED driver with individual LED channel brightness regulation. Features. Description

STEVAL-IKR001V7D. Sub Ghz transceiver daughterboard with power amplifier based on the SPIRIT1. Features. Description

Obsolete Product(s) - Obsolete Product(s)

Order code Package Connection. SPDC400FC12M0.60 Open frame Comb. October 2007 Rev 1 1/9

M24LR04E-R, M24LR16E-R, M24LR64E-R Errata sheet

Mechanical specification. October 2010 Doc ID Rev 1 1/10

2 x 58 W high frequency ballast for T8 fluorescent tubes based on L6562A, L6569, and STL11NM60N in PowerFlat HV package

STEVAL-IHM008V1. BLDC & AC motor control Power board SEMITOP 2 1kW. Features. Applications

Obsolete Product(s) - Obsolete Product(s)

STEVAL-CCA043V1. 25 Watt mono BTL class-d audio amplifier demonstration board based on the TDA7491MV. Features. Description

STEVAL-IHT005V2. Demonstration board with full 3.3 V ACS/Triac control using the STM32F100. Description. Features

AN2421 Application note

Main components Narrow-band OFDM power line networking PRIME compliant system-on-chip

STEVAL-TDR021V1. Demonstration board using the PD84008L-E for 900 MHz 2-way radio. Features. Description

STEVAL-TDR020V1. Portable UHF 2-way radio demonstration board based on the PD84006L-E. Features. Description

GM60028H. DisplayPort transmitter. Features. Applications

STEVAL-TDR007V1. 3 stage RF power amplifier demonstration board using: PD57002-E, PD57018-E, 2 x PD57060-E. Features. Description

VT5365. Single-chip optical mouse sensor for wireless applications. Features. Applications. Technical specifications. Description.

EVAL6208Q. Stepper motor driver mounting the L6208Q. Features. Description

BAL-NRF01D3. 50 ohm balun transformer for 2G45 ISM matched Nordic s chipset: nrf24le1 QFN32, nrf24ap2-1ch and nrf24ap2-8ch. Features.

IMPORTANT NOTICE. Company name - STMicroelectronics NV is replaced with ST-NXP Wireless.

GM68020H. DisplayPort receiver. Features. Applications

Description. Table 1. Device summary. Order codes Temperature range [ C] Package Packing. LPS2HBTR -30 to +105 HLGA - 10L

GM69010H DisplayPort, HDMI, and component input receiver Features Applications

TN0885 Technical note

ST-LINK/V2 in-circuit debugger/programmer for STM8 and STM32

STV6417 R/C/Pr, G/C, B/Pb Switches + Filter. C, Y, CVBS/Y Switches + Filter. Audio Switches Volume Control AUDIO R SLOW BLANK

STEVAL-IHM038V1. BLDC ceiling fan controller based on the STM32 and SLLIMM-nano. Description. Features

STV6110A. 8PSK/QPSK low-power 3.3 V satellite tuner IC. Description. Features

EVAL6474PD. Stepper motor driver mounting the L6474 in a high power PowerSO package. Features. Description

EVLHVLED815W8CV. 8 W - high power factor - constant voltage regulation based on HVLED815PF. Features. Description

Main components Proximity and ambient light sensing (ALS) module

STEVAL-ISA050V1. Monolithic VR for chipset and DDR2/3 demonstration board based on the PM6641. Features. Application. Description

Hello and welcome to this training module for the STM32L4 Liquid Crystal Display (LCD) controller. This controller can be used in a wide range of

Very low-noise, high-efficiency DC-DC conversion circuit

ST10F273M Errata sheet

Obsolete Product(s) - Obsolete Product(s) UM0223 User manual STEVAL-IFS001V1 evaluation kit with MEMS Introduction

STDP4020. DisplayPort receiver. Features. Applications

STW High voltage fast-switching NPN power transistor. Features. Application. Description

IMPORTANT NOTICE. Company name - STMicroelectronics NV is replaced with ST-NXP Wireless.

AN2415 Application note

STEVAL-MKI126V2. MEMS microphone system evaluation board based on the STA321MPL and MP34DB01. Description. Features

STEVAL-MKI126V3. STSmartVoice demonstration board based on MP34DT01. Description. Features

M24SR-DISCOVERY. Discovery kit for the M24SR series Dynamic NFC/RFID tag. Features

PRODUCT TERMINATION NOTIFICATION

STM32-PRIMER/LAB. Raisonance EvoPrimer-LAB to monitor STM32 applications and standalone STM32 Flash programming. Features

Order code Marking Package Packing. STA5630TR STA5630 VFQFPN32 Tape and reel STA5630ATR (1) September 2013 Doc ID Rev 4 1/8

Obsolete Product(s) - Obsolete Product(s)

Main components Proximity and ambient light sensing (ALS) module

AN4178 Application note

STANC0. Stereo HD-PA digitally programmable active noise cancelling audio engine. Features. System. Input and output.

STDP2650 Advanced DisplayPort to HDMI converter Features Applications

STEVAL-ISA001V1. 6W Dual Output Supply using VIPer12A. Features. Blue angel. Applications

STEVAL-IHM034V2. Dual motor control and PFC evaluation board featuring the STM32F103 and STGIPS20C60. Features

EVLHVLED815W10F. 10 W wide-range high power factor isolated LED driver based on HVLED815PF. Description. Features

PRODUCT/PROCESS CHANGE NOTIFICATION

Order code Package Packing

USBLC6-4SC6Y. Automotive very low capacitance ESD protection. Features. Applications. Description. Benefits. Complies with the following standards

Fully integrated stepper motor driver mounting the L6470 in a high power PowerSo package. May 2012 Doc ID Rev 2 1/12

STi5105 High-performance advanced SD decoder for set-top box Features

FLI30x02 Single-chip analog TV processor Features Application

STDP2500. Mobility DisplayPort (MyDP) to DP converter. Features. Applications

STA3005. Dual-IF AM/FM digital radio receiver. Feature summary. Order codes

STDP4320 DisplayPort 1.2a splitter Features Applications

Transcription:

AN267 Application note SMS20xxx LCD software driver Introduction his application note describes two different methods for driving liquid crystal displays (LCD) with any standard SMS20xxx 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 his application note starts with an introduction on LCDs in Section : LCD principle and Section 2: LCD drive signals. Section 3 then presents a solution based on a standard SMS20xxx MCU directly driving a quadruplex LCD. his 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 SMS20xxx microcontroller, and provides the board schematics. For more information on the LCD drive theory, please refer also to AN04. he number of external components is kept to a minimum of two external resistors per COM line. he 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 4296 Rev /22

Contents AN267 Contents LCD principle............................................... 5 2 LCD drive signals........................................... 7 2. Quadruplex LCD drive........................................ 7 2.. LCD mean voltage calculation................................. 2..2 Contrast calculation......................................... 9 3 Example of a quadruplex LCD driver with SM................. 0 3. First method: imer 2........................................ 2 3.2 Second method: Auto-wakeup................................. 3 4 Consumption considerations................................. 4 5 Software contrast control with the first method................. 7 5. Contrast calculations........................................ 7 6 LCD demo board........................................... 9 6. Board information........................................... 20 7 Revision history........................................... 2 2/22 Doc ID 4296 Rev

AN267 List of tables List of tables able. LCD RAM.............................................................. able 2. First method - consumption (imer 2)......................................... 4 able 3. Second method - consumption (AWU)........................................ 4 able 4. Document revision history................................................. 2 Doc ID 4296 Rev 3/22

List of figures AN267 List of figures Figure. 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...................................... Figure 5. Hardware connection diagram.............................................. 2 Figure 6. LCD timing diagram with dead & active time (to decrease Vrms).................... 5 Figure 7. LCD timing diagram with active and dead time (to increase Vrms).................. 6 Figure. Schematic diagram....................................................... 9 4/22 Doc ID 4296 Rev

AN267 LCD principle LCD principle Figure. 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. he 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. he 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. he 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. he 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= MeanSignal 2 ) levels. With a low root mean square voltage applied to it, an LCD is practically transparent (the LCD segment is then inactive or off). o 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. he 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. he LCD threshold voltage depends on the quality of the liquid used in the LCD and the temperature. he 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). he 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 ). he higher the difference between V ON (rms) and V OFF (rms), the higher the optical contrast. he 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. Doc ID 4296 Rev 5/22

LCD principle AN267 In this document, contrast is defined as D = V ON (rms) / V OFF (rms). he applied LCD voltage must also alternate to give a zero DC value to prevent the electrolytic process and so, ensure a long LCD lifetime. he higher the multiplexing rates, the lower the contrast. he signal period also has to be short enough to avoid visible flickering on the display. Figure 2. Equivalent electrical schematic of an LCD segment S C COM R S ai475 Note: he DC value should never be more than 00 mv (refer to the LCD manufacturer s datasheet), otherwise the LCD lifetime may be shortened. he 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 4296 Rev

AN267 LCD drive signals 2 LCD drive signals 2. 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). hus, only (S/4)+4 MCU pins are necessary to drive an LCD with S segments. For example, to drive an LCD with 2 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). hree different voltage levels have to be generated on the common lines: 0, V DD /2, V DD. he Segment line voltage levels are 0 and V DD only. he LCD segment is inactive if the RMS voltage is below the LCD threshold voltage and is active if the LCD RMS voltage is above the threshold. he intermediate voltage V DD /2 is only required for backplane voltages. he MCU I/O pins selected as backplanes are set by software to output mode for 0 or V DD levels and to the high-impedance input mode for V DD /2. he V DD /2 voltage is determined by two resistors of 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 DD /2 to them. Figure 3. Basic LCD segment connection in quadruplexed mode S S2 S3 S S2 S3 S4 COM COM2 COM3 COM4 ai4762 Doc ID 4296 Rev 7/22

LCD drive signals AN267 Figure 4. LCD timing diagram for quadruplex mode V COM COM Single-frame period Control period / /4 /2 3/4 COM LCD COM2 COM2 COM3 COM3 COM4 COM4 Vsegx SEG Segx_ On Segx_2 Off Segx_3 On Segx_4 Off Vseg V COM Vseg V COM Vseg V COM4 ai5954 2.. LCD mean voltage calculation he LCD mean voltage must be very close to zero to guarantee long life to the LCD. he LCD mean voltage for On and Off periods can be calculated as shown below: Vmean(On) = / Vseg + / ( V COM ) + 3(Vseg Vr/2) + 3( Vr/2) () Vmean(Off) = 3(Vseg/2) + 3( Vr/2) (2) Vmean(On) and Vmean(Off) assume identical periods for each phase. Equating equations () & (2) to zero, that is putting Vmean(On) = 0 and Vmean(Off) = 0, gives: Vseg = V COM = Vr = V DD, where: V COM is the maximum voltage on the COM line Vr/2 is the voltage in the middle of the resistor bridge, applied on the COM line Vseg is the maximum voltage on the Segx line V DD is the microcontroller power supply /22 Doc ID 4296 Rev

AN267 LCD drive signals 2..2 Contrast calculation he performance of an LCD driving system is defined by the contrast. Contrast (D) = Vrms(On) / Vrms(Off) For the quadruplex signal as described on the previous page: -- ft 2 dt Vrms(On) = = 0 2 ------ -- -- V DD 2 dt + V DD 2 dt + 0 -- 2 ------ V ---------- DD 2 dt 2 Vrms(On) = -- V DD 2 -- V DD 2 -- V DD 2 ----------------- 6 + + ----------- 4 = 0.66V DD Vrms(Off) = 2 ------ -- -- 0dt + 0dt + 0 -- 2 ------ V ---------- DD 2 dt 2 = 0.433V DD Contrast (D) = Vrms(On) / Vrms(Off) = 0.66V DD / 0.433V DD =.53 For comparison, a hardware LCD drive uses /3 bias voltage. With /3 bias control, the contrast value (D) is.73. herefore, /3 bias gives only a small contrast advantage. his advantage is reduced to zero when using software contrast control. Doc ID 4296 Rev 9/22

Example of a quadruplex LCD driver with SM AN267 3 Example of a quadruplex LCD driver with SM he following example describes a drive for a quadruplex mode (4 COM) LCD using the SMS20xxx (QFP64 package 0 0 mm). he only external components needed for driving the LCD are eight resistors (refer to Figure 5). he resistor value of 470 k is used to reach a low current consumption. One I/O port per segment and one I/O port for each COM line are needed to drive the LCD. In our example, to drive a quadruplex LCD that has 2 segments (with 32 segment lines and 4 COM lines) 36 I/O ports are required. In the example program, the PG0-PG7, PE0-PE7, PD0-PD7 and PB0-PB7 port pins are connected to the 32 segment lines and are used to generate the segment signals. As PE and PE2 are true open drain I/Os (I 2 C alternate function), two 0 k pull-up resistors have been added. Port G segments control the display of LCD digits and 2, port E segments control digits 3 and 4, port D segments controls digits 5 and 6 and port B segments control the display of LCD digits 7 and. Ports PC4 through PC7 are connected to the 4 COM lines (COM 4, 3, 2 and, respectively) and are used to generate the COM signals. he LCD driver consists of: one initialization function (LCD_ON) that correctly configures the required I/Os and the imer 2 resource (to get the 2 real-time clock interrupts) for the first method, or the AWU mode one for the second method. one display function (LCD_Display) that enables the user to easily enter the string of characters ( characters maximum) to be displayed on the -digit LCD screen. one LCD RAM part that contains the coding of the numbers or letters to be displayed on the LCD (refer to able ). his LCD RAM table is filled automatically each time LCD_Display function is called, depending on the characters composing the string to display. a generic.h file containing: the different possible configurations in terms of numbers of COM and SEG (one configuration has to be selected, knowing that the default configuration is 4 COM and 32 SEG) the clock (HSI with one possible prescaler or LSI) the values put in the imer 2 compare and autoreload registers depending on the chosen LCD frame rate for the first method the letter and number constant coding tables which are contained in the lcd.c file. he file can be easily modified by the user depending on the LCD type used. When the LSI clock is used, in order to speed up the I/O toggling execution, the program switches to the HSI clock, and returns to the LSI clock once this is done. For more information regarding the software architecture, please refer to the lcd_awu.pdf and lcd_timer2.pdf files attached with the source codes in the zip file associated with this application note. 0/22 Doc ID 4296 Rev

AN267 Example of a quadruplex LCD driver with SM able. LCD RAM COM 7 6 5 4 3 2 0 Port S7 S6 S5 S4 S3 S2 S S0 Port B COM (PC7) COM2 (PC6) COM3 (PC5) COM4 (PC4) S5 S4 S3 S2 S S0 S9 S Port D S23 S22 S2 S20 S9 S S7 S6 Port E S3 S30 S29 S2 S27 S26 S25 S24 Port G S7 S6 S5 S4 S3 S2 S S0 Port B S5 S4 S3 S2 S S0 S9 S Port D S23 S22 S2 S20 S9 S S7 S6 Port E S3 S30 S29 S2 S27 S26 S25 S24 Port G S7 S6 S5 S4 S3 S2 S S0 Port B S5 S4 S3 S2 S S0 S9 S Port D S23 S22 S2 S20 S9 S S7 S6 Port E S3 S30 S29 S2 S27 S26 S25 S24 Port G S7 S6 S5 S4 S3 S2 S S0 Port B S5 S4 S3 S2 S S0 S9 S Port D S23 S22 S2 S20 S9 S S7 S6 Port E S3 S30 S29 S2 S27 S26 S25 S24 Port G Doc ID 4296 Rev /22

Example of a quadruplex LCD driver with SM AN267 Figure 5. Hardware connection diagram V DD 470 kω Network resistors 470 kω Common lines LCD Glass Segment lines V DD PB0-PB PC4-PC7 PD0-PD PE0-PE PG0-PG PE PE2 0 kω SM ai4904 3. First method: imer 2 In this method, the LCD timing is generated by the imer 2 edge alignment mode using 2 interrupts: a compare one (value loaded into the IM2_CCR register) and an overflow one (value loaded into the IM2_ARR register). Each LCD display cycle consists of 4 phases, one for each backplane. Each COM line generates its waveform during the corresponding phase e.g. COM line during phase, COM2 line during phase 2, etc. When they are not generating their waveforms the COM lines remains at level V DD /2. Each phase consists of two parts:. active time 2. dead time During the active time, the segment lines and COM lines are used to drive the LCD. During the dead time, the segment and COM lines are used to tune the contrast. he active time starts after the Compare interrupt and, the dead time starts after the Overflow interrupt. A total of 6 interrupts is generated in each frame period with 4 interrupts per control period. here are 2 Compare events (CCR_ and CCR_2 managed in the 2/22 Doc ID 4296 Rev

AN267 Example of a quadruplex LCD driver with SM same interrupt function) and 2 Overflow events (OVF) in each phase. he latter are described below: During CCR_, V DD is applied to the segments that have to be turned on and 0, to the segments that have to be turned off. he COM line that corresponds to this phase is set to low level. Other COM lines are set to the V DD /2 level. During OVF, all COM lines are inactive (set to low level), then if Vrms has to be decreased (see Figure 6) all segments are set low or, if it has to be increased (see Figure 7), all segments are set high. During CCR_2, the segment lines are supplied with voltage levels that are inverted compared to those applied during CCR_. he COM line that corresponds to this phase is set to high level. Other COM lines are set to the V DD /2 level. During OVF2, if Vrms has to be decreased then all COM lines and segments are inactive (set to low level) and if Vrms has to be increased (see Figure 7), the COM lines are set high and the segments are set low. In order to reduce consumption, the MCU is placed in WFI (wait for interrupt) mode in the main routine. he MCU is then woken up by the imer 2 interrupts and the external interrupts (PA4/PA5 connected to push-buttons, refer to Section 6 for more information). 3.2 Second method: Auto-wakeup In this method, the LCD timing is generated by the Auto-wakeup time base. he MCU is placed in Auto-wakeup mode, meaning that it is in Halt mode but woken up periodically as the LSI source clock (embedded low-power RC around 2 khz) remains active. When woken up, the MCU toggles the COM and SEG lines in the AWU interrupt routine, exactly as it was doing in the previous method in the imer 2 interrupt routine. he software contrast control is not as easy to implement with this method as AWU timeouts are fixed. It could be less fine-tuned. Using this method, consumption can be very low (a total consumption of.0 ma at 3.3 V with HSI as the master clock). Doc ID 4296 Rev 3/22

Consumption considerations AN267 4 Consumption considerations he number of code lines the MCU has to execute to drive the LCD is the same whatever the CPU frequency. It is then easy to understand that the faster the CPU clock, the faster these code lines are executed, the less they represent in terms of CPU load, and the less the MCU consumes. In order to reduce consumption with both methods, the PCKEN (peripheral clock gating) register of the Clock Controller is used in order to clock only the used peripherals. V DD can also be decreased, especially in the first method (as the contrast can be compensated for by software) to further reduce the consumption. he consumption values obtained with the first method (at 3.3 V) are given in able 2. able 2. First method - consumption (imer 2) Clock master Consumption of the MCU executing LCD driver (ma) Consumption of the LCD driver (ma) Consumption of the MCU executing an empty loop HSI 2.3 0.3 2.0 HSI/2.73 0.3.35 HSI/4.45 0.49 0.96 HSI/.3 0.7 0.6 LSI.7 0.94 0.23 Note: hese typical values are given for guidance only. he LCD driver consumption is obtained by subtracting the consumption of the MCU executing the LCD driver function and the consumption of the MCU executing an empty loop (with all I/Os configured as output low level). he consumption values obtained with the second method (at 3.3 V) are given in able 3. able 3. Clock master Second method - consumption (AWU) Consumption of the MCU executing LCD driver (ma) Consumption of the LCD driver (ma) Consumption of the MCU executing an empty loop HSI.0 0.36 0.72 HSI/2.2 0.4 0.72 HSI/4.26 0.5 0.75 HSI/.34 0.5 0.76 LSI.02 0.33 0.69 Note: hese typical values are given for guidance only. he LCD driver consumption is obtained by subtracting the consumption of the MCU executing the LCD driver function and the consumption of the MCU executing an empty loop (with the MCU in AWU mode with all its I/Os configured as output low level). 4/22 Doc ID 4296 Rev

AN267 Consumption considerations Figure 6. LCD timing diagram with dead & active time (to decrease Vrms) V COM Dead time Active time Control period COM V COM /4 /2 3/4 COM2 V COM COM3 V COM COM4 Vseg Segx_ (On) Segx_ On Vseg V COM Segx_ Off OVF OVF2 CCR_ CCR_2 CCR_ ai5957 Doc ID 4296 Rev 5/22

Consumption considerations AN267 Figure 7. LCD timing diagram with active and dead time (to increase Vrms) Dead time Dead time Dead time Dead time Dead time Dead time Active time V COM COM Control period V COM COM2 /4 /2 3/4 V COM COM3 V COM COM4 Segx Vseg Segx_ On Segx_2 Off Segx_3 On Segx_4 On Segx_ On Vseg Vseg Segx_2 Off CCR_ CCR_2 OVF OVF2 ai5953 6/22 Doc ID 4296 Rev

AN267 Software contrast control with the first method 5 Software contrast control with the first method Software contrast control is under patent from SMicroelectronics. he use of this technique with a non-smicroelectronics microcontroller has to be agreed by SMicroelectronics. LCD contrast is entirely controlled by software with no need for any external component. LCD contrast can be adjusted to the optimal value depending on the operating voltage of the used LCD. LCD contrast is controlled by varying the dead phase timing as shown in the LCD timing diagrams. his corresponds to the variation of the compare event value. Dead time can be used to either decrease or increase the LCD Vrms. Dead time is the voltage compensation time to regulate the rms voltage up and down. Dead time can be implemented either after each control period or at the end of the frame. o avoid flickering, the dead time duration must be adjusted depending on the quality of LCD and the frequency of the frame. In the example shown in Figure 6, the Vrms value of the LCD decreases when the dead time duration increases and the Vrms value increases when the dead time duration decreases. he opposite process is shown in Figure 7. wo push-buttons connected to PA4 and PA5 are used on the demo board to decrease and increase contrast, respectively, using this software method. Relatively high software contrast control steps were chosen with the object of reaching maximum or minimum contrast by pressing the push-buttons around 0 times. his can be further fine-tuned if needed. 5. Contrast calculations Let the frame period be + x, where: is the Active time x is the Dead time In the formulas below, x corresponds to the proportion of dead time and Vx corresponds to the voltage during the Dead time. Vrms(on) = Vrms(on) = + x ---------------- + x ft 2 dt 0 ---------------- + x V 2 dt V DD DD 2 V DD dt ---------- 2 x -- 2 ------ ------ dt Vx 2 + + dt + 2 2 0 -- ------ 0 Vrms(on) = ---------------- + x V 2 2 V 2 -- V DD DD -- ---------- DD 6 4 ------ Vx 2 x ------ + + + Vrms(on) = ----------- 4V 2 DD ----------------- + Vx 2 x + x 32 Doc ID 4296 Rev 7/22

Software contrast control with the first method AN267 Since Vx = 0 (in case of a decrease in Vrms) Vrms(on) = ----------- 4V 2 DD ----------------- = ----------- 0.66V + x 32 + x DD Vrms(off) = Vrms(off) = ---------------- + x 0 V DD dt 0dt ---------- 2 x -- 2 ------ ------ 2 dt Vx 2 + + dt + 2 0 -- ------ 0 ---------------- 6V 2 -------------- DD dt Vx 2 + x + x 32 Since Vx = 0 (in case of a decrease in Vrms) Vrms(off) = ----------- 0.433V + x DD Contrast (Dx) = ----------- 0.66V + x DD ----------------------------------------------------- ----------- 0.433V + x DD, where Dx is the contrast calculated with the contrast control method Contrast D, between V ON and V OFF is constant (quality of contrast). he optical contrast has been changed only by tuning V ON close to the threshold value of the LCD. /22 Doc ID 4296 Rev

AN267 LCD demo board Doc ID 4296 Rev 9/22 6 LCD demo board Figure. Schematic diagram 470K R6 470K R7 470K R 470K R9 470K R0 470K R 0K R 0K R2 0K R3 0K R4 0K R5 470K R2 470K R3 VCC VCC RESE PA/OSCIN 2 PA2/OSCOU 3 VSSIO_ 4 VSS 5 VCAP 6 VDD 7 VDDIO_ PA3/IM_CC3 9 PA4/USAR_RX 0 PA5/USAR_X PA6/USAR_CK 2 PF7/AIN5 3 PF6/AIN4 4 PF5/AIN3 5 PF4/AIN2 6 PF3/AIN 7 PF2/VREF+ VDDA 9 VSSA 20 PB6/AIN6 24 PF0/AIN0 22 PF/VREF- 2 PB7/AIN7 23 PB5/AIN5 25 PB4/AIN4 26 PB3/AIN3 27 PB2/AIN2 2 PB/AIN 29 PB0/AIN0 30 PE7/AIN 3 PE6/AIN9 32 PE5/SPI_NSS 33 PC/IM3_CH 34 PC2/IM3_CH2 35 PC3/IM3_CH3 36 PCA/IM3_CH4 37 PC5/SPI_SCK 3 VDDIO_2 40 PC7/SPI_MISO 42 PD0/IM2_CH2 57 PD2/IM2_CH 59 PD4/IM_CH 6 PD5/LIN_X 62 PD3/IM_CH2 60 PD/SWIM 5 VSSIO_2 39 PC6/SPI_MOSI 4 PG0/CAN_x 43 PG/CAN_Rx 44 PG2 45 PG3 46 PG4 47 PI0 4 PG5 49 PG6 50 PG7 5 PE3/IM3_BKIN 53 PE/I2C_SCL 55 PE0/MCO 56 PE2/I2C_SDA 54 PE4 52 PD6/LIN_RX 63 PD7/LI 64 SM QFP64 SM SM-test VCC GND 00nF C2 00nF C3 00nF C 00nF C6 00nF C4 00nF C5 GND VCC S3 SW-PB S SW-PB S2 SW-PB GND GND VCC VCC PA0 4.7μF C 4.7μF C9 4.7μF C7 GND VCC GND VCC GND VCC 2 2 3 3 4 4 5 5 6 6 7 7 9 9 0 0 2 2 3 3 4 4 5 5 6 6 7 7 9 9 20 20 2 2 22 22 23 23 24 24 25 25 26 26 27 27 2 2 29 29 30 30 3 3 32 32 33 33 34 34 35 35 36 36 VIM7-DP-RC-LV LCD 0 VDD PD 2 VSS 3 PA0 SWIM 2 2 Alim GND VCC W Jumper PA0 PA PG7 PG6 PG5 PG4 PG3 PG2 PG PG0 PB7 PB6 PB5 PB4 PB3 PB2 PE6 PE7 PB0 PB PE5 PC4 PC5 PC6 PC7 PE4 PE3 PE2 PE PE0 PD0 PD PD2 PD3 PD4 PD5 PD6 PD7 PC7 PC6 PC5 PC4 PG6 PG4 PG2 PG0 PE6 PE4 PE2 PE0 PD6 PD4 PD2 PD0 PC6 PC7 PB0 PB2 PB4 PB6 PC5 PC4 PB PB3 PB5 PB7 PG7 PG5 PG3 PG PE7 PE5 PE3 PE PD7 PD5 PD3 PD VCC GND External clock Con VSS Con GND PD PA0 470nF C0 PA ai4970

LCD demo board AN267 6. Board information he LCD demo board should be supplied by a DC voltage of 3.3 V through connector W. here is no regulator present on the demo board to enable the user to modify V DD and see the impact on the LCD contrast. he maximum absolute ratings for the power supply must be respected (please refer to the product datasheet). It is also strongly recommended not to apply a V DD voltage higher than 3.3 V for too long. he LCD chosen for use on the demo board is driven at 3 V, which gives a better contrast for low-voltage range MCUs like the SMS20xxx. he two pieces of software attached to this application note display SM LCD and the contrast can be tuned with the S software patented method through two push-buttons (S to increase the contrast and S2 to decrease it) with the first method (LCD driver directory in the attached zip file). Vrms is increased by applying first V SS, then V DD (during the dead times) to the segment, while first V DD, then V SS is applied to the COM lines. Vrms is decreased by applying V SS to the segment during the same dead times. he voltage average is then kept. Refer to the software attached to this application note for more details. he demo board uses the SMS20xxx microcontroller and can be reprogrammed and debugged using the SWIM communication protocol through the SWIM interface. he board is provided with the SWIM connector. he device can be reset by pressing switch S3 on the demo board. 20/22 Doc ID 4296 Rev

AN267 Revision history 7 Revision history able 4. Document revision history Date Revision Changes 7-Apr-2009 Initial release. Doc ID 4296 Rev 2/22

AN267 Please Read Carefully: Information in this document is provided solely in connection with S products. SMicroelectronics NV and its subsidiaries ( S ) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any time, without notice. All S products are sold pursuant to S s terms and conditions of sale. Purchasers are solely responsible for the choice, selection and use of the S products and services described herein, and S assumes no liability whatsoever relating to the choice, selection or use of the S products and services described herein. No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this document refers to any third party products or services it shall not be deemed a license grant by S for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein. UNLESS OHERWISE SE FORH IN S S ERMS AND CONDIIONS OF SALE S DISCLAIMS ANY EXPRESS OR IMPLIED WARRANY WIH RESPEC O HE USE AND/OR SALE OF S PRODUCS INCLUDING WIHOU LIMIAION IMPLIED WARRANIES OF MERCHANABILIY, FINESS FOR A PARICULAR PURPOSE (AND HEIR EQUIVALENS UNDER HE LAWS OF ANY JURISDICION), OR INFRINGEMEN OF ANY PAEN, COPYRIGH OR OHER INELLECUAL PROPERY RIGH. UNLESS EXPRESSLY APPROVED IN WRIING BY AN AUHORIZED S REPRESENAIVE, S PRODUCS ARE NO RECOMMENDED, AUHORIZED OR WARRANED FOR USE IN MILIARY, AIR CRAF, SPACE, LIFE SAVING, OR LIFE SUSAINING APPLICAIONS, NOR IN PRODUCS OR SYSEMS WHERE FAILURE OR MALFUNCION MAY RESUL IN PERSONAL INJURY, DEAH, OR SEVERE PROPERY OR ENVIRONMENAL DAMAGE. S PRODUCS WHICH ARE NO SPECIFIED AS "AUOMOIVE GRADE" MAY ONLY BE USED IN AUOMOIVE APPLICAIONS A USER S OWN RISK. Resale of S products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by S for the S product or service described herein and shall not create or extend in any manner whatsoever, any liability of S. S and the S logo are trademarks or registered trademarks of S in various countries. Information in this document supersedes and replaces all information previously supplied. he S logo is a registered trademark of SMicroelectronics. All other names are the property of their respective owners. 2009 SMicroelectronics - All rights reserved SMicroelectronics group of companies Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan - Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America www.st.com 22/22 Doc ID 4296 Rev