T0 and Tl are very different in mode 3. When T0 works in mode 3, TL0 and TH0 are divided into two independent 8-bit timer/counters. Among them, TL0 can be used as an 8-bit timer/counter, while TH0 can only be used as an 8-bit timer. At this time, T1 can only work in mode 0, 1 or 2.
Generally, when timer Tl is used as a serial port baud rate generator, T0 is set to mode 3. At this time, timer Tl is often set to mode 2 and used as a baud rate generator.
Assume that two external interrupt sources of an AT89S51 microcontroller application system are occupied, and timer Tl is set to work in mode 2 and used as a baud rate generator. Now it is required to add an external interrupt source and control the P1.0 pin to output a 5 kHz (period is 200μs) square wave. Assume that the system clock is 12 MHz.
Basic idea: Set TL0 to work in mode 3 counting mode, the initial value of TL0 is set to 0FFH, when a negative transition is detected on the T0 pin signal, TL0 overflows and requests an interrupt to the CPU at the same time, where the T0 pin is used as an external interrupt request input terminal triggered by a negative transition. In the interrupt handling subroutine, start TH0, which is set to 100 μs timing of mode 3 in advance, thereby controlling P1.0 to output a square wave signal with a period of 200 μs, as shown in the figure below.
(1) Calculation of initial value X. The initial value of TL0 is set to 0FFH.
The period of the 5 kHz square wave is 200 μs, so the timing time of TH0 is 100 μs. The initial value X of TH0 is calculated as follows:
(2) Program design. The reference program is as follows:
Previous article:Dual-machine serial communication software programming
Next article:Programming and Application of Timer/Counter Mode 2
Recommended ReadingLatest update time:2024-11-16 11:53
- Popular Resources
- Popular amplifiers
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
- MSP430 MCU Development Record (18)
- TI C6000 DSP Basics: GPIO
- PCB drawing issues
- Research on Hybrid Programming of TMS320C6000 DSP
- Oscilloscope probe compensation principle - explain the fundamental reason for oscilloscope probe compensation calibration
- What is the principle of this negative pressure module in the circuit?
- Types of defects in the EMC packaging forming process
- Application of millimeter wave radar technology in corner radar
- Smart Camera Structural Design--Physical Assembly
- Answer questions to win prizes | Prevent machine failures before they happen, and monitor the health status of large machines to help you