單片機中計數器怎么做?
作者:化工綜合網發布時間:2023-04-13分類:無機化工瀏覽:83
外加顯示的,延時查表自己寫
ORG 0000H
MAIN:MOV 30H,#00;(給 30H_40H付值)
MOV 31H,#00
MOV 32H,#00
MOV 33H,#00
MOV 34H,#00
MOV 35H,#00
MOV 36H,#00
MOV 37H,#00
L3: CALL L1 ;(調用子程序)
CALL DELAY2 ;(延時)
INC 30H ;(將30中值遞增1)
MOV A,30H ;( 將30H)
CJNE A,#0AH,L3
MOV 30H,#0
INC 31H
ACALL L1
MOV A,31H
CJNE A,#06H,L3
MOV 31H,#0
INC 32H
ACALL L1
MOV A,32H
CJNE A,#0AH,L3
MOV 32H,#0
INC 33H
ACALL L1
MOV A,33H
CJNE A,#06H,L3
MOV 33H,#0
INC 34H
ACALL L1
MOV A,34H
CJNE A,#0H,L3
MOV 34H,#0
INC 35H
ACALL L1
MOV A,35H
CJNE A,#02H,L3
L4: ACALL L1
CALL DELAY2
INC 34H
ACALL L1
CALL DELAY2
MOV A,34H
CJNE A,#04H,L4
MOV P1,#0
JMP MAIN
L1: MOV DPTR,#TABLE
MOV A,30H
MOVC A,@A+DPTR
MOV P1,A
CLR P0.0
CALL DELAY
SETB P0.0
MOV A,31H
MOVC A,@A+DPTR
MOV P1,A
CLR P0.1
CALL DELAY
SETB P0.1
MOV A,32H
MOVC A,@A+DPTR
MOV P1,A
CLR P0.2
CALL DELAY
SETB P0.2
MOV A,33H
MOVC A,@A+DPTR
MOV P1,A
CLR P0.3
CALL DELAY
SETB P0.3
MOV A,34H
MOVC A,@A+DPTR
MOV P1,A
CLR P0.4
CALL DELAY
SETB P0.4
MOV A,35H
MOVC A,@A+DPTR
MOV P1,A
CLR P0.5
CALL DELAY
SETB P0.5
MOV A,36H
MOVC A,@A+DPTR
MOV P1,A
CLR P0.6
CALL DELAY
SETB P0.6
MOV A,37H
MOVC A,@A+DPTR
MOV P1,A
CLR P0.7
CALL DELAY
SETB P0.7
RET
END
- 無機化工排行
- 最近發表