e viết rồi cho nó chạy mãi mà không đc, ko bít nó sai chỗ nào,mong mọi người chỉ bảo giúp
code nè:
$mod51
;**********chuong trinh dieu khien toc do dong co buoc*********
;*********xuat port 1 dua tin hieu ra dong co*****************
;********port 2 va port 3 la tin hieu dua ra toc do dong co tren led
;4 NÚT NHẤN
org 0000h
START:
MOV R1,#0
MOV P3,#0FFH
MOV P2,#0FFH
MOV P0,#0FFH
MAIN:
JNB P0.3,KIEMTRA
MOV R1,#10
LCALL CHAY
KIEMTRA:
JNB P0.4,KIEMTRA1
MOV R1,#50
LCALL CHAY1
KIEMTRA1:
JNB P0.5,MAIN
MOV R1,#150
LCALL CHAY2
CHAY:
MOV P2,#11011001b
MOV P3,#10101000b
LCALL MOTOR
CHAY1:
MOV P2,#01000110b
MOV P3,#10101010b
LCALL MOTOR
CHAY2:
MOV P2,#01000111b
MOV P3,#01110010b
LCALL MOTOR
MOTOR:
MOV P1,#09H
LCALL DELAY
MOV P1,#00AH
LCALL DELAY
MOV P1,#06H
LCALL DELAY
MOV P1,#05H
LCALL DELAY
LCALL MOTOR
DELAY:
MOV R2,#250
DJNZ R2,$
DJNZ R1,DELAY
RET
END
code nè:
$mod51
;**********chuong trinh dieu khien toc do dong co buoc*********
;*********xuat port 1 dua tin hieu ra dong co*****************
;********port 2 va port 3 la tin hieu dua ra toc do dong co tren led
;4 NÚT NHẤN
org 0000h
START:
MOV R1,#0
MOV P3,#0FFH
MOV P2,#0FFH
MOV P0,#0FFH
MAIN:
JNB P0.3,KIEMTRA
MOV R1,#10
LCALL CHAY
KIEMTRA:
JNB P0.4,KIEMTRA1
MOV R1,#50
LCALL CHAY1
KIEMTRA1:
JNB P0.5,MAIN
MOV R1,#150
LCALL CHAY2
CHAY:
MOV P2,#11011001b
MOV P3,#10101000b
LCALL MOTOR
CHAY1:
MOV P2,#01000110b
MOV P3,#10101010b
LCALL MOTOR
CHAY2:
MOV P2,#01000111b
MOV P3,#01110010b
LCALL MOTOR
MOTOR:
MOV P1,#09H
LCALL DELAY
MOV P1,#00AH
LCALL DELAY
MOV P1,#06H
LCALL DELAY
MOV P1,#05H
LCALL DELAY
LCALL MOTOR
DELAY:
MOV R2,#250
DJNZ R2,$
DJNZ R1,DELAY
RET
END
Comment