【正文】
的單片機(jī)與 PC 機(jī)的串行通信并且通過實(shí)例來更深了解到串行通信的內(nèi)容。第二章的單片機(jī)串口的方法講述了串口的工作方式和單片機(jī)收 /發(fā)數(shù)據(jù)流程,在這流程中需要經(jīng)過 2個(gè)串行緩沖器 SBUF 進(jìn)行。 關(guān)鍵字 :單片機(jī), VB,通信控件 ABSTRACT This article simply introduced VB some mainly control, how with realizes between the monolithic integrated circuit and the puter under the VB environment realizes the serial munication. This article altogether is divided four chapters: First chapter mainly understands the serial munication the basic concept. Needs RS232 in this experiment the connection, therefore in article simple introduction RS232 connection application, serial 江蘇信息職業(yè)技術(shù)學(xué)院 IV munication and synchronous munication and asynchronous munication difference. Second chapter the monolithic integrated circuit string mouth method narrated the string mouth work way and the monolithic integrated circuit receives/sends the data flow, needs to pass through 2 serial buffers SBUF in this flow to carry on. The timer/counter has four work ways, its work way choice and control all by two special functions registers (TMOD and TCON) the content decided. In third chapter is about the VB correspondence module quotation, the attribute, the event. Fourth chapter mainly analyzes the monolithic integrated circuit from the example can correctly receive the order and PC machine which PC machine sends in correctly receives the data message which the monolithic integrated circuit sends. Key words:The monolithic integrated circuit, VB, the correspondence controls. 目 錄 前言 ??????????????????? ?????????????????? Ⅰ 摘要 ????????????????????????????????????? Ⅱ ABSTRACT??????????????????????????????????? Ⅲ 目錄 ??????????????????????????????????? ??Ⅳ 第一章 串行通信的基礎(chǔ) ?? ???????????????????????? ( 1 ) 什么是串行通信 ???? ???????????????????????? ( 1 ) 江蘇信息職業(yè)技術(shù)學(xué)院 V RS232 串行口 ? ? ?? ???????????????????????? ( 1 ) RS232 的串行通信 ??? ??????????????????????? ( 2 ) 串行傳輸方式 ???? ?????????????????????? ? ( 2 ) ??????????????????????????? ( 3 ) ???????????????????????????????? ?? ( 3 ) ???????????????????????? ???? ?? ( 4 ) 第二章 單片機(jī)串行端口的使用方法 ???????????????????? ( 6 ) /計(jì)數(shù)器結(jié)構(gòu) ????? ????????????????????? ( 6 ) 串口工作方式 ???? ??????????????????????? ( 8 ) 串行口控制寄存器 ???? ??????????????????????? ( 9 ) /發(fā)數(shù)據(jù)流程 ? ?????????????????????? ( 10 ) 第三章 Visual Basic中的串行通信組件 ???? ?? ??????????? ( 11 ) Basic 的組件引用步驟 ? ???????????????????? (11) 通信控件的屬性 ?? ? ?????????????????????? (11) 通信控件的事件 ???????????????????????? ( 13) 第四章 單片機(jī)與 PC 機(jī)的實(shí)例 ???????????????????????? ( 14) 通信流程的實(shí)現(xiàn) ????????? ??????????????????? ( 14) 單片機(jī)與 PC機(jī)的串口通信的實(shí)現(xiàn)方法 ?????????????????? ( 14) 單片機(jī)實(shí)現(xiàn)方法 ??????????????????????????? ( 14) PC 機(jī)實(shí)現(xiàn)方法 ??????????????????????????? ( 16) 結(jié)束語 ?????????????????????????????????? (18) 致謝 ?????????????????????????????????? (19) 參 考文獻(xiàn) ????????????????????????????????? (20) 第一章 串行通信的基礎(chǔ) 所謂“串行通信”是指外設(shè)和計(jì)算機(jī)間使用一根數(shù)據(jù)信號線 (另外需要地線 ,可能還需要控制線 ),數(shù)據(jù)在一根數(shù)據(jù)信號線上一位一位地進(jìn)行傳輸,每一位數(shù)據(jù)都占據(jù)一個(gè)固定的時(shí)間長度。串行通信( Serial Communication) 指的是兩個(gè)欲交換信息者的信息流動,而且其信息流動的方式是一個(gè)位接著一個(gè)位,有順序地由一個(gè)方向向另一個(gè)方向流動。 RS232是其最明確的名稱。單向通信是一種最簡單的通信方式 , RS232 接口僅有二根導(dǎo)線組成。 在串行通 信 中,數(shù)據(jù)字節(jié)被拆成一連串 0或 1數(shù)據(jù)位在單根導(dǎo)線上從一端設(shè)備傳送到另一端設(shè)備。 現(xiàn)在的工業(yè)應(yīng)用中,串行通信是一種使用相當(dāng)廣泛的通信方式,其速度雖然沒有并行通信那樣快,可是由于配線數(shù)少,實(shí)現(xiàn)容易,所以長久以來大家一直樂于采用。如何保證這種同步性呢?通常有 2 種解決方法:采用同步通信方式或異步通信方式。 江蘇信息職業(yè)技術(shù)學(xué)院 3 采用同步通信的方式進(jìn)行通信時(shí),一般很難保證收發(fā)雙方的時(shí)鐘嚴(yán)格一致。也就是說,在這種通信方式下,每個(gè)字符作為獨(dú)立的信息單元,可以隨機(jī)地出現(xiàn)在數(shù)據(jù)流中,而每個(gè)字符出現(xiàn)在數(shù)據(jù)流中的相對時(shí)間是隨機(jī)的。 在異步通信中,規(guī)定數(shù)據(jù)線在不傳送數(shù)據(jù)時(shí)保持為“ 1”狀態(tài),在發(fā)送每個(gè)字符時(shí),硬件自動在每個(gè)字符前添加一個(gè)“起始信號”,其長度為 1 位,值為“ 0”。之所以這樣包裝是為了接收方能夠正常接收數(shù)據(jù)。在信號為二進(jìn)制位的特例下,它表征了每秒鐘所傳送的二進(jìn)制的位數(shù)。 江蘇信息職業(yè)技術(shù)學(xué)院 4 串口端口參數(shù) 串行端口的通信方式將字節(jié)拆分成一個(gè)接著一個(gè)的位再傳送出去。 通信端口的初始化必須對以下幾項(xiàng)進(jìn)行設(shè)置: ? 信息的傳送單位:串行通信端口以字符的形式傳送信息,工業(yè)界使用的字符形式有