摘要
为了缩小电路体积、降低硬件成本,同时又保证串口稳定可靠通信,采用的一种波特率自适应方法,该方法充分利用STC单片机运行速度快、拥有片内振荡器、片内资源丰富的特点,在串行通信程序中,利用单片机I/O口和定时器,对主机发送的固定字符进行测量、计算,得到合适的波特率常数,从而实现波特率自适应。给出了设计原理、实现方法、误差分析、流程图和部分程序,并通过应用实例验证该方法切实可行。
To reduce circuit volume and hardware cost, and at the same time, guarantee the stable and reliable serial port communication, a baud rate adaptive method is proposed. This method makes full use of STC microcontroller's characteristics of high-speed running, on-chip oscillator, rich on-chip resources. In the serial communication program, the microcontroller's I/O port and timer are utilized to detect and calculate the fixed character transmitted by host for getting the right baud rate constant, so as to realize the baud rate self-adaption. The design principle and realization method, error analysis, flow chart and part of the program are also given in this paper. The feasibility of the method was verified by a true example.
出处
《现代电子技术》
2013年第23期41-43,46,共4页
Modern Electronics Technique
关键词
STC单片机
串口通信
波特率选择
自适应方法
STC single-chip microcomputer
serial communication
baud rate selection
self-adaptive method