(8) Timer counter

(8) Timer counter

1. Interrupt enable register IE

Insert picture description here

2. Interrupt priority register IP

Insert picture description here

3. Interrupt control special register TCON

Insert picture description here

4. Working mode register TMOD

Insert picture description here

5. The principle of timer counter

Insert picture description here

Working method 0

Insert picture description here

Insert picture description here
Insert picture description here
Insert picture description here
From the above analysis, it can be seen that it takes 500 pulses to generate a periodic signal of t=2ms, and the initial value of 2^13-500 is given to count the pulses to reach 500 when the counter overflows, automatically interrupts, and outputs the waveform

Working method 2

Insert picture description here
Insert picture description here
Insert picture description here

6.100ms timing

Insert picture description here
Insert picture description here
The query method needs to determine whether TF1 is 1, and if it is 1, an overflow has occurred and the count is full. The
Insert picture description here
interrupt method does not need to determine TF1
Insert picture description here

7. 1s timing

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

8. Analysis of the initial value of the timer counter

Insert picture description here
Insert picture description here
Insert picture description here

9. Timing 400us

Insert picture description here
Insert picture description here

10. Duty cycle 70

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

11. 60s countdown

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44026026/article/details/111230504