【正文】
microputer application system, the function of the munication is more and more important. Communication refers to puter information transmission to the outside world, both transmission between the puter and the puter,Also includes the puter and external device, such as terminals, printers, and transmission between devices such as disk. Serial munication refers to using a data line, to transmit data a bit a ground in turn, each data holds a fixed length of time. Its just a few lines can exchange information between the systems, especially used in puter and puter, puter and remote munication between the peripherals. When using a serial port munication sending and receiving to each and every one of the characters are in fact a a delivery, each one is or is zero. This design is to use single chip microputer to plete a system, realize the serial munication between the two MCU. And USES DS18B20 temperature sensor, temperature is measured by a singlechip puter and send to other displayed on a single chip microputer. For single chip microputer serial port munication is of great significance, not only can realize the MCU data transmission to the puter side, but also can realize the puter control of the microcontroller. Due to its less cable, wiring simple, so in the long distance transmission, has been widely used, MCS 51 series microcontroller with a universal asynchronous receiver/transmitter UART, RXD by pin [P3. O] and TXD [] with external sound circuit B full duplex serial asynchronous munication, send data sent by the TXD end, when receiving data from the RXD input. Keywords: serial munications RS 232 serial port baud rate 基于 MCS51的兩片單片機(jī)之間的串行通信接口設(shè)計(jì) 目 錄 第一章 緒論 ............................................................. 1 單片機(jī)的應(yīng)用 ......................................................... 1 MCS51 單片機(jī)的基本組成 ............................................. 2 本課題要實(shí)現(xiàn)的內(nèi)容 ................................................... 2 第二章 串行通信介紹 ..................................................... 3 串行通信與并行通信 ................................................... 3 同步通信與異步通信 ................................................... 3 全雙工方式與半雙工方式 .............................................. 4 串行異步通信 ........................................................ 5 串行同步通信 ......................................................... 5 串口通信參數(shù)設(shè)置 .................................................... 6 51 單片機(jī)串行通信格式及波特率 ........................................ 7 第三章 系統(tǒng)設(shè)計(jì) ......................................................... 8 系統(tǒng)整體框圖 ......................................................... 8 兩個(gè) RS232 串口服務(wù)器之間的連接 ....................................... 9 MAX232 芯片 ........................................................ 9 RS232 連接方式 .................................................... 9 時(shí)鐘電路的作用 ...................................................... 12 LED 的接入 .......................................................... 13 溫度采集與顯示 ...................................................... 13 DS18B20 溫度傳感器 ................................................ 13 溫度傳感器與單片機(jī)的連接 .......................................... 14 LCD 和數(shù)碼管與單片機(jī)的連接和排阻的接入 ............................ 15 排阻的選擇 ..................................................... 15 LCD、數(shù)碼管接入 ................................................ 16 整體電路 ............................................................ 16 第四章 軟件調(diào)試 ........................................................ 18 程序流程圖 .......................................................... 18 串行接口流程圖 .................................................... 18 基于 MCS51的兩片單片機(jī)之間的串行通信接口設(shè)計(jì) K K2 鍵程序流程 圖 ............................................... 19 溫度采集與顯示子程序流程圖 ........................................ 20 主程序流程圖 ..................................................... 21 程序的調(diào)入與仿真結(jié)果 ................................................ 22 第五 章 論文總結(jié) ........................................................ 25 參考文獻(xiàn) ............................................................... 26 謝辭 ................................................................... 27 附錄 ................................................................... 28 基于 MCS51的兩片單片機(jī)之間的串行通信接口設(shè)計(jì) 1 第一章 緒論 為了提高系統(tǒng)管理的先進(jìn)性和安全性,計(jì)算機(jī)工業(yè)自動(dòng)控制和檢測(cè)系統(tǒng)越來(lái)越多地采用集總分散系統(tǒng)。 在本次設(shè)計(jì)中 ,我需要克服的問(wèn)題有怎樣把兩串口與單片機(jī)連接和設(shè)置傳輸?shù)母袷?,和怎樣采集溫度,怎樣顯示等問(wèn)題,總之,在 本次設(shè)計(jì)中我需要對(duì)單片機(jī)有一定的基礎(chǔ),同時(shí)數(shù)電和模電也需要好好溫習(xí)下。而 RS232 是一種比較成熟的串口,所以本次設(shè)計(jì)使用 RS232 串口, 用串口通信時(shí)發(fā)送和接收到的每一個(gè)字符實(shí)際上都是一次一位的傳送的,每一位為 1或者為 0。 本次設(shè)計(jì)就是要利用單片機(jī)來(lái)完成一個(gè)系統(tǒng),實(shí)現(xiàn)兩單片機(jī)之間的串行通信。對(duì)于畫(huà)設(shè)計(jì)的系統(tǒng)電路圖有很大的幫助。較為常見(jiàn)的形式是由一臺(tái)作管理用的上位主計(jì)算機(jī) (主 機(jī) )和多臺(tái)直接參與控制檢測(cè)的下位從計(jì)算機(jī) (從機(jī) )構(gòu)成的主從式多機(jī)系統(tǒng),主機(jī)和從機(jī)之間以通訊的方式來(lái)協(xié)調(diào)工作。今后它仍將是科技界、工業(yè)界廣泛選擇應(yīng)用的 8 位微控制器,仍將是單片機(jī)應(yīng)用的主流機(jī)種。在各類(lèi)儀器儀表中(包括醫(yī)療器械、色譜儀、溫度、濕度、流量、流速、電壓、頻率、功率、厚度、角度、長(zhǎng)度、硬度、元素測(cè)定等)引入單片機(jī)。 時(shí)鐘電路, 12MHz。 串行口,全雙工串行口。 本課題要實(shí)現(xiàn)的內(nèi)容 ( 1)在系統(tǒng)中擴(kuò)展 RS232 串行通信接口,使 A、 B 兩臺(tái) MCS51 單片機(jī)通過(guò) 該接口相連接。 ( 3)使用 DS18B20 溫度傳感器,由 B機(jī)測(cè)量溫度后,傳到 A機(jī)顯示。 在 并行通信 中,一個(gè)字節(jié)( 8 位)數(shù)據(jù)是在 8條并行傳輸線上同時(shí)由源傳到目的地;而在 串行通信 方式中,數(shù)據(jù)是在單條 1 位寬的傳輸線上一位接一位地順序傳送。異步通信以字符(構(gòu)成的幀)為單位進(jìn)行傳輸,字符與字符之間的 間隙(時(shí)間間隔)也是任意的,但每個(gè)字符中的各位是以固定的時(shí)間傳送的。發(fā)送方對(duì)接收方的同步可以通過(guò)外同步和自同步兩種方法實(shí)現(xiàn)。數(shù)據(jù)的輸出 我們把它 稱(chēng)發(fā)送數(shù)據(jù)( TXD),數(shù)據(jù)輸入 時(shí)我們把它 稱(chēng)接收數(shù)據(jù)( RXD)。具體說(shuō),在發(fā)送端, 我們需要把 并行 傳輸?shù)?數(shù)據(jù)轉(zhuǎn)換為串行 傳輸?shù)?數(shù)據(jù); 但是 在接收端, 我們 要把接收到的串行 傳輸?shù)?數(shù)據(jù)轉(zhuǎn)換為并行傳輸?shù)?數(shù)據(jù) , 當(dāng)數(shù)據(jù)發(fā)送 及 接收分流 時(shí) , 采用 兩根不同的傳輸 數(shù)據(jù) 線傳送 的時(shí)候 ,通信 的 雙方都 可以 在同一 時(shí)間 進(jìn)行發(fā)