LJMP MAIN
ORG 0030H
MAIN:
MOV A,P0
ANL A,#1EH
CJNE A,#02H,MAIN1
SETB P1.1
CLR P1.2
CLR P1.8
SJMP MAIN
MAIN1:
CJNE A,#04H,MAIN2
CLR P1.1
SETB P1.2
CLR P1.8
SJMP MAIN
MAIN2:
CJNE A,#1EH,MAIN3
CLR P1.1
CLR P1.2
SETB P1.8
SJMP MAIN
MAIN3:
CLR P1.1
CLR P1.2
CLR P1.8
LJMP MAIN
END
(1)MOV A,30H
ANL A,#3CH
RL A,#02H
MOV 33H,A
MOV A,31H
ANL A,#O3H
RL A,#02H
ORL 33H,A
MOV A,32H
ANL A,#0C0H
RL A,#06H
ORL 33H,A
2:
MOV A,DPH
每个灯亮1秒,每个灯闪亮频率为5次/秒。下列程序,在PROTEUS中仿真通过.
-------------------------------------
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0_INT
ORG 0030H
MAIN:
MOV SP, #7FH
MOV TMOD,#01H
MOV TL0, #LOW(65536-50000)
MOV TH0, #HIGH(65536-50000)
SETB TR0
MOV IE, #82H
MOV R2, #2
MOV R3, #10
MOV R4, #0
M_LOOP:
LJMP M_LOOP等待中断,一切闪动、移位,都在中断里面解决
----------------------------------------------------------------
T0_INT:
MOV TL0, #LOW(65536-50000)
MOV TH0, #HIGH(65536-50000)
DJNZ R2, T0_END
MOV R2, #2加大此数字,如改为8,可降低速度,便于观察.
INC R4
DJNZ R3, FLASH 100ms减一次一.
MOV R3, #10
INC R6 1s加一次一
FLASH:
MOV A, R6
ANL A, #7
MOV R5, A 0~7, 1s换一次位.
INC R5
MOV A, R4
MOV C, ACC.0
MOV A, #255
MOV P1, A 关显示
T0_LOOP:
RLC A
DJNZ R5, T0_LOOP
MOV P1, A
T0_END:
RETI
------------------------------------------------------------
END
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)