mình mô phỏng không được ai chỉ mình sai chỗ nào với. Mình dùng P3.5 đưa tín hiệu xung vào, đếm xung trong 1 phút rùi hiển thị ra LED.
PHẦN CỨNG :
CODE :
ORG 000H
MOV DPTR,#LUT
MOV P1,#00000000B
MOV P0,#00000000B
MAIN: MOV R6,#230D
SETB P3.5
MOV TMOD,#01100001B
MOV TL1,#00000000B
MOV TH1,#00000000B
SETB TR1
BACK: MOV TH0,#00000000B
MOV TL0,#00000000B
SETB TR0
HERE: JNB TF0,HERE
CLR TR0
CLR TF0
DJNZ R6,BACK
CLR TR1
CLR TF0
CLR TF1
ACALL DLOOP
SJMP MAIN
DLOOP: MOV R5,#252D
BACK1: MOV A,TL1
MOV B,#4D
MUL AB
MOV B,#100D
DIV AB
SETB P1.0
ACALL DISPLAY
MOV P0,A
ACALL DELAY
ACALL DELAY
MOV A,B
MOV B,#10D
DIV AB
CLR P1.0
SETB P1.1
ACALL DISPLAY
MOV P0,A
ACALL DELAY
ACALL DELAY
MOV A,B
CLR P1.1
SETB P1.2
ACALL DISPLAY
MOV P0,A
ACALL DELAY
ACALL DELAY
CLR P1.2
DJNZ R5,BACK1
MOV P0,#11111111B
RET
DELAY: MOV R7,#250D
DEL1: DJNZ R7,DEL1
RET
DISPLAY: MOVC A,@A+DPTR
CPL A
RET
LUT: DB 3FH
DB 06H
DB 5BH
DB 4FH
DB 66H
DB 6DH
DB 7DH
DB 07H
DB 7FH
DB 6FH
END
FILE ĐÍNH KÈM :
New folder (2).zip
PHẦN CỨNG :
CODE :
ORG 000H
MOV DPTR,#LUT
MOV P1,#00000000B
MOV P0,#00000000B
MAIN: MOV R6,#230D
SETB P3.5
MOV TMOD,#01100001B
MOV TL1,#00000000B
MOV TH1,#00000000B
SETB TR1
BACK: MOV TH0,#00000000B
MOV TL0,#00000000B
SETB TR0
HERE: JNB TF0,HERE
CLR TR0
CLR TF0
DJNZ R6,BACK
CLR TR1
CLR TF0
CLR TF1
ACALL DLOOP
SJMP MAIN
DLOOP: MOV R5,#252D
BACK1: MOV A,TL1
MOV B,#4D
MUL AB
MOV B,#100D
DIV AB
SETB P1.0
ACALL DISPLAY
MOV P0,A
ACALL DELAY
ACALL DELAY
MOV A,B
MOV B,#10D
DIV AB
CLR P1.0
SETB P1.1
ACALL DISPLAY
MOV P0,A
ACALL DELAY
ACALL DELAY
MOV A,B
CLR P1.1
SETB P1.2
ACALL DISPLAY
MOV P0,A
ACALL DELAY
ACALL DELAY
CLR P1.2
DJNZ R5,BACK1
MOV P0,#11111111B
RET
DELAY: MOV R7,#250D
DEL1: DJNZ R7,DEL1
RET
DISPLAY: MOVC A,@A+DPTR
CPL A
RET
LUT: DB 3FH
DB 06H
DB 5BH
DB 4FH
DB 66H
DB 6DH
DB 7DH
DB 07H
DB 7FH
DB 6FH
END
FILE ĐÍNH KÈM :
New folder (2).zip
Comment