急求!!!51单片机用汇编语言如何编写LED灯逐渐变亮在逐渐变暗?谢谢大神们

我编过一个脉冲占空比的,怎么改改能 LED灯逐渐变亮在逐渐变暗
ORG 0
AJMP MAIN
ORG 000BH
AJMP T0_INT
ORG 0030H
MAIN: SETB P1.7
SETB F0
MOV R3,#1
MOV R4,#9
MOV SP,#30H
MOV TMOD,#01H
MOV TL0,#030H
MOV TH0,#0F8H
SETB EA
SETB ET0
SETB TR0
SJMP $
ORG 0050H
T0_INT: MOV TL0,#030H
MOV TH0,#0F8H
JNB F0,LOWER
DJNZ R4,LOOP
CPL P1.7
CLR F0
MOV R4,#1
SJMP LOOP
LOWER: DJNZ R3,LOOP
CPL P1.7
SETB F0
MOV R3,#9
LOOP: RETI
END

第1个回答  2016-06-24
PWM_JS EQU 0X30
PWM EQU 0X31
LED EQU P1.7
ORG 0
JMP MAIN
ORG 0BH
JMP T0_INT
MAIN:

MOV SP,#0X60
MOV TMOD,#01H
SETB EA
SETB ET0
SETB TR0
MOV PWM,#0

LOOP:
CALL DELAY
INC PWM
MOV A,PWM
CJNE A,#10,LOOP
L1:
CALL DELAY
DEC PWM
MOV A,PWM
CJNE A,#0,L1
JMP LOOP
DELAY:
//...
RET

T0_INT:
PUSH PSW
PUSH ACC
MOV TL0,#LOW(65536-1000)
MOV TH0,#HIGH(65536-1000)
INC PWM_JS
MOV A,PWM_JS
CLR C
SUBB A,#10
JC T0_1
MOV PWM_JS,#0
T0_1: CALL SET_LED

T0_OUT:
POP ACC
POP PSW
RETI

SET_LED:
MOV A,PWM
SETB C
SUBB A,PWM_JS
JC SET_LED1
CLR LED
RET
SET_LED1:
SETB LED
RET

END本回答被提问者和网友采纳
相似回答