隨著計算機技術特別是單片機技術的發展,串口通信在諸多領域得到了廣泛的應用。
本文介紹了一種簡單的串口通信。其中單片機負責數據采集、處理和控制,上位機進行現場可視化檢測,通信協議采用異步串行通信方式,通過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