随着计算机技术特别是单片机技术的发展,串口通信在诸多领域得到了广泛的应用。
本文介绍了一种简单的串口通信。其中单片机负责数据采集、处理和控制,上位机进行现场可视化检测,通信协议采用异步串行通信方式,通过RS-232-C 的RTS信号进行收发转换,传输数据采用二进制数据,上位机与下位机之间采用主从式通讯。首先,单片机发固定编好的代码" Welcome to Hangzhou, Zhejiang, thank you everyone."这个显示内容在串口调试界面上接收;然后,在串口调试界面上发送 0-9 十个数字中的任意一个,在单片机板上的数码管上显示出来。其中,单片机程序由汇编语言实现,PC机程序由VB实现。
关键词:RS-232串口,PC机,单片机
ABSTRACT
With the development of computer technology, especially the development of single-chip technology, serial communication has been widely used in many fields.
This paper describes a simple serial communication. The single-chip microcomputer is responsible for collecting, processing and controlling data. Upper computer is performing visual field testing, using asynchronous serial communication protocol communication. It sends and receives and converts through the RTS signal of the RS-232-C. The binary system is used in the transmission of data, and the head-subordinate communication is adopted between the PC machines and single-chip. First of all, a fixed code is sent by single-chip, and " Welcome to Hangzhou, Zhejiang, thank you everyone." will be shown in the debug serial interface. Then, any one of the numbers between 0 to 9 is sent in the serial debug interface, and it is shown in single-chip digital panel. The single-chip is programmed in assembly language, PC programmed in VB.
Keywords: RS-232 serial port, PC machines, single-chip