0.3MB

The following document contains information on Cypress products.
AN702-00001-1v0-E
F2MC-8FX Family
8-BIT MICROCONTROLLER
MB95260H series
LCD Module control
Example of connection to SC1602BS
AN702-00001-1v0-E
All Rights Reserved.
The contents of this document are subject to change without notice. Customers are advised to consult with
FUJITSU sales representatives before ordering.
The information, such as descriptions of function and application circuit examples, in this document are
presented solely for the purpose of reference to show examples of operations and uses of Fujitsu
semiconductor device; Fujitsu does not warrant proper operation of the device with respect to use based on
such information. When you develop equipment incorporating the device based on such information, you
must assume any responsibility arising out of such use of the information. Fujitsu assumes no liability for
any damages whatsoever arising out of the use of the information.
Any information in this document, including descriptions of function and schematic diagrams, shall not be
construed as license of the use or exercise of any intellectual property right, such as patent right or
copyright, or any other right of Fujitsu or any third party or does Fujitsu warrant non-infringement of any
third-party’s intellectual property right or other right by using such information. Fujitsu assumes no liability
for any infringement of the intellectual property rights or other rights of third parties which would result from
the use of information contained herein.
The products described in this document are designed, developed and manufactured as contemplated for
general use, including without limitation, ordinary industrial use, general office use, personal use, and
household use, but are not designed, developed and manufactured as contemplated (1) for use
accompanying fatal risks or dangers that, unless extremely high safety is secured, could have a serious
effect to the public, and could lead directly to death, personal injury, severe physical damage or other loss
(i.e., nuclear reaction control in nuclear facility, aircraft flight control, air traffic control, mass transport
control, medical life support system, missile launch control in weapon system), or (2) for use requiring
extremely high reliability (i.e., submersible repeater and artificial satellite).
Please note that Fujitsu will not be liable against you and/or any third party for any claims or damages
arising in connection with above-mentioned uses of the products.
Any semiconductor devices have an inherent chance of failure. You must protect against injury, damage or
loss from such failures by incorporating safety design measures into your facility and equipment such as
redundancy, fire protection, and prevention of over-current levels and other abnormal operating conditions.
If any products described in this document represent goods or technologies subject to certain restrictions on
export under the Foreign Exchange and Foreign Trade Law of Japan, the prior authorization by Japanese
government will be required for export of those products from Japan.
The company names and brand names herein are the trademarks or registered trademarks of their
respective owners.
Copyright©2010 FUJITSU SEMICONDUCTOR LIMITED all rights reserved
1
AN702-00001-1v0-E
Revision History
Revision
Date
Description
1.0
Sep 9,2010
Initial release
2
AN702-00001-1v0-E
Subject
Revision History.................................................................................................................... 2
Subject.................................................................................................................................. 3
1
Introduction.................................................................................................................... 4
2
About LCD module of SC1602BS.................................................................................. 5
2.1
Control signal of LCD module............................................................................. 6
2.2
How to control the SC1602BS LCD module. ...................................................... 6
2.3
Initialization of the SC1602BS ............................................................................ 7
2.4
Example of writing instruction command to SC1602BS. .................................. 10
2.5
Example of writing data to LCD module of SC1602BS..................................... 12
Sample code of writing data to SC1602BS.................................................................... 13
Sample code of writing character data. ......................................................................... 13
Sample code of writing character data. ......................................................................... 14
Sample code of writing command code to SC1602BS.................................................... 15
3
Example of circuit diagram. ......................................................................................... 16
3
AN702-00001-1v0-E
1
Introduction
This application note explains the method of controlling the LCD display module SC1602BS by
external Fujitsu 8-bit MCU F2MC-8FX family. MB95F260H series is used in the explanation of
control methods.
4
AN702-00001-1v0-E
2
About LCD module of SC1602BS
The SC1602BS is popular LCD module of offered commercially. The SC1602BS has LCD driver
controller for LCD display. These LCD minimum controls required are 4bit parallel command line
and 2bit control line.
Figur 2-1
5
AN702-00001-1v0-E
2.1
Control signal of LCD module
Shown below the LCD module signals.
No
Symbol
Function
No
Symbol
Function
1
VDD
5V
9
DB2
Data bit2
2
VSS
GND
10
DB3
Data bit3
3
Vo
Contrast ADJ.
11
DB4
Data bit4
4
RS
REGISTER SELECT
12
DB5
Data bit5
5
R/W
READ/WRITE
13
DB6
Data bit6
6
E
ENABLE SIGNAL
14
DB7
Data bit7
7
DB0
Data bit0
8
DB1
Data bit1
Chart 2-1
VDD : Supply Voltage 5V
VSS : GND
Vo : LCD contrast voltage
RS : Register select
High : Character data input mode
Low : Instruction command input mode
R/W : Read/Write Data bus selector
High : Data bus read mode
Low : Data bus write mode
E : Data enable
Data valid is high to low.
DBn : From DB7 to DB0 are Data bus line.
2.2
How to control the SC1602BS LCD module.
The LCD module of SC1602BS has two kind of controlling.
One is read/write from instruction command or character data use on 8bit bus from DB7 to DB0.
Other one is 4bit bus from DB7 to DB4 use. In this case user need read/write to bus access twice.
This application manual used 4bit bus access mode which will be able to save the microcontroller
pin.
The SC1602BS will be able to use BUSY signal but, this application manual is using software wait
time instead of the BUSY signal.
6
AN702-00001-1v0-E
2.3
Initialization of the SC1602BS
The SC1602BS need initialization to LCD control module when startup.
Showing below are flowchart of initialization sequence and sample program.
7
AN702-00001-1v0-E
Power ON
RS pin = “Low”
R/W pin = Low.
Fixed by hardware.
15ms
DB7~DB4 = 0011b
4.1ms
DB7~DB4 = 0011b
Initial sequence
100us
DB7~DB4 = 0011b
DB7~DB4 = 0010b
DB7~DB4 = 0010b
Function set(2line)
DB7~DB4 = 1000b
0x28
DB7~DB4 = 0000b
Display off
DB7~DB4 = 1000b
0x08
DB7~DB4 = 0000b
Display Clear
DB7~DB4 = 0001b
0x01
DB7~DB4 = 0001b
Display Cursor
DB7~DB4 = 0100b
0x14
DB7~DB4 = 0000b
Display on
DB7~DB4 = 1100b
0x0c
return
8
right
AN702-00001-1v0-E
Sample code of Initialization to SC1602BS.
/*********************************************************************
NAME:
LCD_Initial()
FUNCTION:
SC1602 Initialization
*********************************************************************/
void LCD_Initial(void) {
// Port direction
LCD_Control_DDR &= 0xf0;
LCD_Enable
/* Lower 4bit output */
= 0;
LCD_Register_sel = 0;
mDelay(15);
/* delay time */
SC1602LCD_4bit(LCD_DL_8BIT >> 4);
mDelay(5);
/* delay time */
SC1602LCD_4bit(LCD_DL_8BIT >> 4);
mDelay(1);
/* delay time */
SC1602LCD_4bit(LCD_DL_8BIT >> 4);
SC1602LCD_4bit(LCD_DL_4BIT >> 4);
SC1602LCD_Control(LCD_DL_4BIT |
LCD_N_2LINE |
LCD_DH_NORMAL);
SC1602LCD_Control(LCD_DISP_OFF);
SC1602LCD_Control(LCD_DISP_CLEAR_HOME);
mDelay(2);
/* delay time */
SC1602LCD_Control(LCD_CURSOR_RIGHT);
SC1602LCD_Control(LCD_DISP_ON);
return;
}
9
AN702-00001-1v0-E
2.4
Example of writing instruction command to SC1602BS.
Writing an instruction command to LCD module of SC1602BS.
Showing below are flow chart of sequence.
Start
R/W pin = Low.
Fixed by hardware.
RS pin = “Low”
E pin = “High”
DB7~DB4 = 0010b
Example:
DB7~DB4 = 1000b
Function set(2line)
0x28
E pin = “Low”
return
Control of Writing:
Below is example of hardware timing chart.
R/W
RS
40ns(min)
10ns(min)
E
60ns(min)
DB
220ns(min)
500ns(min)
10
10ns(min)
AN702-00001-1v0-E
Sample code of writing instruction to SC1602BS.
/*********************************************************************
NAME:
SC1602LCD_Control()
FUNCTION:
Instruction input
*********************************************************************/
void SC1602LCD_Control(unsigned char cmd) {
LCD_Register_sel = 0;
// Control
SC1602LCD_4bit(cmd >> 4);
SC1602LCD_4bit(cmd);
vDelay(32);
//delay time
return;
}
11
AN702-00001-1v0-E
2.5
Example of writing data to LCD module of SC1602BS.
Writing data to LCD module of SC1602BS.
Showing below are flow chart of sequence.
Start
R/W pin = Low.
RS pin = “High”
Fixed by hardware.
E pin = “High”
DB7~DB4 = 0011b
Example:
DB7~DB4 = 0001b
Function set(2line)
0x31 (ASCII = “1”)
E pin = “Low”
return
Control of Writing:
Below is example of hardware timing chart.
R/W
RS
40ns(min)
10ns(min)
E
60ns(min)
DB
220ns(min)
500ns(min)
12
10ns(min)
AN702-00001-1v0-E
Sample code of writing data to SC1602BS.
/*********************************************************************
NAME:
LCD_WriteData()
FUNCTION:
Data set to SC1602
*********************************************************************/
void LCD_WriteData(unsigned char data) {
LCD_Register_sel = 1;
/* Data mode */
SC1602LCD_4bit(data >> 4);
SC1602LCD_4bit(data);
vDelay(32);
/* delay time */
return;
}
/*********************************************************************
NAME:
SC1602LCD_4bit()
FUNCTION:
Data set and Enable latch to SC1602
*********************************************************************/
void SC1602LCD_4bit(unsigned char c)
{
LCD_Enable = 1;
/* Enable signal = High */
LCD_Control_port = (LCD_Control_port & 0x0f) | (c << 4);
vDelay(1);
/* delay time */
LCD_Enable = 0;
/* Enable signal = Low */
return;
}
13
AN702-00001-1v0-E
Sample code of writing character data.
/*********************************************************************
NAME:
LCD_Printf()
FUNCTION:
Character Data set to SC1602
*********************************************************************/
void LCD_Printf(const char* str)
{
while(*str)
{
LCD_WriteData(*str++);
}
}
Sample code of writing ASCII code.
/*********************************************************************
NAME:
LCD_Printf()
*********************************************************************/
// LCD "ABCD" charactor //
LCD_Printf("ABCD");
14
AN702-00001-1v0-E
Sample code of writing command code to SC1602BS.
/*********************************************************************
NAME:
SC1602LCD_Control()
FUNCTION:
Instruction input
*********************************************************************/
void SC1602LCD_Control(unsigned char cmd) {
LCD_Register_sel = 0;
// Control
SC1602LCD_4bit(cmd >> 4);
SC1602LCD_4bit(cmd);
vDelay(32);
//delay time//
__delay_us(40);
return;
}
Example of cursor move by command code.
#define LCD_CURSOR_SH_RIGHT
0x14
/*********************************************************************
NAME:
LCD_Printf()
*********************************************************************/
SC1602LCD_Control(LCD_CURSOR_SH_RIGHT);
note:These code are excerpt from sample program.
Please get more detailed information from sample program.
15
AN702-00001-1v0-E
3
Example of circuit diagram.
Figur 3-1example circuit diagram
16
AN702-00001-1v0-E
Additional Information
For more information about how to use MB95260 series MCU, BGM adaptor and SOFTUNE,
please visit website
http://jp.fujitsu.com/group/fsl/en/
17