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:Use the microcontroller timer T0 to generate a 50HZ square wave
Next article:The external RAM of the 8051 microcontroller uses a 6116 chip. Programming example
- 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
- 【PLC based on IoT】---Testing RPI-400 performance based on AI
- Smart car based on ESP32 road sign recognition
- Regarding the issue of isolated communication:
- Seven lines of code to implement an ultrasonic rangefinder (Oled screen display)
- New forum feature: Post by uploading a word document (good news for those who like to post a lot of pictures)
- A new version of micro:bit (V2) will be released soon
- What is this error?
- Have my friends in Beijing grabbed any Winter Olympics souvenirs?
- Some Problems of PMOS as Anti-Reverse Connection Circuit
- Recruiting analog IC design engineers