25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more...
Home   Projects   Up   Sitemap   Search   Blog   Forum+Chat   About Us   Privacy   Terms of Use   Feedback   FAQ   Images   Services   Ads   Donate   Humor

RS-232 Serial Communication Notes

6-8-99, 11-20-04

Notes I made during experiments connecting two computers together via their serial ports.

Handshaking

  • Bios (DOS) will not output any char until DSR is active. ZPC (a 1980's Heath Users Group program that emulates an IBM PC on a Heath/Zenith H/Z-100 computer), in its notes on INT14, says the default for IBM is to use both CTS and DSR. It probably provides, and requires, all defined status lines. So, probably, does Windows for OutputDebugString() [Except that it must refer to ControlPanel to get the communication settings, and if so, why does it ignore the "NO Handshaking" one? Maybe it doesn't use ControlPanel, but just the DOS settings directly?]. If there is not a legitimate device providing all required handshaking, it won't work.
  • QBASIC provides a means of ignoring DSR and other signals. MSDOS doesn’t, which means you can’t ignore them in a generic DOS C++ program. Qbasic and commercial modem programs probably bypass bios to communicate with the chip directly.
  • Borland C++ Library Reference p.475 implies (and Inside Visual C++ p.244, even more so) that WinAPI OutputDebugString() may be sent to multiple destinations, i.e. it tries AUX, tries..., and generates an interrupt which may or may not be acted on by some process, and sends a "notification" to (any?) process(es?) that have registered themselves to receive it. (See DIAGXPRT.IDE.)
  • When properly cabled, you can write to a modem with Qbasic "Open Com" without using any modifiers to ignore signals.
  • MSDOS generic output (such as dir > com1) is the least forgiving. If it works, the setup is probably right.
  • H89 Configur.com should be able to test both RTS and DSR, either high or low.

Hardware

COM1, COM2

  • P5-90 computer CMOS stores no communication parameters.
  • Chips do not stay initialized with the last values used.
  • AUX is COM1
  • COM1 and COM2 seem to be redefinable mnemonics. In Control Panel, you can specify the ports and IRQs. And the P5-90 CMOS booklet refers only to "first serial port" and "second serial port". So the names aren't inherently linked to either port. If you reversed the serial port addresses in CMOS (or in Control Panel Ports > Advanced Setup), you should get COM1 on the DTE plug.
  • When COM1 and COM2 are connected to each other, MSD after system boot reports all lines not detected, but communications between them does work everywhere, including Windows, even with hardware handshaking specified in Control Panel. When I ran MSD in a window, it did detect proper signals from the port it was able to access (the other was in use by Terminal.exe).

Serial Communication Chips

  • The 16550AF is probably a descendant of the INS8250, and must be backwards compatible for old programs to work. Which means ancient (Heathkit) H-89 serial code (Modem8, MEX, etc.) is probably more IBM compatible than the H-100 is, and might be useful as a reference.

DB9 and DB25 Pin Assignments and Connection Tables

Cable must connect a DCE device to a DTE device, or use a null modem cable.

The only DB9 pin I haven't been able to test experimentally is RI, but it does have a DB9 pin assigned to it (MSD reports it, and when I had it crosswired with another, it was detected), and DB9 pin 9 was the only one left that I hadn't tested.

A B C D E F G
9 pin 25 pin   Connect   25 pin 9 pin
             
  pin 1 FG <------> FG pin 1  
pin 1 pin 8 DCD <------> DCD pin 8 pin 1
pin 2 pin 2 Transmit* <------> Receive* pin 3 pin 3
pin 3 pin 3 Receive* <------> Transmit* pin 2 pin 2
pin 4 pin 6 DSR <------> DTR pin 20 pin 6
pin 5 pin 7 SG <------> SG pin 7 pin 5
pin 6 pin 20 DTR <------> DSR pin 6 pin 4
pin 7 pin 5 CTS <------> RTS pin 4 pin 8
pin 8 pin 4 RTS <------> CTS pin 5 pin 7
pin 9 pin 22 RI <------> RI pin 22 pin 9

*DB9/DB25 (DCE/DTE) inherently transmit & receive on different pins, and must. Thus, for a regular connection between those two, it is proper to connect the same-numbered pins, just as you do when using two connectors of the same type.

Use the columns shown below, from the table above, to create:

From To Regular Cable Null Modem Cable
DB25 DB25 B - B B - F
DB25 DB9 A - B B - G
DB9 DB9 A - A A - G

Table of RS-232C Pin Assignments

Description field is from the point of view of the terminal, DTE, which is the "data terminal".

"Data set" is the modem, which is a DCE device.

9 Pin 25 Pin Abbr. DCE-DTE Direction Description EIA Circuit CCITT v.24
  1 FG == Frame Ground. Connects equipment chassis to prevent electrical shock. AA 101
3 2 TxD <---- Transmitted Data (Transmit line for DTE, Receive line for DCE) BA 103
2 3 RxD ----> Received Data (Receive line for DTE, Transmit line for DCE) BB 104
8 4 RTS <---- Request to Send. (Tells the modem that the TERMINAL or computer is ready to transmit data.) CA 105
7 5 CTS ----> Clear to Send. (Tells the terminal or computer that the MODEM is ready to accept data for transmission.) CB 106
4 6 DSR ----> Data Set Ready (Indicates that the MODEM is ready to establish the communications link and exchange control characters to begin data transmission.) CC 107
5 7 SG == Signal Ground (Return path for signal current) AB 102
1 8 DCD/RLSD ----> Data Carrier Detect / Received Line Signal Detector (Indicates that the MODEM has detected the data carrier of the remote modem.) CF 109
  9 v+ == + DC test voltage    
  10 v- == - DC test voltage    
  11 QM ----> Equalizer Mode Bell 208A
  12 SDCD/SRLSD ----> Secondary DCD SCF 122
  13 SCTS ----> Secondary CTS SCB 121
  14 STxD <---- Secondary TxD SBA 118
    NS <---- New Sync Bell 208A
  15 TxC ----> Transmitter Clock DCE Source DB 114
  16 SRxD ----> Secondary RxD SBB 119
    DCT ----> Divided Clock Transmitter Bell 208A
  17 RxC ----> Receiver Clock DD 115
  18 DCR ----> Divided Clock Receiver Bell 208A
    LL   Local Loopback    
  19 SRTS <---- Secondary RTS SCA 120
6 20 DTR <---- Data Terminal Ready (Indicates that the TERMINAL or computer is ready to establish the communications link and exchange control characters to begin data transmission.) CD 108.2
  21 SQ ----> Signal Quality Detect CG 110
9 22 RI ----> Ring Indicator (Indicates that the modem has received a ring signal on the telephone line.) CE 125
  23   <---- Data Rate Selector CH 111
      ----> Data Rate Selector CI 112
  24 ETxC <---- External Transmitter Clock DTE Source DA 113
  25   <---- Busy    
    TM   Test Mode    

Modem Programs and Serial Programming

There are at least two programs on the site dealing with RS-232 programming, including serial communications C++ classes for MSDOS and Windows. A site Search on RS232, RS-232, or serial might turn up more.

 

IBM BIOS uses INT 14h for serial communications operations. If you use this, you can do serial programming independent of the actual com port addresses, and don't have to program the ACE chip yourself. INT 14h appears to be able to set all parameters except hardware handshaking options. (Haven't researched this.)

But you can program the ACE yourself, and get more flexibility. Commsupp (IBM PC serial support for DeSmet C) does this, and is the best starting point for such a program.

See also:

  1. Help notes at Borland bioscom(), _bios_serialcom().
  2. ZPC INT14.ASM and the ZPC manual. (One question to research: ZPC can specify desired type of hardware handshaking. How can it do it, if the real INT 14h can't?)
  3. ASM source for Mex or other H89 programs. The 8250 methods would apply to IBM, though the asm statements would have to be translated.

 

 

Valid HTML 4.01 Transitional Valid CSS
View content labeling at ICRA.
Copyright ©2007 Steven Whitney. Last modified 09/25/2007.