(62)--CH2-6-2 Usage of Counters and Ti嵌入式系统原理.ppt

上传人:奉*** 文档编号:96637442 上传时间:2024-02-01 格式:PPT 页数:9 大小:111.21KB
返回 下载 相关 举报
(62)--CH2-6-2 Usage of Counters and Ti嵌入式系统原理.ppt_第1页
第1页 / 共9页
(62)--CH2-6-2 Usage of Counters and Ti嵌入式系统原理.ppt_第2页
第2页 / 共9页
点击查看更多>>
资源描述

《(62)--CH2-6-2 Usage of Counters and Ti嵌入式系统原理.ppt》由会员分享,可在线阅读,更多相关《(62)--CH2-6-2 Usage of Counters and Ti嵌入式系统原理.ppt(9页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、第第2 2章章 单片机原理与应用单片机原理与应用Principles Principles and Applications of and Applications of MicrocontrollerMicrocontrollerChapter 2.6 Counters and Timers2.6.1 Usage of Counter/TimerChapter 2.6 Counters and Timers2.6.2 Usage of Counter/Timer (1)Set working mode of Timer 0 (TMOD=0 x01 ;c language);16 bit,ti

2、mer,doesnt use INT0Chapter 2.6 Counters and Timers2.6.1 Usage of Counter/TimerT0M1T0M0MODEDESCRIPTION00013-bit timer01116-bit timer1028-bit auto-reload113Split modeTimer Working ModeChapter 2.6 Counters and Timers2.6.1 Usage of Counter/Timer(2)Set counters initial value For example:The pulses counte

3、d coming from oscillator(12MHz),so the frequency of pulses is 1MHz.Want to get 50 millisecond(0.05 second)time long,we should count for 50,000 pulses.So the initial value of counter should be:65536-50000=15536=3CB0HProgramming(in c language):TH0=0 x3c;TL0=0 xb0;Chapter 2.6 Counters and Timers2.6.1 U

4、sage of Counter/Timer (3)Start Timer 0 (TCON=TCON|0 x10 ;c language)Chapter 2.6 Counters and Timers2.6.1 Usage of Counter/Timer(4)Detect the end flag of counting TF0(bit 5 of TCON)indicate the end of counting(TH0 TL0=0)while(TF0=0);Chapter 2.6 Counters and Timers2.6.1 Usage of Counter/Timer/Example:

5、Using timer0 to delay preciselyvoid delay(int n)/n msecondsint i;TMOD=0 x01;/16 bits,internal pulse counting for(i=0;i20*n;i+)TH0=0 x3c;TL0=0 xb0;/Initial value=65536-50000=15536,0.05s in 12MHz TF0=0;TR0=1;/start Timer 0 while(TF0=0);/Wait for end flag TF0,delay for 0.5s TR0=0;/stop timer 0 Chapter

6、2.6 Counters and TimersSummary:(1)There are two timers in 8051 MCU,which called T0 and T1。(2)They are incremented counter.(3)They can be used as 8/13/16 bits counter according to their work mode(4)The pulses they counted come from oscillator or PINs(5)To operate the counter by programming the related SFRs.

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 大学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁