計(jì)時(shí)秒表程序設(shè)計(jì)
;題目要求:
;秒表計(jì)時(shí),按S0開(kāi)始計(jì)時(shí),并由數(shù)碼管顯示;
;再按S0停止。若計(jì)滿1分鐘結(jié)束未按S0停止,則蜂鳴器報(bào)警。
;要在proteus軟件上面模擬......
;==================================================================
;提問(wèn)者給出了程序,經(jīng)過(guò)修改,要求的功能,除了蜂鳴器報(bào)警,都能實(shí)現(xiàn)。
;蜂鳴器報(bào)警,從原來(lái)的程序上修改,困難較大,建議改成LED發(fā)光報(bào)警。
;程序如下:
;----------------------------------------------
TEMP EQU 22H
ORG 0000H
SJMP START
ORG 0003H
LJMP X0_INT
ORG 0050H
;----------------------------------------------
START:
MOV IE, #85H
MOV IP, #00000001B
MOV TEMP, #0
;----------------------------------------------
M_LOOP:
CALL DISPLAY
CALL DELAY2 ;延時(shí)約500ms
CALL DELAY2
JNB F0, NEXT
INC TEMP
MOV A, TEMP
CJNE A, #61, NEXT
CLR P0.1
MOV TEMP, #60
NEXT:
SJMP M_LOOP ;一個(gè)循環(huán),約1s
;----------------------------------------------
X0_INT:
CPL F0
JB P0.1, X0_END
SETB P0.1
MOV TEMP, #0
X0_END:
JNB P3.2, $
RETI
;----------------------------------------------
DISPLAY:
MOV DPTR, #NUMTAB ;指定查表地址
MOV A, TEMP
MOV B, #10
DIV AB ;A/B商=a,余數(shù)=b
MOVC A, @A+DPTR ;查十位七段碼
MOV P1, A ;送出十位七段碼
MOV A, B ;個(gè)位在b
MOVC A, @A+DPTR ;查個(gè)位七段碼
MOV P2, A ;送出個(gè)位七段
RET
;----------------------------------------------
NUMTAB:
DB 0C0H,0F9H,0A4H,0B0H,099H
DB 092H,082H,0F8H,080H,090H
;----------------------------------------------
DELAY2: ;延時(shí)約500ms
MOV R5, #10
DEL3: MOV R6, #100
DEL4: MOV R7, #248
DJNZ R7, $
DJNZ R6, DEL4
DJNZ R5, DEL3
RET
END
;----------------------------------------------
;程序用PROTEUS運(yùn)行,屏幕截圖如下: