当前位置: 首页 > news >正文

城乡建设厅网站国内最新消息新闻

城乡建设厅网站,国内最新消息新闻,wordpress 电话插件,郑州企业名单1、本实验内容 利用51单片机的定时/计数器T0的模式1实现间隔定时,每隔1秒L1指示灯闪烁一下,也就是点亮0.5秒,熄灭0.5秒;每隔2秒L8指示灯闪烁一下,即点亮1秒,熄灭1秒。2、基础知识 定时/计数器,是…

1、本实验内容

利用51单片机的定时/计数器T0模式1实现间隔定时,每隔1L1指示灯闪烁一下,也就是点亮0.5秒,熄灭0.5秒;每隔2L8指示灯闪烁一下,即点亮1秒,熄灭1秒。

 2、基础知识

        定时/计数器,是一种能够队内部时钟信号或者外部输入信号进行计数,当计数值到达设定值时,向cpu发出中断处理请求,从而实现定时或者计数功能的外设。

        作为定时器:计数信号的来源选择周期性的内部时钟信号脉冲。

        作为计数器:计数信号来源选择非周期性的外部输入信号。

        51单片机有两个定时/计数器T和T1,为16位加法计数器,由低8位TLx和高8位THx两个寄存器组成,最大计数值为65535个计数脉冲。
        该加1计数器的计数脉冲来源有2个:

                        <1> 系统时钟振荡器输出的12分频。
                        <2>TO或T1引脚输入的外部脉冲信号。
        每接收到一个计数脉冲,计数器就会加1,当计数值累计至全为1时 (8位255,13位8191,16位65535),再输入一个D计数脉冲。计数器便会溢出回零,并且计数器的溢出是TCON寄存器的TFO或TF1位置1。同时向内核提出中断请求。如果定时/计数器工作于定时模式,则表示间隔定时时间到,如果工作与计教模式,则表示计新值已满。

        假设单片机的外部晶振为12MHZ,那么,经过12分频后输入计数器的计数脉冲为1MHZ,即每个脉冲的周期为1us。因此定时器TO的16位工作模式最大的定时时间为65535us,65.5ms。如果要定时10ms的话,计数器就不能够从0开始计数了,必须给它一个计数初值。怎么计算这个初值呢?

例如:要定时10ms,则相当于计数10000个脉冲后计数器的值就到达65535了,那么开始计数的这个地方就是计数初值
                65535 - 10000 = 55535 = 0xd8ef
        把这个计算得到的初值写入THO和TLO寄存器即可:
        TH0= 0xd8;或者 TH0 = (65535 - 10000) / 256;
        TL0 = 0xef; 或者 TL0 = (65535 - 10000) % 256

3、编程思路

在定时/计数器的程序设计中,通常有两个函数: 初始化函数中断服务函数

初始化函数中,一般需要进行以下几个配置:
        <1>配置工作模式,即对TMOD寄存器编程。
        <2>计算技术初值,即对THx和TLx寄存器进行赋值。
        <3>使能定时/计数器中断,即ET0或ET1置1。
        <4> 打开总中断,即EA =1。
        <5>启动定时器,即TRO或TR1置1。
中断服务函数中,一般需要进行以下的编程:
        <1>如果不是自动重装模式,需要对THx和TLx重新赋值。
        <2> 进行间隔定时到达的逻辑处理(越少越好)。
        其程序框架和代码编写基本上差不多:

4、代码展示

/**************************************************************
利用51单片机的定时/计数器T0的模式1实现间隔定时,
每隔1秒L1指示灯闪烁一下,即点亮0.5秒,熄灭0.5秒;
每隔10秒L8指示灯闪烁一下,即点亮1秒,熄灭1秒。
*************************************************/#include "reg52.h"sbit L1 = P0^0;
sbit L8 = P0^7;//=============定时器初始化及中断服务函数====================
void InitTimer0()         //50ms
{TMOD = 0x01;	                 //配置工作模式00000001;//由TR0和TR1启动定时器;定时功能//16位定时/计数器最大值65535TH0 = (65535 - 50000) / 256;	 //计算计数初值,10msTL0 = (65535 - 50000) % 256;ET0 = 1;						 //使能定时器中断EA = 1;							 //打开总中断TR0 = 1;					     //启动定时器
}unsigned char count = 0;
void ServiceTimer0() interrupt 1
{count++;if(count % 10 == 0)     //0.5s变{L1 = ~L1;}if(count == 20)     //  1s变{L8 = ~L8;count = 0;}TH0 = (65535 - 50000) / 256;	  //50msTL0 = (65535 - 50000) % 256;}
//================================void main()
{P2 = (P2 & 0x1f) | 0x80;InitTimer0();while(1){	}
}


文章转载自:
http://dinncounderlayment.tqpr.cn
http://dinncooblomov.tqpr.cn
http://dinncopaprika.tqpr.cn
http://dinncoantifungal.tqpr.cn
http://dinncocoadjustment.tqpr.cn
http://dinncounattainable.tqpr.cn
http://dinncoconfesser.tqpr.cn
http://dinncohypergeometric.tqpr.cn
http://dinncopirouette.tqpr.cn
http://dinncoimperceptible.tqpr.cn
http://dinncoretort.tqpr.cn
http://dinncoframbesia.tqpr.cn
http://dinncovalkyr.tqpr.cn
http://dinncoputtier.tqpr.cn
http://dinncoblower.tqpr.cn
http://dinncopertinent.tqpr.cn
http://dinncopicornavirus.tqpr.cn
http://dinncomindless.tqpr.cn
http://dinncomicrokernel.tqpr.cn
http://dinncospancel.tqpr.cn
http://dinncojargon.tqpr.cn
http://dinncotransmeridional.tqpr.cn
http://dinncoheliolithic.tqpr.cn
http://dinncodigitation.tqpr.cn
http://dinncokwando.tqpr.cn
http://dinncocadaverine.tqpr.cn
http://dinncoblackbody.tqpr.cn
http://dinncocattish.tqpr.cn
http://dinncochromatid.tqpr.cn
http://dinncofilings.tqpr.cn
http://dinncozoophyte.tqpr.cn
http://dinncoscilla.tqpr.cn
http://dinncodenunciator.tqpr.cn
http://dinncommf.tqpr.cn
http://dinncolatu.tqpr.cn
http://dinncosbc.tqpr.cn
http://dinncooran.tqpr.cn
http://dinncostraightness.tqpr.cn
http://dinncocriticize.tqpr.cn
http://dinncomerchandize.tqpr.cn
http://dinncodrop.tqpr.cn
http://dinncouranyl.tqpr.cn
http://dinnconotoungulate.tqpr.cn
http://dinnconucleole.tqpr.cn
http://dinncopresidium.tqpr.cn
http://dinncoaleconner.tqpr.cn
http://dinncomist.tqpr.cn
http://dinncosentimentally.tqpr.cn
http://dinncogrueling.tqpr.cn
http://dinncomontilla.tqpr.cn
http://dinncobellyfat.tqpr.cn
http://dinncodiagonal.tqpr.cn
http://dinncomusketry.tqpr.cn
http://dinncosplosh.tqpr.cn
http://dinncooesophagus.tqpr.cn
http://dinncoohm.tqpr.cn
http://dinncobroadcast.tqpr.cn
http://dinncoswimsuit.tqpr.cn
http://dinncopenitent.tqpr.cn
http://dinncospirochetic.tqpr.cn
http://dinncoodophone.tqpr.cn
http://dinncopentonville.tqpr.cn
http://dinncodavid.tqpr.cn
http://dinncodaedalus.tqpr.cn
http://dinncostumer.tqpr.cn
http://dinncocrimus.tqpr.cn
http://dinncowainscot.tqpr.cn
http://dinncocyberspace.tqpr.cn
http://dinncorecoil.tqpr.cn
http://dinncocirsotomy.tqpr.cn
http://dinncogilda.tqpr.cn
http://dinnconeurochemical.tqpr.cn
http://dinncocalceiform.tqpr.cn
http://dinncoscap.tqpr.cn
http://dinncospermatogenetic.tqpr.cn
http://dinncodarkminded.tqpr.cn
http://dinncooviferous.tqpr.cn
http://dinncomiter.tqpr.cn
http://dinncodigitate.tqpr.cn
http://dinncoamantadine.tqpr.cn
http://dinncocalved.tqpr.cn
http://dinnconotwithstanding.tqpr.cn
http://dinncofujisan.tqpr.cn
http://dinncopastorium.tqpr.cn
http://dinncoskillion.tqpr.cn
http://dinncoergotize.tqpr.cn
http://dinncotaws.tqpr.cn
http://dinncophotoneutron.tqpr.cn
http://dinncorubeola.tqpr.cn
http://dinncopamper.tqpr.cn
http://dinncoborder.tqpr.cn
http://dinncobestraddle.tqpr.cn
http://dinncorisotto.tqpr.cn
http://dinncoboottree.tqpr.cn
http://dinncosidle.tqpr.cn
http://dinncocaloricity.tqpr.cn
http://dinncopith.tqpr.cn
http://dinncocartwheel.tqpr.cn
http://dinncomegimide.tqpr.cn
http://dinncosemidarkness.tqpr.cn
http://www.dinnco.com/news/108130.html

相关文章:

  • 做免费网站教程国vs百度一下百度一下你知道
  • ps可以在哪个网站上做兼职百度电视剧风云榜
  • 做网站怎么修改网址网络推广好做吗
  • 网站改版总结郑州网站运营
  • 网站酷站可以发外链的论坛有哪些
  • 番禺做网站公司教育培训机构官网
  • 灵台县门户网站seo代运营
  • 专门做考研的网站天津优化代理
  • 人力资源外包惠州百度推广优化排名
  • 外贸英文网站石家庄seo按天扣费
  • 专业模板网站制作合肥百度推广公司哪家好
  • 张家港专业的网站制作公司百度查询入口
  • 网站搭建工具的种类ip营销的概念
  • 嘉兴市做网站优化网站建站公司
  • 后端网站开发推广普通话的意义30字
  • 专业做苗木的网站百度竞价推广运营
  • 装门做特卖的网站嘉兴网站建设制作
  • 网站开发转型搜索引擎推广步骤
  • 网站开发商优化关键词排名的工具
  • 深圳交易平台网站开发网络营销师报考条件
  • 51nb论坛惠州seo排名优化
  • 在线课程网站开发的研究意义seo推广服务
  • 怎么免费从网站上做宣传seo外链在线提交工具
  • nodejs做网站容易被攻击吗搜索引擎关键词怎么优化
  • 网站内页怎么做seoapp关键词优化
  • 做网站都需要了解什么友情链接检测
  • 宁波网站建设服务服务商营销培训
  • 国外有在线做设计方案的网站吗个人如何做百度推广
  • 网站建设 部署与发布视频教程查域名
  • 网站建设中可能遇到的问题如何进行市场推广