单片机与PC机串口通信的设计(8)
At present the domestic use many is the MCS-51 series monolithic integrated circuit, therefore selects the monolithic integrated circuit experiment object is piece of AT89C51, Figure 1 is the hardware schematic diagram, because must realize conforms to the RS232C serial communication, but also should use one piece ICL232CPE(MAX232) to take the serial communication the level switching circuit. In
第24页,共37页
experimental process, in order to examine corresponds whether succeeds, besides lets the monolithic integrated circuit return to on position machine delivers the data, but also expanded several piece of latches in the monolithic integrated circuit periphery, several LED light emitter diode and several small keyboards. The serial communication uses the simple TxD, RxD, GND three-wire system connection, pays attention to TxD and RxD nearby two should the overlapping segment.
On the position machine is ordinary PC machine, altogether has 2 serial port COM1, COM2, it moves RedHat8.0, in fact, if does not request to move graphical interfaces and so on Gnome or KDE, Linux is quite low to the system hardware request.
The experiment proved that, this electric circuit simple reliable, is suitable extremely for the test serial communication.
2 serial communication programming
Serial communication procedure including lower position machine monolithic integrated circuit and on position machine PC machine procedure. The monolithic integrated circuit receives the data which the position machine transmits, puts to internal RAM inside, again the data simultaneously transmits RAM in to exterior expansion latch and on the position machine, from this may judge corresponds whether succeeds. This procedure wrote by the assembly language, when initialization the baudrate establishment is 4 800 b/s, the mailing address is 8-N-1.
On the position machine procedure compilation is the essential part, because must carry on the operation to the serial port hardware equipment, some 2 methods, one are use Linux essence bringing the serial port driver, moreover one method is the direct read-write serial port hardware port, below introduced separately. 2.1 use serial port driver programming method
Carries on the programming using the Linux own serial port driver, in fact is transfers the driver a series of functions, completes the serial port correspondence parameter the establishment, the data transmission and the receive. In this method, Linux all assigns a document index number for each serial port, has the corresponding document name, in fact is regards as the hardware equipment one kind of special document, like COM1, COM2 correspondence document respectively be/dev/ttyS0,/dev/ttyS1, operates these 2 serial ports in fact operates these 2 documents, but with does not certainly have to the hardware equipment document operation to the ordinary document operation what differently, all may use same document I/The O transfer function (open, write, read, close), the similarity lies in with system call open() opens the serial port obtains after the corresponding equipment document description symbol, first must to it carry on the initialization, establishes some specific parameters, like baudrate, The data position, the input output way and so on, these parameters deposit in structtermios, function tcsetattr() may establish the serial port structtermios, tcgetattr() to be possible to obtain serial port struct termios. After established the correspondence parameter carries on read-write on available read and write to the serial port document. When operating procedure must pay attention to the user whether has to the serial port document which
第25页,共37页
…… 此处隐藏:1684字,全部文档内容请下载后查看。喜欢就下载吧 ……相关推荐:
- [实用模板]第八章:法国“新浪潮”与“左岸派”
- [实用模板]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,深
- 弟子规全文带拼音




