MCS-51单片机定时器/计数器控制详解

需积分: 0 6 下载量 104 浏览量 更新于2024-08-09 收藏 5.74MB PDF 举报
"定时器/计数器控制寄存器在单片机中扮演着关键角色,用于设置和管理定时器和计数器的工作模式。这些寄存器主要包括TMOD和TCON,它们在MCS-51系列单片机中被广泛使用。" TMOD寄存器是定时器/计数器方式寄存器,它的低4位(GATE、C/T、M1、M0)对应定时器0,高4位对应定时器1。TMOD的M1和M0位组合定义了定时器的工作模式: - 模式0(00):13位定时器/计数器。在该模式下,定时器的THx和TLx寄存器的低5位不参与计数,形成13位计数范围。 - 模式1(01):16位定时器/计数器。此时,THx和TLx寄存器共同构成16位计数器。 - 模式2(10):常数自动重装的8位定时器/计数器。在溢出时,定时器会自动加载预设值到TLx,而THx保持不变。 - 模式3(11):仅适用于定时器0,将定时器0分为两个独立的8位定时器。 C/T位决定了定时器是工作在定时模式还是计数模式。当C/T为0时,定时器处于定时模式,根据系统时钟自增;当C/T为1时,定时器工作在计数模式,它会根据外部输入引脚(通常为T1的P3.5或T0的P3.4)的脉冲变化来计数。 GATE位控制了定时器的启动条件。如果GATE为0,只要TRx(x代表0或1)为1,定时器就会开始工作,即软启动。若GATE为1,则定时器的启动需要INTx引脚和TRx同时为1,这在测量外部脉冲宽度时非常有用。 TCON寄存器则用来控制定时器的启动、停止,以及处理溢出和中断。其中TF1和TF0是定时器1和定时器0的溢出标志位。当定时器溢出时,这些标志位会被硬件自动置1,并向CPU请求中断。CPU响应中断后,硬件会自动清零这些标志位。 这本书《单片机原理与应用及C51程序设计》由唐颖主编,详细介绍了MCS-51系列单片机的各个方面,包括内部结构、指令系统、C语言程序设计以及各种硬件资源的应用。书中通过丰富的实例,特别是汇编与C语言的对照编程,帮助读者理解并掌握单片机技术,适合于高校电气信息类专业教学使用,也适合作为工程技术人员的参考书籍。

翻译 This is Elsevier's new document class for typeset journal articles, elsarticle.cls. It is now accepted for submitted articles, both in Elsevier's electronic submission system and elsewhere. Elsevier's previous document class for typeset articles, elsart.cls, is now over 10 years old. It has been replaced with this newly written document class elsarticle.cls, which has been developed for Elsevier by the leading TeX developer STM Document Engineering Pvt Ltd. elsarticle.cls is based upon the standard LaTeX document class article.cls. It uses natbib.sty for bibliographical references. Bugs and problems with elsarticle.cls may be reported to the developers of the class via elsarticle@stmdocs.in. The file manifest.txt provides a list of the files in the elsarticle bundle. The following are the main files available: - elsarticle.dtx, the dtx file - elsdoc.pdf, the user documentation - elsarticle-template-num.tex, template file for numerical citations - elsarticle-template-harv.tex, template file for name-year citations - elsarticle-template-num-names.tex, template file for numerical citations + new natbib option. Eg. Jones et al. [21] - elsarticle-num.bst, bibliographic style for numerical references - elsarticle-harv.bst, bibliographic style for name-year references - elsarticle-num-names.bst, bibliographic style for numerical referencces + new natbib option for citations. To extract elsarticle.cls from *.dtx: latex elsarticle.ins The documentation file is elsdoc.tex in the contrib directory. To compile it: 1. pdflatex elsdoc 2. pdflatex elsdoc 3. pdflatex elsdoc

2023-06-01 上传