源代码:
COM EQU 50H ;指令寄存器
DAT EQU 51H ;数据寄存器
RS EQU P2.1 ;LCD寄存器选择信号
RW EQU P2.2 ;LCD读/写选择信号
E EQU P2.3 ;LCD使能信号
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP BT0
ORG 0030H
MAIN: MOV SP, #60H
LCALL INT
MOV 30H, #30H
MOV 31H, #0A5H
MOV 32H, #30H
MOV 33H, #30H
MOV 34H, #30H
LCALL WPAD ;调用自定义汉字字符子程序
LCALL N2 ;显示自定义字符型汉字
LCALL N1 ;显示"Voltage = "
MOV DPTR, #0F4FFH ;启动0808
MOV A, #00H
MOVX @DPTR, A
;************************定时器初始化程序******************************
MOV TMOD, #00H
MOV TH0, #00H
MOV TL0, #01H
SETB TR0
SETB EA
SETB ET0
;**********************************************************************
LP: LCALL DISPLAY
SJMP LP
;************************定时器中断服务程序****************************
BT0: PUSH ACC ;进栈
PUSH DPH
PUSH DPL
MOV TH0, #00H
MOV TL0, #01H
MOV DPTR, #0F4FFH ;读取0808第0通道的转换结果
MOVX A, @DPTR
MOV P1, A
JB ACC.7, BAOJING ;报警
MOV B, #51 ;将二进制转换为十进制
DIV AB
MOV DPTR, #NUMCODE
MOVC A, @A+DPTR
MOV 30H, A
MOV 31H, #0A5H
MOV A, B
MOV B, #05H
DIV AB
MOVC A, @A+DPTR
MOV 32H, A
MOV A, B
MOV B, #02H
MUL AB
MOVC A, @A+DPTR
MOV 33H, A
MOV 34H, #30H
MOV A, #00H ;重新启动0808
MOV DPTR, #0F4FFH
MOVX @DPTR, A
POP DPL ;出栈
POP DPH
POP ACC
SJMP KKKK
BAOJING:
LCALL N3
SJMP $
KKKK: RETI
NUMCODE:DB 30H,31H,32H,33H,34H,35H,36H,37H,38H,39H
;**********************************************************************
DISPLAY:;MOV COM, #8AH ;LCD显示子程序
MOV COM, #0CAH
LCALL PR1
MOV R1, #05H
MOV R0, #30H
L: MOV DAT, @R0
LCALL PR2
INC R0
DJNZ R1, L
RET
;逐字依次输入方式演示程序段
N1: MOV COM, #0C0H
LCALL PR1
MOV DPTR, #TAB
MOV R2, #10
MOV R3, #00H
WAIN: MOV A, R3
MOVC A, @A+DPTR
MOV DAT, A
LCALL PR2
INC R3
DJNZ R2, WAIN
RET
TAB: DB "Voltage = "
;显示自定义字符型汉字
N2: MOV COM, #01H
LCALL PR1
MOV COM, #06H
LCALL PR1
MOV COM, #85H
LCALL PR1
MOV R4, #05H
MOV DPTR, #ZIFU
LCALL WP1 ;显示汉字
RET
ZIFU: DB 00H,01H,"-",02H,03H,20H
;逐字依次输入方式演示程序段
N3: MOV COM, #01H
LCALL PR1
MOV COM, #0C5H
LCALL PR1
MOV DPTR, #TAB3
MOV R2, #5
MOV R3, #00H
WAIN3: MOV A, R3
MOVC A, @A+DPTR
MOV DAT, A
LCALL PR2
INC R3
DJNZ R2, WAIN3
RET
TAB3: DB "OVER!"
;LCD间接控制方式下的初始化子程序
INT: LCALL DELAY
MOV COM, #38H
LCALL PR1
MOV COM, #01H
LCALL PR1
MOV COM, #06H
LCALL PR1
MOV COM, #0EH
LCALL PR1
RET
DELAY: MOV R6, #0FH
MOV R7, #00H
DELAY1: NOP
DJNZ R7, DELAY1
DJNZ R6, DELAY1
RET
;LCD间接控制方式的驱动子程序
;2 写指令代码子程序
PR1: PUSH ACC
CLR RS
SETB RW
PR11: MOV P0, #0FFH
SETB E
LCALL DELAY
NOP
MOV A, P0
CLR E
JB ACC.7, PR11
CLR RW
MOV P0, COM
SETB E
CLR E
POP ACC
RET
;3 写显示数据子程序
PR2: PUSH ACC
CLR RS
SETB RW
PR21: MOV P0, #0FFH
SETB E
LCALL DELAY
MOV A, P0
CLR E
JB ACC.7, PR21
SETB RS
CLR RW
MOV P0, DAT
SETB E
CLR E
POP ACC
RET
;自定义汉字字符子程序
WPAD: MOV COM, #40H
LCALL PR1
MOV R4, #32
MOV DPTR, #ZIMO
WP1: CLR A
MOVC A, @A+DPTR
MOV DAT, A
LCALL PR2
INC DPTR
DJNZ R4, WP1
RET
ZIMO: DB 04H,1FH,01H,0AH,04H,0AH,11H,00H;"刘"
DB 04H,04H,14H,14H,14H,0CH,04H,00H
DB 06H,05H,06H,05H,06H,04H,04H,00H ;"陈"
DB 04H,1FH,08H,1FH,04H,0EH,15H,00H
END