Job Recruitment Website - Zhaopincom - Please clearly introduce the four working modes of the timer.
Please clearly introduce the four working modes of the timer.
1 working mode 0
The working mode 0 of timer/counter is called 13-bit timing/counting mode. It consists of the lower 5 bits of TL( 1/0) and the 8 bits of TH(0/ 1), and the upper 3 bits of TL( 1/0) are unused.
M 1M0: the timer/counter I * * has four working modes, which are controlled by M 1M0, and the two bits are exactly four combinations.
C/T: As we said before, the timer/counter can be used for both timing and counting. It is up to us to decide what to do, that is, it is up to us programmers to decide. If C/T is 0, it is used as a timer (switching up), and if C/T is 1, it is used as a counter (switching down). By the way, a timer/counter can be used for both timing and counting, which is a very common sense and cannot be used at the same time. Few textbooks will mention this, but many beginners will be confused.
Gate: Look at the picture. When we select the timing or counting mode, the timing/counting pulse may not reach the counter. There is also a switch in the middle. Obviously, if this switch is not connected, the counting pulse cannot pass. So when will this change pass? There are two situations.
GATE=0, analyzing logic, the gate is 1, or the gate always outputs 1, regardless of the other input terminal INT 1 of the OR gate. In this case, the switch only depends on TR 1, as long as TR 1 is 65438+.
GATE= 1。 In this case, the switch on the counting pulse path should be controlled not only by TR 1, but also by INT 1 pin. Only when TR 1 is 1 and the INT 1 pin is high, the switch will be closed and the counting pulse will pass. This characteristic can be used to measure the width of signal high level. Think about it. How come?
Why does this mode only use 13 bits? Why not use 16 bit? This is a working mode designed to be compatible with the predecessor 48 series of 5 1 machine. If it doesn't work, just use the second working mode.
2 working mode 1
Working mode 1 is 16-bit timing/counting mode. Just set M 1M0 to 0 1, and the other characteristics are the same as those of working mode 0.
3 working mode 2
Before introducing this method, let's think about a problem: last time we mentioned the problem of arbitrary counting and arbitrary timing. For example, I want to count 1000, but the counter of 16 won't be full until 65536. What should I do? After our discussion, the solution is to use the preset number, first put 64536 into the counter, and then 1000 pulses. Isn't that enough? Yes, but what should we do when the meter is full? You know, counting is always repeated, and the next counting will start as soon as the pipeline is full. Will the next count still be 1000? When the counter overflows, the value in the counter becomes 0 (why, please refer to the explanation in the previous course), so it will overflow after the next time it reaches 65536, which does not meet the requirements. What should I do? Of course, the method is simple, that is, execute a program every time it overflows (this is often necessary, otherwise why will it overflow? In this program, you can send the preset number 64536 into the counter. Therefore, when working mode 0 or 1 is adopted, the preset number needs to be reset after overflow. Of course, it takes time to do this work. Generally speaking, this time is nothing, but in some cases we still have to care, so there is a third working mode, which automatically reloads the preset number.
Since the preset number is to be loaded automatically, the preset number must be put in one place, otherwise what should be loaded? So where do you put the preset number? Put it in the upper 8 bits of T (0/ 1), so the upper 8 bits can't participate in the counting? Yes, in working mode 2, only the lower 8 bits participate in counting, and the upper 8 bits do not participate in counting, which is used to store preset numbers, so the counting range is much smaller. Of course, there is always a price for doing anything, and the key is whether it is worth it. If I don't need to count that much, then I can use this method. As shown in fig. 4, whenever the count overflows, the switch between the high and low 8 bits of T(0/ 1) will be turned on, and the preset count will enter the low 8 bits. This is done automatically by hardware without manual intervention.
This method is often used in baud rate generator (we will explain it in serial port). When used for this purpose, the timer provides a time reference. After the count overflows, there is no way out. There is only one thing to do, that is, reload the preset number and start counting again without any delay. As can be seen, this task is completed by working method 2.
4 working mode 3
In this way, timer/counter 0 is divided into two independent timers/counters for use. Among them, TL0 can work as an 8-bit timer or counter, while TH0 can only be used as a timer. We know that it needs to be controlled to be used as a timer and a counter. When the meter is full, the overflow mark is needed. T0 is split in two, so two sets of control sums and overflow flags are needed. Where did it come from? TL0 is still marked with the original T0, while TH0 borrows T 1. So T 1 is unmarked and the control is available? be
Generally, T0 can only operate in mode 3 when T 1 operates in mode 2 (when baud rate generator is used).
- Previous article:Is there a sulfur mine in Hegang?
- Next article:How to work in CCTV?
- Related articles
- What are the following aspects of corporate image?
- How far is it from Zhenjiang Dagang South to Jiangsu Traffic Technician College?
- Genmao Electronics (Suzhou) Co., Ltd., what about this factory?
- Foshan Shiwan Sub-district Office Economic Promotion Bureau recruits civil servants this year.
- What good job does Beipiao Hongfa have?
- How many days off do employees of Shenzhen tea shop have in a month?
- How much is the joining fee for Xiamen slime? Where is it?
- What is the column planning and columnization of radio and television?
- Shangsi county recruitment
- Is the eHR system developed or bought by yourself?