📄 interfacing the serial - rs-232 port part1-2.htm
字号:
<TD>Baud Output - Output from Programmable Baud Rate Generator.
Frequency = (Baud Rate x 16)</TD></TR>
<TR>
<TD>
<CENTER>Pin 16</CENTER></TD>
<TD>
<CENTER>XIN</CENTER></TD>
<TD>External Crystal Input - Used for Baud Rate Generator
Oscillator</TD></TR>
<TR>
<TD>
<CENTER>Pin 17</CENTER></TD>
<TD>
<CENTER>XOUT</CENTER></TD>
<TD>External Crystal Output</TD></TR>
<TR>
<TD>
<CENTER>Pin 18</CENTER></TD>
<TD>
<CENTER>nWR</CENTER></TD>
<TD>Write Line - Inverted</TD></TR>
<TR>
<TD>
<CENTER>Pin 19</CENTER></TD>
<TD>
<CENTER>WR</CENTER></TD>
<TD>Write Line - Not Inverted</TD></TR>
<TR>
<TD>
<CENTER>Pin 20</CENTER></TD>
<TD>
<CENTER>VSS</CENTER></TD>
<TD>Connected to Common Ground</TD></TR>
<TR>
<TD>
<CENTER>Pin 21</CENTER></TD>
<TD>
<CENTER>RD</CENTER></TD>
<TD>Read Line - Inverted</TD></TR>
<TR>
<TD>
<CENTER>Pin 22</CENTER></TD>
<TD>
<CENTER>nRD</CENTER></TD>
<TD>Read Line - Not Inverted</TD></TR>
<TR>
<TD>
<CENTER>Pin 23</CENTER></TD>
<TD>
<CENTER>DDIS</CENTER></TD>
<TD>Driver Disable. This pin goes low when CPU is reading from
UART. Can be connected to Bus Transceiver in case of high capacity
data bus.</TD></TR>
<TR>
<TD>
<CENTER>Pin 24</CENTER></TD>
<TD>
<CENTER>nTXRDY</CENTER></TD>
<TD>Transmit Ready</TD></TR>
<TR>
<TD>
<CENTER>Pin 25</CENTER></TD>
<TD>
<CENTER>nADS</CENTER></TD>
<TD>Address Strobe. Used if signals are not stable during read or
write cycle</TD></TR>
<TR>
<TD>
<CENTER>Pin 26</CENTER></TD>
<TD>
<CENTER>A2</CENTER></TD>
<TD>Address Bit 2</TD></TR>
<TR>
<TD>
<CENTER>Pin 27</CENTER></TD>
<TD>
<CENTER>A1</CENTER></TD>
<TD>Address Bit 1</TD></TR>
<TR>
<TD>
<CENTER>Pin 28</CENTER></TD>
<TD>
<CENTER>A0</CENTER></TD>
<TD>Address Bit 0</TD></TR>
<TR>
<TD>
<CENTER>Pin 29</CENTER></TD>
<TD>
<CENTER>nRXRDY</CENTER></TD>
<TD>Receive Ready</TD></TR>
<TR>
<TD>
<CENTER>Pin 30</CENTER></TD>
<TD>
<CENTER>INTR</CENTER></TD>
<TD>Interrupt Output</TD></TR>
<TR>
<TD>
<CENTER>Pin 31</CENTER></TD>
<TD>
<CENTER>nOUT2</CENTER></TD>
<TD>User Output 2</TD></TR>
<TR>
<TD>
<CENTER>Pin 32</CENTER></TD>
<TD>
<CENTER>nRTS</CENTER></TD>
<TD>Request to Send</TD></TR>
<TR>
<TD>
<CENTER>Pin 33</CENTER></TD>
<TD>
<CENTER>nDTR</CENTER></TD>
<TD>Data Terminal Ready</TD></TR>
<TR>
<TD>
<CENTER>Pin 34</CENTER></TD>
<TD>
<CENTER>nOUT1</CENTER></TD>
<TD>User Output 1</TD></TR>
<TR>
<TD>
<CENTER>Pin 35</CENTER></TD>
<TD>
<CENTER>MR</CENTER></TD>
<TD>Master Reset</TD></TR>
<TR>
<TD>
<CENTER>Pin 36</CENTER></TD>
<TD>
<CENTER>nCTS</CENTER></TD>
<TD>Clear To Send</TD></TR>
<TR>
<TD>
<CENTER>Pin 37</CENTER></TD>
<TD>
<CENTER>nDSR</CENTER></TD>
<TD>Data Set Ready</TD></TR>
<TR>
<TD>
<CENTER>Pin 38</CENTER></TD>
<TD>
<CENTER>nDCD</CENTER></TD>
<TD>Data Carrier Detect</TD></TR>
<TR>
<TD>
<CENTER>Pin 39</CENTER></TD>
<TD>
<CENTER>nRI</CENTER></TD>
<TD>Ring Indicator</TD></TR>
<TR>
<TD>
<CENTER>Pin 40</CENTER></TD>
<TD>
<CENTER>VDD</CENTER></TD>
<TD>+ 5 Volts</TD></TR></TBODY></TABLE><FONT size=-1>
<CENTER>Table 2 : Pin Assignments for 16550A
UART</CENTER></FONT></CENTER>
<P>The UART requires a Clock to run. If you look at your serial card a
common crystal found is either a 1.8432 MHZ or a 18.432 MHZ Crystal. The
crystal in connected to the XIN-XOUT pins of the UART using a few extra
components which help the crystal to start oscillating. This clock will
be used for the Programmable Baud Rate Generator which directly
interfaces into the transmit timing circuits but not directly into the
receiver timing circuits. For this an external connection mast be made
from pin 15 (BaudOut) to pin 9 (Receiver clock in.) Note that the clock
signal will be at Baudrate * 16. </P>
<P>If you are serious about pursuing the 16550 UART used in your PC
further, then would suggest downloading a copy of the PC16550D data
sheet from <A href="http://www.natsemi.com/">National Semiconductors
Site</A>. Data sheets are available in .PDF format so you will need
Adobe Acrobat Reader to read these. <A href="http://www.ti.com/">Texas
Instruments</A> has released the 16750 UART which has 64 Byte FIFO's.
Data Sheets for the TL16C750 are available from the Texas Instruments
Site. </P>
<P><A name=9><FONT size=+1>Types of UARTS (For PC's)</FONT>
<HR>
</A>
<P></P>
<UL>
<TABLE>
<TBODY>
<TR>
<TD vAlign=top width="10%">8250</TD>
<TD>First UART in this series. It contains no scratch register.
The 8250A was an improved version of the 8250 which operates
faster on the bus side. </TD></TR>
<TR>
<TD vAlign=top width="10%">8250A</TD>
<TD>This UART is faster than the 8250 on the bus side. Looks
exactly the same to software than 16450.</TD></TR>
<TR>
<TD vAlign=top width="10%">8250B</TD>
<TD>Very similar to that of the 8250 UART.</TD></TR>
<TR>
<TD vAlign=top width="10%">16450</TD>
<TD>Used in AT's (Improved bus speed over 8250's). Operates
comfortably at 38.4KBPS. Still quite common today.</TD></TR>
<TR>
<TD vAlign=top width="10%">16550</TD>
<TD>This was the first generation of buffered UART. It has a 16
byte buffer, however it doesn't work and is replaced with the
16550A.</TD></TR>
<TR>
<TD vAlign=top width="10%">16550A</TD>
<TD>Is the most common UART use for high speed communications eg
14.4K & 28.8K Modems. They made sure the FIFO buffers worked
on this UART.</TD></TR>
<TR>
<TD vAlign=top width="10%">16650</TD>
<TD>Very recent breed of UART. Contains a 32 byte FIFO,
Programmable X-On / X-Off characters and supports power
management.</TD></TR>
<TR>
<TD vAlign=top width="10%">16750</TD>
<TD>Produced by Texas Instruments. Contains a 64 byte
FIFO.</TD></TR></TBODY></TABLE><BR></UL></UL><A name=part2></A>
<HR>
<I><FONT size=+2>Part Two : Serial Port's Registers (PC's)</FONT></I>
<HR>
<P></P>
<UL>
<P><A name=12><FONT size=+1>Port Addresses & IRQ's</FONT><BR>
<HR>
</A>
<P></P>
<CENTER>
<TABLE border=1 width="60%">
<TBODY>
<TR>
<TD>
<CENTER><B>Name </B></CENTER></TD>
<TD>
<CENTER><B>Address</B></CENTER></TD>
<TD>
<CENTER><B>IRQ</B></CENTER></TD></TR>
<TR>
<TD>
<CENTER>COM 1 </CENTER></TD>
<TD>
<CENTER>3F8 </CENTER></TD>
<TD>
<CENTER>4</CENTER></TD></TR>
<TR>
<TD>
<CENTER>COM 2 </CENTER></TD>
<TD>
<CENTER>2F8 </CENTER></TD>
<TD>
<CENTER>3</CENTER></TD></TR>
<TR>
<TD>
<CENTER>COM 3 </CENTER></TD>
<TD>
<CENTER>3E8 </CENTER></TD>
<TD>
<CENTER>4</CENTER></TD></TR>
<TR>
<TD>
<CENTER>COM 4 </CENTER></TD>
<TD>
<CENTER>2E8 </CENTER></TD>
<TD>
<CENTER>3</CENTER></TD></TR></TBODY></TABLE><FONT size=-1>Table 3 :
Standard Port Addresses </FONT></CENTER>
<P>Above is the standard port addresses. These should work for most
P.C's. If you just happen to be lucky enough to own a IBM P/S2 which has
a micro-channel bus, then expect a different set of addresses and IRQ's.
Just like the LPT ports, the base addresses for the COM ports can be
read from the BIOS Data Area. </P>
<CENTER>
<TABLE border=1 width="60%">
<TBODY>
<TR>
<TD width="40%"><B>
<CENTER>Start Address</CENTER><B></B></B></TD>
<TD width="60%"><B>
<CENTER>Function</CENTER><B></B></B></TD></TR>
<TR>
<TD>
<CENTER>0000:0400</CENTER></TD>
<TD>COM1's Base Address</TD></TR>
<TR>
<TD>
<CENTER>0000:0402</CENTER></TD>
<TD>COM2's Base Address</TD></TR>
<TR>
<TD>
<CENTER>0000:0404</CENTER></TD>
<TD>COM3's Base Address</TD></TR>
<TR>
<TD>
<CENTER>0000:0406</CENTER></TD>
<TD>COM4's Base Address</TD></TR></TBODY></TABLE><FONT size=-1>Table 4 -
COM Port Addresses in the BIOS Data Area;</FONT></CENTER>
<P>The above table shows the address at which we can find the
Communications (COM) ports addresses in the BIOS Data Area. Each address
will take up 2 bytes. The following sample program in C, shows how you
can read these locations to obtain the addresses of your communications
ports. </P>
<UL><PRE>#include <stdio.h>
#include <dos.h>
void main(void)
{
unsigned int far *ptraddr; /* Pointer to location of Port Addresses */
unsigned int address; /* Address of Port */
int a;
ptraddr=(unsigned int far *)0x00000400;
for (a = 0; a < 4; a++)
{
address = *ptraddr;
if (address == 0)
printf("No port found for COM%d \n",a+1);
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -