当前位置:网站首页>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
边栏推荐
- 【力扣刷题笔记(二)】特别技巧,模块突破,45道经典题目分类总结,在不断巩固中精进
- Fundamentals of Electronic Technology (III)_ Integrated operational amplifier and its application__ Basic arithmetic circuit
- Windows下MySQL的安装和删除
- 在三线城市、在县城,很难毕业就拿到10K
- Process communication - semaphore
- Install local sources using yum
- 【順利畢業】[1]-遊覽 [學生管理信息系統]
- 01仿B站项目业务架构
- 【男保姆式】教你打开第一个微信小程序
- [22 graduation season] I'm a graduate yo~
猜你喜欢

手机都算是单片机的一种,只不过它用的硬件不是51的芯片

Matlab reads hexadecimal numbers and converts them into signed short

Fundamentals of Electronic Technology (III)_ Integrated operational amplifier and its application__ Basic arithmetic circuit

Comment la base de données mémoire joue - t - elle l'avantage de la mémoire?

Idea remote breakpoint debugging jar package project

uniapp 实现微信小程序全局分享及自定义分享按钮样式

03 FastJson 解决循环引用

Nr-prach:prach format and time-frequency domain

STM32 serial port usart1 routine

我想各位朋友都应该知道学习的基本规律就是:从易到难
随机推荐
uniapp 实现微信小程序全局分享及自定义分享按钮样式
2021-01-03
I didn't think so much when I was in the field of single chip microcomputer. I just wanted to earn money to support myself first
学习开发没有捷径,也几乎不存在带路会学的快一些的情况
Successful graduation [2] - student health management system function development...
STM32 serial port usart1 routine
In third tier cities and counties, it is difficult to get 10K after graduation
MYSQL数据库底层基础专栏
Hal library sets STM32 clock
Synchronization control between tasks
Introduction to chromium embedded framework (CEF)
Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 3 --blinker_ MIOT_ Light (lighting technology app control + Xiaoai classmate control)
Fundamentals of Electronic Technology (III)__ Logic gate symbols in Chapter 5
NR PUCCH format0 sequence generation and detection mechanism
Epollet lessons
MySQL environment variable configuration
在三线城市、在县城,很难毕业就拿到10K
Qt QComboBox QSS样式设置
You need to use MySQL in the opening experiment. How can you forget the basic select statement? Remedy is coming~
The third paper of information system project manager in soft examination