MCS-51片内通用异步接收发送端口
MCS-51片内通用异步接收发送端口
MCS-51家族包括一系列可兼容的微控制器。这些8位潜入式控制器各有特色,例如片内程序存储器,数据存储器,甚至有些控制器还集成了A/D转换器。MCS-51家族所有的微控制器都有一个集成的通用异步接收发送端口。
本说明书可以使任何有基本微控制器设计经验的程序员都能学会如何掌握MCS-51微控制器中片内`通用异步接收发送端口的一般特性。这分资料是为了解答在串行口使用上的重复疑问而设计的。为了简化学习过程,下面列举了一些实际工作中的例子来进行说明。
串行口可以有4种工作模式:
模式0:TXD输出移位时钟。在这种方式下,8位数据被同样的引脚RXD传送并接收。数据传送首先从最低的有效位开始,到最高的有效位结束。波特率为振荡器频率的1/12。
模式1:串行数据通过RXD引脚进入,TXD引脚输出。在这种方式下,首先传送逻辑电平0作为开始,然后是8位数据从最低有效位到最高有效位的传送,跟在最高有效位后的是停止位即逻辑电平1。当用这种方式接收数据时,停止位被放入特殊功能寄存器SCON的TB8位,波特率是变化的,并且是由定时器1或定时器2的重装值决定的。
模式2:串行数据通过RXD引脚进入,由TXD引脚输出。在这种方式下,全部11位数据是按其逻辑电平为0的起始位、8位数据位、1位用户编程的第9位和1位逻辑电平为1的停止位的顺序来发送和接收的。第9位是SCON寄存器中TB8位的数据。这个可编程是经常用于奇偶校验的。波特率是振荡器频率的1/32或1/64,因而是可编程的。 (毕业设计)
[资料来源:http://www.doc163.com]
模式3:模式3和模式2是一样的,不同的是模式3的波特率的可变的,并且由定时器1或定时器2的重装值决定的。
关于每个串行口工作方式的更详细的信息可以看1993年嵌入式微控制器和处理器270645中“8051,8052和80C51的硬件说明书”。
MCS-51 on-chip UART
The MCS-51 family contains a flexible set of microcontrollers. These 8-bit embedded controllers have different features such as on-chip program memory, data RAM and some even have integrated A/D converters. One feature that all of the microcontrollers in the MCS-51 family have in common is an integrated UART.
This guide has been designed so that any programmer with basic microcontroller experience can learn how to use the general features of the on-chip UART in a MCS-51 microcontroller .This document has been created and designed in response to repeated inquires on the usage of the serial port. Working examples has been included and explained to ease the learning process.
The serial port can operate in 4 modes:
Mode 0: TXD outputs the shift clock .in this mode, 8 bit are transmitted and received by same pin RXD. The data is transmitted starting with the least significant bit first, and ending with the most significant bit. The baud rate is fixed at 1/12th the oscillator frequency.
[版权所有:http://DOC163.com]
Mode 1: Serial data enters through the RXD pin and exits through the TXD pin. In this mode, a start bit of logic level o is transmitted, and then 8 bits are transmitted with the least significant bits first up to the most significant bit. What follows the most significant bit is the stop bit that is logic 1. When receiving data in this mode, the stop bit is placed into RB8 in the SFR (Special Function Register) SCON. The baud rate is variable and is controlled by either timer 1 or timer2’s reloaded values.
Mode 2: Serial data enters through the RXD pin and exits through the TXD pin and exits through the TXD pin. In this mode, a total of 11 bits are transmitted or received starting with a start bit of logic level 0,8bits of data ,a user programmable ninth data bit, and a stop bit of logic level 1.The ninth data bit is the value of the TB8 bit inside the SCON register. This programmable bit is often used for parity information .The baud rate is programmable to either 1/32nd or 1/64th of the oscillator frequency. [资料来源:www.doc163.com]
全文 8000字 [资料来源:http://Doc163.com]