Some knowledge about CPU timing:
Oscillation period: The period of the oscillation source that provides timing signals for the microcontroller (crystal oscillator period or external oscillation period).
State cycle: 2 oscillation cycles are 1 state cycle, represented by S. Oscillation cycle is also called S cycle or clock cycle. Machine cycle: 1 machine cycle contains 6 state cycles and 12 oscillation cycles.
Instruction cycle: The total time taken to complete one instruction, which is measured in machine cycles.
Some knowledge about timers:
The 51 single-chip microcomputer has two sets of timer/counters, which are called timer/counters because they can be used for both timing and counting.
The timer/counter and the microcontroller's CPU are independent of each other. The timer/counter works automatically without the CPU's involvement.
The timer/counter in the 51 single-chip microcomputer adds 1 to the data in the register based on the internal clock of the machine or the external pulse signal.
structure:
The essence of the timer/counter is a 16-bit add-on counter, which consists of two registers, THx and TLx, with high and low 8 bits. TMOD is the working mode register of the timer/counter, which determines the working mode and function; TCON is the control register, which controls the start and stop of T0 and T1 and sets the overflow flag.
TMOD is used to set its working mode; TCON is used to control its startup and interrupt application.
Working mode register TMOD Working mode register TMOD is used to set the working mode of the timer/counter. The lower four bits are used for T0 and the upper four bits are used for T1.
GATE is the gate bit. When GATE=0, the timer/counter can be started by setting TR0 or TR1 in TCON to 1 through software. When GATA=1, the timer/counter can be started by setting TR0 or TR1 to 1 through software and the external interrupt pin INT0/1 is also at a high level.
C/T: Timing/counting mode selection bit. C/T = 0 is timing mode; C/T = 1 is counting mode.
M1M0: Working mode setting bit. The timer/counter has four working modes.
TR1 (TCON.6): T1 operation control bit. When TR1 is set to 1, T1 starts to work; when TR1 is set to 0, T1 stops working. TR1 is set to 1 or cleared to 0 by software. Therefore, the start and stop of the timer/counter can be controlled by software. (Timer 1)
TR0 (TCON.4): T0 operation control bit, its function is similar to TR1. (Timer 0)
TF1 (TCON.7): T1 overflow interrupt request flag. When T1 counts overflow, TF1 is automatically set to 1 by hardware. After the CPU responds to the interrupt, TF1 is automatically cleared to 0 by hardware. When T1 is working, the CPU can query the status of TF1 at any time. Therefore, TF1 can be used as a flag for query testing. TF1 can also be set to 1 or cleared to 0 by software, which has the same effect as setting 1 or clearing 0 by hardware.
TF0 (TCON.5): T0 overflow interrupt request flag, its function is similar to TF1
Previous article:"Beginner's C51 Self-study Notes" Interrupt (External Interrupt 0)
Next article:"Beginner's C51 Self-study Notes" - Four working modes of timer (Part 2)
Recommended ReadingLatest update time:2024-11-16 16:32
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- How to read electrical control circuit diagrams (Classic best-selling books on electronics and electrical engineering) (Zheng Fengyi)
- MCU C language programming and Proteus simulation technology (Xu Aijun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- I would like to ask if the 8255A chip can only select one port at a time. After defining the address for the port, such as Q8255A XBYTE...
- Power supplies with digital control
- Please advise, brothers.
- One year's work equals three years' work? TSMC engineer shows off 2.5 million yuan bonus
- Evaluation summary: Mil based on NXP's first NPU kit MYC-JX8MPQ
- How to choose a suitable water level sensor?
- Can someone help me think of a microcontroller project?
- Development of User Graphical Interface (GUI) for Digital Oscilloscope Based on DSP
- [Xianji HPM6750 Review] + Software simulation IIC reads the temperature and humidity sensor values
- In fact, Valentine's Day 20200214 was cancelled