发表于:2007/7/26 11:53:00
#0楼
我写了一个51程序,单步调试看到单片机实验板按照要求显示效果,但是当完全运行的时候,实验板就没有反应了。程序大概意思:当P3.2接按键,按下接通低电平,触发定时中断,延时时间到循环显示0~9。程序如下:
ORG 00H
AJMP START
ORG 0BH
AJMP LINT0
ORG 30H
START: MOV R0,#00H
MOV P2,#0F7H
START1:MOV P3,#0FFH
MOV R3,#10
CLR EA
CLR ET0
CLR TR0
JNB P3.2 ,MAIN
AJMP START1
MAIN: MOV SP,#060H
MOV TMOD,#01H
MOV TL0,#0B0H
MOV TH0,#3CH
SETB EA
SETB ET0
SETB TR0
JNB P3.2 ,MAIN
AJMP START1
LINT0: PUSH ACC
PUSH PSW
MOV TL0,#0B0H
MOV TH0,#3CH
DJNZ R3,LOOP
MOV R3,#10
INC R0
CJNE R0,#10, LINT1
MOV R0,#0
LINT1: MOV A,R0
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
LOOP: POP PSW
POP ACC
RETI
TAB:DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
END
请大家看看,究竟哪里出问题了。谢谢大家!
ORG 00H
AJMP START
ORG 0BH
AJMP LINT0
ORG 30H
START: MOV R0,#00H
MOV P2,#0F7H
START1:MOV P3,#0FFH
MOV R3,#10
CLR EA
CLR ET0
CLR TR0
JNB P3.2 ,MAIN
AJMP START1
MAIN: MOV SP,#060H
MOV TMOD,#01H
MOV TL0,#0B0H
MOV TH0,#3CH
SETB EA
SETB ET0
SETB TR0
JNB P3.2 ,MAIN
AJMP START1
LINT0: PUSH ACC
PUSH PSW
MOV TL0,#0B0H
MOV TH0,#3CH
DJNZ R3,LOOP
MOV R3,#10
INC R0
CJNE R0,#10, LINT1
MOV R0,#0
LINT1: MOV A,R0
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,A
LOOP: POP PSW
POP ACC
RETI
TAB:DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
END
请大家看看,究竟哪里出问题了。谢谢大家!