当前位置:网站首页>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
边栏推荐
- Process communication - semaphore
- 嵌入式系统没有特别明确的定义
- 顺利毕业[3]-博客系统 更新中。。。
- Windows下MySQL的安装和删除
- uniapp 实现微信小程序全局分享及自定义分享按钮样式
- Nr-prach:prach format and time-frequency domain
- Matlab reads hexadecimal numbers and converts them into signed short
- Development of fire evacuation system
- Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 3 --blinker_ MIOT_ Light (lighting technology app control + Xiaoai classmate control)
- [22 graduation season] I'm a graduate yo~
猜你喜欢
Fundamentals of Electronic Technology (III)_ Integrated operational amplifier and its application__ Basic arithmetic circuit
Stm32-hal library learning, using cubemx to generate program framework
单片机职业发展:能做下去的都成牛人了,熬不动就辞职或者改行了
STM32 interrupt priority management
Windows下MySQL的安装和删除
How does the memory database give full play to the advantages of memory?
[csdn] C1 analyse des questions de formation Partie III Bar _ JS Foundation
Nr-prach:prach format and time-frequency domain
Successful graduation [2] - student health management system function development...
编程思想比任何都重要,不是比谁多会用几个函数而是比程序的理解
随机推荐
学习开发没有捷径,也几乎不存在带路会学的快一些的情况
Education is a pass and ticket. With it, you can step into a higher-level environment
开学实验里要用到mysql,忘记基本的select语句怎么玩啦?补救来啦~
byte alignment
Project cost management__ Plan value_ Earned value_ Relationship among actual cost and Countermeasures
STM32 port multiplexing and remapping
要選擇那種語言為單片機編寫程序呢
UCI and data multiplexing are transmitted on Pusch (Part V) -- polar coding
Do you understand automatic packing and unpacking? What is the principle?
SSB Introduction (PbCH and DMRs need to be supplemented)
Synchronization control between tasks
Runtime. getRuntime(). GC () and runtime getRuntime(). The difference between runfinalization()
Exception handling of arm
MYSQL数据库底层基础专栏
Emballage automatique et déballage compris? Quel est le principe?
顺利毕业[3]-博客系统 更新中。。。
MySQL data manipulation language DML common commands
Development of electrical fire system
Gpiof6, 7, 8 configuration
自動裝箱與拆箱了解嗎?原理是什麼?