128X64的点阵的汉字图形型液晶显示模块的介绍及使用资料概述

电子说

1.3w人已加入

描述

一、液晶显示模块概述

1. 液晶显示模块是128×64点阵的汉字图形型液晶显示模块,可显示汉字及图形,内置8192个中文汉字(16X16点阵)、128个字符(8X16点阵)及64X256点阵显示RAM(GDRAM)。可与CPU直接接口,提供两种界面来连接微处理机:8-位并行及串行两种连接方式。具有多种功能:光标显示、画面移位、睡眠模式等。

2. 外观尺寸:93×70×12.5mm

3. 视域尺寸:73×39mm

外形尺寸图

RAM

RAM

二、模块引脚说明

128X64 引脚说明

RAM

*注释1:如在实际应用中仅使用串口通讯模式,可将PSB接固定低电平,也可以将模块上的J8和“GND”用焊锡短接。

*注释2:模块内部接有上电复位威廉希尔官方网站 ,因此在不需要经常复位的场合可将该端悬空。

*注释3:如背光和模块共用一个电源,可以将模块上的JA、JK用焊锡短接。

2.2并行接口

管脚号管脚名称电平管脚功能描述

1VSS0V电源地

2VCC3.0+5V电源正

3V0-对比度(亮度)调整

4RS(CS)H/LRS=“H”,表示DB7——DB0为显示数据

RS=“L”,表示DB7——DB0为显示指令数据

5R/W(SID)H/LR/W=“H”,E=“H”,数据被读到DB7——DB0

R/W=“L”,E=“H→L”, DB7——DB0的数据被写到IR或DR

6E(SCLK)H/L使能信号

7DB0H/L三态数据线

8DB1H/L三态数据线

9DB2H/L三态数据线

10DB3H/L三态数据线

11DB4H/L三态数据线

12DB5H/L三态数据线

13DB6H/L三态数据线

14DB7H/L三态数据线

15PSBH/LH:8位或4位并口方式,L:串口方式(见注释1)

16NC-空脚

17/RESETH/L复位端,低电平有效(见注释2)

18VOUT-LCD驱动电压输出端

19AVDD背光源正端(+5V)(见注释3)

20KVSS背光源负端(见注释3)

*注释1:如在实际应用中仅使用并口通讯模式,可将PSB接固定高电平,也可以将模块上的J8和“VCC”用焊锡短接。

*注释2:模块内部接有上电复位威廉希尔官方网站 ,因此在不需要经常复位的场合可将该端悬空。

*注释3:如背光和模块共用一个电源,可以将模块上的JA、JK用焊锡短接。

二、控制器接口信号说明:

1、RS,R/W的配合选择决定控制界面的4种模式:

RSR/W功能说明

LLMPU写指令到指令暂存器(IR)

LH读出忙标志(BF)及地址记数器(AC)的状态

HLMPU写入数据到数据暂存器(DR)

HHMPU从数据暂存器(DR)中读出数据

2、E信号

E状态执行动作结果

高——》低I/O缓冲——》DR配合/W进行写数据或指令

高DR——》I/O缓冲配合R进行读数据或指令

低/低——》高无动作

● 忙标志:BF BF标志提供内部工作情况.BF=1表示模块在进行内部操作,此时模块不接受外部指令和数据.BF=0时,模块为准备状态,随时可接受外部指令和数据。 利用STATUS RD 指令,可以将BF读到DB7总线,从而检验模块之工作状态。● 字型产生ROM(CGROM) 字型产生ROM(CGROM)提供8192个此触发器是用于模块屏幕显示开和关的控制。DFF=1为开显示(DISPLAY ON),DDRAM 的内容就显示在屏幕上,DFF=0为关显示(DISPLAY OFF)。 DFF 的状态是指令DISPLAY ON/OFF和RST信号控制的。● 显示数据RAM(DDRAM)模块内部显示数据RAM 提供64×2个位元组的空间,最多可控制4行16字(64个字)的中文字型显示,当写入显示数据RAM时,可分别显示CGROM与CGRAM的字型;此模 块可显示三种字型,分别是半角英数字型(16*8)、CGRAM字型及CGROM的中文字型,三种字型的选择,由在DDRAM中写入的编码选择,在 0000H—0006H的编码中(其代码分别是0000、0002、0004、0006共4个)将选择CGRAM的自定义字型,02H—7FH的编码中将 选择半角英数字的字型,至于A1以上的编码将自动的结合下一个位元组,组成两个位元组的编码形成中文字型的编码BIG5(A140—D75F),GB (A1A0-F7FFH)。 ● 字型产生RAM(CGRAM) 字型产生RAM提供图象定义(造字)功能, 可以提供四组16×16点的自定义图象空间,使用者可以将内部字型没有提供的图象字型自行定义到CGRAM中,便可和CGROM中的定义一样地通过DDRAM显示在屏幕中。● 地址计数器AC地址计数器是用来贮存DDRAM/CGRAM之一的地址,它可由设定指令暂存器来改变,之后只要读取或是写入DDRAM/CGRAM的值时,地址计数器的值就会自动加一,当RS为“0”时而R/W为“1”时,地址计数器的值会被读取到DB6——DB0中。

● 光标/闪烁控制威廉希尔官方网站

此模块提供硬体光标及闪烁控制威廉希尔官方网站 ,由地址计数器的值来指定DDRAM中的光标或闪烁位置。

外形尺寸

ITEMNOMINAL DIMENUNIT

模块体积93×78×12.5mm

视域70.7×38.8mm

行列点阵数128×64dots

点距离0.52×0.52mm

点大小0.48×0.48mm

三、液晶硬件接口

1、逻辑工作电压(VDD):4.5~5.5V

2、电源地(GND):0V

3、工作温度(Ta):0~60℃(常温) / -20~75℃(宽温)

4、电气特性见附图1 外部连接图(参考附图2)

RAM

模块有并行和串行两种连接方法(时序如下):

1、8位并行连接时序图

MPU写资料到模块

RAM

MPU从模块读出资料

RAM

2、串行连接时序图

四、用户指令集

1、指令表1:(RE=0:基本指令集)

RAM

指令表—2:(RE=1:扩充指令集)

RAM

HS12864-12串口接线方式:

RAM

备注:

1、 当模块在接受指令前,微处理顺必须先确认模块内部处于非忙碌状态,即读取BF标志时BF需为0,方可接受新的指令;如果在送出一个指令前并不检查BF标志,那么在前一个指令和这个指令中间必须延迟一段较长的时间,即是等待前一个指令确实执行完成,指令执行的时间请参考指令表中的个别指令说明。

2“RE”为基本指令集与扩充指令集的选择控制位元,当变更“RE”位元后,往后的指令集将维持在最后的状态,除非再次变更“RE”位元,否则使用相同指令集时,不需每次重设“RE”位元。

具体指令介绍:

1、清除显示

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLLLLLLLLH

功能:清除显示屏幕,把DDRAM位址计数器调整为“00H”

2、位址归位

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLLLLLLLHX

功能:把DDRAM位址计数器调整为“00H”,游标回原点,该功能不影响显示DDRAM

3、位址归位

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLLLLLLHI/DS

功能:把DDRAM位址计数器调整为“00H”,游标回原点,该功能不影响显示DDRAM功能:执行该命令后,所设置的行将显示在屏幕的第一行。显示起始行是由Z地址计数器控制的,该命令自动将A0-A5位地址送入Z地址计数器,起始地址可以是0-63范围内任意一行。Z地址计数器具有循环计数功能,用于显示行扫描同步,当扫描完一行后自动加一。

4、显示状态 开/关

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLLLLLHDCB

功能: D=1;整体显示ON C=1;游标ON B=1;游标位置ON

5、游标或显示移位控制

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLLLLHS/CR/LXX

功能:设定游标的移动与显示的移位控制位:这个指令并不改变DDRAM的内容

6、功能设定

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLLLHDLX0 REXX

功能:DL=1(必须设为1) RE=1;扩充指令集动作 RE=0:基本指令集动作

7、设定CGRAM位址

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLLHAC5AC4AC3AC2AC1AC0

功能:设定CGRAM位址到位址计数器(AC)

8、设定DDRAM位址

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLHAC6AC5AC4AC3AC2AC1AC0

功能:设定DDRAM位址到位址计数器(AC)

9、读取忙碌状态(BF)和位址

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LHBFAC6AC5AC4AC3AC2AC1AC0

功能:读取忙碌状态(BF)可以确认内部动作是否完成,同时可以读出位址计数器(AC)的值

10、写资料到RAM

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

HLD7D6D5D4D3D2D1D0

功能:写入资料到内部的RAM(DDRAM/CGRAM/TRAM/GDRAM)

11、读出RAM的值

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

HHD7D6D5D4D3D2D1D0

功能:从内部RAM读取资料(DDRAM/CGRAM/TRAM/GDRAM)

12、 待命模式(12H)

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLLLLLLLLH

功能:进入待命模式,执行其他命令都可终止待命模式

13、卷动位址或IRAM位址选择(13H)

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLLLLLLLHSR

功能:SR=1;允许输入卷动位址 SR=0;允许输入IRAM位址

14、反白选择(14H)

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLLLLLLHR1R0

功能:选择4行中的任一行作反白显示,并可决定反白的与否

15、睡眠模式(015H)

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLLLLLHSLXX

功能:SL=1;脱离睡眠模式 SL=0;进入睡眠模式

16、扩充功能设定(016H)

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLLLHHX1 REGL

功能:RE=1;扩充指令集动作 RE=0;基本指令集动作 G=1;绘图显示ON G=0;绘图显示OFF

17、设定IRAM位址或卷动位址(017H)

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLLHAC5AC4AC3AC2AC1AC0

功能:SR=1;AC5~AC0为垂直卷动位址 SR=0;AC3~AC0写ICONRAM位址

18、设定绘图RAM位址(018H)

CODE: RW RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0

LLHAC6AC5AC4AC3AC2AC1AC0

功能:设定GDRAM位址到位址计数器(AC)

五、显示坐标关系

1、图形显示坐标

RAM

2、汉字显示坐标

X坐标

Line180H81H82H83H84H85H86H87H

Line290H91H92H93H94H95H96H97H

Line388H89H8AH8BH8CH8DH8EH8FH

Line498H99H9AH9BH9CH9DH9EH9FH

六、显示步骤

1、显示资料RAM(DDRAM)

显示资料RAM提供64×2个位元组的空间,最多可以控制4行16字(64个字)的中文字型显示,当写入显示资料RAM时,可以分别显示CGROM、HCGROM与CGRAM的字型;ST7920A可以显示三种字型 ,分别是半宽的HCGROM字型、CGRAM字型及中文CGROM字型 ,三种字型的选择,由在DDRAM中写入的编码选择,在0000H—0006H的编码中将自动的结合下一个位元组,组成两个位元组的编码达成中文字型 的编码(A140—D75F),各种字型详细编码如下:

1、显示半宽字型 :将8位元资料写入DDRAM中,范围为02H—7FH的编码。

2、显示CGRAM字型:将16位元资料写入DDRAM中,总共有0000H,0002H,0004H,0006H四种编码。

3、显示中文字形:将16位元资料写入DDRAMK ,范围为A1A1H—F7FEH的编码。

绘图RAM(GDRAM)

绘图显示RAM提供64×32个位元组的记忆空间,最多可以控制256×64点的二维也纳绘图缓冲空间,在更改绘图RAM时,先连续写入水平与垂直的坐标值,再写入两个8位元的资料到绘图RAM,而地址计数器(AC)会自动加一;在写入绘图RAM的期间,绘图显示必须关闭,整个写入绘图RAM的步骤如下:

1、关闭绘图显示功能。

2、先将水平的位元组坐标(X)写入绘图RAM地址;

3、再将垂直的坐标(Y)写入绘图RAM地址;

4、将D15——D8写入到RAM中;

5、将D7——D0写入到RAM中;

6、打开绘图显示功能。

绘图显示的记忆体对应分布请参考表

2、游标/闪烁控制

ST7920A提供硬体游标及闪烁控制威廉希尔官方网站 ,由地址计数器(address counter)的值来指定DDRAM中的游标或闪烁位置。

编程参考(部分)

并口通信模式:

;*********************************************

;Controller:ST7920

;MCU:AT89C52 ,晶体频率:12MHz

;LCM:128*64

;LCM型号:带中文字库的128X64-0402

;LCM 接口:1:GND 2:VCC 3:V0 4.RS 5:RW 6:E 7--14:DB0-DB7 15:PSB 16:NC 17:RST 18:Vout

;**********************************************

RS EQU P1.3

RW EQU P1.4

E EQU P1.5

PSB EQU P1.6

RST EQU P2.7

COM EQU 20H

DAT EQU 21H

;******************************以上是接口定义

START:

ORG 0000H

MOV SP,#60H

LJMP DISP

;*********************************主程序入口地址

ORG 0040H

DISP: CLR PSB

LCALL DELAY

SETB PSB ;将PSB置1,通信方式为8位数据并口

LCALL DELAY

MOV COM,#30H ;功能设置---8BIT控制界面,基本指令集

ACALL WRI ;调用写指令子程序

LCALL DELAY ;延迟39uS

MOV COM,#0CH ;显示打开,光标关,反白显示关

ACALL WRI ;调用写指令子程序

LCALL DELAY ;延迟39uS

MOV COM,#01H ;清除屏幕显示,将DDRAM的地址计数器归零

ACALL WRI ;调用写指令子程序

LCALL DELAY ;延迟39uS

MOV COM,#06H ;DDRAM的地址计数器(AC)加1

ACALL WRI ;调用写指令子程序

LCALL DELAY ;延迟39uS

;****************************************************

DISPLAY5A:

MOV R2,#64 ;DDRAM地址记数器设为最大值

MOV R1,#10H

MOV COM,#80H ;DD RAM 地址-----0000000

ACALL WRI

DISP5A: MOV DAT,R1

ACALL WRD ;写入第二字节数据

INC R1

DJNZ R2,DISP5A

LCALL DELAY1 ;1S延时子程序

;*************************************以上是写入半角字符

DISPLAY5:

MOV R2,#64 ;DDRAM地址记数器设为最大值

MOV R1,#0DEH

MOV COM,#80H ;DD RAM 地址-----0000000

ACALL WRI

DISP5: MOV DAT,#0B4H

ACALL WRD ;写入第一字节数据

MOV DAT,R1

ACALL WRD ;写入第二字节数据

INC R1

DJNZ R2,DISP5

LCALL DELAY1 ;1S延时子程序

;**********************************以上是从字库中“崔”字处开始显示

MOV COM,#01H ;清屏

ACALL WRI ;调用写指令子程序

LCALL DELAY

MOV COM,#32H ;功能设置---8BIT控制界面,绘图显示ON

ACALL WRI ;调用写指令子程序

LCALL DELAY ;延迟39uS

MOV COM,#36H ;功能设置---8BIT控制界面,扩充指令集

ACALL WRI ;调用写指令子程序

LCALL DELAY ;延迟39uS

DISPLAY6:

MOV DPTR,#DAB2 ;图形数据入口地址

MOV R2,#32 ;32行,(双屏结构中上半屏)

MOV R3,#80H ;Y地址寄存器

DISP6: MOV COM,R3 ;设置绘图区的Y地址坐标

INC R3 ;Y地址加1

LCALL WRI

MOV COM,#80H ;设置绘图区的X地址坐标

LCALL WRI

MOV R1,#16 ;16*8列

DISP7: CLR A

MOVC A,@A+DPTR

MOV DAT,A

LCALL WRD

INC DPTR

DJNZ R1,DISP7

DJNZ R2,DISP6 ;写满全屏的16*8字节X64

MOV R2,#32 ;32行,(双屏结构的下半屏)

MOV R3,#80H ;Y地址寄存器

DISP8: MOV COM,R3 ;设置绘图区的Y地址坐标

INC R3 ;Y地址加1

LCALL WRI

MOV COM,#88H ;设置绘图区的X地址坐标

LCALL WRI

MOV R1,#16 ;16*8列

DISP9: CLR A

MOVC A,@A+DPTR

MOV DAT,A

LCALL WRD

INC DPTR

DJNZ R1,DISP9

DJNZ R2,DISP8 ;写满全屏的16*8字节X64

LCALL DELAY1 ;1S延时子程序

;********************************以上是写入一幅图画(电脑桌面图)

WRI: PUSH ACC

CLR RS

SETB RW

WRI1: MOV P0,#0FFH

SETB E

MOV A,P0

CLR E

JB ACC.7,WRI1

CLR RW

MOV P0,COM

SETB E

CLR E

POP ACC

RET

;******************************************以上是写指令子程序

WRD: PUSH ACC

CLR RS

SETB RW

WRD1: MOV P0,#0FFH

SETB E

MOV A,P0

CLR E

JB ACC.7,WRD1

SETB RS

CLR RW

MOV P0,DAT

SETB E

CLR E

POP ACC

RET

;******************************************以上是写数据子程序

DELAY: MOV R7,#0FFH

DELAY4: MOV R6,#00FH

LOOP2: DJNZ R6,LOOP2

DJNZ R7,DELAY4

RET

DELAY1: MOV R4,#08H

DELAY11:MOV R7,#0FFH

DELAY41:MOV R6,#0FFH

DJNZ R6,$

DJNZ R7,DELAY41

DJNZ R4,DELAY11

RET

XX: MOV R5,#0FFH

XX1: MOV R6,#0FFH

XX2: DJNZ R6,XX2

DJNZ R5,XX1

RET

;******************************************以上是延时子程序

DAB2:

DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,03FH,0FFH,0F0H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,040H,000H,018H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,0BFH,0FFH,0DCH,000H,001H

DB 080H,000H,01FH,0FFH,0FFH,000H,000H,000H,000H,000H,000H,0BFH,0FFH,0BCH,000H,001H

DB 080H,000H,030H,000H,001H,080H,000H,000H,000H,000H,001H,07FH,0FFH,0B8H,000H,001H

DB 080H,000H,030H,000H,000H,080H,000H,000H,000H,000H,001H,07FH,0FFH,078H,000H,001H

DB 080H,000H,019H,0FFH,0FEH,0C0H,000H,000H,000H,000H,002H,0FFH,0FFH,070H,000H,001H

DB 080H,000H,018H,000H,000H,040H,000H,000H,000H,000H,002H,0FFH,0FEH,0F0H,000H,001H

DB 080H,000H,00CH,001H,0FFH,060H,000H,000H,000H,000H,005H,0FFH,0FEH,0E0H,000H,001H

DB 080H,000H,00CH,07FH,0D0H,020H,000H,000H,000H,000H,005H,0FFH,0FDH,0E0H,000H,001H

DB 080H,000H,006H,000H,00FH,0B0H,000H,000H,000H,000H,00BH,0FFH,0FDH,0C0H,000H,001H

DB 080H,000H,006H,003H,0FCH,010H,000H,000H,000H,000H,00BH,0FFH,0FBH,0C0H,000H,001H

DB 080H,000H,003H,01FH,000H,018H,000H,000H,000H,000H,017H,0FFH,0FBH,080H,000H,001H

DB 080H,000H,003H,000H,000H,008H,000H,000H,000H,000H,017H,0FFH,0F7H,080H,000H,001H

DB 080H,000H,001H,080H,000H,00CH,000H,000H,000H,000H,017H,0FFH,0F7H,000H,000H,001H

DB 080H,000H,001H,080H,000H,004H,000H,000H,000H,000H,009H,0FFH,0EFH,000H,000H,001H

DB 080H,000H,000H,0C0H,000H,0F6H,000H,000H,000H,000H,006H,07FH,0EEH,000H,000H,001H

DB 080H,000H,000H,0C0H,003H,0C2H,000H,000H,000H,000H,001H,09FH,0DEH,000H,000H,001H

DB 080H,000H,000H,060H,000H,03BH,000H,000H,000H,000H,000H,067H,0DFH,000H,000H,001H

DB 080H,000H,000H,060H,000H,0E3H,000H,000H,000H,000H,000H,019H,0BFH,000H,000H,001H

DB 080H,000H,000H,030H,003H,08EH,000H,000H,000H,000H,000H,006H,03FH,000H,000H,001H

DB 080H,000H,000H,030H,006H,03CH,000H,000H,000H,000H,000H,001H,0FFH,000H,000H,001H

DB 080H,000H,000H,018H,000H,0F0H,000H,000H,000H,000H,000H,000H,0FFH,000H,000H,001H

DB 080H,000H,000H,018H,003H,0C0H,000H,000H,000H,000H,000H,00FH,07FH,080H,000H,001H

DB 080H,000H,000H,00CH,00FH,000H,000H,000H,000H,000H,000H,030H,01FH,0C0H,000H,001H

DB 080H,000H,000H,00CH,03CH,000H,000H,000H,000H,000H,000H,040H,007H,0E0H,000H,001H

DB 080H,000H,000H,006H,0F0H,000H,000H,000H,000H,000H,000H,0E0H,01FH,0E0H,000H,001H

DB 080H,000H,000H,007H,0C0H,000H,000H,000H,000H,000H,000H,0F8H,03FH,0C0H,000H,001H

DB 080H,000H,000H,003H,000H,000H,000H,000H,000H,000H,000H,07EH,0FFH,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,01FH,0FCH,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,007H,0F0H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H,0C0H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,005H,040H,088H,004H,001H,008H,000H,000H,00AH,081H,010H,004H,000H,020H,001H

DB 080H,079H,021H,008H,002H,021H,049H,000H,000H,0F2H,042H,010H,004H,047H,010H,001H

DB 080H,009H,007H,0DFH,07FH,0F7H,0AAH,000H,000H,012H,00FH,0BEH,07FH,0E5H,0FEH,001H

DB 080H,07FH,0F4H,051H,008H,081H,02CH,000H,000H,0FFH,0E8H,0A2H,044H,047H,000H,001H

DB 080H,009H,004H,061H,008H,081H,07FH,000H,000H,012H,008H,0C2H,07FH,0C5H,04AH,001H

DB 080H,00BH,024H,051H,008H,083H,081H,000H,000H,016H,048H,0A2H,044H,045H,06AH,001H

DB 080H,01DH,047H,0C9H,005H,005H,001H,000H,000H,03AH,08FH,092H,044H,047H,052H,001H

DB 080H,068H,084H,049H,005H,005H,07FH,000H,000H,0D1H,008H,092H,07FH,0C5H,06AH,001H

DB 080H,009H,094H,041H,002H,001H,001H,000H,000H,013H,028H,082H,044H,005H,04AH,001H

DB 080H,00EH,057H,0C1H,00DH,081H,001H,000H,000H,01CH,0AFH,082H,004H,029H,042H,001H

DB 080H,038H,034H,04EH,070H,071H,07FH,000H,000H,070H,068H,09CH,003H,0EBH,07EH,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 080H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,000H,001H

DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

END

串口通信模式:

;12864-12串行通信广告显示例程

; RS--------P3.0

; R/W-------P3.1

; E---------P3.2

CS EQU P3.0

SID EQU P3.1

CLK EQU P3.2

PSB EQU P3.3

ORG 0000H

AJMP START

; ORG 0003H

; LCALL PAUSE

ORG 0100h

START:

; MOV IE,#81H ;EXT. INT0 PERMIT

; MOV IP,#01H ;INT0 IS FIRST INT. LEVEL

; MOV TCON,#00H ;TIMER/COUNTER CONTROLER INIT.

mov SP, #67h

CLR PSB

LCALL DELAY

LCALL DELAY

LCALL SETUP

LCALL DEF_CHAR

MOV A,#80H

LCALL WRITE_COM

MOV R3,#8

TEST11: MOV DPTR,#CGRAM1 ;CGRAM TEST

LCALL WRITE_CGRAM

DJNZ R3,TEST11

MOV A,#90H

LCALL WRITE_COM

MOV R3,#8

TEST12: MOV DPTR,#CGRAM1

LCALL WRITE_CGRAM

DJNZ R3,TEST12

MOV A,#88H

LCALL WRITE_COM

MOV R3,#8

TEST13: MOV DPTR,#CGRAM1

LCALL WRITE_CGRAM

DJNZ R3,TEST13

MOV A,#98H

LCALL WRITE_COM

MOV R3,#8

TEST14: MOV DPTR,#CGRAM1

LCALL WRITE_CGRAM

DJNZ R3,TEST14

LCALL DELAY

LCALL DELAY

LCALL DELAY

LCALL DELAY

LCALL DELAY

MOV A,#80H

LCALL WRITE_COM

MOV R3,#8

TEST21: MOV DPTR,#CGRAM2

LCALL WRITE_CGRAM

DJNZ R3,TEST21

MOV A,#90H

LCALL WRITE_COM

MOV R3,#8

TEST22: MOV DPTR,#CGRAM2

LCALL WRITE_CGRAM

DJNZ R3,TEST22

MOV A,#88H

LCALL WRITE_COM

MOV R3,#8

TEST23: MOV DPTR,#CGRAM2

LCALL WRITE_CGRAM

DJNZ R3,TEST23

MOV A,#98H

LCALL WRITE_COM

MOV R3,#8

TEST24: MOV DPTR,#CGRAM2

LCALL WRITE_CGRAM

DJNZ R3,TEST24

LCALL DELAY

LCALL DELAY

LCALL DELAY

LCALL DELAY

LCALL DELAY

MOV A,#80H

LCALL WRITE_COM

MOV R3,#8

TEST31: MOV DPTR,#CGRAM3

LCALL WRITE_CGRAM

DJNZ R3,TEST31

MOV A,#90H

LCALL WRITE_COM

MOV R3,#8

TEST32: MOV DPTR,#CGRAM3

LCALL WRITE_CGRAM

DJNZ R3,TEST32

MOV A,#88H

LCALL WRITE_COM

MOV R3,#8

TEST33: MOV DPTR,#CGRAM3

LCALL WRITE_CGRAM

DJNZ R3,TEST33

MOV A,#98H

LCALL WRITE_COM

MOV R3,#8

TEST34: MOV DPTR,#CGRAM3

LCALL WRITE_CGRAM

DJNZ R3,TEST34

LCALL DELAY

LCALL DELAY

LCALL DELAY

LCALL DELAY

LCALL DELAY

MOV A,#80H

LCALL WRITE_COM

MOV R3,#8

TEST41: MOV DPTR,#CGRAM4

LCALL WRITE_CGRAM

DJNZ R3,TEST41

MOV A,#90H

LCALL WRITE_COM

MOV R3,#8

TEST42: MOV DPTR,#CGRAM4

LCALL WRITE_CGRAM

DJNZ R3,TEST42

MOV A,#88H

LCALL WRITE_COM

MOV R3,#8

TEST43: MOV DPTR,#CGRAM4

LCALL WRITE_CGRAM

DJNZ R3,TEST43

MOV A,#98H

LCALL WRITE_COM

MOV R3,#8

TEST44: MOV DPTR,#CGRAM4

LCALL WRITE_CGRAM

DJNZ R3,TEST44

LCALL DELAY

LCALL DELAY

LCALL DELAY

LCALL DELAY

LCALL DELAY

MOV A,#80H ;WORD TEST

LCALL WRITE_COM

MOV DPTR,#ETAB

LCALL WRITE_ASCII

MOV A,#90H

LCALL WRITE_COM

MOV DPTR,#ETAB+16

LCALL WRITE_ASCII

MOV A,#88H ;WORD TEST

LCALL WRITE_COM

MOV DPTR,#TABLE1

LCALL WRITE_ASCII

MOV A,#98H

LCALL WRITE_COM

MOV DPTR,#TABLE1+16

LCALL WRITE_ASCII

LCALL DELAY

LCALL DELAY

LCALL DELAY

LCALL DELAY

LCALL DELAY

LCALL DELAY

MOV A,#80H

LCALL WRITE_COM

MOV DPTR,#CTAB

LCALL WRITE_HZ

MOV A,#90H

LCALL WRITE_COM

MOV DPTR,#chinese

LCALL WRITE_hz

MOV A,#88H

LCALL WRITE_COM

MOV DPTR,#CTAB

LCALL WRITE_HZ

MOV A,#98H

LCALL WRITE_COM

MOV DPTR,#chinese

LCALL WRITE_hz

LCALL DELAY

LCALL DELAY

LCALL DELAY

LCALL DELAY

LCALL DELAY

AAA: LJMP START

SETUP: CLR PSB

LCALL DELAY

LCALL DELAY

LCALL DELAY

MOV A,#00110000B ;FUNCTION SETTING

LCALL WRITE_COM

MOV A,#00000010B ;DDRAM SET TO ‘00H’

LCALL WRITE_COM

MOV A,#00000100B ;

LCALL WRITE_COM

MOV A,#00001100B ;DISPLAY ON

LCALL WRITE_COM

MOV A,#00000001B ;CLEARING SCREEN

LCALL WRITE_COM

MOV A,#10000000B ;SET DDRAM ADDRESS

LCALL WRITE_COM

RET

WRITE_COM: ;Serial Port

LCALL DELAY1 ;INSTEAD OF CHECKING BF STATE

SETB CS

PUSH ACC

MOV R0,#8

MOV A,#11111000B

COMM1:

CLR C

RLC A

MOV SID,C

CLR CLK

SETB CLK

DJNZ R0,COMM1

POP ACC

MOV R5,A

ANL A,#0F0H

MOV R0,#8

COMM2: CLR C

RLC A

MOV SID,C

CLR CLK

SETB CLK

DJNZ R0,COMM2

MOV A,R5

SWAP A

ANL A,#0F0H

MOV R0,#8

COMM3: CLR C

RLC A

MOV SID,C

CLR CLK

SETB CLK

DJNZ R0,COMM3

CLR CS

RET

WRITE_DAT:

LCALL DELAY1

SETB CS

PUSH ACC

MOV R0,#8

MOV A,#11111010B

DATA1: CLR C

RLC A

MOV SID,C

CLR CLK

SETB CLK

DJNZ R0,DATA1

POP ACC

MOV R5,A

ANL A,#0F0H

MOV R0,#8

DATA2: CLR C

RLC A

MOV SID,C

CLR CLK

SETB CLK

DJNZ R0,DATA2

MOV A,R5

SWAP A

ANL A,#0F0H

MOV R0,#8

DATA3: CLR C

RLC A

MOV SID,C

CLR CLK

SETB CLK

DJNZ R0,DATA3

CLR CS

RET

DELAY1:

MOV R7,#010H

D11: MOV R6,#010H

DJNZ R6,$

DJNZ R7,D11

RET

DELAY:

MOV R1,#00H

D2: MOV R2,#00H

LCALL DELAY1

DJNZ R2,$

DJNZ R1,D2

RET

DEF_CHAR: ;WRITE TO CGRAM

MOV A,#01000000B ;SET CGRAM ADDRESS

LCALL WRITE_COM

MOV R3,#14

MOV A,#07fH

LCALL WRITE_DAT

MOV A,#0feH

LCALL WRITE_DAT

DEF1:

MOV A,#080H

LCALL WRITE_DAT

MOV A,#001H

LCALL WRITE_DAT

DJNZ R3,DEF1

MOV A,#07fH

LCALL WRITE_DAT

MOV A,#0feH

LCALL WRITE_DAT

MOV R3,#8

DEF2:

MOV A,#0AAH

LCALL WRITE_DAT

MOV A,#0AAH

LCALL WRITE_DAT

MOV A,#0AAH

LCALL WRITE_DAT

MOV A,#0AAH

LCALL WRITE_DAT

DJNZ R3,DEF2

MOV R3,#8

DEF3:

MOV A,#055H

LCALL WRITE_DAT

MOV A,#055H

LCALL WRITE_DAT

MOV A,#0AAH

LCALL WRITE_DAT

MOV A,#0AAH

LCALL WRITE_DAT

DJNZ R3,DEF3

mov R3,#8

DEF4:

MOV A,#0FFH

LCALL WRITE_DAT

MOV A,#0FFH

LCALL WRITE_DAT

MOV A,#0FFH

LCALL WRITE_DAT

MOV A,#0FFH

LCALL WRITE_DAT

DJNZ R3,DEF4

RET

WRITE_ASCII:

MOV R4,#16

DDDD: CLR A

MOVC A,@A+DPTR

LCALL WRITE_DAT

INC DPTR

DJNZ R4,DDDD

RET

WRITE_HZ: ;WRITE 8 CHINESE TO LCD

MOV R4,#8

DD: CLR A

MOVC A,@A+DPTR

INC DPTR

LCALL WRITE_DAT

CLR A

MOVC A,@A+DPTR

INC DPTR

LCALL WRITE_DAT

DJNZ R4,DD

RET

WRITE_CGRAM: ;CGRAM TESTING

CLR A

MOVC A,@A+DPTR

LCALL WRITE_DAT

INC DPTR

CLR A

MOVC A,@A+DPTR

LCALL WRITE_DAT

RET

PAUSE: SETB P3.2 ;PAUSE KEY PROCESS

SETB P3.2

LCALL DELAY1

MOV C,P3.2

MOV C,P3.2

JNC PAUSE ;CHECK KEY WAS PRESSED

PAUSE1: MOV C,P3.2

MOV C,P3.2

LCALL DELAY1

JC PAUSE1 ;CHECK KEY OPEN AFTER PRESSED

PAUSE2: SETB P3.2

SETB P3.2

LCALL DELAY1

MOV C,P3.2

MOV C,P3.2

JNC PAUSE2 ;CHECK KEY WAS PRESSED AGAIN

RETI

TABLE1:

DB ‘ABCDEFGHIJKLMNOP’

DB ‘0123456789!@#$%^’

ETAB:

DB ‘ LCDINLINE.COM! ’

DB ‘WELCOME TO HERE!’

CGRAM1: DB 000H,000H

CGRAM2: DB 000H,002H

CGRAM3: DB 000H,004H

CGRAM4: DB 000H,006H

CHINESE:

DB ‘中文液晶显示模块’

CTAB:

DB ‘福星电子专业服务’

END

附录部分

附录1:ASCII码表

RAM

16*8半宽字符表

附录2:汉字码址表

RAM

RAM

RAM

RAM

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分