em mô phỏng trên pruteus thì chạy mà sao khi làm mạch nó không hiện thị LCD mong các sư huynh chỉ giúp em với....
;#include <sfr51.inc>
LCDPORT EQU P1
RS BIT P3.0
RW BIT P3.1
EN BIT P3.2
;**************************
TD_THAP EQU 30H
TD_CAO EQU 31H
BUOC_cao EQU 32H
buoc_thap EQU 33H
CD EQU 34H
MODE EQU 35H
TRE_CAO EQU 36H
TRE_THAP EQU 37H
;************************
CHIEU_QUAY BIT 01H
C_START BIT 02H
C_STOP BIT 03H
TANG BIT P0.1
GIAM BIT P0.2
SET_MODE BIT P0.3
START BIT P0.4
STOP BIT P0.5
;************
ORG 00H
LJMP MAIN
ORG 0BH
LJMP NGAT_T0
ORG 30H
MAIN:
MOV IE,#82H
MOV TMOD,#01H
MOV TH0,#HIGH(6535-1000)
MOV TL0,#LOW(6535-1000)
;***********KHOI TAO LCD**************
MOV A,#3CH
CLR C
LCALL LCDOUT8
MOV A,#0CH
CLR C
LCALL LCDOUT8
MOV A,#01H
CLR C
LCALL LCDOUT8
MOV DPTR,#STEPMOTOR
LCALL OUTST
MOV R0,#8
MOV R1,#1
LCALL GOTOXY
MOV DPTR,#CONTROL
LCALL OUTST
LCALL DELAY3S
MOV A,#01H
CLR C
LCALL LCDOUT8
;*************CHUONG TRINH CHINH**********
LAP:
LCALL DAT_THONG_SO
LAP1:
LCALL KT_START
LCALL DK
LCALL HIEN_THI
MOV C,C_START
JC LAP1
LJMP LAP
;****************DAT THONG SO****************
DAT_THONG_SO:
KT_MODE:
JB SET_MODE,KT_NUT_AN
JNB SET_MODE,$
MOV A,MODE
INC A
MOV MODE,A
CJNE A,#5,KT_NUT_AN
MOV MODE,#0
KT_NUT_AN:
MOV R3,MODE
CJNE R3,#0,KT_TANG
LJMP KT_START
KT_TANG:
JB TANG,KT_GIAM
BUOC1:
CJNE R3,#01,TOC_DO1
MOV A,BUOC_THAP
INC A
MOV BUOC_THAP,A
CJNE A,#100,KT_GIAM
MOV BUOC_THAP,#0
MOV A, BUOC_CAO
INC A
MOV BUOC_CAO,A
CJNE A,#10,KT_GIAM
MOV BUOC_CAO,#0
SJMP KT_GIAM
;*********************************
TOC_DO1:
CJNE R3,#02,CHIEU_QUAY1
MOV A,TD_THAP
INC A
MOV TD_THAP,A
CJNE A,#100,KT_GIAM
MOV TD_THAP,#0
MOV A,TD_CAO
INC A
MOV TD_CAO,A
CJNE A,#10,KT_GIAM
MOV TD_CAO,#0
SJMP KT_GIAM
;**********************************
CHIEU_QUAY1:
CJNE R3,#03,CHE_DO1
SETB CHIEU_QUAY
SJMP KT_GIAM
;************************************
CHE_DO1:
CJNE R3,#4,KT_GIAM
MOV A,CD
INC A
MOV CD,A
CJNE A,#3,KT_GIAM
MOV CD,#0
SJMP KT_GIAM
;*************************************************
KT_GIAM:
JB GIAM,THOAT_KT
BUOC2:
CJNE R3,#01,TOC_DO2
MOV A,BUOC_THAP
DEC A
MOV BUOC_THAP,A
CJNE A,#255,THOAT_KT
MOV BUOC_THAP,#99
MOV A, BUOC_CAO
DEC A
MOV BUOC_CAO,A
CJNE A,#255,THOAT_KT
MOV BUOC_CAO,#9
SJMP THOAT_KT
;*********************************
TOC_DO2:
CJNE R3,#02,CHIEU_QUAY2
MOV A,TD_THAP
DEC A
MOV TD_THAP,A
CJNE A,#255,THOAT_KT
MOV TD_THAP,#99
MOV A, TD_CAO
DEC A
MOV TD_CAO,A
CJNE A,#255,THOAT_KT
MOV TD_CAO,#9
SJMP THOAT_KT
;***************************
CHIEU_QUAY2:
CJNE R3,#03,CHE_DO2
CLR CHIEU_QUAY
SJMP THOAT_KT
;*************************
CHE_DO2:
CJNE R3,#4,THOAT_KT
MOV A,CD
DEC A
MOV CD,A
CJNE A,#255,THOAT_KT
MOV CD,#2
SJMP THOAT_KT
THOAT_KT:
LCALL TRE50MS
RET
;******************************************
KT_START:
MOV R3,MODE
CJNE R3,#0,THOAT_KT1
JB START,KT_STOP
SETB C_START
CLR C_STOP
KT_STOP:
JB STOP,THOAT_KT1
CLR C_START
SETB C_STOP
THOAT_KT1:
RET
;**************************************
DK:
MOV C,C_START
JNC DUNG_DC
SETB TR0
SJMP THOAT_DK
DUNG_DC:
MOV C,C_STOP
JNC THOAT_DK
CLR TR0
LCALL TRE50MS
MOV P2,#0FFH
CLR C_STOP
THOAT_DK:
RET
;***************************
HIEN_THI:
LCALL TACH_SO
LCALL LCD_OUT
RET
;***************
TACH_SO:
MOV A,BUOC_THAP
MOV B,#10
DIV AB
ADD A,#30H
MOV 40H,A
MOV A,B
ADD A,#30H
MOV 41H,A
MOV A,TD_THAP
MOV B,#10
DIV AB
ADD A,#30H
MOV 42H,A
MOV A,B
ADD A,#30H
MOV 43H,A
RET
;********************************
LCD_OUT:
MOV A,#01H
CLR C
LCALL LCDOUT8
MOV R3,MODE
CJNE R3,#0,TT1
MOV DPTR,#BUOC_LCD
LCALL OUTST
MOV A,BUOC_CAO
ADD A,#30H
SETB C
LCALL LCDOUT8
MOV A,40H
LCALL LCDOUT8
MOV A,41H
LCALL LCDOUT8
MOV DPTR,#C_DO_LCD
LCALL OUTST
MOV A,CD
ADD A,#30H
SETB C
LCALL LCDOUT8
MOV R0,#0
MOV R1,#1
LCALL GOTOXY
MOV DPTR,#T_DO_LCD
LCALL OUTST
MOV A,TD_CAO
ADD A,#30H
SETB C
LCALL LCDOUT8
MOV A,42H
LCALL LCDOUT8
MOV A,43H
LCALL LCDOUT8
MOV DPTR,#BMS
LCALL OUTST
MOV C,CHIEU_QUAY
JNC TRAI
MOV A,#'P'
LCALL LCDOUT8
LJMP THOAT_HT
TRAI:
SETB C
MOV A,#'T'
LCALL LCDOUT8
LJMP THOAT_HT
TT1:
CJNE R3,#01,TT2
MOV DPTR,#SO_BUOC_LCD
LCALL OUTST
MOV A,BUOC_CAO
ADD A,#30H
SETB C
LCALL LCDOUT8
MOV A,40H
LCALL LCDOUT8
MOV A,41H
LCALL LCDOUT8
LJMP THOAT_HT
TT2:
CJNE R3,#02,TT3
MOV DPTR,#TOC_DO_LCD
LCALL OUTST
MOV A,TD_CAO
ADD A,#30H
SETB C
LCALL LCDOUT8
MOV A,42H
LCALL LCDOUT8
MOV A,43H
LCALL LCDOUT8
MOV DPTR,#DV_TD_LCD
MOV R0,#5
MOV R1,#1
LCALL GOTOXY
LCALL OUTST
LJMP THOAT_HT
TT3:
CJNE R3,#03,TT4
MOV DPTR,#CHIEU_QUAY_LCD
LCALL OUTST
MOV C,CHIEU_QUAY
JNC TRAI1
MOV A,#'P'
LCALL LCDOUT8
LJMP THOAT_HT
TRAI1:
SETB C
MOV A,#'T'
LCALL LCDOUT8
LJMP THOAT_HT
TT4:
MOV R3,MODE
CJNE R3,#4,THOAT_HT
MOV DPTR,#CD_LCD
LCALL OUTST
MOV A,CD
M1: cjne a,0,M2
MOV DPTR,#CA_BUOC_M_NHO
SJMP M4
M2:CJNE A,#1,M3
MOV DPTR,#CA_BUOC_M_LON
SJMP M4
M3:
MOV DPTR,#NUA_BUOC
M4:
ADD A,#30H
SETB C
LCALL LCDOUT8
MOV R0,#0
MOV R1,#1
LCALL GOTOXY
LCALL OUTST
THOAT_HT:
lcall tre50ms
RET
;************************************************
NGAT_T0:
CLR TR0
MOV TH0,#HIGH(65535-1000)
MOV TL0,#LOW(65535-1000)
SETB TR0
PUSH DPH
PUSH DPL
PUSH PSW
PUSH ACC
;*****
MOV A,TRE_THAP
DEC A
MOV TRE_THAP,A
CJNE A,#255,KT
MOV TRE_THAP,#99
MOV A, TRE_CAO
DEC A
MOV TRE_CAO,A
CJNE A,#255,KT
MOV TRE_THAP,TD_THAP
MOV TRE_CAO,TD_CAO
;**************
TH11: MOV A,CD
CJNE A,#0,TH2
MOV DPTR,#BANG_MA_1
SJMP EN_DC
TH2:
CJNE A,#01,TH3
MOV DPTR,#BANG_MA_2
SJMP EN_DC
TH3:
CJNE A,#02,EN_DC
MOV DPTR,#BANG_MA_3
EN_DC:
MOV C,C_START
JNC KT
MOV A,BUOC_THAP
DEC A
MOV BUOC_THAP,A
CJNE A,#255,QUAY
MOV BUOC_THAP,#99
MOV A, BUOC_CAO
DEC A
MOV BUOC_CAO,A
CJNE A,#255,QUAY
MOV BUOC_THAP,#0
MOV BUOC_CAO,#0
CLR TR0
CLR C_START
SETB C_STOP
LJMP KT
QUAY:
QUAY_PHAI: MOV C,CHIEU_QUAY
JNC QUAY_TRAI
MOV A,R2
MOVC A,@A+DPTR
MOV P2,A
INC R2
CJNE R2,#8,KT
MOV R2,#0
SJMP KT
QUAY_TRAI:
MOV A,R2
MOVC A,@A+DPTR
MOV P2,A
DEC R2
CJNE R2,#255,KT
MOV R2,#7
KT:
POP ACC
POP PSW
POP DPL
POP DPH
RETI
DELAY3S:
MOV R7,#10
DL1:
MOV R6,#100
DL2:
MOV R5,#200
DL3:
NOP
NOP
NOP
DJNZ R5,DL3
DJNZ R3,DL2
DJNZ R7,DL1
RET
;***************
TRE10MS:
MOV R7,#10
DL11:
MOV R6,#200
DLL2:
NOP
NOP
NOP
DJNZ R6,D2
DJNZ R7,D1
RET
TRE2MS:
MOV R7,#1
D1:
MOV R6,#200
D2:
NOP
NOP
NOP
DJNZ R6,D2
DJNZ R7,D1
RET
TRE50MS:
MOV R7,#50
D11:
MOV R6,#200
D22:
NOP
NOP
NOP
DJNZ R6,D22
DJNZ R7,D11
RET
BANG_MA_1B 1H,2H,4H,8H,1H,2H,4H,8H
BANG_MA_2B 3H,6H,0CH,9H,3H,6H,0CH,9H
BANG_MA_3B 1H,3H,2H,6H,4H,0CH,8H,9H
;***************************************
LCDOUT8:
;VAO: C BIT DIEU KHIEN TUONG UNG VOI RS
; A CHUA DU LIEU HOAC LENH CAN GUI DEN LCD
;MOV P2,#255
;SETB RW
;CLR RS
;SETB EN
;LAP:
;JB P2.7,LAP
LCALL TRE2MS
CLR EN
CLR RW
MOV RS,C
MOV P1,A
SETB EN
CLR EN
RET
;*****************************
OUTST:
;VAO: DPTR CHUA DIA CHI BAT DAU CHUOI, VOI CHUOI KET THUC BANG #
LAP2:
MOV A,#0
MOVC A,@A+DPTR
CJNE A,#'#',HT
SJMP KTO
HT:
SETB C
LCALL LCDOUT8
INC DPTR
SJMP LAP2
KTO:
RET
;***********************
GOTOXY:
;VAO: X (R0) COT 0...39
; Y (R1) DONG 0..1
CJNE R1,#0,MOT
MOV A,R0
ADD A,#80H
CLR C
LCALL LCDOUT8
SJMP KTGOTO
MOT:
MOV A,R0
ADD A,#0C0H
CLR C
LCALL LCDOUT8
KTGOTO:
RET
;****************************************8
STEPMOTOR: DB"STEPMOTOR#"
BUOC_LCD: DB"BUOC:#"
C_DO_LCD: DB" C_DO:#"
T_DO_LCD: DB"T_D0:#"
BMS: DB" MS/B_#"
CONTROL: DB"CONTROL#"
CD_LCD: DB"CHE DO:#"
CHIEU_QUAY_LCD: DB"CHIEU QUAY:#"
SO_BUOC_LCD: DB"SO BUOC:#"
TOC_DO_LCD: DB"TOC DO:#"
DV_TD_LCD: DB" MS/BUOC#"
CA_BUOC_M_NHO: DB"(ca buoc M nho)#"
CA_BUOC_M_LON: DB"(ca buoc M lon)#"
NUA_BUOC: DB"(nua buoc)#"
END
LCDPORT EQU P1
RS BIT P3.0
RW BIT P3.1
EN BIT P3.2
;**************************
TD_THAP EQU 30H
TD_CAO EQU 31H
BUOC_cao EQU 32H
buoc_thap EQU 33H
CD EQU 34H
MODE EQU 35H
TRE_CAO EQU 36H
TRE_THAP EQU 37H
;************************
CHIEU_QUAY BIT 01H
C_START BIT 02H
C_STOP BIT 03H
TANG BIT P0.1
GIAM BIT P0.2
SET_MODE BIT P0.3
START BIT P0.4
STOP BIT P0.5
;************
ORG 00H
LJMP MAIN
ORG 0BH
LJMP NGAT_T0
ORG 30H
MAIN:
MOV IE,#82H
MOV TMOD,#01H
MOV TH0,#HIGH(6535-1000)
MOV TL0,#LOW(6535-1000)
;***********KHOI TAO LCD**************
MOV A,#3CH
CLR C
LCALL LCDOUT8
MOV A,#0CH
CLR C
LCALL LCDOUT8
MOV A,#01H
CLR C
LCALL LCDOUT8
MOV DPTR,#STEPMOTOR
LCALL OUTST
MOV R0,#8
MOV R1,#1
LCALL GOTOXY
MOV DPTR,#CONTROL
LCALL OUTST
LCALL DELAY3S
MOV A,#01H
CLR C
LCALL LCDOUT8
;*************CHUONG TRINH CHINH**********
LAP:
LCALL DAT_THONG_SO
LAP1:
LCALL KT_START
LCALL DK
LCALL HIEN_THI
MOV C,C_START
JC LAP1
LJMP LAP
;****************DAT THONG SO****************
DAT_THONG_SO:
KT_MODE:
JB SET_MODE,KT_NUT_AN
JNB SET_MODE,$
MOV A,MODE
INC A
MOV MODE,A
CJNE A,#5,KT_NUT_AN
MOV MODE,#0
KT_NUT_AN:
MOV R3,MODE
CJNE R3,#0,KT_TANG
LJMP KT_START
KT_TANG:
JB TANG,KT_GIAM
BUOC1:
CJNE R3,#01,TOC_DO1
MOV A,BUOC_THAP
INC A
MOV BUOC_THAP,A
CJNE A,#100,KT_GIAM
MOV BUOC_THAP,#0
MOV A, BUOC_CAO
INC A
MOV BUOC_CAO,A
CJNE A,#10,KT_GIAM
MOV BUOC_CAO,#0
SJMP KT_GIAM
;*********************************
TOC_DO1:
CJNE R3,#02,CHIEU_QUAY1
MOV A,TD_THAP
INC A
MOV TD_THAP,A
CJNE A,#100,KT_GIAM
MOV TD_THAP,#0
MOV A,TD_CAO
INC A
MOV TD_CAO,A
CJNE A,#10,KT_GIAM
MOV TD_CAO,#0
SJMP KT_GIAM
;**********************************
CHIEU_QUAY1:
CJNE R3,#03,CHE_DO1
SETB CHIEU_QUAY
SJMP KT_GIAM
;************************************
CHE_DO1:
CJNE R3,#4,KT_GIAM
MOV A,CD
INC A
MOV CD,A
CJNE A,#3,KT_GIAM
MOV CD,#0
SJMP KT_GIAM
;*************************************************
KT_GIAM:
JB GIAM,THOAT_KT
BUOC2:
CJNE R3,#01,TOC_DO2
MOV A,BUOC_THAP
DEC A
MOV BUOC_THAP,A
CJNE A,#255,THOAT_KT
MOV BUOC_THAP,#99
MOV A, BUOC_CAO
DEC A
MOV BUOC_CAO,A
CJNE A,#255,THOAT_KT
MOV BUOC_CAO,#9
SJMP THOAT_KT
;*********************************
TOC_DO2:
CJNE R3,#02,CHIEU_QUAY2
MOV A,TD_THAP
DEC A
MOV TD_THAP,A
CJNE A,#255,THOAT_KT
MOV TD_THAP,#99
MOV A, TD_CAO
DEC A
MOV TD_CAO,A
CJNE A,#255,THOAT_KT
MOV TD_CAO,#9
SJMP THOAT_KT
;***************************
CHIEU_QUAY2:
CJNE R3,#03,CHE_DO2
CLR CHIEU_QUAY
SJMP THOAT_KT
;*************************
CHE_DO2:
CJNE R3,#4,THOAT_KT
MOV A,CD
DEC A
MOV CD,A
CJNE A,#255,THOAT_KT
MOV CD,#2
SJMP THOAT_KT
THOAT_KT:
LCALL TRE50MS
RET
;******************************************
KT_START:
MOV R3,MODE
CJNE R3,#0,THOAT_KT1
JB START,KT_STOP
SETB C_START
CLR C_STOP
KT_STOP:
JB STOP,THOAT_KT1
CLR C_START
SETB C_STOP
THOAT_KT1:
RET
;**************************************
DK:
MOV C,C_START
JNC DUNG_DC
SETB TR0
SJMP THOAT_DK
DUNG_DC:
MOV C,C_STOP
JNC THOAT_DK
CLR TR0
LCALL TRE50MS
MOV P2,#0FFH
CLR C_STOP
THOAT_DK:
RET
;***************************
HIEN_THI:
LCALL TACH_SO
LCALL LCD_OUT
RET
;***************
TACH_SO:
MOV A,BUOC_THAP
MOV B,#10
DIV AB
ADD A,#30H
MOV 40H,A
MOV A,B
ADD A,#30H
MOV 41H,A
MOV A,TD_THAP
MOV B,#10
DIV AB
ADD A,#30H
MOV 42H,A
MOV A,B
ADD A,#30H
MOV 43H,A
RET
;********************************
LCD_OUT:
MOV A,#01H
CLR C
LCALL LCDOUT8
MOV R3,MODE
CJNE R3,#0,TT1
MOV DPTR,#BUOC_LCD
LCALL OUTST
MOV A,BUOC_CAO
ADD A,#30H
SETB C
LCALL LCDOUT8
MOV A,40H
LCALL LCDOUT8
MOV A,41H
LCALL LCDOUT8
MOV DPTR,#C_DO_LCD
LCALL OUTST
MOV A,CD
ADD A,#30H
SETB C
LCALL LCDOUT8
MOV R0,#0
MOV R1,#1
LCALL GOTOXY
MOV DPTR,#T_DO_LCD
LCALL OUTST
MOV A,TD_CAO
ADD A,#30H
SETB C
LCALL LCDOUT8
MOV A,42H
LCALL LCDOUT8
MOV A,43H
LCALL LCDOUT8
MOV DPTR,#BMS
LCALL OUTST
MOV C,CHIEU_QUAY
JNC TRAI
MOV A,#'P'
LCALL LCDOUT8
LJMP THOAT_HT
TRAI:
SETB C
MOV A,#'T'
LCALL LCDOUT8
LJMP THOAT_HT
TT1:
CJNE R3,#01,TT2
MOV DPTR,#SO_BUOC_LCD
LCALL OUTST
MOV A,BUOC_CAO
ADD A,#30H
SETB C
LCALL LCDOUT8
MOV A,40H
LCALL LCDOUT8
MOV A,41H
LCALL LCDOUT8
LJMP THOAT_HT
TT2:
CJNE R3,#02,TT3
MOV DPTR,#TOC_DO_LCD
LCALL OUTST
MOV A,TD_CAO
ADD A,#30H
SETB C
LCALL LCDOUT8
MOV A,42H
LCALL LCDOUT8
MOV A,43H
LCALL LCDOUT8
MOV DPTR,#DV_TD_LCD
MOV R0,#5
MOV R1,#1
LCALL GOTOXY
LCALL OUTST
LJMP THOAT_HT
TT3:
CJNE R3,#03,TT4
MOV DPTR,#CHIEU_QUAY_LCD
LCALL OUTST
MOV C,CHIEU_QUAY
JNC TRAI1
MOV A,#'P'
LCALL LCDOUT8
LJMP THOAT_HT
TRAI1:
SETB C
MOV A,#'T'
LCALL LCDOUT8
LJMP THOAT_HT
TT4:
MOV R3,MODE
CJNE R3,#4,THOAT_HT
MOV DPTR,#CD_LCD
LCALL OUTST
MOV A,CD
M1: cjne a,0,M2
MOV DPTR,#CA_BUOC_M_NHO
SJMP M4
M2:CJNE A,#1,M3
MOV DPTR,#CA_BUOC_M_LON
SJMP M4
M3:
MOV DPTR,#NUA_BUOC
M4:
ADD A,#30H
SETB C
LCALL LCDOUT8
MOV R0,#0
MOV R1,#1
LCALL GOTOXY
LCALL OUTST
THOAT_HT:
lcall tre50ms
RET
;************************************************
NGAT_T0:
CLR TR0
MOV TH0,#HIGH(65535-1000)
MOV TL0,#LOW(65535-1000)
SETB TR0
PUSH DPH
PUSH DPL
PUSH PSW
PUSH ACC
;*****
MOV A,TRE_THAP
DEC A
MOV TRE_THAP,A
CJNE A,#255,KT
MOV TRE_THAP,#99
MOV A, TRE_CAO
DEC A
MOV TRE_CAO,A
CJNE A,#255,KT
MOV TRE_THAP,TD_THAP
MOV TRE_CAO,TD_CAO
;**************
TH11: MOV A,CD
CJNE A,#0,TH2
MOV DPTR,#BANG_MA_1
SJMP EN_DC
TH2:
CJNE A,#01,TH3
MOV DPTR,#BANG_MA_2
SJMP EN_DC
TH3:
CJNE A,#02,EN_DC
MOV DPTR,#BANG_MA_3
EN_DC:
MOV C,C_START
JNC KT
MOV A,BUOC_THAP
DEC A
MOV BUOC_THAP,A
CJNE A,#255,QUAY
MOV BUOC_THAP,#99
MOV A, BUOC_CAO
DEC A
MOV BUOC_CAO,A
CJNE A,#255,QUAY
MOV BUOC_THAP,#0
MOV BUOC_CAO,#0
CLR TR0
CLR C_START
SETB C_STOP
LJMP KT
QUAY:
QUAY_PHAI: MOV C,CHIEU_QUAY
JNC QUAY_TRAI
MOV A,R2
MOVC A,@A+DPTR
MOV P2,A
INC R2
CJNE R2,#8,KT
MOV R2,#0
SJMP KT
QUAY_TRAI:
MOV A,R2
MOVC A,@A+DPTR
MOV P2,A
DEC R2
CJNE R2,#255,KT
MOV R2,#7
KT:
POP ACC
POP PSW
POP DPL
POP DPH
RETI
DELAY3S:
MOV R7,#10
DL1:
MOV R6,#100
DL2:
MOV R5,#200
DL3:
NOP
NOP
NOP
DJNZ R5,DL3
DJNZ R3,DL2
DJNZ R7,DL1
RET
;***************
TRE10MS:
MOV R7,#10
DL11:
MOV R6,#200
DLL2:
NOP
NOP
NOP
DJNZ R6,D2
DJNZ R7,D1
RET
TRE2MS:
MOV R7,#1
D1:
MOV R6,#200
D2:
NOP
NOP
NOP
DJNZ R6,D2
DJNZ R7,D1
RET
TRE50MS:
MOV R7,#50
D11:
MOV R6,#200
D22:
NOP
NOP
NOP
DJNZ R6,D22
DJNZ R7,D11
RET
BANG_MA_1B 1H,2H,4H,8H,1H,2H,4H,8H
BANG_MA_2B 3H,6H,0CH,9H,3H,6H,0CH,9H
BANG_MA_3B 1H,3H,2H,6H,4H,0CH,8H,9H
;***************************************
LCDOUT8:
;VAO: C BIT DIEU KHIEN TUONG UNG VOI RS
; A CHUA DU LIEU HOAC LENH CAN GUI DEN LCD
;MOV P2,#255
;SETB RW
;CLR RS
;SETB EN
;LAP:
;JB P2.7,LAP
LCALL TRE2MS
CLR EN
CLR RW
MOV RS,C
MOV P1,A
SETB EN
CLR EN
RET
;*****************************
OUTST:
;VAO: DPTR CHUA DIA CHI BAT DAU CHUOI, VOI CHUOI KET THUC BANG #
LAP2:
MOV A,#0
MOVC A,@A+DPTR
CJNE A,#'#',HT
SJMP KTO
HT:
SETB C
LCALL LCDOUT8
INC DPTR
SJMP LAP2
KTO:
RET
;***********************
GOTOXY:
;VAO: X (R0) COT 0...39
; Y (R1) DONG 0..1
CJNE R1,#0,MOT
MOV A,R0
ADD A,#80H
CLR C
LCALL LCDOUT8
SJMP KTGOTO
MOT:
MOV A,R0
ADD A,#0C0H
CLR C
LCALL LCDOUT8
KTGOTO:
RET
;****************************************8
STEPMOTOR: DB"STEPMOTOR#"
BUOC_LCD: DB"BUOC:#"
C_DO_LCD: DB" C_DO:#"
T_DO_LCD: DB"T_D0:#"
BMS: DB" MS/B_#"
CONTROL: DB"CONTROL#"
CD_LCD: DB"CHE DO:#"
CHIEU_QUAY_LCD: DB"CHIEU QUAY:#"
SO_BUOC_LCD: DB"SO BUOC:#"
TOC_DO_LCD: DB"TOC DO:#"
DV_TD_LCD: DB" MS/BUOC#"
CA_BUOC_M_NHO: DB"(ca buoc M nho)#"
CA_BUOC_M_LON: DB"(ca buoc M lon)#"
NUA_BUOC: DB"(nua buoc)#"
END
Comment