12864液晶显示源程序汇编程序
扫描二维码
随时随地手机看文章
;12864液晶显示源程序全部程序如下:
;============================
COM EQU 20H
LINE EQU 31H
DAT EQU 21H
COLUMN EQU 30H
PAGE0 EQU 31H
CODE0 EQU 32H
COUNT EQU 33H
CSA EQU P3.2 ;15
CSB EQU P3.4 ;16
D_I EQU P3.7 ;4
R_W EQU P3.6 ;5
E EQU P3.5 ;6
;=================================================
;中文演示程序段
ORG 0000H
AJMP MAIN
ORG 20H
MAIN: MOV SP,#60H
ACALL INT ;初始化子程序
ACALL DELAY ;延时子程序
ACALL CLEAR ;清屏子程序
;==============================================
;第一页第一行第1~2汉字显示
;==================
MOV R1,#50H ;x坐标
MOV R2,#0 ;计数器初始化(汉字数)
YS_1: MOV PAGE0,#02H ;y坐标
MOV COLUMN,R1
MOV CODE0,R2
ACALLCCW_PR ;中文字符写入子程序
ACALL DELAY ;延时程序
ACALL DELAY ;延时程序
MOV A,R1
ADD A,#10H ;两汉字间间隔距离(16象素点)
MOV R1,A
INC R2
CJNE R2,#3,YS_1 ;屏蔽后将让第2字不显示
CALL DELAY ;延时程序
CALL DELAY ;延时程序
;=========================================
;第一页第一行第3~5汉字显示
;=============
MOV R1,#80H
MOV R2,#3
YS_2: MOV PAGE0,#02H
MOV COLUMN,R1
MOV CODE0,R2
ACALL CCW_PR
ACALL DELAY
ACALL DELAY
MOV A,R1
ADD A,#10H
MOV R1,A
INC R2
CJNE R2,#05,YS_2 ;屏蔽后让4~5字不显示
;=========================================
;第一页第二行汉字显示
;===============
MOV R1,#50H
MOV R2,#5
YS_3: MOV PAGE0,#04H
MOV COLUMN,R1
MOV CODE0,R2
ACALL CCW_PR
ACALL DELAY
ACALL DELAY
MOV A,R1
ADD A,#10H
MOV R1,A
INC R2
CJNE R2,#11,YS_3
; ACALL DELAY10
;============================================
;第一页第三行显示
;====================
MOV R1,#50H
MOV R2,#11
YS_4: MOV PAGE0,#06H
MOV COLUMN,R1
MOV CODE0,R2
ACALL CCW_PR
ACALL DELAY
ACALL DELAY
MOV A,R1
ADD A,#10H
MOV R1,A
INC R2
CJNE R2,#15,YS_4
ACALL DELAY10
ACALL DELAY10
ACALL DELAY10
ACALL DELAY10
ACALL CLEAR
;==============================================
;第二页第一行显示
;==================
MOV R1,#60H
MOV R2,#15
YS_5: MOV PAGE0,#02H
MOV COLUMN,R1
MOV CODE0,R2
ACALL CCW_PR
ACALL DELAY
ACALL DELAY
MOV A,R1
ADD A,#10H
MOV R1,A
INC R2
CJNE R2,#19,YS_5
;=============================================
;第二页第二行显示
;=====================
MOV R1,#50H
MOV R2,#19
YS_6: MOV PAGE0,#04H
MOV COLUMN,R1
MOV CODE0,R2
ACALL CCW_PR
ACALL DELAY
ACALL DELAY
MOV A,R1
ADD A,#10H
MOV R1,A
INC R2
CJNE R2,#25,YS_6
;==============================================
ACALL DELAY10
ACALL DELAY10
ACALL DELAY10
ACALL DELAY10
ACALL CLEAR
ACALL DELAY10
;=============================================
;第三页显示
;====================
MOV R1,#50H
MOV R2,#25
YS_7: MOV PAGE0,#02H
MOV COLUMN,R1
MOV CODE0,R2
ACALL CCW_PR
ACALL DELAY
ACALL DELAY
MOV A,R1
ADD A,#10H
MOV R1,A
INC R2
CJNE R2,#31,YS_7
;==============================================
ACALL DELAY10
ACALL DELAY10
ACALL DELAY10
ACALL DELAY10
ACALL CLEAR
ACALL DELAY10
AJMP MAIN
;===============================================
;延时子程序
DELAY:PUSH 00
PUSH 01
MOV R0,#0FFH
DELAY1:
MOV R1,#0FFH
DELAY2:
DJNZ R1,DELAY2
DJNZ R0,DELAY1
POP 01
POP 00
RET
DELAY10:
MOV R4,#06H
DELAY11:
ACALL DELAY
DJNZ R4,DELAY11
RET
;==============================================
;中文字符写入子程序
CCW_PR:
NOP
MOV DPTR,#CCTAB ;表地址写入
MOV A,CODE0 ;计数器初始化(汉字数)
MOV B,#20H ;32
MUL AB
ADD A,DPL
MOV DPL,A
MOV A,B
ADDC A,DPH
MOV DPH,A
PUSH COLUMN
PUSH COLUMN
MOV CODE0,#00H
CCW_1: MOV COUNT,#10H ;16
MOV A,PAGE0
ANL A,#07H
ORL A,#0B8H
MOV COM,A
ACALL PRM0 ;写指令代码子程序(左)
ACALL PRR0 ;写指令代码子程序(右)
POP COLUMN
MOV A,COLUMN
CLR C
SUBB A,#40H
JC CCW_2
MOV COLUMN,A
SUBB A,#40H
JC CCW_11
MOV COLUMN,A
MOV A,PAGE0
SETB ACC.5
MOV PAGE0,A
LJMP CCW_2
CCW_11:
MOV A,PAGE0
SETB ACC.4
MOV PAGE0,A
CCW_2:
MOV COM,COLUMN
ORL COM,#40H
MOV A,PAGE0
ANL A,#30H
CJNE A,#10H,CCW_31
ACALL PRM0 ;写指令代码子程序(左)
LJMP CCW_4
CCW_31:
CJNE A,#20H,CCW_32
ACALL PRR0 ;写指令代码子程序(右)
LJMP CCW_4
CCW_32:
NOP
CCW_4:
MOV A,CODE0
MOV C A,@A+DPTR
MOV DAT,A
MOV A,PAGE0
ANL A,#30H
CJNE A,#10H,CCW_41
ACALL PRM1
LJMP CCW_5
CCW_41:
CJNE A,#20H,CCW_42
ACALL PRR1
LJMP CCW_5
CCW_42:
NOP
CCW_5:INC CODE0
INC COLUMN
MOV A,COLUMN
CJNE A,#40H,CCW_6
CCW_6:JC CCW_7
MOV COLUMN,#00H
MOV A,PAGE0
JB ACC.5,CCW_09
JB ACC.4,CCW_61
SETB ACC.4
MOV PAGE0,A
MOV COM,#40H
ACALL PRM0 ;写指令代码子程序(左)
LJMP CCW_7
CCW_61:
SETB ACC.5
CLR ACC.4
MOV PAGE0,A
MOV COM,#40H
ACALL PRR0 ;写指令代码子程序(右)
CCW_7:
DJNZ COUNT,CCW_4
CCW_09:
MOV A,PAGE0
JB ACC.7,CCW_9
INC A
SETB ACC.7
ANL A,#0CFH
MOV PAGE0,A
MOV CODE0,#10H
LJMP CCW_1
CCW_9:
RET
;=================================================
PRL0: NOP
RET
PRL1: NOP
RET
PRL2: NOP
RET
;=============================
;写指令代码子程序(左)
PRM0: CLR CSA
SETB CSB
CLR D_I
SETB R_W
PRM01: MOV P0,#0FFH
SETB E
MOV A,P0
CLR E
JB ACC.7,PRM01
CLR R_W
MOV P0,COM
SETB E
CLR E
RET
;===============================
;写显示数据子程序(左)
PRM1: CLR CSA
SETB CSB
CLR D_I
SETB R_W
PRM11: MOV P1,#0FFH
SETB E
MOV A,P0
CLR E
JB ACC.7,PRM11
SETB D_I
CLR R_W
MOV P0,DAT
SETB E
CLR E
RET