mọi người cho em hỏi về thằng LCD 16x2 này tí. sao mà em muốn chữ hiện tại hàng thứ 2 hoài mà kg dc. code như thế này ạ
;-----------------
-CHON_TG BIT P0.1 ; BIT 0 LA CHON THANH GHI
;LENH " --BIT 1 LA TG "DU LIEU"
-CHO_PHEP BIT P0.0
-D0C_GHI BIT P0.2
ORG 0
MAIN:
MOV SP,#5FH
mov TMOD,#21H
MOV TH0,#HIGH(-20000)
MOV TL0,#LOW(-20000)
SETB TR0
JNB TF0,$
CLR TR0
CLR TF0
;------------------ KHOI TAO LCD
MOV A,#38H; THIET LAP CHE DO 2 DONG
CALL COMNWRT
MOV A,#0CH; HIEN MAN HINH, TAT CON TRO
CALL COMNWRT
MOV A,#01; XOA MAN HINH LCD
CALL COMNWRT
MOV A,#06H; DICH CON TRO SANG PHAI MOI KHI GHI XONG 1 KY TU
CALL COMNWRT
MOV A,#0C0H ; hien thị tại hàng thứ 2
CALL COMNWRT
MOV A,#'L'
CALL DATAWRT
MOV A,#'O'
CALL DATAWRT
MOV A,#'V'
CALL DATAWRT
MOV A,#'E'
CALL DATAWRT
JMP $
COMNWRT:
MOV P1,A
CLR CHON_TG
CLR D0C_GHI
CLR CHO_PHEP
SETB CHO_PHEP
NOP
CLR CHO_PHEP
CALL KT_CO
RET
;----- GHI DU LIEU CHO LCD
DATAWRT:
MOV P1,A
SETB CHON_TG
CLR D0C_GHI
CLR CHO_PHEP
SETB CHO_PHEP
NOP
CLR CHO_PHEP
CALL KT_CO
RET
;-------- KIEM TRA CO BF CUA LCD
KT_CO:
MOV P1,#0FFH
CLR CHON_TG
SETB D0C_GHI
VE_KT_CO:
CLR CHO_PHEP
SETB CHO_PHEP
MOV A,P1
JB ACC.7,VE_KT_CO
NOP
RET
END
;-----------------
-CHON_TG BIT P0.1 ; BIT 0 LA CHON THANH GHI
;LENH " --BIT 1 LA TG "DU LIEU"
-CHO_PHEP BIT P0.0
-D0C_GHI BIT P0.2
ORG 0
MAIN:
MOV SP,#5FH
mov TMOD,#21H
MOV TH0,#HIGH(-20000)
MOV TL0,#LOW(-20000)
SETB TR0
JNB TF0,$
CLR TR0
CLR TF0
;------------------ KHOI TAO LCD
MOV A,#38H; THIET LAP CHE DO 2 DONG
CALL COMNWRT
MOV A,#0CH; HIEN MAN HINH, TAT CON TRO
CALL COMNWRT
MOV A,#01; XOA MAN HINH LCD
CALL COMNWRT
MOV A,#06H; DICH CON TRO SANG PHAI MOI KHI GHI XONG 1 KY TU
CALL COMNWRT
MOV A,#0C0H ; hien thị tại hàng thứ 2
CALL COMNWRT
MOV A,#'L'
CALL DATAWRT
MOV A,#'O'
CALL DATAWRT
MOV A,#'V'
CALL DATAWRT
MOV A,#'E'
CALL DATAWRT
JMP $
COMNWRT:
MOV P1,A
CLR CHON_TG
CLR D0C_GHI
CLR CHO_PHEP
SETB CHO_PHEP
NOP
CLR CHO_PHEP
CALL KT_CO
RET
;----- GHI DU LIEU CHO LCD
DATAWRT:
MOV P1,A
SETB CHON_TG
CLR D0C_GHI
CLR CHO_PHEP
SETB CHO_PHEP
NOP
CLR CHO_PHEP
CALL KT_CO
RET
;-------- KIEM TRA CO BF CUA LCD
KT_CO:
MOV P1,#0FFH
CLR CHON_TG
SETB D0C_GHI
VE_KT_CO:
CLR CHO_PHEP
SETB CHO_PHEP
MOV A,P1
JB ACC.7,VE_KT_CO
NOP
RET
END
Comment