当前位置:网站首页>Timer and counter of 51 single chip microcomputer
Timer and counter of 51 single chip microcomputer
2022-07-03 09:55:00 【Yiao】
One · The principle of timer and counter
They are automatically added with the input pulse of the counter 1, Every pulse , Counter auto Jia 1, When the counters are all 1 when , Then input a pulse counter back 0, And the overflow of the counter makes the corresponding interrupt flag position 1, towards CPU Make an interrupt request . In the timing mode, it means that the time has come , In counting mode, the count is full .
Two · Timer structure
timing / The counter is essentially a plus 1 Counter . It adds itself with the input pulse of the counter 1, That is, every pulse , The counter automatically adds 1,, When added to the counter, it is all 1 when , One more pulse will set the counter back to zero , And the overflow of the counter makes the corresponding interrupt flag position 1, towards CPU Make an interrupt request ( timing / When the Counter interrupt is allowed ). If timing / The counter operates in timing mode , It means that the timing time has expired ; If working in counting mode , Indicates that the count value is full .
so , The initial value of the count is subtracted from the value of the counter at the time of overflow 1 The count value of the counter .
3、 ... and · Timer counter structure
TMOD Decide whether the working mode is counting or timing ,TCON Then control the start and interrupt application of the counter timer working principle ( With TH0,TL0) For example : Pulse at TL0( low 8 position ) Add up in , After filling up ,TH0 Add 1,TL0 return 0; wait until TH1 Also accumulated after full , overflow TF0 Set up 1. 1·TMOD

(1)GATE Gate control position There are two ways to start the timer ; The first one is :GATE=0,TR0/1=1; The second kind ;GATE=1,TR0/1=1;INT0/1=1; (2)C/T;C/T=0 For timing mode ,C/T=1 In counting mode ; (3)M1M0

2.TCON The upper four bits control the start and interrupt application of the timing counter , Low four bit control external interrupt

(1)TF1:T1 Overflow request flag bit .T1 When count overflows , The hardware is set automatically TF1 by 1,CPU After responding to the interrupt, the hardware automatically clears it 0.T1 Working hours ,CPU Check at any time TF1 Working state of , Once detected TF1 Set up 1,CPU Respond immediately . (2)TR1:T Operation control bit .TR1 Set up 1 Start working , Set up 0 Stop when .TR1 Set by software 1 or 0. TF0 and TR0 Be similar to TR1 and TF1.
Four · How the timer works

1. Operation mode 0 TL0 The lower five bits of overflow forward TH0 High octave carry of ,TH0 Overflow time , Set up TF0,TF0 towards CPU Apply for interruption 2. Operation mode 1 16 Bit working mode ,TH0 It's the top eight ,TL0 It's eight lower 3. Operation mode 2
For automatic reload timer
边栏推荐
- [combinatorics] Introduction to Combinatorics (context of combinatorics | skills of combinatorics | thought of combinatorics 1: one-to-one correspondence)
- 2020-08-23
- 自动装箱与拆箱了解吗?原理是什么?
- Notes on C language learning of migrant workers majoring in electronic information engineering
- Blue Bridge Cup for migrant workers majoring in electronic information engineering
- Fundamentals of Electronic Technology (III)_ Chapter 2 principle of amplification circuit__ Crystal triode and field effect triode
- STM32 general timer 1s delay to realize LED flashing
- STM32 serial communication principle
- The cyclic shift of PUCCH in NR channel is generated by MATLAB
- 【順利畢業】[1]-遊覽 [學生管理信息系統]
猜你喜欢

MySQL environment variable configuration

Not many people can finally bring their interests to college graduation

编程思想比任何都重要,不是比谁多会用几个函数而是比程序的理解

GPIO port details, Hal library operation keys

要選擇那種語言為單片機編寫程序呢
![Successful graduation [2] - student health management system function development...](/img/91/72cdea3eb3f61315595330d2c9016d.png)
Successful graduation [2] - student health management system function development...

要选择那种语言为单片机编写程序呢

端午节快乐!—— canvas写的粽子~~~~~

新系列单片机还延续了STM32产品家族的低电压和节能两大优势

Embedded systems are inherently flawed. Compared with the Internet, there are so many holes that it is simply difficult to walk away from
随机推荐
[CSDN]C1训练题解析_第二部分_Web基础
JMX、MBean、MXBean、MBeanServer 入门
JS基础-原型原型链和宏任务/微任务/事件机制
Seven sorting of ten thousand words by hand (code + dynamic diagram demonstration)
2020-08-23
Stm32f407 key interrupt
2021-01-03
Nr--- Pusch I: sorting out the agreement process
Basic knowledge of MySQL database (an introduction to systematization)
Getting started with shell programming
Gpiof6, 7, 8 configuration
新系列单片机还延续了STM32产品家族的低电压和节能两大优势
嵌入式系统没有特别明确的定义
顺利毕业[2]-学生健康管理系统 功能开发中。。。
Learn the contents of 5g toolbox supporting NR through the NR resources provided by MATLAB
UCI and data multiplexing are transmitted on Pusch - Part I
SCM career development: those who can continue to do it have become great people. If they can't endure it, they will resign or change their careers
The new series of MCU also continues the two advantages of STM32 product family: low voltage and energy saving
当你需要使用STM32某些功能,而51实现不了时, 那32自然不需要学
Not many people can finally bring their interests to college graduation