home *** CD-ROM | disk | FTP | other *** search
/ Byte OS/2 Programmer's Cookbook / OS2TOOLS.ISO / ibminfo / 16550.doc < prev    next >
Text File  |  1992-09-11  |  18KB  |  341 lines

  1. Area Os2, Msg#1586, Sep-09-92 09:52PM
  2.    From: Wilson Navarro                       
  3.      To: All                                  
  4. Subject: 16550 under os2
  5.  
  6. I found this message on internet. I hope it helps someone understand com 
  7. ports under OS/2. ------------------------------------------------------------
  8. ------------ Article 11617 (102 more) in comp.os.os2.misc: From: db3l@ans.net 
  9. (David Bolen)
  10.  
  11. Subject: COM performance hints with 16550 Date: Thu, 3 Sep 1992 20:18:53 GMT 
  12. Organization: Advanced Network & Services, Inc. - Elmsford, NY Lines: 325
  13.  
  14. Warning: This is pretty long, but there's a summary at the end.  If you just
  15.          want to see a brief statement now:
  16.  
  17.      If you have a 16550, have a serial device that keeps DSR high while
  18.      it is on (I think most modems do this by default, or are configurable),
  19.      doesn't do hardware flow control, or doesn't mind getting up to 15
  20.      characters after dropping CTS and/or DSR, make sure you set BUFFER=ON
  21.      when configuring your COM port with the MODE command.  With default
  22.      settings, BUFFER=AUTO is really no different than BUFFER=DISABLED.
  23.  
  24.          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  25.  
  26. I recently obtained a copy of the OS/2 physical device driver reference and 
  27. was reading through the information about the async drivers (COM/VCOM.SYS).
  28.  
  29. From the number of posts on the subject (some from myself), it seems that a 
  30. number of people are confused about what the various MODE COM settings mean, 
  31. and what sort of setup was the most efficient use of COM ports when a 16550 
  32. UART was present (which seems to be universally regarded as a good idea to 
  33. have in order to gain good performance).  I normally use OS/2 COM programs 
  34. with the RTS=HS,BUFFER=AUTO settings (as is normally recommended on the net 
  35. and in the FAQ) and wondered if I was fully exploiting the capabilities of my 
  36. 16550.  In addition, I was still having problems with DOS environment 
  37. programs (notably kermit 3.11 that just dies a horrible death) and hoped to 
  38. learn a bit about how that might be improved.
  39.  
  40. After reading a bit, and performing some experimentation, I've come up with 
  41. the following information and conclusions that may help other people with the 
  42. 16550s.  I don't place any guarantees on this information, other than that it 
  43. is accurate to the best of my knowledge and seems to be backed up by my 
  44. experimental results.  I hope it proves helpful, or at least helps to explain 
  45. the relationship between some of the MODE parameters and the use of the FIFO 
  46. buffers provided by the 16550.
  47.  
  48. (in the following, when I use the term 16550, the OS/2 drivers actually
  49.  require an NS-16550A or compatible chip, and I believe the current level
  50.  chips as discussed previously in the OS/2 groups are 16550AFN or 16550AF)
  51.  
  52.          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  53.  
  54. Introduction:
  55. ------------
  56.  
  57. The 16550 provides for a 16-character receive hardware buffer that can be set 
  58. to generate an interrupt every 1, 4, 8 or 14 characters.  It can also hold up 
  59. to 16 characters in a transmit buffer, generating an interrupt only when that 
  60. buffer is empty.  In other words, in its most efficient mode, the 16550 can 
  61. handle transmission and receipt of data in roughly 16-byte chunks, only 
  62. interrupting the CPU at the end of each chunk.
  63.  
  64. Note that even if you don't make use of the extended buffering from the point 
  65. of view of interrupt handling, but still receive an interrupt for every 
  66. character received or transmitted, the 16550 buffer can be helpful, as it can 
  67. buffer received characters if the COM handler misses an interrupt, thereby 
  68. preventing receive overruns.
  69.  
  70. The OS/2 COM driver can fully exploit these capabilities of the 16550 
  71. depending on how it is configured.  Here's the rub though - if you take the 
  72. default COM settings, and even if you use MODE to set the BUFFER parameter to 
  73. AUTO, the COM driver is only partially using the capabilities of the UART. In 
  74. other words, the settings that are normally posted to these groups, and are 
  75. in the FAQ are not the most efficient settings.  In fact, from what I can 
  76. tell, a BUFFER value of AUTO is no better than DISABLED with the other 
  77. defaults for the modem signaling values.
  78.  
  79.  
  80. COM Driver Settings (MODE):
  81. --------------------------
  82.  
  83. The extended hardware buffering mode of the async driver can be controlled 
  84. via the BUFFER parameter of the MODE command.  It can take on three values:
  85.  
  86.      ON         Set transmit/receive triggers to fully exploit buffering.
  87.                 (16-character transmit/receive queues for 16550).
  88.      OFF        Set transmit/receive triggers to a single character.
  89.      AUTO       "Automatic Protocol Override".  Adjust the transmit/receive
  90.                 triggers according to handshaking protocols in effect.
  91.  
  92. The "handshaking protocols" for AUTO mode use the following signals:
  93.  
  94.         RTS = Request To Send           ( Signals FROM OS/2 COM Driver )
  95.         DTR = Data Terminal Ready
  96.         CTS = Clear To Send             ( Signals TO OS/2 COM Driver )
  97.         DCD = Data Carrier Detect
  98.         DSR = Data Set Ready
  99.  
  100. and refer to the following:
  101.  
  102.    * Input Sensitivity using DSR
  103.         - MODE option IDSR, default ON
  104.         - If this setting is ON, then the driver will only accept data from
  105.           the device while the DSR line is active.
  106.    * Output Handshaking using CTS, DSR, DCD
  107.         - MODE options OCTS, ODSR, default is both ON
  108.         - No MODE option for DCD - MODE always sets it OFF
  109.         - This setting controls whether CTS, DSR or DCD are used to control
  110.           the flow of data to the modem.  If any of these settings are ON,
  111.           the driver stops giving data to the transmit hardware as soon as
  112.           the corresponding control signal drops.
  113.    * RTS Control Mode
  114.         - MODE option RTS, default is ON.  Can be one of the following:
  115.             + Enabled                                              [MODE=ON]
  116.             + Disabled                                             [MODE=OFF]
  117.             + Input Handshaking (RTS drops on input queue full)    [MODE=HS]
  118.             + Toggling on Transmit (RTS drops unless transmitting) [MODE=TOG]
  119.         - This setting controls how the RTS signal is controlled by the
  120.           driver.  If ON, DTR is used to signal when the COM port is
  121.           active, while if HS, DTR is used to control the flow of data
  122.           from the modem.
  123.    * DTR Control Mode
  124.         - MODE option DTR, default is ON.  Can be one of the following:
  125.             + Enabled                                              [MODE=ON]
  126.             + Disabled                                             [MODE=OFF]
  127.             + Input Handshaking (DTR drops on input queue full)    [MODE=HS]
  128.         - This setting controls how the DTR signal is used to control
  129.           the flow of data.
  130.         - This setting controls how the RTS signal is controlled by the
  131.           driver.  If ON, DTR is used to signal when the COM port is
  132.           active, while if HS, DTR is used to control the flow of data
  133.           from the modem.
  134.  
  135. A typical default configuration for the COM port is (ignoring some of the 
  136. MODE parameters not relevant to this post):
  137.  
  138.         IDSR = ON               ODSR   = ON
  139.         OCTS = ON               DTR    = ON
  140.         RTS  = ON               BUFFER = AUTO
  141.  
  142. And most suggestions for configuring the COM port for better control 
  143. explicitly set RTS=HS, and BUFFER=AUTO, so I expect that many people are 
  144. running with the above settings, except with RTS=HS, allowing full hardware 
  145. flow control (RTS/CTS) to the modem.
  146.  
  147.  
  148. Setting Interaction:
  149. -------------------
  150.  
  151. For the purposes of this post (getting the most performance out of the 
  152. 16550), the only settings that are really important from the above discussion 
  153. are the "Extended Hardware Buffering" (BUFFER), "Input Sensitivity using DSR" 
  154. (IDSR), and "Output Handshaking using CTS, DSR, DCD" (OCTS,ODSR).
  155.  
  156. Here's the basic problem.  In order to accomplish the latter two settings in 
  157. their default mo