请问这个程序里面的延时程序要怎么改才能使它的延时速度最快?请高手们帮帮忙~!~!~! 5
ORG0000HLJMPSTARTORG001BHLJMPIT11ORG0100HSTART:MOVTMOD,#10H;主程序MOVTH1,#0D8HMOVTL1,#0F...
ORG 0000H
LJMP START
ORG 001BH
LJMP IT11
ORG 0100H
START:MOV TMOD,#10H ;主程序
MOV TH1,#0D8H
MOV TL1,#0F0H
MOV IE,#88H;中断允许
MOV R1,#100
MOV B,R1
MOV R2,#60
MOV R3,#00H
MOV R4,#05H
MOV R5,#00H
MOV P1,#0F3H
SETB TR1
BASE:CJNE R2,#00H,YE ;判断是否定时时间到
DEC R4;定时时间到-1
CHANGE:CJNE R4,#04H,CHANGE1;R4等于#04H,60秒到,东西黄灯亮
MOV P1,#0F5H
MOV R1,#100
MOV B,R1
MOV R2,#3
LJMP YE
CHANGE1: CJNE R4,#03H,CHANGE2;R4等于#03H,3秒到,东西亮红,南北亮绿
MOV P1,#0DEH
MOV R5,#01H
MOV R1,#100
MOV B,R1
MOV R2,#50
LJMP YE
CHANGE2: CJNE R4,#02H,CHANGE3;R4等于#02H,50秒到,南北亮黄
MOV P1,#0EEH
MOV R1,#100
MOV A,R1
MOV R2,#3
LJMP YE
CHANGE3:CJNE R4,#01H,CHANGE4;R4等于#01H,3秒到,东西亮绿,南北亮红
MOV P1,#0F3H
MOV R5,#00H
MOV R1,#100
MOV B,R1
MOV R2,#60
LJMP YE
CHANGE4: MOV R4,#04 H ;R4等于#00H,给重送#04H
LJMP CHANGE
YE: CJNE R5,#00H,DIREC1 ;判断哪边的箭头亮
DIREC: CJNE R3,#08H,NEXT1 ;东西方向箭头亮
MOV R3,#00H
NEXT1: MOV A,R3
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
MOV DPTR,#TAB1
MOV A,R3
MOVC A,@A+DPTR
MOV P2,A
MOV P3,#0FFH
LCALL DELAY
INC R3
LJMP BASE
DIREC1: CJNE R3,#08H,NEXT2 ;南北方向箭头亮
MOV R3,#00H
NEXT2: MOV P0,#0FFH
MOV A,R3
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
MOV DPTR,#TAB1
MOV A,R3
MOVC A,@A+DPTR
MOV P3,A
MOV P2,#0FFH
LCALL DELAY
INC R3
LJMP BASE
ORG 0300H
IT11: DJNZ R1,NEXT;中断程序
MOV R1,B
DEC R2
NEXT: MOV TH1,#0D8H;重装初值
MOV TL1,#0F0H
RETI
TAB: DB 01H,02H,04H,08H,10H,20H,40H,80H;列控制数
TAB1: DB 0F7H,0F3H,0F9H,00H,00H,0F9H,0F3H,0F7H;行控制数
DELAY: MOV R6,#0FFH;延时程序
D1: MOV R7,#43H
DJNZ R7,$
DJNZ R6,D1
RET
END 展开
LJMP START
ORG 001BH
LJMP IT11
ORG 0100H
START:MOV TMOD,#10H ;主程序
MOV TH1,#0D8H
MOV TL1,#0F0H
MOV IE,#88H;中断允许
MOV R1,#100
MOV B,R1
MOV R2,#60
MOV R3,#00H
MOV R4,#05H
MOV R5,#00H
MOV P1,#0F3H
SETB TR1
BASE:CJNE R2,#00H,YE ;判断是否定时时间到
DEC R4;定时时间到-1
CHANGE:CJNE R4,#04H,CHANGE1;R4等于#04H,60秒到,东西黄灯亮
MOV P1,#0F5H
MOV R1,#100
MOV B,R1
MOV R2,#3
LJMP YE
CHANGE1: CJNE R4,#03H,CHANGE2;R4等于#03H,3秒到,东西亮红,南北亮绿
MOV P1,#0DEH
MOV R5,#01H
MOV R1,#100
MOV B,R1
MOV R2,#50
LJMP YE
CHANGE2: CJNE R4,#02H,CHANGE3;R4等于#02H,50秒到,南北亮黄
MOV P1,#0EEH
MOV R1,#100
MOV A,R1
MOV R2,#3
LJMP YE
CHANGE3:CJNE R4,#01H,CHANGE4;R4等于#01H,3秒到,东西亮绿,南北亮红
MOV P1,#0F3H
MOV R5,#00H
MOV R1,#100
MOV B,R1
MOV R2,#60
LJMP YE
CHANGE4: MOV R4,#04 H ;R4等于#00H,给重送#04H
LJMP CHANGE
YE: CJNE R5,#00H,DIREC1 ;判断哪边的箭头亮
DIREC: CJNE R3,#08H,NEXT1 ;东西方向箭头亮
MOV R3,#00H
NEXT1: MOV A,R3
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
MOV DPTR,#TAB1
MOV A,R3
MOVC A,@A+DPTR
MOV P2,A
MOV P3,#0FFH
LCALL DELAY
INC R3
LJMP BASE
DIREC1: CJNE R3,#08H,NEXT2 ;南北方向箭头亮
MOV R3,#00H
NEXT2: MOV P0,#0FFH
MOV A,R3
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
MOV DPTR,#TAB1
MOV A,R3
MOVC A,@A+DPTR
MOV P3,A
MOV P2,#0FFH
LCALL DELAY
INC R3
LJMP BASE
ORG 0300H
IT11: DJNZ R1,NEXT;中断程序
MOV R1,B
DEC R2
NEXT: MOV TH1,#0D8H;重装初值
MOV TL1,#0F0H
RETI
TAB: DB 01H,02H,04H,08H,10H,20H,40H,80H;列控制数
TAB1: DB 0F7H,0F3H,0F9H,00H,00H,0F9H,0F3H,0F7H;行控制数
DELAY: MOV R6,#0FFH;延时程序
D1: MOV R7,#43H
DJNZ R7,$
DJNZ R6,D1
RET
END 展开
2个回答
展开全部
DELAY: MOV R6,#0FFH;延时程序
D1: MOV R7,#43H
DJNZ R7,$
DJNZ R6,D1
RET
这个是延时子程序
改成
DELAY:
MOV R6,#01
DJNZ R6,$
RET
就是最快了,不知你什么用。如果是12M晶振,只要2uS
D1: MOV R7,#43H
DJNZ R7,$
DJNZ R6,D1
RET
这个是延时子程序
改成
DELAY:
MOV R6,#01
DJNZ R6,$
RET
就是最快了,不知你什么用。如果是12M晶振,只要2uS
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询