2个回答
展开全部
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
MAIN:
MOV TMOD,#01H
MOV TL0,#0B0H
MOV TH0,#3CH
SETB TR0
SETB ET0
SETB EA
MOV R4,#20
MOV A,#11H
MOV P1,A
SJMP $
T0ISR:
CLR TR0
MOV TL0,#0B0H
MOV TH0,#3CH
SETB TR0
DJNZ R4,T0END
RL A
MOV P1,A
MOV R4,#20
T0END:
RETI
END
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
MAIN:
MOV TMOD,#01H
MOV TL0,#0B0H
MOV TH0,#3CH
SETB TR0
SETB ET0
SETB EA
MOV R4,#20
MOV A,#11H
MOV P1,A
SJMP $
T0ISR:
CLR TR0
MOV TL0,#0B0H
MOV TH0,#3CH
SETB TR0
DJNZ R4,T0END
RL A
MOV P1,A
MOV R4,#20
T0END:
RETI
END
展开全部
TEMP DATA 30H
ORG 0000H
LJMP START
ORG 000BH
LJMP Timer0Interrupt
START:
MOV SP,#60H
MOV P1,#11H
MOV 30H,#20
LCALL InitTimer0
LOOP:
;add your code here!
LJMP LOOP
InitTimer0:
MOV TMOD,#01H
MOV TH0,#0B0H
MOV TL0,#3CH
SETB EA
SETB ET0
SETB TR0
RET
Timer0Interrupt:
PUSH DPH
PUSH DPL
PUSH ACC
MOV TH0,#0FFH
MOV TL0,#9CH
DJNZ 30H,FH
MOV 30H,#20
MOV A,P1
RL A
MOV P1,A
FH:
POP ACC
POP DPL
POP DPH
RETI
END
ORG 0000H
LJMP START
ORG 000BH
LJMP Timer0Interrupt
START:
MOV SP,#60H
MOV P1,#11H
MOV 30H,#20
LCALL InitTimer0
LOOP:
;add your code here!
LJMP LOOP
InitTimer0:
MOV TMOD,#01H
MOV TH0,#0B0H
MOV TL0,#3CH
SETB EA
SETB ET0
SETB TR0
RET
Timer0Interrupt:
PUSH DPH
PUSH DPL
PUSH ACC
MOV TH0,#0FFH
MOV TL0,#9CH
DJNZ 30H,FH
MOV 30H,#20
MOV A,P1
RL A
MOV P1,A
FH:
POP ACC
POP DPL
POP DPH
RETI
END
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询