The timer counts on-chip clock pulses, and the counter counts external pulses.
The 51 microcontroller has two 16-bit timers/counters: timer 0P3.4 and timer 1 P3.5
3.0 RXD serial port input
3.1TXD
3.2 External interrupt 0
3.3 External interrupt 1
3.4 T0
3.5 T1
3.6 WR external write control
3.7 RD external read control
We know the clock cycle of the microcontroller through the crystal oscillator frequency, and then multiply it by 12 to get the machine cycle. Each machine cycle adds 1 to the register until an overflow occurs and an interrupt is generated.
100MHZ
Period=1/frequency t=1/100M=10^-8(s)=10ns
1. In the timing mode, every time a machine cycle passes, the counter value increases by one, and overflows when the register is full.
The maximum single timing time is 65535*1.085us
2. In counting mode P3.4 P3.5, the counting register increases by one every time a pulse comes.
TCON (timing control register)----start timing counter (bit addressable)
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
TF1: T1 overflow flag, set by hardware when the timer counter overflows.
TR1: Timer TI operation control bit, equal to 1 to allow counting
IE0/1: External interrupt request flag. 0 – No application
IT0/1: Trigger mode selection bit for external interrupt request. 0—effective at low level 1—effective at negative transition
TMOD (timing mode register)----Set the timer counter operating mode (not bit addressable
GATE C/T M1 M0 GATE C/T M1 M0
GATE: Controls T1. When it is 1, T1 will only be started when pin 3.3 is high and TR1 is set to 1.
C/T: When set to 1, T1 acts as a counter and 0 acts as a timer.
M1, M0:
When M1 = 0, M0 = 0, working mode 0
When M1 = 0 and M0 = 1, the working mode is 1. At this time, TH1 and TL1 form a 16-bit counter.
When M1 = 1, M0 = 0, working mode 2, 8-bit automatic reload timer
When M1 = 1, M0 = 1, working mode 3, T1 counting
SCON (Serial Port Control Register)
SM0 SM1 SM2 REN TB8 RB8 TI RI
SM2: Multi-machine communication 0 dual-machine 1 multi-machine
REN: Accept control 0 prohibited 1 allowed
TB8: The ninth digit of the sent data
TI: Transmit interrupt flag bit
SM0SM1: Working mode selection bit
0 0 shift register fosc/12
0 1 10-bit asynchronous reception and reception variable
1 0 11-bit asynchronous reception and transmission fosc/64 or fosc/32
1 1 11 variable
Previous article:Detailed explanation of the control register of 51 microcontroller
Next article:[51 single chip microcomputer] The problem of erasing of data tube
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- 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
- TFTP network burning system
- Introduction to the estimation method of the remaining capacity SOC of lithium batteries
- [RVB2601 Creative Application Development] Ultrasonic pressure-sensitive buttons based on RISC-V processor
- First of all, the 9 boards sent by National Technology have arrived. It's so fast.
- Pingtou Ge RRVB2601 Review: Unboxing, Hardware Analysis and Environment Setup
- OrangePi Zero GPIO Control
- What is the use of a diode in parallel with a pull-up resistor?
- Regarding the improvement suggestions after studying "PCB layout and thermal design system of high-density power system", please use the website as "Editor"...
- ESP-S3-12K (Part 2) ---- Let's power it up
- What to do next?