-
The pulse input pin of the microcontroller counter. The main pulse input pins are px, y, which also refer to the corresponding t0 and t1, which are mainly used to detect pulses outside the chip. Pins 18 and 19 correspond to the input pulse of the crystal oscillator, and the frequency and period of the pulse are.
f = f/12 = = t = 1/f =
2. The timer has two working modes, which are counting mode and timing mode. The input pulses of px,y are counted in counting mode. In timing mode, the master clock of the MCU is counted after 12 divisions.
Because the master clock is relatively stable, the time elapsed by the count can be extrapolated from the count value.
The counter counts are stored in a special function register. t0(tl0-0x8a, th0-0x8c), t1(tl1-0x8b, th1-0x8d)
4. The collocation relationship between TLX and THX.
1) 32 base between TLX and THX. That is, when the TLX is counted to 32 pulses, the TLX returns to 0 and THX goes to 1. This is also known as Way 0.
2) 256 base between TLX and THX. That is, when the TLX is counted with 256 pulses, the TLX returns to 0 and THX goes to 1. This is also known as Way 1.
In mode 1, a maximum of 65,536 pulses are counted to produce overflow. When the main frequency is , each pulse is counted, so the time of overflow is once.
3) THX is used to store the starting point of the next count of TLX after TLX overflow. This is also known as Way 2.
4) THX and TLX count their own input pulses independently. This is also known as Way 3.
5. Timer initialization.
1) Determine the counting mode of the timer.
2) Determine the collocation relationship between TLX and THX.
3) Determine the starting value of counting. That is, the initial value of TLX and THX.