- UID
- 142169
- 性别
- 男
|
ORG 0000H
SJMP START
ORG 000BH
AJMP JJ0
ORG 001BH
AJMP PZ
ORG 0030H
START: MOV SP,#30h
MOV TMOD,#01H
MOV TH1,#1CH
MOV TL1,#18H
MOV TH0,#1CH
MOV TL0,#18h
SETB EA
SETB ET0
SETB ET1
MOV 79H,#20H
MVO 78H,#30H
MOV 77H,#20H
MOV 76H,#30H
SETB TR0
SETB P1.2 ;从P1.2输出一路PWM波
MOV R7,#10
DJNZ R7,$
SETB TR1
SETB P1.3 ;从P1.2输出二路PWM波
LOOP: JNB P3.0,ADD0
JNB P3.1,SUB0
MOV C,P1.2
ORL C,P1.3 ;判断输出端的状态,两者都零等等定时中断
JNC $
MOV A,R0
JZ LOOP0 ;判断R0的值,为0就跳转执行LOOP0
DEC R0
SJMP LOOP2
LOOP0: CLR P1.2
NOP ;补偿
NOP
LOOP2: MOV A,R1
JZ LOOP3
DEC R1
SJMP LOOP1
LOOP3: CLR P1.3
NOP
NOP
LOOP1: SJMP LOOP
ADD0: ACALL DELAY ;清除键抖
JB P3.0,LEAP1
CJNE 79H,#50,LEAP0
MOV 79H,#50
LEAP0: INC 79H
LEAP1: SJMP LOOP
SUB0: ACALL DELAY
JB P3.1,LEAP3
CJNE 79H,#0,LEAP2
MOV 79H,#0
LEAP2: DEC 79H
LEAP3: SJMP LOOP
DELAY: MOV R6,#200
LP0: MOV R5,#200
DJNZ R5,$
DJNZ R6,LP0
RET
JJ0: MOV TH0,#1CH
MVO TL0,#18H
JNB P1.5,BS0 ;反转
MOV 79H,R0
SJMP BS1
BS0: MVO R0,78H
BS1: SETB C ;等待结束
SETB TR0
SETB P1.2
RETI
PZ: MOV TH1,#1CH
MOV TL1,#18H
JNB P1.6,BS2
MVO R1,77H
SJMP BS3
BS2: MOV R1,76H
BS3: SETB C
SETB TR1
SETB P1.3
RET
END
|
|