1. Mode 0
When bit M1M0=00. T is a 13-bit counter, THi is the high 8 bits, and TLi is the low 5 bits.
The design value is N, then the initial value of the count is X=2^13-N; 2^13=8192=2000H
Example 1: Assume fosc=6MHz, and use T1 mode 0 for 10ms. Find the initial values of TH1 and TL1.
The design initial value is X; from the known conditions: 1 machine cycle=12/fosc=2us;
10,000us=12/fosc*(2^13-X)us
X=2^13-10000/2=8192-5000=3192=0C78H
So: TL1=18H, TH1=63H
2. Mode 1
When bit M1M0=01. T is a 16-bit counter, THi is the high 8 bits, and TLi is the low 8 bits.
If the design value is N, then the initial value of the count is X=2^16-N; 2^16==65536=10000H
Example 2: Assume fosc=6MHz, and use T1 mode 1 for 100ms. Find the initial values of TH1 and TL1.
The initial value of the design number is X; from the known conditions, we get: 1 machine cycle=12/fosc=2us;
100,000us=12/fosc*(2^16-X)us
X=2^16-100000/2=65536-50000=15536=3CB0H.
We get: TH1=3CH, TL1=0B0H
3. Mode 2
When bit M1M0=10. T is an 8-bit counter that automatically reloads the initial value. The count is in TLi. When TL overflows, not only TF=1, but also the value in TH is automatically sent to TL, and the value of TH remains unchanged.
If the design value is N, then the initial value of the count is X=2^8-N; 2^8=256=100H.
Example 3: If fosc=6MHz, and it is required to use T1 mode 2 for 500us, find the initial values of TH1 and TL1.
The initial value of the design number is X; from the known conditions, we get: 1 machine cycle = 12/fosc=2us;
500us=12/fosc*(2^8-X)us
X=2^8-500/2=256-250=6,
so: TH1=6H, TL1=6H, in fact, just assign an initial value to TH.
4. Mode 3
When bit M1M0=11. Only T0 has mode 3. If T1 is set to mode 3, it will stop working.
When T0 is in mode 3, TH0 and TL0 become two independent 8-bit counters; TL0 uses T0's control resources: GATE, C//T, TR0, TF0, /INT0 pin, etc., and can be used as an 8-bit timer/counter, while TH0 occupies T1's TR1 and TF1, and is a fixed 8-bit timer. At this time, T1 is controlled by the mode bit, mode 3 stops, and modes 0~2 are allowed to work, but TF1 is not set to 1 when the count overflows, that is, an interrupt request cannot be generated. In this case, T1 is generally used as a baud rate generator for the serial port.
Previous article:Write a single-chip counter program to count pulses
Next article:89C51 MCU timer/counter, P1 port programming example
Recommended ReadingLatest update time:2024-11-15 07:12
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Recruiting part-time lecturers in motor control related majors
- It is recommended to merge the ATMEL and PIC microcontroller sections
- TI TMS320C6678 Evaluation Module
- IoT wireless communication data transmission module: multi-host gateway working mode, understand it in one article
- [RT-Thread reading notes]——The definition of threads and the implementation of thread switching
- How to read and write attributes through the characteristic uuid in sdk!
- [Runhe Neptune Review] Five PWM
- How to use the wireless transceiver module
- Understanding of MSP430G2553
- A lightweight and precise positioning algorithm based on multiple inertial measurement units (LSM6DSOX)