单片机与PC机串口通信的设计(9)
must operate carries on the read-write authority, may use chmod to order to carry on the document jurisdiction revision.
It initialization function is as follows:
The initialization will later start to transmit and to receive the data, first for a string of character transmission the monolithic integrated circuit, after the monolithic integrated circuit receives the data, will give the data returns the position machine. But needs to pay attention, because on the position machine speed is much quicker than the monolithic integrated circuit, a time cannot transmit excessively many data, otherwise will have the possibility to cause extremely to transmit the buffer overflow to lose the data, the transmission from now on, but also will have to wait for period of time, will cause the monolithic integrated circuit to transmit completely the data after on position machine, then will carry on the read. 2.2 direct read-write serial port hardware port method
Is using this method time, must have some understandings to the serial port correspondence hardware principle. The PC machine serial port is by general asynchronous transceiver 8250UART (or 16550) is the core constitution, the register base address respectively is 0x3f8(COM1) and 0x2f8(COM2), but also has the register which other some use in controlling. Has very many registers is with the Modem correlation, but carries on the correspondence when the use three-wire system with, only uses the care and the correspondence related register, compares the use to come for the general function compilation serial port equipment driver, the direct read-write correlation register efficiency is higher.
After the initialization, might carry on the data receiving and dispatching, accepted in front of the data had to guarantee the receive data ready, this might judge through 0x2fd D0, transmitted in front of the data must guarantee transmission register for spatial, this might judge through 0x2fd D5, the code was as follows: 3 conclusions
The experiment indicated, this system uses 2 methods all completely have realized between LinuxPC machine and the monolithic integrated circuit the point-to-point correspondence, the method simple reliable, basically in need to use PC machine and the monolithic integrated circuit serial communication situation may use this method. Along with recent years Linux in the domestic application scope daily strength, in domains and so on industry control, data acquisition also will certainly more and more many use Linux, this article to be possible to calculate did is a beneficial attempt. Certainly in the practical application also needs to consider some questions, for instance carry on make a mistake the processing question, may again transmit a verification after the string of character which must transmit and, when receives the returns the verification and with the transmission verification and inconsistent again carries on the reproduction, again for instance uses the RS232C transmitting range is very short, and antijamming ability is very bad, by now needed to transform the main line the difference transmission RS485/RS422。 Moreover, improves slightly, may realize PC machine with the multi-piece 51 monolithic integrated circuit serial communications,
第26页,共37页
because by now used in common a main line, had to give each monolithic integrated circuit to assign an address, then carried on the arbitration by PC machine to the main line, only then obtained the main line right of use the monolithic integrated circuit to be able to carry on the correspondence with on position machine, here no longer gave unnecessary detail.
In brief, this article only was Linux PC and the monolithic integrated circuit serial communication has provided a typical model, had to apply in the actual project, but also needed according to the actual situation concrete consideration, the nimble application, finally to be able to form one reliably based on the Linux platform system.
第27页,共37页
附录B 中文翻译
Linux PC和51系列单片机串行通信的设计
摘 要:介绍了一种采用Linux操作系统的PC机通过串口和MCS-51系列单片机进行通信的设计方法,给出了基本的硬件原理和通信程序设计的2种方法。实验证明,这种方案简单可靠、价格低廉,为Linux在工业控制等领域中的应用提供了一种解决方法。 关键词:Linux;单片机;串行通信;工业控制
单片机性能稳定、价格低廉、功能强大,在智能仪器、工业装备以及日用电子消费品中得到了越来越广泛的应用。在单片机的输入输出控制中,除直接接上小键盘和LCD显示屏等方法外,一般都通过串口和上位机PC进行通信,而后一种方法由于能实现远程控制,并且能够利用PC机强大的数据处理功能以及友好的控制界面,显得尤为重要。在一般的利用PC机对单片机进行控制的场合,都是采用Windows作为上位机的平台,其优点是界面友好,编程和操作都比较容易,缺点是稳定性太差,这对于需要连续数天或数月运行的装置来说,尤其不合适。在要求比较苛刻的场合,一般都采用UNIX工作站作为主控平台,如合肥同步辐射加速器的主控平台采用的是SUN的Solaris工作站系统,然而UNIX工作站昂贵的价格又大大限制了其使用的范围。近年来,随着Linux的迅猛发展,使其逐渐从少数人的玩具变成了主流的操作系统。Linux是遵循GPL协议的免费源代码开放软件,任何人都可以自由的从Internet上取得其源程序,也可在GPL的协议下修改其源代码以适应特定的应用,其运行在普通的PC上,性能稳定,特别适于做工业控制,因此实现Linux和单片机的串行通信非常有意义,他可以是昂贵的UNIX工作站的一种可选的替代方法。 1 硬件原理
目前国内使用较多的为MCS-51系列的单片机,因此选用的单片机实验对象为一片AT89C51,图1是硬件原理图,由于要实现符合RS232C的串行通信,还应该用一片ICL232CPE(MAX232)作为串行通信的电平转换电路。在实验过程中,为了查看通信是否成功,除了让单片机对上位机回送数据外,还在单片机外围扩展了几片锁存器,几个LED发光二极管和几个小键盘。串行通信是采用最简单的TxD,RxD,GND三线制连接,注意TxD和RxD两边应该交叉连线。
上位机是一台普通的PC机,共有2个串行口COM1,COM2,其运行RedHat8.0,实际上,如果不要求运行Gnome或KDE等图形界面,Linux对系统硬件的要求相 …… 此处隐藏:3466字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [实用模板]第八章:法国“新浪潮”与“左岸派”
- [实用模板]2021年北京上半年临床医学检验技师生物
- [实用模板]SAP GUI 7.10客户端安装配置文档
- [实用模板]2001年临床执业医师资格考试综合笔试试
- [实用模板]36机场工作实用英语词汇总结
- [实用模板](一)社会保险稽核通知书
- [实用模板]安全教育主题班会材料
- [实用模板]濉溪县春季呼吸道传染病防控应急演练方
- [实用模板]长沙房地产市场周报(1.30-2.3)
- [实用模板]六年级数学上册典中点 - 图文
- [实用模板]C程序设计(红皮书)习题官方参考答案
- [实用模板]中国证监会第一届创业板发行审核委员会
- [实用模板]桥梁工程复习题
- [实用模板]2011学而思数学及答案
- [实用模板]初中病句修改专项练习
- [实用模板]监理学习知识1 - 图文
- [实用模板]小机灵杯四年级试题
- [实用模板]国贸专业毕业论文模板
- [实用模板]教育学概论考试练习题-判断题4
- [实用模板]2015届高考英语一轮复习精品资料(译林
- 00Nkmhe_市场营销学工商管理_电子商务_
- 事业单位考试法律常识
- 诚信教育实施方案
- 吉大小天鹅食品安全检测箱方案(高中低
- 房地产销售培训资料
- 高一地理必修1复习提纲
- 新概念英语第二册lesson_1_练习题
- 证券公司内部培训资料
- 小学英语时间介词专项练习
- 新世纪英语专业综合教程(第二版)第1册U
- 【新课标】浙教版最新2018年八年级数学
- 工程建设管理纲要
- 外研版 必修一Module 4 A Social Surve
- Adobe认证考试 AE复习资料
- 基于H.264AVC与AVS标准的帧内预测技术
- 《食品检验机构资质认定管理办法》(质
- ABB变频器培训课件
- (完整版)小学说明文阅读练习题及答案
- 深思洛克(SenseLock) 深思IV,深思4,深
- 弟子规全文带拼音




