我便写了一个时钟显示的程序,但数码管在显示过程中有一个比较暗,不知道是怎么回事啊?硬件没有问题的,我已经测试过了!电路图中:P1.0-P1.2通过138译码控制位选信号,P1.4-P1.7通过147译码控制段选信号。 程序如下: ORG 0000H LJMP MAIN ORG 000BH LJMP TT0INT ORG 0030H MAIN: MOV SP,#6FH MOV TMOD,#01H SETB EA SETB ET0 SETB TR0 MOV TH0,#0ACH ;(50MS) MOV TL0,#0AFH MOV R0,#33H MOV R1,#5 MOV A,#00H L0: MOV @R0,A INC R0 DJNZ R1,L0 MOV R7,#20 MOV R6,#60 MOV R5,#60 MOV R4,#24 MOV R3,#00H MOV R2,#00H MOV R1,#00H LL: LCALL DISPLAY0 ;秒个位显示 LCALL DELAY LCALL DISPLAY1 ;秒十位显示 LCALL DISPLAY2 ;分个位显示 LCALL DELAY LCALL DISPLAY3 ;分十位显示 LCALL DELAY LCALL DISPLAY4 ;时个位显示 LCALL DELAY LCALL DISPLAY5 ;时十位显示 LCALL DELAY LJMP LL TT0INT: MOV TH0,#0ACH MOV TL0,#0AFH ;DJNZ R7,EXIT ;MOV R7,#20 INC R3 DJNZ R6,SECOND MOV R3,#00H MOV R6,#60 INC R2 DJNZ R5,MINUTE MOV R2,#00H MOV R5,#60 INC R1 DJNZ R4,HOUR MOV R1,#00H MOV R4,#24 HOUR: MOV A,R1 MOV B,#10 DIV AB MOV 33H,A MOV 34H,B MINUTE: MOV A,R2 MOV B,#10 DIV AB MOV 35H,A MOV 36H,B SECOND: MOV A,R3 MOV B,#10 DIV AB MOV 37H,A MOV 38H,B EXIT: RETI DISPLAY0:MOV A,38H MOV DPTR,#TABLE0 MOVC A,@A+DPTR MOV P0,A RET DISPLAY1:MOV A,37H MOV DPTR,#TABLE1 MOVC A,@A+DPTR MOV P0,A RET DISPLAY2:MOV A,36H MOV DPTR,#TABLE2 MOVC A,@A+DPTR MOV P0,A RET DISPLAY3:MOV A,35H MOV DPTR,#TABLE3 MOVC A,@A+DPTR MOV P0,A RET DISPLAY4:MOV A,34H MOV DPTR,#TABLE4 MOVC A,@A+DPTR MOV P0,A RET DISPLAY5:MOV A,33H MOV DPTR,#TABLE5 MOVC A,@A+DPTR MOV P0,A RET DELAY: MOV R0,#10 L: NOP NOP NOP DJNZ R0,L RET TABLE0:DB 00H,10H,20H,30H,40H,50H,60H,70H,80H,90H TABLE1:DB 01H,11H,21H,31H,41H,51H TABLE2:DB 02H,12H,22H,32H,42H,52H,62H,72H,82H,92H TABLE3:DB 03H,13H,23H,33H,43H,53H TABLE4:DB 04H,14H,24H,34H,44H,54H,64H,74H,84H,94H TABLE5:DB 05H,15H,25H END 不知道我说的够不够清楚,请高手指教啊!谢谢啦! |