【正文】
( 7) PC 機(jī)采用 COM2通信。 ( 2)幀格式為 :一位起始位 ,八位數(shù)據(jù)位 ,一位可編程的第九位 (此位為發(fā)送和接收的地址 /數(shù)據(jù)的標(biāo)志位 ),一位停止位。 ( 2)配置串口。當(dāng)通信方案完全由 PC 微機(jī)發(fā)送的數(shù)據(jù)交換,代碼為“ 1”可寫入發(fā)送緩沖區(qū)。定時(shí)器從 0開始計(jì)數(shù)初始值 65535,然后中斷設(shè)定的定時(shí)器0被調(diào)用,在其中 。當(dāng)單片機(jī)接收通過 PC 電腦發(fā)送的數(shù)據(jù)信號時(shí),它就會調(diào)用中斷服務(wù)程序。 MAX232的引腳 T1IN、 T2IN、 R1OUT、 R2OUT 為接 TTL/CMOS 電平的引腳,引腳 T1OUT、T2OUT、 R1IN、 R2IN 為接 RS232C 電平的引腳。 12V 電源電壓,而 MCI1489可以將 RS232轉(zhuǎn)換成標(biāo)準(zhǔn)級的 TTL 電平,它需要電源電壓為 +5V。 RS232被定義為單端標(biāo)準(zhǔn),它具有許多的優(yōu)點(diǎn),如更低速的串行通信,通信距離遠(yuǎn),適中的價(jià)格和良好的系統(tǒng)實(shí)用性,所以它是最適用的一個通信端口。 RS232C 標(biāo)準(zhǔn)是異步串行協(xié)議溝通,并已廣泛應(yīng)用于個人電腦和通信產(chǎn)業(yè)。 MCS51系列單片機(jī)片內(nèi)含有一個全雙工的串行接口 ,通過編程也可實(shí)現(xiàn)串行通信功能。 串行通信有異步通信和同步通信兩種基本通信方式。波特率通常以每秒的位數(shù)( bps)來計(jì)量。有些設(shè)備因?yàn)樵谕粫r(shí)間發(fā)送和接收數(shù)據(jù),被稱為全雙工設(shè)備。對于并行通信,你需要采用 8條導(dǎo)線。此外,電壓等級會因?yàn)檩旊娋€路的因素和電磁干擾而改變。 關(guān)鍵詞: 串行通信;單片機(jī);程序設(shè)計(jì) 一、緒論 在控制系統(tǒng)的工作中, PC 微機(jī)通過發(fā)送指令到步進(jìn)電機(jī)中來收集圖像信息。 its disadvantage is that transmission speed is low. As mentioned, a serial device sends and receives data one bit at a time. Some devices can send and receive data at the same time and are known as fullduplex devices. Others that can either send or receive at any one time are known as singleduplex. To initiate transmission, a device first transmits a start bit, followed by the data bits. The data bits can be five, six, seven, or eight bits, depending on what has been agreed upon. Both the sender and the receiver must be set to the same data bits for munication to take place correctly. Once the data bits are sent, a stop bit is sent. A stop bit can be one, one and a half, and two bits. The baud rate is the speed of transmission of data from one device to another. Baud rate is usually measured in bits per second (bps).Most serial devices transmit in seven or eight bits. To detect that the data has been sent correctly, an optional parity bit can be included together with the data bits. A parity bit can be one of the following: odd, even, mark, space, or none (mark and space parity are almost always used). Using a parity bit provides a basic mechanism to detect corruption of data that was sent and does not guarantee that the data received is free from error. Nevertheless, a parity bit is useful for improving the integrity of the data sent. Most serial ports adhere to the RS232C standard, which specifies a connector either with 25 pins or with 9 pins. Most serial devices use the ninepin connector. Serial munication with asynchronous munication and synchronous munication are two basic means of munication. Synchronous munication for the case of high transmission speed, the hardware plexity. The asynchronous munication 3 used in transmission speed between 50 and 19200 baud. Transmission is relatively mon. In asynchronous munication, data is transmitted frame by frame, each frame of serial data format by a start bit, 5 to 8 data bits, a parity bit (optional) and a Stop bit of four parts. Before the serial munication, the sender and receiver to agree the specific data format and baud rate (munication protocol). PCprogrammable serial asynchronous munication controller 8250 to implement asynchronous serial munication. By 8250 the initial programming, you can control serial data transmission format and speed. In the PC, in general there are two standard RS232C serial interface COM1 and COM21MCS 51 series microcontroller chip includes a fullduplex serial interface, can also be realized by programming the serial munications. CMOS smart sensor IC has received wide application for low cost, miniaturization, intelligence and standardization. In smart sensor IC designs, the munication interface circuits also play an important role other than sensors and signal processing circuits. There are more serial munication standard interfaces, such as RS232, RS485, USB Interface, IEEE1394, which has itself good features and also has focused on areas of application. RS485 has a antinoise capacity transmitting data, so it is monly used in industrial production. USB interface and IEEE1394 have fast speed, but some puters and operating systems do not support such interfaces. RS232 is most widely used as a serial interface in a PC puter and munications industries. RS232C standard is a protocol of asynchronous serial munication and has been widely used in PC and munication industries. Many short distance municational peripherals of PC such as printers, disks and terminals all municate with PC via RS232 serial interface. RS232C standard RS232C is the American Electronics Industry Association (EIA) formally announced, in the asynchronous serial munication, the most widely used standard bus. The standard for DCE and DTE serial binary munication between the maximum data transfer rate of up to 19. 2kbps, the longest transmission cables up to 15 meters 1RS 232C standard defines the 25lead, twoway munication in general, just Serial input RXD, serial output TXD and ground GND1RS 232C standard levels using negative logic, the provisions of + 3V ~ + 15V at any level between a logic 0level, 3V ~ 15V of Any level between a logic 1 level, with TTL and CMOS levels are different. In the interface circuit and puter interface chip in the