mcu-an-300001-e-v13

Fujitsu Microelectronics Europe
Application Note
MCU-AN-300001-E-V13
F²MC-8L/16LX FAMILY
8/16-BIT MICROCONTROLLER
ALL SERIES
LC-DISPLAY
APPLICATION NOTE
LC-Display
Revision History
Revision History
Date
19.03.2003
19.03.2003
10.09.2003
05.04.2004
Issue
V1.0, H. Wech, first release
V1.1, H. Wech, chapt. 3.1: MCUs added, Example code completed
V1.2, H. Wech, Appendix: Q&A “LCD using I/O” added
V1.3, H. Wech, chapter 3.3: Note added
This document contains 22 pages.
MCU-AN-300001-E-V13
-2-
© Fujitsu Microelectronics Europe GmbH
LC-Display
Warranty and Disclaimer
Warranty and Disclaimer
To the maximum extent permitted by applicable law, Fujitsu Microelectronics Europe GmbH restricts
its warranties and its liability for all products delivered free of charge (eg. software include or
header files, application examples, target boards, evaluation boards, engineering samples of IC’s
etc.), its performance and any consequential damages, on the use of the Product in accordance with
(i) the terms of the License Agreement and the Sale and Purchase Agreement under which
agreements the Product has been delivered, (ii) the technical descriptions and (iii) all accompanying
written materials. In addition, to the maximum extent permitted by applicable law, Fujitsu
Microelectronics Europe GmbH disclaims all warranties and liabilities for the performance of the
Product and any consequential damages in cases of unauthorised decompiling and/or reverse
engineering and/or disassembling. Note, all these products are intended and must only be used
in an evaluation laboratory environment.
1.
Fujitsu Microelectronics Europe GmbH warrants that the Product will perform substantially in
accordance with the accompanying written materials for a period of 90 days form the date of
receipt by the customer. Concerning the hardware components of the Product, Fujitsu
Microelectronics Europe GmbH warrants that the Product will be free from defects in material
and workmanship under use and service as specified in the accompanying written materials
for a duration of 1 year from the date of receipt by the customer.
2.
Should a Product turn out to be defect, Fujitsu Microelectronics Europe GmbH´s entire liability
and the customer´s exclusive remedy shall be, at Fujitsu Microelectronics Europe GmbH´s
sole discretion, either return of the purchase price and the license fee, or replacement of the
Product or parts thereof, if the Product is returned to Fujitsu Microelectronics Europe GmbH in
original packing and without further defects resulting from the customer´s use or the transport.
However, this warranty is excluded if the defect has resulted from an accident not attributable
to Fujitsu Microelectronics Europe GmbH, or abuse or misapplication attributable to the
customer or any other third party not relating to Fujitsu Microelectronics Europe GmbH.
3.
To the maximum extent permitted by applicable law Fujitsu Microelectronics Europe GmbH
disclaims all other warranties, whether expressed or implied, in particular, but not limited to,
warranties of merchantability and fitness for a particular purpose for which the Product is not
designated.
4.
To the maximum extent permitted by applicable law, Fujitsu Microelectronics Europe GmbH´s
and its suppliers´ liability is restricted to intention and gross negligence.
NO LIABILITY FOR CONSEQUENTIAL DAMAGES
To the maximum extent permitted by applicable law, in no event shall Fujitsu
Microelectronics Europe GmbH and its suppliers be liable for any damages whatsoever
(including but without limitation, consequential and/or indirect damages for personal
injury, assets of substantial value, loss of profits, interruption of business operation,
loss of information, or any other monetary or pecuniary loss) arising from the use of
the Product.
Should one of the above stipulations be or become invalid and/or unenforceable, the remaining
stipulations shall stay in full effect
© Fujitsu Microelectronics Europe GmbH
-3-
MCU-AN-300001-E-V13
LC-Display
Contents
Contents
REVISION HISTORY ............................................................................................................ 2
WARRANTY AND DISCLAIMER ......................................................................................... 3
CONTENTS .......................................................................................................................... 4
1 INTRODUCTION.............................................................................................................. 5
2 INTRODUCTION IN LIQUID CRYSTALS ........................................................................ 6
2.1
The Physics............................................................................................................. 6
2.2
Addressing .............................................................................................................. 7
2.2.1
Static addressing ....................................................................................... 7
2.2.2
Multiplexed addressing .............................................................................. 7
3 CONTROLLING OF LIQUID CRYSTALS ........................................................................ 9
3.1
Microcontroller with LCD-driver ............................................................................... 9
3.1.1
Internal LCD-controller............................................................................... 9
3.1.2
LCD control register................................................................................. 10
3.1.3
Example code: ½ bias, ½ duty ................................................................. 11
3.2
External LCD-controller ......................................................................................... 12
3.3
Discrete LCD-controller with I/O-ports ................................................................... 13
3.4
Alphanumeric LC-Displays .................................................................................... 14
3.4.1
Software Example.................................................................................... 16
4 CONCLUSION ............................................................................................................... 20
5 APPENDIX ..................................................................................................................... 21
5.1
Q&A: Discrete LCD-controller using I/O-ports........................................................ 21
MCU-AN-300001-E-V13
-4-
© Fujitsu Microelectronics Europe GmbH
LC-Display
Chapter 1 Introduction
1 Introduction
Segment displays based on liquid crystal material (LCD) are very common if only a small
number of characters or symbols should be displayed.
This application-note gives a rough overview about how this kind of display works and
illuminates some different methods to control a LCD by a microcontroller.
Further, the connection of alphanumeric-LC modules with integrated segment- and
character- controller to any parallel-I/O-port of a microcontroller will be discussed.
© Fujitsu Microelectronics Europe GmbH
-5-
MCU-AN-300001-E-V13
LC-Display
Chapter 2 Introduction in Liquid Crystals
2 Introduction in Liquid Crystals
This chapter reflects the technical background of passive LC-segments
2.1
The Physics
The main characteristic of Liquid Crystal is based on anisotropic material. Most common are
Nematic LC molecules all tend to align in the same direction to each other.
In the following, the basic construction and basic function of a standard display will be
explained. A first special glass will polarise random ambient light. When entering the next
layer the twisted structure of the crystal-molecules rotates the polarisation of linearly
polarised incident light by 90 degrees, so that it passes through a second polariser, and the
device appears white.
H-Polarised light
Randomly
Polarised
Light
LinearPolariser
Crystal-molecules
Glass with
Electrode
(Segment)
V-Polarised light
Glass with
Electrode
(COM-plane)
Analyzer
(2nd Polariser)
If an electric field is applied to the cell, the molecular axes align with the field and the
structure no longer twists the polarisation of the incident light, so the emerging light is
absorbed by the second polariser and the device appears black.
Polarised light
Randomly
Polarised
Light
LinearPolariser
Crystal-molecules
Glass with
Electrode
(Segment)
~
Glass with
Electrode
(COM-plane)
Analyzer
(2nd Polariser)
If the field is removed the nematic relaxes to the twisted structure.
The mobility of the crystal depends very much on the temperature, in cold environment the
movement is very slow.
Seen from the electrical side one element can be compared with a capacitor, together with
the signal-lines it can be handled as a RC-element.
Direct current will attack Liquid crystals and last destroy it. So any DC-offset should be
prevent from the molecules. In general, datasheets of LC-displays allow less than 50mV.
MCU-AN-300001-E-V13
-6-
© Fujitsu Microelectronics Europe GmbH
LC-Display
Chapter 2 Introduction in Liquid Crystals
2.2
Addressing
Addressing is the process to turn on and off a pixel in order to create an image. There are
two main types of addressing, direct and multiplexing.
2.2.1 Static addressing
Direct addressing is convenient for displays with only a few elements that have to be
activated. With direct addressing, each pixel in the display has its own drive circuit. The
control-voltage has to be applied to each element.
COM
a
b
f
g
e
c
d
Segment-lines
A common application of direct addressing is the traditional seven-segment liquid crystal
display, found in wristwatches and similar devices.
2.2.2 Multiplexed addressing
In multiplex addressing, a larger number of pixels are involved. When the elements are in a
regular order, they can be addressed by their row and column instead of each element being
driven separately.
row1
row2
row3
row4
col1
col2
col3
© Fujitsu Microelectronics Europe GmbH
col4
-7-
MCU-AN-300001-E-V13
LC-Display
Chapter 2 Introduction in Liquid Crystals
This reduces the complexity of the circuitry because each pixel no longer needs its own
driver circuit. If you have a 4x4 matrix of pixels, with direct addressing, you need 16
individual drivers. However, if you use multiplex addressing, you only need eight drivers, one
for each row and one for each column.
a
b
f
f
g
e
SEG3
b
COM2
c
COM3
g
c
d
COM1
a
e
dp
SEG2
d
SEG1
dp
COM4
SEG0
Example:
Figure 1.2a at the right represents the
2x2 format (bias 1:2, duty 1:2).
Only two COM-lines (duty 1:2) are used
and only two output-voltages V1 and V3
(bias 1:2) will be output.
The shown waveform demonstrates two
segments: SEGn=OFF and SEGn+1=ON.
The algebraically summed voltages
between the COM- and the segmentlines are depicted in the “difference”waveforms.
In order to prevent deterioration of the
crystals by DC power the LCD is driven
with a two-frame AC waveform.
Voltage level V1(=V2) is the symmetrical
average reference for the display.
(1 ) (V3 – V1) = - (V0 – V1)
(2) V1 = V3/2
In addition, the time-interval each signal
is applied has to be constant, too.
If the number of common planes (COMx) is increased, the time each pixel is controlled (duty
cycle) decrease what result in worse contrast and angle view.
The liability is the increase complexity of drive circuitry.
The method of drive for multiplexed displays is essentially a time division multiplex with the
number of time divisions equal to twice the number of common planes used in a given
format. As is the case with conventional LCDs, in order to prevent irreversible
electrochemical action from destroying the display, the voltage at all segment locations must
be caused to reverse polarity periodically so that zero net DC voltage is applied.
This is the reason for the doubling in time divisions: Each common plane must be alternately
driven with a voltage pulse of opposite polarity.
MCU-AN-300001-E-V13
-8-
© Fujitsu Microelectronics Europe GmbH
LC-Display
Chapter 3 Controlling of Liquid Crystals
3 Controlling of Liquid Crystals
This chapter reflects how to Control passive LC-segments
3.1
Microcontroller with LCD-driver
Fujitsu Microelectronics provides some microcontrollers with integrated line-drivers:
MCU series
Type
LCD-lines
MCU series
Type
LCD-lines
MB89150
8bit
4x36
MB89820
8bit
4x50
MB89160
8bit
4x24
MB89940
8bit
4x17
MB89180
8bit
4x32
MB89950
8bit
4x42
MB89480
8bit
4x31
MB90420
16bit
4x24
MB89560
8bit
4x24
MB90425
16bit
4x24
MB89570
8bit
4x14
MB90520
16bit
4x32
MB89650
8bit
4x32
MB90620
16bit
4x32
MB89800
8bit
4x70
3.1.1 Internal LCD-controller
The MB90420 series will be used exemplary to reflect the internal LCD-controller. The block
diagram shows the main features.
© Fujitsu Microelectronics Europe GmbH
-9-
MCU-AN-300001-E-V13
LC-Display
Chapter 3 Controlling of Liquid Crystals
The LCD controller/driver has a built-in 12 × 8-bit display data memory, and controls the LCD
display by means of four common outputs and 24 segment outputs. A selection of three duty
outputs is available. A LCD (liquid crystal display) panel can be driven directly. The LCD
controller/driver provides functions for directly displaying the contents of display data
memory on the LCD panel by means of segment output and common output.
Further features:
•
LCD drive voltage divider resistance is built-in. External divider resistance can also be
connected.
•
Up to 4 common outputs (COM0 to COM3)
•
Up to 24 segment outputs (SEG0 to SEG23)
•
12-byte display data memory (display RAM) is built-in
•
The duty can be selected at 1/2, 1/3, 1/4 (limited by bias setting)
•
Drives the LCD directly
3.1.2 LCD control register
Beside of the display-RAM two control-registers (LCRH, LCRL) are used to define the basic
settings of the internal LCD-controller. One register selects the function mode of the
controller. Another register selects which segment-outputs want to be used, remaining
outputs may be used as general-purpose outputs.
bit7
bit0
Register: LCRL
CSS
LCEN
Clock- and Sub-clock Mode
selection
VSEL
BK
int./ext.
Display-
Display Mode
Bias
Blanking
Duty Cycles
bit7
MS1
MS0
FP1
FP0
Frame rate
bit0
Register: LCRH
-
SEG5
SEG4
DTCH
SEG3
SEG2
SEG1
SEG0
Specifies port as segment output or general-purpose output
A 12x8bit display-memory is also included on chip to store each “on/off”-setting of all 4x24
segments. This RAM is automatically read in synchronisation with the selected timing
(LCRL). Each “1” bits will result in the according waveform to switch on the segment, while a
“0” bit will output the waveform to switch off the according segment.
Display-RAM:
Address
Register- name
3960 hex
SEG00
3960 hex
SEG01
3961 hex
SEG02
3962 hex
SEG03
Bit-definition*1
bit7
COM3
COM2
COM1
COM0
COM3
COM2
COM1
COM0
396B hex
396B hex
SEG23
COM3
COM2
COM1
bit0
COM3
COM2
COM1
COM0
COM3
COM2
COM1
COM0
COM3
COM2
COM1
COM0
COM0
*1
: The name of the Bit-definition may be different from the name that will be found in the datasheet and/or Hardware-manual.
However, in order to simplify the software for the user the renaming was done in all Header-Files according to the table above.
Doing this software code can be exchanged easily between different MCU series.
MCU-AN-300001-E-V13
- 10 -
© Fujitsu Microelectronics Europe GmbH
LC-Display
Chapter 3 Controlling of Liquid Crystals
3.1.3 Example code: ½ bias, ½ duty
The following software example will switch the LCD-controller to the ½ bias, ½ duty mode.
This mode was already discussed in chapter 2.2.2.
#include "mb90425.h"
void main(void)
{
LCRL = 0x25; /* internal Resistor, Main Clock
*/
LCRH = 0x7f; /* use all 24 segment-lines SEG00...SEG23, DTCH=0 */
/* In 1/2bias, ½ duty mode 2x24 Segments (SEG00..SEG23 x COM0/COM1) can be used. */
/* Different methods can be used to switch on/off a segment
*/
/* All methods will have same result, but keep in mind
/* that Byte-access always will be faster than Bit-access
*/
*/
/* In the following example these segment lines will be switch on:
/* SEG00-COM0, SEG00-COM1, SEG01-COM0, SEG01-COM1
/* In the same way other Segments can be switched on/off, too
*/
*/
*/
/* 1.) Write directly to the RAM-address:
*/
*(volatile unsigned char __far*)(0x3960) = 0x33;
/* 2.) Use Register-definition of Header-File :
/*
Take care that one byte contents two segment lines
*/
*/
SEG00 = 0x33; /* same as SEG01 = 0x33 */
/* 3.) Use Bit-definition of Header-File:
*/
SEG00_COM0=1;
SEG00_COM1=1;
SEG01_COM0=1;
SEG01_COM1=1;
while (1)
asm(„\tNOP“); /* nothing else to do */
}
Note:
Please take care of an error within older hardware-manuals of the MB90420/425series.
Unfortunately the Bit DTCH (Duty Change) in register LCRH was not mentioned.
However, this bit has to be set in order to use the ½ bias, ½ duty mode.
© Fujitsu Microelectronics Europe GmbH
- 11 -
MCU-AN-300001-E-V13
LC-Display
Chapter 3 Controlling of Liquid Crystals
3.2
External LCD-controller
Some semiconductor companies offer different kinds of external LCD-controllers. The
functionality is more ore less the same but differences can be found in number of Common/Segment-lines and of course the interface circuitry to the microcontroller.
A very interesting IC comes from Philips. The PCF8576 is a single-chip LCD-controller with
included LCD-driver and data-RAM for up to 160 segments. By only 2-wires it can easily be
connected to the microcontroller.
Fujitsu
MCU
8 / 16Bit
Here an uncompleted list of manufactures for external LCD-controllers:
Company
Web-site
Remark
Hitachi
www.hitachi.com
miscellaneous
Holtek
www.holtek.com
HT162x (4x32 … 8x64Segments)
MAXIM
www.maxim-ic.com
miscellaneous
OKI
http://www.okisemi.com/
miscellaneous
Philips
www.semiconductors.philips.com
I2C-interface: PCF8576 (4x40)
SAMSUNG
http://www.samsungelectronics.com
miscellaneous
MCU-AN-300001-E-V13
- 12 -
© Fujitsu Microelectronics Europe GmbH
LC-Display
Chapter 3 Controlling of Liquid Crystals
3.3
Discrete LCD-controller with I/O-ports
A LC-Display could also be connected direct to the I/O-ports of a microcontroller. Doing this,
an important issue is to provide symmetrical bias voltage in order to prevent harming the
liquid crystal molecules. Any DC-offset has to be minimized.
Some proposals exist how to realise the bias-voltage of the common lines.
Figure 2.3a uses the high-Z characteristic of an I/O-port set for input in order to get the three
output-levels 0, Vcc/2 and Vcc.
Disadvantage of this method is the need to change the I/O-port setting between input and
output frequently what may result in low performance.
Vcc
Vcc
input
Vcc/2
output low
GND
P00
COM
LC-Display
O
O
SEG1
output high
I/O
SEG0
COM
Microcontroller
Port P00
P10
P11
Figure 2.3a
Note: Because of the CMOS-technology an input-voltage of Vcc/2 may increase the powerconsumption of the device. Please find details in the application note an-900103-11.
Another proposal can be found in Figure 2.3b. In this example, two output-ports P00 and
P01 have to be used for performing the bias-voltage.
COM
high
high
Vcc
high
low
Vcc/2
low
low
GND
COM
O
O
O
LC-Display
P01
SEG1
P01
SEG0
P00
P00
Microcontroller
O
P10
P11
Figure 2.3b
In this case, there is no need to change the port-direction. That makes software
implementation much easier, because a simple table of constants may be used to deposit
the bias-pattern.
© Fujitsu Microelectronics Europe GmbH
- 13 -
MCU-AN-300001-E-V13
LC-Display
Chapter 3 Controlling of Liquid Crystals
Controlling LCDs by I/O-ports contains many risks.
As already mentioned before LC-molecules are very sensitive against DC voltage. Already a
DC offset of about 50mV, the specified value depends on the manufacture and technology
process, may cause a damage of the molecules. The time interval of phase and opposite
phase has to be very constant. The expense to handle the bias-voltage by switching the I/Oport value and maybe direction signifies a relatively big software-overhead. This means that
controlling the LCD by I/O-ports has to be taken as a high-priority task of the microcontroller.
The performance will decrease for other services. This has to be taken seriously when the
code will be implemented. In addition, other interrupts could be very interfering.
Further, the electrical specification of the output level and the temperature drift of the outputport as well as of the external resistor might be another important issue that could influence
the bias-voltage.
Because of all that disadvantages this kind of controlling a LC-display can not be
recommended at all.
3.4
Alphanumeric LC-Displays
Some applications require more than only some few symbols. In case that alphanumeric
characters want to be displayed there exist a lot of LC-modules ready-to-use.
These modules already include LC-controller as well as segment drivers. Additionally it
provides a simple parallel interface to establish communication with a microcontroller. In
mostly all modules, the HD44780 or derivative can be found. Hitachi Semiconductor settled
like a standard with introducing this controller that makes it easy to use software libraries.
Up to 80 alphanumeric characters can be displayed, very common are displays in
configurations like 2x14, 2x16, 2x20, 2x24, 2x40 and 4x20 characters.
I/O
I/O
I/O
I/O
P60
5
(HD44780)
6
11 12 13 14
3
2
1
GND
E
Alphanumerical LC-Display
+5V
O
P64
4
V0
O
R/W
D3/D7
RS
P66
D2/D6
P67
D1/D5
O
D0/D4
Microcontroller
According the microcontroller and the interface there are not too much requirements. Only
seven I/O pins have to be reserved. Figure 2.4 shows how to connect such a standard LCD
module. In this example, port 6 is used, but any other port can be used, too. The display
supports two modes: Three Control-Lines (E, R/W, RS) are used at all, but for the data 4 or
8 data-lines can be used. In order to minimise the number of port-pins this example works in
4-bit mode. Every data byte is transmitted in two nibbles using a handshake protocol.
P61
P62
contrastadjustment
P63
+5V GND
Figure 2.4
MCU-AN-300001-E-V13
- 14 -
© Fujitsu Microelectronics Europe GmbH
LC-Display
Chapter 3 Controlling of Liquid Crystals
The same pin-out can be found at the most modules:
Pin
Symbol
Level
I/O-Function
Function (8-bit mode)
Function (4-bit mode)
1
Vss
-
-
Power supply (GND)
Power supply (GND)
2
Vcc
-
-
Power supply (+5V)
Power supply (+5V)
3
Vee
-
-
Contrast adjust
Contrast adjust
4
RS
0/1
I
0 = Instruction 1 = data
0 = Instruction 1 = data
5
R/W
0/1
I
0 = Write to 1=Read from LCD
0 = Write to 1=Read from LCD
6
E
1
I
Enable signal
Enable signal
7
D0
0/1
I/O
Data bus line 0 (LSB)
not used
8
D1
0/1
I/O
Data bus line 1
not used
9
D2
0/1
I/O
Data bus line 2
not used
10
D3
0/1
I/O
Data bus line 3
not used
11
D4
0/1
I/O
Data bus line 4
Data bus line 0 (LSB) and 4
12
D5
0/1
I/O
Data bus line 5
Data bus line 1 and 5
13
D6
0/1
I/O
Data bus line 6
Data bus line 2 and 6
14
D7
0/1
I/O
Data bus line 7 (MSB)
Data bus line 3 and 7 (MSB)
0
An initial sequence has to be sent to the module in order to select the 4bit interface as well
as some basic display-settings. Data transfer between the controller and the LCD consists of
instructions or data (ASCII-compatible character set).
Instruction
RS
RW
DB7
DB6
DB5
DB4
DB3
DB2
DB1
DB0
Clear display
0
0
0
0
0
0
0
0
0
1
Clears display and returns
cursor home
Cursor home
0
0
0
0
0
0
0
0
1
*
Returns cursor to home
position
Entry mode set
0
0
0
0
0
0
0
1
ID
S
Sets cursor move direction
(I/D),
Display On/Off
0
0
0
0
0
0
1
D
C
B
Sets On/Off of all display (D),
cursor
Cursor- /
display-shift
0
0
0
0
0
1
SL
RL
*
*
Sets cursor-move or displayshift
Function set
0
0
0
0
1
DL
N
F
*
*
Sets interface data length
(DL), number
Set CGRAM
address
0
0
0
1
a
a
a
a
a
Set DDRAM
address
0
0
1
a
a
a
a
a
a
a
Sets the DDRAM address.
Read busy-flag
0
1
BF
a
a
a
a
a
a
a
Reads Busy-flag (BF) and
address counter
Write to CG- or
DD-RAM
1
0
d
d
d
d
d
d
d
d
Writes data to CGRAM or
DDRAM.
Read from CGor DD-RAM
a
Description
Sets the CGRAM address.
Reads data from CGRAM or
DDRAM.
DDRAM = Display Data RAM. CGRAM = Character Generator RAM. a=address. d=data
1
1
d
d
d
d
d
d
d
d
I/D: 0=Decrement cursor position,1=Increment cursor position
S: 0 = No display shift, 1 = Display shift
D: 0 = Display off, 1 = Display on
C: 0 = Cursor off, 1 = Cursor on
B: 0 = Cursor blink off, 1 = Cursor blink on
S/L: 0 = Move cursor, 1 = Shift display
R/L: 0 = Shift left 1 = Shift right
DL: 0 = 4-bit interface, 1 = 8-bit interface
N: 0 = 1/8 or 1/11 Duty (1 line), 1 = 1/16 Duty (2 lines)
F: 0 = 5x7 dots, 1 = 5x10 dots
BF: 0=Can accept instruction, 1=Internal operation in progress
© Fujitsu Microelectronics Europe GmbH
- 15 -
MCU-AN-300001-E-V13
LC-Display
Chapter 3 Controlling of Liquid Crystals
3.4.1 Software Example.
A software example is available, written in C.
/******************************************************************************
**
LCD-DEMO
**
**
initializes an LCD-display and displays a message
**
**
LCD connected to Port 6 (default-LCD-Type : LTN111)
**
**
(C) Fujitsu Mikroelectronic GmbH
**
******************************************************************************/
/* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */
/* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */
/* ELIGIBILITY FOR ANY PURPOSES.
*/
/*
*/
(C) Fujitsu Microelectronics Europe GmbH
#include <sample\extn\mb90675.h>
/* for all Register Names */
/*----------------------- variables --------------------*/
typedef unsigned char BYTE;
/* BYTE definition */
int cursor;
/* display position */
int i;
/* general purpose integer variable */
/*---------------------
prototypes --------------------*/
void initdisp(void);
void outb(unsigned char);
void busy(void);
void print(char *Name2);
void printnum(int n);
void wait(int i);
/*---------------------------------------------------------------*/
/*
MAIN PROGRAM
*/
/*---------------------------------------------------------------*/
void main(void)
{
initdisp();
/* initialize display on port 6 */
print("Hello World !");
/* show a message on the LCD */
wait(10000);
/* wait a short while */
for (i=1;i<1000;i++)
/* count up to 1000 */
{
print("i=");
printnum(i);
/* display the number */
wait(5000);
}
}
MCU-AN-300001-E-V13
- 16 -
© Fujitsu Microelectronics Europe GmbH
LC-Display
Chapter 3 Controlling of Liquid Crystals
/*---------------------- function bodies ----------------------*/
void initdisp(void)
/* This Routine initializes the LCD on port6 */
{
DDR6=0x0DF;
/* set Port to Output (P65 not used) */
PDR6=0;
/* Port 6 Off*/
PDR6=0x013;
/* Startup sequence */
PDR6=0x03;
wait(1000);
PDR6=0x013;
PDR6=0x03;
wait(1000);
PDR6=0x013;
PDR6=0x03;
wait(1000);
PDR6=0x012;
PDR6=0x02;
outb(0x028);
/* Switch to 4-bit mode */
outb(0x0C);
/* Cursor Off (on=0x0F) */
outb(0x06);
/* No shift */
outb(0x03);
/* Cursor home */
outb(0x01);
/* Display clear */
}
/*---------------------------------------------------------------*/
void outb(unsigned char a)
/* send one byte to the display */
{
BYTE b;
cursor++;
if (cursor == 9)
{
PDR6=0x01C;
/* correct position !LNT111-R only!*/
PDR6=0x00C;
PDR6=0x010;
PDR6=0;
busy();
}
b=(a & 0x0F0);
/* shift upper nibble */
b = b >> 4;
/* to lower nibble */
if (a & 0x080)
/* but keep Bit 7 */
{b=(b | 0x080);};
b=(b & 135);
/* set other bits to zero
b=(b | 16);
/* set E line
PDR6=b;
/* send to LCD
b=(b & 135);
/* clear E line
PDR6=b;
/* send to LCD
b=(a & 143);
/* take lower nibble
© Fujitsu Microelectronics Europe GmbH
*/
*/
*/
*/
*/
*/
- 17 -
MCU-AN-300001-E-V13
LC-Display
Chapter 3 Controlling of Liquid Crystals
b=(b | 16);
/* set E line */
PDR6=b;
/* send to LCD
b=(b & 143);
/* clear E line
PDR6=b;
/* send to LCD
busy();
/* wait for busy-line */
*/
*/
*/
}
/*---------------------------------------------------------------*/
void busy(void)
/* This Routine polls the busy-line */
{
BYTE b;
PDR6=0;
/* Port 3 Off before reading ! */
b=1;
while (b)
/* wait for Busy-line */
{
DDR6=0x0D0;
/* set Bus as input to read Bit .3 (Busy) */
PDR6=0x05F;
/* busy request */
b=PDR6_PD63;
/* read Port
*/
PDR6_PD64 = 0;
PDR6_PD64 = 1;
/* toggle E */
PDR6_PD64 = 0;
PDR6_PD66 = 0;
DDR6=0x0DF;
/* reset Port to output */
}
}
/*---------------------------------------------------------------*/
void print(char *Name2) /* This Routine displays a String */
{
unsigned char c;
BYTE b;
int i,l;
outb(1);
/* Display clear */
l=strlen(Name2);
cursor=0;
for (i=0; i<l; i++)
/* go through string */
{
c=(Name2[i]);
/* pick char */
b=(c | 128);
outb(b);
/* and display it */
}
}
/*---------------------------------------------------------------*/
MCU-AN-300001-E-V13
- 18 -
© Fujitsu Microelectronics Europe GmbH
LC-Display
Chapter 3 Controlling of Liquid Crystals
void printnum(int n)
/* show integer value on LCD display */
{
float x;
int l;
if (n < 10)
/* only one digit value */
{
outb(0x0b0);
outb(0x0b0);
outb((n+48) | 128);
}
else if (n >= 10 && n<100)
/* two digit value */
{
outb(0x0b0);
outb(((n/10)+48) | 128);
x = n-(10*(n / 10));
l = x;
outb((l+48) | 128);
}
else if (n >= 100)
/* show three digits */
{
outb(((n/100)+48) | 128);
x = n-(100*(n / 100));
n = x;
outb(((n/10)+48) | 128);
x = n-(10*(n / 10));
l = x;
outb((l+48) | 128);
}
}
/*---------------------------------------------------------------*/
void wait(int i)
{
for (; i ; i--);
/* very simple delay loop */
}
/*---------------------------------------------------------------*/
© Fujitsu Microelectronics Europe GmbH
- 19 -
MCU-AN-300001-E-V13
LC-Display
Chapter 4 Conclusion
4 Conclusion
This chapter summarises the results of the different control-mechanism of LC-displays
The most useful way how to control a LC-display depends very much on the application.
For very low-cost applications, e.g. toys, and if lifetime-guaranty is not an issue, then a real
software-based solution like controlling by I/O-ports might be acceptable.
For industrial and automotive application, where lifetime and temperature influence is a very
important point, a dedicated LCD-controller should be used. A microcontroller with built-in
LCD-controller may help to save costs, because no further external components are
necessary. In case that a big number of segments have to be controlled, then an external
LCD-controller is indispensable.
If the application requires displaying text-messages then alphanumeric LC-modules will be a
good choice, because hard- and software overhead can be reduced.
MCU-AN-300001-E-V13
- 20 -
© Fujitsu Microelectronics Europe GmbH
LC-Display
Chapter 5 Appendix
5 Appendix
In this chapter, frequently asked questions will be answered.
5.1
Q&A: Discrete LCD-controller using I/O-ports
Q: Can I connect a LC-segment-display to the I/O-port of my Fujitsu-controller?
You can, but Fujitsu does not recommend connecting a segmented LCD to the I/O-port.
Fujitsu provides MCUs with LCD-driver on chip!
Q: Why does Fujitsu not recommend connecting a segmented LCD to the I/O-port?
Because solution “LCD @ IO” carries a lot of disadvantages:
Lifetime and quality are very important topics within automotive application.
The lifetime of a LCD is very sensitive regarding any DC-offset.
The allowed DC-offset (around 50mV) depends on manufacture-process of the LCD.
DC-offset may caused by
- Segment-driver
IO-solution needs e.g. external resistor network that might be temperature-sensitive
- Timing-control
IO-solution will claim system-performance and especially high priority,
e.g. CAN-messages may be handled with lower priority in order to guarantee timing.
Beside of the required RAM and ROM space, another disadvantage may be the lost of at
least one system-timer and the increased Interrupt occurrence.
The more segments has to be controlled the more software-complexity and external
hardware is necessary, what furthermore leads in additional costs.
That's why it does not make any sense at all to use “LCD @ IO” for big number of segments.
If we are talking about controlling a small display with only some symbols to be controlled,
“LCD @ IO” might be discussible, but always with the restrictions of lifetime/quality as
mentioned before.
Because of the complexity of timing-control for the LCD-segments in order to reduce DCoffset, it is nearly impossible to provide a "Ready-to-use" LCD-driver using I/Os.
Always the whole application/software-complexity has to be considered, in order to check, if
really the highest priority can be assigned to the “LCD @ IO”, knowing that all other systemservices (CAN, A/D, Operating-system like OSEK, etc) have to comply.
Q: Why do other companies offer “LCD @ IO”?
They do it the same way as we do, sometimes with example-code for demonstration only.
If their application-notes were read carefully, the same risks are mentioned, too.
© Fujitsu Microelectronics Europe GmbH
- 21 -
MCU-AN-300001-E-V13
LC-Display
Chapter 5 Appendix
Q: Why does Fujitsu not provide any software-code?
Fujitsu would like to prevent customers falling into a trap.
Controlling “LCD @ IO” might be possible in some cases, but has to be handled manually
and very carefully by customer's software-programmers and hardware-designers.
Any code-example would imply simplicity and security, and that's not!
“LCD @ IO” has always to be integrated into the whole system, but it can not be handled as
a simple-task, or only with restrictions.
Conclusion
Of course, (small number) LCD-segments can be controlled by IO-ports, especially because
most of Fujitsu's IO-cells have hysteresis inputs, that is very important to allow ½-bias
voltage generated by external resistors.
Software- and hardware-overhead as well as the risk of long-term consequences, like
lifetime- or quality-issue, are high.
The best and professional solution results always in a MCU with integrated LCD-driver.
Controlling a LCD for a demonstration is one thing,
controlling a LCD for an application is another thing.
MCU-AN-300001-E-V13
- 22 -
© Fujitsu Microelectronics Europe GmbH