⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interfacing the serial - 1.htm

📁 软硬件结合
💻 HTM
📖 第 1 页 / 共 5 页
字号:
  two DTE's together. This is commonly used as a cheap way to network games or
  to transfer files between computers</span><span style='font-family:宋体;
  mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>常用在两个电脑终端</span><span
  lang=EN-US> using Zmodem Protocol, Xmodem Protocol</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>协议</span><span
  lang=EN-US> etc. This can also be used with many Microprocessor Development
  Systems</span><span style='font-family:宋体;mso-ascii-font-family:Arial;
  mso-hansi-font-family:Arial'>也用于单片机系统</span><span lang=EN-US>.</span></p>
  <p align=center style='margin-left:36.0pt;text-align:center'><span
  lang=EN-US><img border=0 width=391 height=148 id="_x0000_i1281"
  src="Interfacing%20The%20Serial%20-%201.files\nullmode.gif"
  alt="Null Modem Connections"><br>
  </span><span lang=EN-US style='font-size:10.0pt'>Figure 1 : Null Modem Wiring
  Diagram</span><span style='font-size:10.0pt;font-family:宋体;mso-ascii-font-family:
  Arial;mso-hansi-font-family:Arial'>无</span><span lang=EN-US style='font-size:
  10.0pt'>Modem</span><span style='font-size:10.0pt;font-family:宋体;mso-ascii-font-family:
  Arial;mso-hansi-font-family:Arial'>串行连线图</span></p>
  <p style='margin-left:36.0pt'><span lang=EN-US>Above is my preferred method
  of wiring a Null Modem. It only requires 3 wires (TD</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>发送</span><span
  lang=EN-US>, RD</span><span style='font-family:宋体;mso-ascii-font-family:Arial;
  mso-hansi-font-family:Arial'>接收</span> <span lang=EN-US>&amp; SG</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>地</span><span
  lang=EN-US>) to be wired straight through thus is more cost effective to use
  with long cable runs. The theory of operation is reasonably easy. The aim is
  to make to computer think it is talking to a modem rather than another
  computer. Any data transmitted from the first computer must be received by
  the second thus TD is connected to RD. The second computer must have the same
  set-up</span><span style='font-family:宋体;mso-ascii-font-family:Arial;
  mso-hansi-font-family:Arial'>同样的结构</span><span lang=EN-US> thus RD is
  connected to TD. Signal Ground (SG) must also be connected so both grounds
  are common</span><span style='font-family:宋体;mso-ascii-font-family:Arial;
  mso-hansi-font-family:Arial'>共地</span><span lang=EN-US> to each computer.</span></p>
  <p style='margin-left:36.0pt'><span lang=EN-US>The Data Terminal Ready is
  looped back to Data Set Ready and Carrier Detect on both computers. When the
  Data Terminal Ready is asserted active, then the Data Set Ready and Carrier
  Detect immediately become active. At this point the computer thinks the
  Virtual</span><span style='font-family:宋体;mso-ascii-font-family:Arial;
  mso-hansi-font-family:Arial'>虚的</span><span lang=EN-US> Modem to which it is
  connected is ready and has detected the carrier of the other modem.</span></p>
  <p style='margin-left:36.0pt'><span lang=EN-US>All left to worry about now is
  the Request to Send and Clear To Send. As both computers communicate together
  at the same speed, flow control is not needed</span><span style='font-family:
  宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>由于两台电脑以同样的速度彼此通信不需要流控制</span><span
  lang=EN-US> thus these two lines are also linked together</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>这两根线短接在一起</span><span
  lang=EN-US> on each computer. When the computer wishes to send data, it
  asserts the Request to Send high and as it's hooked together with the Clear
  to Send, It immediately gets a reply that it is ok to send and does so.</span></p>
  <p style='margin-left:36.0pt'><span lang=EN-US>Notice that the ring indicator
  is not connected to anything of each end. This line is only used to tell the
  computer that there is a ringing signal on the phone line</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>电话</span><span
  lang=EN-US>. As we don't have a modem connected to the phone line this is
  left disconnected.</span></p>
  <p class=MsoNormal style='margin-left:36.0pt'><a name=5><span lang=EN-US
  style='font-size:13.5pt;font-family:Arial'>LoopBack Plug</span></a><span
  style='mso-bookmark:5'><span lang=EN-US style='font-family:Arial'> </span></span><span
  style='mso-bookmark:5'><span style='mso-ascii-font-family:Arial;mso-hansi-font-family:
  Arial;mso-bidi-font-family:Arial'>单串口回传</span></span><span style='mso-bookmark:
  5'><span lang=EN-US style='font-family:Arial'><o:p></o:p></span></span></p>
  <span style='mso-bookmark:5'></span>
  <div class=MsoNormal align=center style='margin-left:36.0pt;text-align:center'><span
  style='mso-bookmark:5'><span lang=EN-US style='font-family:Arial'>
  <hr size=2 width="100%" align=center>
  </span></span></div>
  <span style='mso-bookmark:5'></span>
  <table border=0 cellpadding=0 style='mso-cellspacing:1.5pt;margin-left:36.0pt;
   mso-padding-alt:0cm 0cm 0cm 0cm'>
   <tr>
    <td valign=top style='padding:.75pt .75pt .75pt .75pt'>
    <p align=center style='text-align:center'><span lang=EN-US><img border=0
    width=160 height=187 id="_x0000_i1283"
    src="Interfacing%20The%20Serial%20-%201.files\loopback.gif"
    alt="Loopback Plug"><br>
    </span><span lang=EN-US style='font-size:10.0pt'>Figure 2 : Loopback Plug
    Wiring Diagram</span></p>
    </td>
    <td style='padding:.75pt .75pt .75pt .75pt'>
    <p class=MsoNormal><span lang=EN-US style='font-family:Arial'>This loopback
    plug can come in extremely handy when writing Serial / RS232 Communications
    Programs. It has the receive and transmit lines connected together, so that
    anything transmitted out of the Serial Port is immediately received by the
    same port. If you connect this to a Serial Port , load a Terminal Program
    then anything you type will be immediately displayed on the screen. This
    can be used with the examples later in this tutorial</span><span
    style='mso-ascii-font-family:Arial;mso-hansi-font-family:Arial;mso-bidi-font-family:
    Arial'>指南</span><span lang=EN-US style='font-family:Arial'>.<br>
    <br>
    <i>Please note that this is not intended for use with Diagnostic Programs
    and thus will probably not work. For these programs you require a
    differently wired Loop Back plug which may vary from program to program.</i>
    <o:p></o:p></span></p>
    </td>
   </tr>
  </table>
  <p style='margin-left:36.0pt'><a name=6><span lang=EN-US style='font-size:
  13.5pt'>DTE / DCE Speeds</span><span lang=EN-US> </span></a><span
  style='mso-bookmark:6'><span style='font-family:宋体;mso-ascii-font-family:
  Arial;mso-hansi-font-family:Arial'>速度</span></span></p>
  <span style='mso-bookmark:6'></span>
  <div class=MsoNormal align=center style='margin-left:36.0pt;text-align:center'><span
  style='mso-bookmark:6'><span lang=EN-US style='font-family:Arial'>
  <hr size=2 width="100%" align=center>
  </span></span></div>
  <span style='mso-bookmark:6'></span>
  <p style='margin-left:3.0gd;text-indent:24.0pt;mso-char-indent-count:2.0;
  mso-char-indent-size:12.0pt'><span lang=EN-US>We have already talked briefly
  about DTE &amp; DCE. A typical Data Terminal Device is a computer</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>典型的数据终端设备是一台电脑</span><span
  lang=EN-US> and a typical Data Communications Device is a Modem</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>而典型的数据通信设备就是一个</span><span
  lang=EN-US>Modem</span><span style='font-family:宋体;mso-ascii-font-family:
  Arial;mso-hansi-font-family:Arial'>。</span><span lang=EN-US>Often people will
  talk about DTE to DCE or DCE to DCE speeds. </span></p>
  <p style='margin-left:3.0gd;text-indent:24.0pt;mso-char-indent-count:2.0;
  mso-char-indent-size:12.0pt'><i><span lang=EN-US>DTE to DCE</span></i><span
  lang=EN-US> is the speed between your modem and computer, sometimes referred
  to as your terminal speed</span><span style='font-family:宋体;mso-ascii-font-family:
  Arial;mso-hansi-font-family:Arial'>也叫终端速度</span><span lang=EN-US>. This
  should run at faster speeds than the DCE to DCE speed</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'> 比</span><span
  lang=EN-US>DCE </span><span style='font-family:宋体;mso-ascii-font-family:Arial;
  mso-hansi-font-family:Arial'>到</span><span lang=EN-US> DCE</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>速度快</span><span
  lang=EN-US>. </span></p>
  <p style='margin-left:3.0gd;text-indent:24.0pt;mso-char-indent-count:2.0;
  mso-char-indent-size:12.0pt'><i><span lang=EN-US>DCE to DCE</span></i><span
  lang=EN-US> is the link between modems, sometimes called the line speed</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>连接速度</span><span
  lang=EN-US>. </span></p>
  <p style='margin-left:36.0pt'><span lang=EN-US>Most people today will have
  28.8K or 33.6K modems. Therefore we should expect the DCE to DCE speed to be
  either 28.8K or 33.6K. Considering the high speed of the modem we should
  expect the DTE to DCE speed to be about 115,200 BPS.(Maximum Speed of the
  16550a UART) This is where some people often fall into a trap. The
  communications program</span><span style='font-family:宋体;mso-ascii-font-family:
  Arial;mso-hansi-font-family:Arial'>通讯程序</span><span lang=EN-US> which they
  use have settings for DCE to DTE speeds. However they see 9.6 KBPS, 14.4 KBPS
  etc and think it is your modem speed. </span></p>
  <p style='margin-left:36.0pt'><span lang=EN-US>Today's Modems should have
  Data Compression</span><span style='font-family:宋体;mso-ascii-font-family:
  Arial;mso-hansi-font-family:Arial'>压缩</span><span lang=EN-US> build into
  them. This is very much like PK-ZIP but the software</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>软件</span><span
  lang=EN-US> in your modem compresses and decompresses the data. When set up
  correctly you can expect compression ratios</span><span style='font-family:
  宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>压缩比</span><span
  lang=EN-US> of 1:4 or even higher. 1 to 4 compression would be typical of a
  text file. If we were transferring that text file at 28.8K (DCE-DCE), then
  when the modem compresses it you are actually transferring 115.2 KBPS between
  computers and thus have a DCE-DTE speed of 115.2 KBPS. Thus this is why the
  DCE-DTE should be much higher than your modem's connection speed.</span></p>
  <p style='margin-left:36.0pt'><span lang=EN-US>Some modem manufacturers</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>调制解调器厂商</span><span
  lang=EN-US> quote</span><span style='font-family:宋体;mso-ascii-font-family:
  Arial;mso-hansi-font-family:Arial'>提供</span><span lang=EN-US> a maximum
  compression ratio as 1:8. Lets say for example its on a new 33.6 KBPS modem
  then we may get a maximum 268,800 BPS transfer between modem and UART. If you
  only have a 16550a which can do 115,200 BPS tops</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>如果你用的是</span><span
  lang=EN-US>16550a</span><span style='font-family:宋体;mso-ascii-font-family:
  Arial;mso-hansi-font-family:Arial'>,它最快也只有</span><span lang=EN-US>115,200 BPS,
  then you would be missing out on a extra bit of performance</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>那么就会丢失</span><span
  lang=EN-US>. Buying a 16C650 should fix</span><span style='font-family:宋体;
  mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>要解决这个问题,可以改用</span><span
  lang=EN-US>16C650</span><span style='font-family:宋体;mso-ascii-font-family:
  Arial;mso-hansi-font-family:Arial'>,它可以达到</span><span lang=EN-US>230,400 BPS</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>的速度</span><span
  lang=EN-US> your problem with a maximum transfer rate of 230,400 BPS.</span></p>
  <p style='margin-left:36.0pt'><span lang=EN-US>However don't abuse</span><span
  style='font-family:宋体;mso-ascii-font-family:Arial;mso-hansi-font-family:Arial'>虐待</span><span
  lang=EN-US> your modem if you don't get these rates. These are MAXIMUM
  compression ratios. In some instances if you try to send an already
  compressed file, your modem can spend more time trying to compress it, thus
  you get a transmission speed less than your modem's connection speed. If this
  occurs try turning off your data compression. This should be fixed on newer
  modems. Some files compress easier than others thus any file which compresses
  easier is naturally going to have a higher compression ratio.</span></p>
  <p style='margin-left:36.0pt'><a name=7><span lang=EN-US style='font-size:
  13.5pt'>Flow Control</span><span lang=EN-US> </span></a></p>
  <span style='mso-bookmark:7'></span>
  <div class=MsoNormal align=center style='margin-left:36.0pt;text-align:center'><span
  style='mso-bookmark:7'><span lang=EN-US style='font-family:Arial'>
  <hr size=2 width="100%" align=center>
  </span></span></div>
  <span style='mso-bookmark:7'></span>
  <p style='margin-left:36.0pt'><span lang=EN-US>So if our DTE to DCE speed is
  several times faster than our DCE to DCE speed the PC can send data to your
  modem at 115,200 BPS. Sooner or later data is going to get lost as buffers
  overflow, thus flow control is used. Flow control has two basic varieties,
  Hardware or Software.</span></p>
  <p style='margin-left:36.0pt'><span lang=EN-US>Software flow control,
  sometimes expressed as Xon/Xoff uses two characters Xon and Xoff. Xon is
  normally indicated by the ASCII 17 character where as the ASCII 19 character
  is used for Xoff. The modem will only have a small buffer so when the
  computer fills it up the modem sends a Xoff character to tell the computer to
  stop sending data. Once the modem has room for more data it then sends a Xon
  character and the computer sends more data. This type of flow control has the
  advantage that it doesn't require any more wires as the characters are sent
  via the TD/RD lines. However on slow links each character requires 10 bits
  which can slow communications down.</span></p>
  <p style='margin-left:36.0pt'><span lang=EN-US>Hardware flow control is also
  known as RTS/CTS flow control. It uses two wires in your serial cable rather
  than extra characters transmitted in your data lines. Thus hardware flow
  control will not slow down transmission times like Xon-Xoff does. When the
  computer wishes to send data it takes active the Request to Send line. If the
  modem has room for this data, then the modem will reply by taking active the
  Clear to Send line and the computer starts sending data. If the modem does
  not have the room then it will not send a Clear to Send.</span></p>
  <p style='marg

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -