现代电子技术
現代電子技術
현대전자기술
MODERN ELECTRONICS TECHNIQUE
2013年
23期
41-43,46
,共4页
STC单片机%串口通信%波特率选择%自适应方法
STC單片機%串口通信%波特率選擇%自適應方法
STC단편궤%천구통신%파특솔선택%자괄응방법
STC single-chip microcomputer%serial communication%baud rate selection%self-adaptive method
为了缩小电路体积、降低硬件成本,同时又保证串口稳定可靠通信,采用的一种波特率自适应方法,该方法充分利用STC单片机运行速度快、拥有片内振荡器、片内资源丰富的特点,在串行通信程序中,利用单片机I/O口和定时器,对主机发送的固定字符进行测量、计算,得到合适的波特率常数,从而实现波特率自适应。给出了设计原理、实现方法、误差分析、流程图和部分程序,并通过应用实例验证该方法切实可行。
為瞭縮小電路體積、降低硬件成本,同時又保證串口穩定可靠通信,採用的一種波特率自適應方法,該方法充分利用STC單片機運行速度快、擁有片內振盪器、片內資源豐富的特點,在串行通信程序中,利用單片機I/O口和定時器,對主機髮送的固定字符進行測量、計算,得到閤適的波特率常數,從而實現波特率自適應。給齣瞭設計原理、實現方法、誤差分析、流程圖和部分程序,併通過應用實例驗證該方法切實可行。
위료축소전로체적、강저경건성본,동시우보증천구은정가고통신,채용적일충파특솔자괄응방법,해방법충분이용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.