You are on page 1of 18

AN702-00001-1v0-J

F2MC-8FX Family
8-BIT MICROCONTROLLER
MB95260H series

LCD
SC1602BS

AN702-00001-1v0-J

Copyright 2010 FUJITSU SEMICONDUCTOR LIMITED all rights reserved

AN702-00001-1v0-J

1.0

2010.06.10

AN702-00001-1v0-J

...............................................................................................................................1
...............................................................................................................................2
...................................................................................................................................... 3
1

........................................................................................................................ 4

LCD SC1602BS .......................................................................... 5


2.1

LCD SC1602BS ............................................................ 6

2.2

LCD SC1602BS ................................................. 6

2.3

LCD SC1602BS ................................................................ 7

2.4

LCD SC1602BS ...................... 10

2.5

LCD SC1602BS ............................................ 12

SC1602BS ................................................................. 13
SC1602BS () ............................................. 13
SC1602BS () ............................................. 14
LCD SC1602BS ....................................................... 15
3

.......................................................................................................................... 16

AN702-00001-1v0-J

, F2MC-8FX MB95260H
LCD LCD SC1602BS

AN702-00001-1v0-J

LCD SC1602BS

SC1602BS LCD
LCD LCD 4bit

4 2 6 LCD

2-1

AN702-00001-1v0-J

2.1

LCDSC1602BS

LCD

pinNo

Symbol

Function

No

Symbol

Function

VDD

5V

DB2

Data bit2

VSS

GND

10

DB3

Data bit3

Vo

11

DB4

Data bit4

RS

12

DB5

Data bit5

R/W

13

DB6

Data bit6

14

DB7

Data bit7

DB0

Data bit0

DB1

Data bit1
2-1

VDD : 5V
VSS : GND
Vo :
RS :
High :
Low :
R/W : Data /
High : Data
Low : Data
E :
High Low Data
DBn : DB7 DB0

2.2

LCDSC1602BS

LCD SC1602BS 2 DB7 DB0


8bit Read/Write
DB7 DB4 4bit
2 Read/Write
LCD 4bit

SC1602BS Read/Write LCD BUSY

AN702-00001-1v0-J

BUSY

2.3

LCDSC1602BS

LCD SC1602BS

AN702-00001-1v0-J

Power ON
RS = Low
R/W =
Low

15ms

DB7DB4 = 0011b

4.1ms

Initial sequence

DB7DB4 = 0011b

100us

DB7DB4 = 0011b

DB7DB4 = 0010b
DB7DB4 = 0010b

Function set(2line)

DB7DB4 = 1000b

0x28

DB7DB4 = 0000b

Display off

DB7DB4 = 1000b

0x08

DB7DB4 = 0000b

Display Clear

DB7DB4 = 0001b

0x01

DB7DB4 = 0001b

Display Cursor

DB7DB4 = 0100b

0x14

DB7DB4 = 0000b

Display on

DB7DB4 = 1100b

0x0c

return

right

AN702-00001-1v0-J

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;
}

AN702-00001-1v0-J

2.4

LCD SC1602BS

LCD SC1602BS

Start

R/W

RS = Low

Low

E = High
DB7DB4 = 0010b

() Function set(2line)

DB7DB4 = 1000b

0x28

E = Low
return

R/W Low()

R/W

RS

40ns(min)

10ns(min)

E
60ns(min)
DB
220ns(min)

500ns(min)

10

10ns(min)

AN702-00001-1v0-J

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-J

2.5

LCD SC1602BS

LCD SC1602BS

Start

R/W

RS = High

Low

E = High
DB7DB4 = 0011b

() Function set(2line)

DB7DB4 = 0001b

0x31 (ASCII = 1)

E = Low
return

R/W Low()

R/W

RS

40ns(min)

10ns(min)

E
60ns(min)
DB
220ns(min)

500ns(min)

12

10ns(min)

AN702-00001-1v0-J

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-J

SC1602BS ()
/*********************************************************************
NAME:

LCD_Printf()

FUNCTION:

Character Data set to SC1602

*********************************************************************/
void LCD_Printf(const char* str)
{
while(*str)
{
LCD_WriteData(*str++);
}
}

ASCII
/*********************************************************************
NAME:

LCD_Printf()

*********************************************************************/
LCD_Printf("ABCD");

// LCD "ABCD" charactor //

14

AN702-00001-1v0-J

LCDSC1602BS
/*********************************************************************
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;
}

#define LCD_CURSOR_SH_RIGHT

0x14

/*********************************************************************
NAME:

LCD_Printf()

*********************************************************************/
SC1602LCD_Control(LCD_CURSOR_SH_RIGHT);

15

AN702-00001-1v0-J

3-1

16

AN702-00001-1v0-J

, Web

http://jp.fujitsu.com/fsl/

17

You might also like