Stopwatch Programming

Publisher:数据探险家Latest update time:2018-05-11 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

;Question requirements:
;Stopwatch timing, press S0 to start timing, and the digital tube will display;
;Press S0 again to stop. If S0 is not pressed to stop after counting for 1 minute, the buzzer will alarm.
;To simulate on the proteus software......
;===============================================================================
;The questioner gave a program. After modification, the required functions, except for the buzzer alarm, can be realized.
;The buzzer alarm is difficult to modify from the original program. It is recommended to change it to an LED light alarm.
;The program is as follows:
;----------------------------------------------
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 ;Delay about 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 ;One loop, about 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 ;Specify table address
        MOV A, TEMP
        MOV B, #10
        DIV AB ;A/B quotient = a, remainder = b
        MOVC A, @A+DPTR ;Check the ten-digit seven-segment code
        MOV P1, A ;Send the ten-digit seven-segment code
        MOV A, B ;The ones digit is in b
        MOVC A, @A+DPTR ;Check the ones digit seven-segment code
        MOV P2, A ;Send the ones digit seven-segment
        RET
;----------------------------------------------
NUMTAB:
        DB 0C0H,0F9H,0A4H,0B0H,099H
        DB 092H,082H,0F8H,080H,090H
;----------------------------------------------
DELAY2: ; Delay about 500ms
        MOV R5, #10     
DEL3: MOV R6, #100
DEL4: MOV R7, #248
        DJNZ R7, $
        DJNZ R6, DEL4
        DJNZ R5, DEL3
        RET
END
;----------------------------------------------
; The program is run with PROTEUS, and the screenshot is as follows:

Stopwatch Programming - Non-Famous Blogger - Electronic Information Corner


Reference address:Stopwatch Programming

Previous article:Using the Bubble Method to Write a Sorting Program for 51 Single Chip Microcomputer
Next article:Simple digital frequency meter based on 51 single chip microcomputer

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号