教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 实用模板 >

单片机与PC机串口通信的设计(8)

来源:网络收集 时间:2026-07-17
导读: 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 hardwar

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字,全部文档内容请下载后查看。喜欢就下载吧 ……
单片机与PC机串口通信的设计(8).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/520285.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)