Timing calculation method of single chip microcomputer timer

Publisher:骄阳少年Latest update time:2016-09-28 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
For 12MHz, 1 machine cycle is 1us, 12/fosc = 1us.

Mode 0: 13-bit timer maximum time interval = 2^13 = 8.192ms.
Mode 1: 16-bit timer maximum time interval = 2^16 = 65.536ms.
Mode 2: 8-bit timer maximum time interval = 2^8 = 0.256ms. =256 us.

Timing is 5ms. Calculate the initial value of the timer M = 2^KX*Fosc/12. 12MHz
mode 0: K=13,X=5ms,Fosc=12MHz. Then M = 2^13 - 5*10^(-3)*12*10^6/12= 3192 = 0x0C78. 
       THx = 0CH,TLx = 78H,
   mode 1: K=16,X=5ms,Fosc=12MHz. Then M = 2^16 - 5*10^(-3)*12*10^6/12= 60536 = 0xEC78
       THx = ECH,TLx = 78H,  

     50ms 12MHz THx = 3CH,TLx = B0H, 
       10ms THx = D8H,TLx = F0H,  
 Method 2: Maximum time 2^8Fosc/12 = 0.256ms

  Where does the decimal number come from?
  6MHz One machine cycle 12/6 = 2us
  Timing 1ms Counting initial value x
 (2^16-x)*2us = 1000us
 x = 2^16 - 500, TH, TL can be set to -500
 
12MHz One machine cycle 12/12 = 1us
12MHz One machine cycle 12/12 = 1us
 Timing 50ms Counting initial value x
 (2^16-x)*1us = 50000us
 x = 2^16 - 50000, TH, TL can be set to -500

Timer Counts the internal crystal frequency
Counter Counts the number of pulses on the external input CPU pin P3.4 (T0) P3.5 (T1) Negative jump plus one
When the crystal oscillator is 6MHz, the maximum counting frequency is 500KHz

Register 
1 TH TL
2 TCON
  TR0 TR1 Other bits are interrupt control bits

TMOD
GATE C/T1 M1 M0 GATE C/T0 M1 M0


C8051F00X
timer: add 1 for each clock. The clock can be the system clock or 1/12 of the system clock. When a level appears on the
CKCON  

pin, start T0. When it is not satisfied, stop T0 and clear it after reading.
Keywords:MCU Reference address:Timing calculation method of single chip microcomputer timer

Previous article:51 MCU 1 second timing C language program (through debugging)
Next article:Detailed explanation of 51 single-chip microcomputer instruction cycle, machine cycle, and clock cycle

Recommended ReadingLatest update time:2024-11-16 13:40

Detailed explanation of push-pull and open-drain output of microcontroller I/O port
Push-pull output: can output high and low levels, connect digital devices; push-pull structure generally refers to two transistors being controlled by two complementary signals, and one transistor is always turned on while the other is turned off. Open drain output: The output terminal is equivalent to the collector
[Microcontroller]
Detailed explanation of push-pull and open-drain output of microcontroller I/O port
Overview of Qinheng Co., Ltd. multi-interface microcontroller CH548
Overview CH548 is an enhanced E8051 core microcontroller compatible with MCS51. 79% of the instructions are single-byte single-cycle instructions. It runs fast and has built-in 32KB Flash-ROM and 2K+256B RAM. CH548's built-in USB controller and USB transceiver support USB-Host host mode and USB-Device device mode, s
[Microcontroller]
Overview of Qinheng Co., Ltd. multi-interface microcontroller CH548
Design of Traffic Control System Based on C51 Series Single Chip Microcomputer
  0 Introduction   With the continuous improvement and development of microcontroller technology, the application of single-chip microcomputers continues to deepen. Its application will inevitably lead to fundamental changes in traditional control technology. It has been widely used in industrial control, data acqui
[Microcontroller]
Design of Traffic Control System Based on C51 Series Single Chip Microcomputer
Stepper motor control + Puzhong 51 single chip microcomputer + Puzhong official
1 Experimental Phenomenon The running direction and speed of the 28BYJ48 stepper motor are controlled by the ULN2003 driver module. When the KEY1 key is pressed, the motor rotation direction can be adjusted; when the KEY2 key is pressed, the motor accelerates (5 gears); when the KEY3 key is pressed, the m
[Microcontroller]
Stepper motor control + Puzhong 51 single chip microcomputer + Puzhong official
MCU---HLK-W801 Graphics Framework LVGL Development (IV)
The effect was released on March 24, 2022. Chinese translation has been added. The APP includes temperature and humidity, calculator, and wifi connection. When connected to wifi, it can perform NTP time synchronization and query the weather. MCU host developed by Hilink w801 Chapter Highlights The previous version w
[Microcontroller]
MCU---HLK-W801 Graphics Framework LVGL Development (IV)
51 MCU serial communication ---- self-study notes
1. Serial communication 1.1. The basis of computer communication Computer communication: It is the combination of computer technology and communication technology to complete the information exchange between computers and external devices or between computers. It can be divided into two categories: parallel communicat
[Microcontroller]
51 MCU serial communication ---- self-study notes
Simulation and source code of 8*8LED dot matrix vertical scrolling display of "I love you"
Share an 8*8 LED dot matrix screen that scrolls vertically and displays three words "I love you" The simulation schematic is as follows The microcontroller source program is as follows: #include reg51.h unsigned char code image ={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,          0xC3,0xE7,0xE7,0xE7,0xE7,0xE7,0xC
[Microcontroller]
Simulation and source code of 8*8LED dot matrix vertical scrolling display of
Application of ICL7135 and PIC microcontroller in temperature transmitter
introduction In the design of intelligent instruments, A/D converters are often used. Among the commonly used A/D converters, 7135 is the most widely used. It has 41/2-bit A/D conversion accuracy, strong anti-interference ability, and low price. It is mainly used for the measurement and display of detection par
[Microcontroller]
Application of ICL7135 and PIC microcontroller in temperature transmitter
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号