Using the T0 and T1 timing counter functions of the AT89S51 microcontroller

Publisher:悦耳旋律Latest update time:2024-08-30 Source: eepwKeywords:AT89S51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The T0 and T1 timing counter functions of the AT89S51 microcontroller are used to count the frequency of the input signal, and the counting frequency result is displayed through an 8-bit dynamic digital tube. It is required to be able to accurately count the signal frequency of 0-250KHZ, and the counting error does not exceed ±1HZ.


1. Circuit Schematic



2. Hardware connection on the system board

(1) Connect P0.0-P0.7 in the "MCU System" area to the ABCDEFGH ports in the "Dynamic Digital Display" area using an 8-core cable.


(2) Connect P2.0-P2.7 in the "MCU System" area to the S1S2S3S4S5S6S7S8 ports in the "Dynamic Digital Display" area using an 8-core cable.


(3) Connect the P3.4 (T0) terminal in the "MCU System" area to the WAVE terminal in the "Frequency Generator" area with a wire.


3. Programming content

(1) The working mode of the timer/counter T0 and T1 is set. As shown in the figure, T0 is working in the counting state and counting the input frequency signal. However, for T0 working in the counting state, the maximum counting value is fOSC/24. Since fOSC = 12MHz, the maximum counting frequency of T0 is 250KHz. The concept of frequency is the number of pulses counted in one second, which is the frequency value. Therefore, when T1 works in the timing state, every time the timing reaches 1 second, T0 stops counting and reads the count value from T0's counting unit, and then processes the data. It is sent to the digital tube for display.


(2) When T1 is working in the timing state, the maximum timing time is 65ms, which cannot reach the timing of 1 second. Therefore, a timing of 50ms is used, and a total of 20 times are used to complete the timing function of 1 second.


Keywords:AT89S51 Reference address:Using the T0 and T1 timing counter functions of the AT89S51 microcontroller

Previous article:Design of Taxi Meter Based on Single Chip Microcomputer
Next article:Microcontroller Test 1: Light up a LED

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号