Simple digital frequency meter based on 51 single chip microcomputer

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

It is required to use timer/counter 1 for timing, with a timing of 1 second; timer/counter 0 for counter, and the external pulse to be counted is connected from P3.4 (T0).
The microcontroller will count the pulses within 1 second and send them to the four-digit digital tube for display. The maximum count display value is 0FFFFH.
Request a program.
;==============================================
Best answer: This is a simple frequency meter. The program is as follows:
;---------------------------------
    ORG 0000H
    JMP START
    ORG 000BH
    JMP T0_INT
;---------------------------------
START:
    MOV TMOD, #51H ;/*01010001 T1 counting, T0 timing*/ 
    MOV TH0, #HIGH(65536 - 50000) ;50ms@12MHz
    MOV TL0, #LOW (65536 - 50000)
    MOV TH1, #0
    MOV TL1, #0
    SETB TR0
    SETB TR1
    SETB ET0
    SETB EA
    MOV R7, #20

    SJMP $
;---------------------------------
T0_INT: ;Execute once every 50ms
    MOV TL0, #LOW (65536 - 50000) ;Rewrite the initial value
    MOV TH0, #HIGH(65536 - 50000) ;50ms@12MHz
    DJNZ R7, T0_END
    MOV R7, #20
    MOV P1, TL1
    MOV P2, TH1
    MOV TL1, #0
    MOV TH1, #0
T0_END:
    ​​RETI
;---------------------------------
END
The simulation with PROTEUS is as shown below.

Simple digital frequency meter based on 51 single chip microcomputer - Non-famous blogger - Electronic Information Corner


Reference address:Simple digital frequency meter based on 51 single chip microcomputer

Previous article:Stopwatch Programming
Next article:Use T1 timing to output square waves with periods of 2ms and 500 microseconds at the P1.0 and P1.1 pins respectively.

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号