📄 lcd.asm
字号:
lCALL TDL20ms
mov a,#c0h
lcall WRITECONTROL
ret
lcd_shift_cursor_left:
CLR e ;set the LCD to read mode, so we don't corrupt it
lCALL TDL20ms
mov a,#10h
call WRITECONTROL
ret
lcd_shift_cursor_right:
CLR e ;set the LCD to read mode, so we don't corrupt it
lCALL TDL20ms
mov a,#14h
call WRITECONTROL
ret
;*****************************************************************
;Function : use to let the lcd to display the character
;*****************************************************************
WRITEDATA:
PUSH DPH
PUSH DPL
; push 0
SETB e ;PUT ENABLE HIGH
SETB rs ;set R/S high to make teh data input
MOV P2,A
lCALL TDL10ms
CLR e ;put enable low, stop to input anything
lCALL TDL10ms
; pop 0
POP DPL
POP DPH
RET
;*****************************************************************
;Function : use to let cpu to input the controlword to the Lcd
;*****************************************************************
WRITECONTROL:
PUSH DPH
PUSH DPL
; push 0
; push 1
SETB e ;PUT ENABLE HIGH
CLR rs ;SET R/S low and make the instruction code input
MOV P2,A
lCALL TDL10ms
CLR e ;put enable low, stop to input anything
lCALL TDL10ms
; pop 1
; pop 0
POP DPL
POP DPH
RET
;*****************************************************************
;Function : printout the string that the program setting before
;*****************************************************************
PRINTOUT:
CLR A
MOVC A,@A+DPTR
CJNE A,#'$',W
JMP ENDING
W: LCALL WRITEDATA ;printout the character to the lcd
INC DPTR ;shift the d-pointer with 1
LJMP PRINTOUT
ENDING:
LCALL TDL10ms
LCALL TDL10ms
RET
;*****************************************************************
send_org11: mov scon,#50h
mov pcon,#70h
mov c,psw.0
mov tb8,c
mov sbuf,#0ah
w_g: jbc ti,rn_0
jmp w_g
rn_0: ret
send_org12: mov scon,#50h
mov pcon,#70h
mov c,psw.0
mov tb8,c
mov sbuf,#0DH
w_00: jbc ti,rn_00
jmp w_00
rn_00: ret
send_o: mov scon,#50h
mov pcon,#70h
mov c,psw.0
mov tb8,c
mov sbuf,#"."
ol: jbc ti,lex
jmp ol
lex: ret
;--------------------------------------
send_t1: mov scon,#50h
mov pcon,#70h
mov c,psw.0
mov tb8,c
anl a,#0fh
cjne a,#00h,skp_0
mov sbuf,#"A"
jmp tran
skp_0: anl a,#0fh
cjne a,#01h,skp_1
mov sbuf,#"B"
jmp tran
skp_1: anl a,#0fh
cjne a,#02h,skp_2
mov sbuf,#"E"
jmp tran
skp_2: anl a,#0fh
cjne a,#03h,skp_3
mov sbuf,#"H"
jmp tran
skp_3: cjne a,#04h,skp_4
mov sbuf,#"O"
jmp tran
skp_4: cjne a,#05h,skp_5
mov sbuf,#"C"
jmp tran
skp_5: cjne a,#06h,skp_6
mov sbuf,#"F"
jmp tran
skp_6: cjne a,#07h,skp_7
mov sbuf,#"I"
jmp tran
skp_7: cjne a,#08h,skp_8
mov sbuf,#"P"
jmp tran
skp_8: cjne a,#09h,exit1
mov sbuf,#"D"
jmp tran
skp_9: cjne a,#0ah,skp_10
mov sbuf,#"G"
jmp tran
skp_10: cjne a,#0bh,skp_11
mov sbuf,#"J"
jmp tran
skp_11: cjne a,#0ch,skp_12
mov sbuf,#"N"
jmp tran
skp_12: cjne a,#0dh,skp_13
mov sbuf,#"M"
jmp tran
skp_13: cjne a,#0eh,skp_14
mov sbuf,#"L"
jmp tran
skp_14: cjne a,#0fh,exit1
mov sbuf,#"K"
tran: jbc ti,exit1
jmp tran
exit1: ret
;--------------------------------
;---- bcd to hex ----------
;--------------------------------
bcdhex: push b
jz bcd_hex
clr a
mov b,#00h
redo: inc b
add a,#1
da a
cjne a,bcdbuff,redo
mov hexbuff,b
jmp bcd_hex_exit
bcd_hex: clr a
mov b,#00h
mov hexbuff,b
bcd_hex_exit: pop b
ret
;--------------------------------
;---- hex to bcd ---------
;--------------------------------
hex_bcd: push b
jz hex_bcd_exit
mov b,a
clr a
hex_bcd_lp:
add a,#1
da a
djnz b,hex_bcd_lp
hex_bcd_exit: pop b
ret
;------------------------------
td_200ms: mov time,#4
lcall t_50ms
ret
;-------------------------------
td_100ms: mov time,#2
lcall t_50ms
ret
;-------------------------------
td_50ms: mov time,#1
lcall t_50ms
ret
;-------------------------------
td_300ms: mov time,#6
lcall t_50ms
ret
;-------------------------------
td_500ms: mov time,#10
lcall t_50ms
ret
;-------------------------------
td_1s: mov time,#20
lcall t_50ms
ret
;-------------------------------
td_5s: mov time,#100
lcall t_50ms
ret
;-------------------------------
td_1ms: mov time,#1
lcall t_1ms
ret
;-------------------------------
TDL10ms: mov time,#1
lcall t_10ms
ret
;-------------------------------
TDL20ms: mov time,#2
lcall t_10ms
ret
;---------------------------------
;---- delay 50ms
;---------------------------------
t_1ms: mov r5,time
clr tr0
clr tf0
td_1m: mov th0,#>(65536-1000)
mov tl0,#<(65536-1000)
setb tr0
td_1ms_lp: jnb tf0,td_1ms_lp
clr tf0
djnz r5,td_1m
clr tr0
clr tf0
ret
;---------------------------------
;---- delay 10ms
;---------------------------------
t_10ms: mov r5,time
clr tr0
clr tf0
td_10m: mov th0,#>(65536-10000)
mov tl0,#<(65536-10000)
setb tr0
td_10ms_lp: jnb tf0,td_10ms_lp
clr tf0
djnz r5,td_10m
clr tr0
clr tf0
ret
;---------------------------------
;---- delay 50ms
;---------------------------------
t_50ms: mov r5,time
clr tr0
clr tf0
td_50s: mov th0,#>(65536-50000)
mov tl0,#<(65536-50000)
setb tr0
td_50ms_lp: jnb tf0,td_50ms_lp
clr tf0
djnz r5,td_50s
clr tr0
clr tf0
ret
;--------------------------------------------------
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -