Timer T0 is used to generate timing pulses. A positive pulse with a width of 2 machine cycles is generated every 2ms, and this timing sequence pulse signal is output by P1.0 (assuming the clock frequency is 6MHZ).
Answer: First, find the initial value of timer T0. Since the clock frequency is 6MHZ, the machine cycle is 2µs.
Because: t = (213-T0 initial value) ´ Machine cycle
Therefore, when t=2ms, then: (213-T0 initial value) ´ 2´10-6=2´10-3
Solution: T0 initial value = 7096 = 11011101 11000B, where the upper 8 bits 11011101 B = DDH are assigned to TH0, and the lower 5 bits 11000B = 18H are assigned to TL0.
method one:
Using the query working mode, the programming is as follows:
ORG 0000H
AJMP MAIN
ORG 0100H
MAIN: CLR P1.0
MOV TMOD, #00H; Set the working mode of T0
MOV TH0 , #0DDH ; send initial value to timer T0
MOV TL0 , #18H
SETB TR0; start T0 work
LOOP: JNB TF0, $; $ is the current instruction pointer address
CLR TF0
SETB P1.0; generates a 2µs positive pulse
CLR P1.0
MOV TH0 , #0DDH; reload TH0 and TL0
MOV TL0 , #18H
SJMP LOOP
END
Method Two:
Using interrupt working mode, programming is as follows:
ORG 0000H
AJMP MAIN
ORG 000BH
AJMP T0INT
ORG 0100H
MAIN:CLR P1.0
MOV TH0 , #0DDH ; send initial value to timer T0
MOV TL0 , #18H
MOV IE , #82H; Enable T0 interrupt
SETB TR0; Start T0
SJMP$
Interrupt service routine:
ORG 0300H
T0INT: SETB P1.0
CLR P1.0
MOV TH0 , #0DDH; reload TH0 and TL0
MOV TL0 , #18H
RETI
Previous article:Programming of outputting square wave pulse signal in T0 working mode of internal timer of single chip microcomputer
Next article:Comparison of two programming methods for 16-bit unsigned numerical control stored in the internal RAM of 8031 microcontroller
Recommended ReadingLatest update time:2024-11-16 16:18
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
- EEWORLD University Hall----What can universal fast charging bring?
- Complete learning manual for using RT-Thread on RISC-V (based on Longan development board)
- How does Tbox protect itself to ensure data security? What good methods can you recommend?
- Byte/word alignment issues in DSP
- Pre-registration for the live broadcast with prizes: Cytech & ADI discuss with you Gigabit digital isolators for video, converters, and communications
- GPIO Operation of TMS320C6748
- Gigabit Ethernet Courseware.zip
- 1. “Wanli” Raspberry Pi car - Establishing a project warehouse
- ST Live: Introduction to MEMS sensor development kit, learn about sensors with embedded "finite state machine and machine learning core"
- EEWORLD University ---- Basics of Brushless DC Motors - Drive Control