ORG 0000H
AJMP START
ORG 0080H
START: MOV SP, #60H
NOP
NOP
NOP
NOP
NOP
MOV P0CR, #01000111B ;设置为输出方式
MOV P1CR, #00000011B
MOV P2CR, #01100000B
MOV P3CR, #00110100B
LOOP_1: MOV R4, #6 ;LED闪烁6次
MOV P0, #01000111B ;口置为高电平灯全亮
MOV P1, #00000011B
MOV P2, #01100000B
MOV P3, #00110100B
ACALL DELAY_1S ;延时
LOOP: CPL P0.6 ;输出低电平灯全亮
CPL P0.2
CPL P0.1
CPL P0.0
CPL P1.0
CPL P1.1
CPL P2.6
CPL P2.5
CPL P3.5
CPL P3.4
CPL P3.2
ACALL DELAY_1S ;延时
DJNZ R4, LOOP ;6次未到返回再次执行
CLR P0.6 ;6次到口输出低电平灯全灭
CLR P0.2
CLR P0.1
CLR P0.0
CLR P3.5
CLR P3.4
CLR P3.2
CLR P2.5
CLR P2.6
CLR P1.1
CLR P1.0
ACALL DELAY_1S ;延时进入流水灯程序段
SETB P0.6
SETB P3.5
ACALL DELAY_1S
CLR P3.5
SETB P2.5
ACALL DELAY_1S
CLR P2.5
SETB P2.6
ACALL DELAY_1S
CLR P2.6
SETB P3.2
ACALL DELAY_1S
CLR P3.2
SETB P1.1
ACALL DELAY_1S
CLR P1.1
SETB P1.0
ACALL DELAY_1S
CLR P1.0
SETB P3.4
ACALL DELAY_1S
CLR P0.6
CLR P3.4
ACALL DELAY_1S
SETB P0.2
SETB P3.5
ACALL DELAY_1S
CLR P3.5
SETB P2.5
ACALL DELAY_1S
CLR P2.5
SETB P2.6
ACALL DELAY_1S
CLR P2.6
SETB P3.2
ACALL DELAY_1S
CLR P3.2
SETB P1.1
ACALL DELAY_1S
CLR P1.1
SETB P1.0
ACALL DELAY_1S
CLR P1.0
SETB P3.4
ACALL DELAY_1S
CLR P0.2
CLR P3.4
ACALL DELAY_1S
SETB P0.1
SETB P3.5
ACALL DELAY_1S
CLR P3.5
SETB P2.5
ACALL DELAY_1S
CLR P2.5
SETB P2.6
ACALL DELAY_1S
CLR P2.6
SETB P3.2
ACALL DELAY_1S
CLR P3.2
SETB P1.1
ACALL DELAY_1S
CLR P1.1
SETB P1.0
ACALL DELAY_1S
CLR P1.0
SETB P3.4
ACALL DELAY_1S
CLR P0.1
CLR P3.4
ACALL DELAY_1S
SETB P0.0
SETB P3.5
ACALL DELAY_1S
CLR P3.5
SETB P2.5
ACALL DELAY_1S
CLR P2.5
SETB P2.6
ACALL DELAY_1S
CLR P2.6
SETB P3.2
ACALL DELAY_1S
CLR P3.2
SETB P1.1
ACALL DELAY_1S
CLR P1.1
SETB P1.0
ACALL DELAY_1S
CLR P1.0
SETB P3.4
ACALL DELAY_1S
CLR P0.0
CLR P3.4
ACALL DELAY_1S
AJMP LOOP_1 ;进入下一个循环
DELAY_1S: MOV R7, #7FH
DL1: MOV R6, #0EBH
DL0: MOV R5, #20H
DJNZ R5, $
DJNZ R6, DL0
DJNZ R7, DL1
NOP
RET
END
|