1、/*应该是 2 位数码管显示 00-99 的 89c51 单片机电子秒表设计 的程序和电路图*/P0 段选 ,P2.0 个位位选,P2.1 十位位选 。共阳数码管 16M 晶振。STRT EQU P2.5STP EQU P2.6CLRR EQU P2.7ORG 00HAJMP MAINORG 0BHAJMP T0INTORG 30HMAIN: MOV R0,#20MOV TMOD,#01H MOV TH0,#3CH MOV TL0,#0B0H MOV DPTR,#TABLESETB EASETB ET0k1: LCALL DISP JB STRT,K2LCALL DISPJNB STRT,$-
2、3AJMP STARTk2: JB STP,K3LCALL DISPJNB STP,STOPK3: JB CLRR,K1LCALL DISPJNB CLRR,CLEAR AJMP K3START: SETB TR0AJMP K1STOP: CLR TR0AJMP K2CLEAR: CLR TR0MOV 40H,#0AJMP K1T0INT: MOV TH0,#3CH MOV TL0,#0B0H DJNZ R0,RTIMOV R0,#20MOV A,40HCJNE A,#99,ADD1MOV 40H,#00HCLR TR0AJMP RTI ADD1: ADD A,#01HMOV 40H,ARTI
3、: RETI DISP: MOV A,40HMOV B,#10DIV AB ;/当前值除以 10MOV 20H,A ;/得出的商送给十位MOV 21H,B ;/得出的余数送给个位CLR P2.0SETB P2.1MOV A,20H ;/十位显示MOVC A,A+DPTRMOV P0,ALCALL DELAYCLR P2.1SETB P2.0MOV A,21H ; /个位显示MOVC A,A+DPTRMOV P0,ARETDELAY: ;误差 0usMOV R6,#01HDL0:MOV R5,#61HDJNZ R5,$DJNZ R6,DL0RETTABLE: DB 0C0H,0F9H,0A4H,0B0H,99H ;/共阳极 0-9 显示代码DB 92H,82H,0F8H,80H,90HEND