📄 rs232.txt
字号:
1.3 Register Summary (Continued)
REG 3 : Line Control Register (LCR)
RS-232 line parameters are selected by writing to this register.
bit 7 : DLAB = 0
bit 6 : BREAK on(1), off(0).
bits 5-3 : Parity None(000),ODD(001),EVEN(011),MARK(101),SPACE(111)
bit 2 : One stop bit(0), two stop bits(1).
bits 1-0 : Data bits = 5 (00), 6(01), 7(10), 8(11).
Parity Meaning
Odd The parity bit is 1 if the sum of the data bits is odd.
Even The parity bit is 1 id the sum of the data bits is even.
None There is no parity bit.
Mark The parity bit is always set to 0.
Space The parity bit is always set to 1.
When the Divisor Latch Access Bit (DLAB) is 1, registers 0 and 1
become the LS and MS bytes of the Baud Rate Divisor registers.
The baud rate is computed as (115200 / BaudRateDivisor). Thus,
common baud rates correspond to divisors as follows:
Baud Divisor Baud Divisor Baud Divisor
300 0180 4800 0018 38400 0003
1200 0060 9600 000C 57600 0002
2400 0030 19200 0006 115200 0001
NOTES:
(1) Must write BF hex to LCR before EFR [16650 ONLY] can be
accessed (see 16650 data sheet).
(2) Must set DLAB = 1 (80 hex) before 64 byte FIFO bit can be
accessed (see 16750 data sheet).
RS-232 Serial Communications Page 8
1.3 Register Summary (Continued)
REG 4 : Modem Control Register (MCR)
RTS, DTR, loopback testing, and General Purpose Outputs #1 and #2 are
controlled by the Modem Control register as follows:
bit 7 : Clock select. X1 (if 0), X4 (if 1). [16750 ONLY]
bit 6 : IR enable [16650 ONLY]
bit 5 : Interrupt type select [16650 ONLY] or
Flow control enable [16750 ONLY].
bit 4 : Enable local loopback.
bit 3 : Enable GP02. Necessary for UART interrupts.
bit 2 : Enable GP01.
bit 1 : Set / clear RTS.
bit 0 : Set / clear DTR.
REG 5 : Line Status Register (LSR)
Reading the Line Status register provides status information as
follows (1 for TRUE, 0 for FALSE) :
bit 7 : FIFO data error [16650 & 16750 ONLY].
bit 6 : Transmitter Empty.
bit 5 : Transmitter Buffer Empty (TBE).
bit 4 : BREAK detect.
bit 3 : Framing error.
bit 2 : Parity error.
bit 1 : Overrun error.
bit 0 : Data Ready.
RS-232 Serial Communications Page 9
1.3 Register Summary (Continued)
REG 6 : Modem Status Register (MSR)
Reading the Modem Status register provides the following status
information (1 for TRUE, 0 for FALSE) :
bit 7 : DCD status.
bit 6 : RI status.
bit 5 : DSR status.
bit 4 : CTS status.
bit 3 : Delta DCD status.
bit 2 : Delta RI status.
bit 1 : Delta DSR status.
bit 0 : Delta CTS status.
The delta bits (bits 0 through 3) are set whenever one of the status
bits (bits 4 through 7) changes (from 0 to 1 or from 1 to 0) since
the last time that the Modem Status register was read. Reading the
Modem Status register clears the delta bits.
REG 7 : Scratch Register
There is no function associated with register 7. It does not exist
in early versions of the 8250.
RS-232 Serial Communications Page 10
2.0 Modems
A modem is used to extend the distance over which you may
communicate. Without a modem, your RS-232 cable is limited to a
maximum of approximately 50 feet. But with a modem, you can
communicate literally around the world.
2.1 Modem Standards
Two modems can communicate over a telephone line only if they are
both using the same signaling frequencies and modulation, which are
determined by the the modem standards used. Modem standards can be
divided into three sets: (1) speed, (2) data compression used, and
(3) error control.
The Bell standards (103 & 212A) are those of AT&T. The CCITT (The
International Consultative Committee for Telephone and Telegraph)
standards are designated as 'V. '.
Speed
Bell 103 : 300 baud
Bell 212A : 1200 baud
V.21 : 300 baud
V.22bis : 1200 & 2400 baud
V.32 : 4800 & 9600 baud
V.32bis : 4800, 7200, 9600, 12000, and 14400 baud
V.34 : V.32bis plus 16800, 19200, 21600, 24000, 26400,
and 28800 baud.
V.34bis : V.34 plus 31200 and 33600 baud.
USR X2 : US Robotics 56KB standard (33.6 KB uploads).
K56flex : Rockwells 56KB standard (33.6 KB uploads).
V.90 : The new 56K standard.
Data Compression
MNP 5 : Microcom Networking Protocol (proprietary).
V.42bis : International data compression standard.
Error Control
MNP 2,3,4 : Three level error correction (public domain).
V.42 : International error correction standard.
RS-232 Serial Communications Page 11
2.2 Flow Control
With modems using data compression, the modem to modem connection
will run at various speeds depending on the quality of the line.
The computer to modem connection will be at a fixed baud rate.
Therefore, a protocol (flow control) is necessary to synchronize the
data flow between a modem and the computer to which it is connected.
Refer to your modem manual for information on flow control protocols
supported.
Two flow control protocols are used by most all modems which require
flow control. Software flow control is called 'XON/XOFF' (other
software flow control character pairs are defined but operate the
same as XON/XOFF) and hardware flow control is called 'RTS/CTS'. Most
modems which require flow control enable hardware flow control by
default.
In XON/XOFF (software) flow control, the computer suspends
transmitting data if it receives a XOFF character (13 hex) from the
modem, and continues transmitting when it receives a XON character
(11 hex). Similiarly, the computer can signal the modem not to send
any more data by transmitting a XOFF to it, and can tell the modem to
continue transmission be sending a XON.
In RTS/CTS (hardware) flow control, the RTS line is used by the
computer to signal the modem , while the CTS line is used by the
modem to signal the computer. The RTS line is set OFF by the
computer to tell the modem to suspend transmission, and set to ON to
tell the modem to continue transmission. The CTS line is set to OFF
by the modem to tell the computer to stop transmitting, and set to ON
to tell the computer to continue transmitting.
Given the choice, always choose hardware flow control over software
flow control so that all data transmission is transparent. If
hardware flow control is not the default (which it almost always is),
you should modify your modem initialization string to turn hardware
flow control on.
RS-232 Serial Communications Page 12
2.3 Modem Initialization
If an application uses a modem (as opposed to using a null modem
cable), then it should always send an initialization string to the
modem. Communication programs such as PROCOMM and TELIX always send
such a string automatically as soon as they start up.
The particular initialization string depends on the make of your
modem. For most modems, the following string (followed by a carriage
return) should work:
AT E1 S7=60 S11=60 V1 X1 Q0 S0=0
Recall that the modem must be in command mode in order to send AT
commands. To force command mode, send the character string "+-+"
(without the quotes), preceeded by 1 second of silence, and followed
by one second of silence.
Refer to your Modem User's Guide for a full discussion of these
commands. A brief description is as follows:
AT Modem attention command.
E1 Modem will echo what you send to it.
S7=60 Wait 60 seconds for carrier and/or dial tone.
S11=60 Use 60 milliseconds for tone dialing duration & spacing.
V1 Display result code as words (not numbers).
X1 Use the extended result message (CONNECT XXXX) set.
Q0 Modem displays result codes.
S0=0 Do not answer RING.
If the application will answer incoming calls, set the S0 register to
the ring on which to automatically answer.
Most modems can be set to the 'factory default' by transmitting
AT&F
RS-232 Serial Communications Page 13
3.0 Other Serial Devices
To be sure, the modem is the most common serial device. But there are
many other serial devices such as digitizing tablets, scanners,
digital cameras, numerical control machines, card readers, panel
displays, etc.
Some serial devices (such as modems) use hardware (RTS/CTS) flow
control, but DTR/DSR flow control and software (XON/XOFF) flow
control are also common.
If you are writing a program to communicate with a serial device,
keep in mind the following:
(1) Always set DTR and RTS. Many serial devices "play dead" if DTR
is not set.
(2) You may need to add a small time delay (0.25 sec) between
transmitted characters. This can be reduced or eliminated once
everything is working.
(3) Make sure that your receive buffer is sufficently large. You want
to avoid buffer overflow.
4.0 Shareware Libraries
MarshallSoft Computing develops serial communications libraries for
DOS (real and protected mode) and Windows (Windows 3.1, 95/98, and
NT) marketed as shareware.
There are specific libraries for C/C++, Delphi, Pascal (DOS only),
Visual Basic (Windows & DOS versions), and Power Basic.
WSC4C WIN C/C++ Windows Standard Comm Library for C/C++
WSC4D WIN Delphi Windows Standard Comm Library for Delphi
WSC4VB WIN Visual Basic Windows Standard Comm Library for VB
WSC4PB WIN Power Basic Windows Standard Comm Library for PBCC
PCL4W WIN C/C++ Personal Comm Library for Windows
PCLVBW WIN Visual Basic Personal Comm Library for C/C++
PCL4C DOS C/C++ Personal Comm Library for C/C++
PCL4P DOS Pascal Personal Comm Library for Pascal
PCL4VB DOS Visual Basic Personal Comm Library for Visual Basic
PCL4PB DOS Power Basic Personal Comm Library for Power Basic
Our libraries have also been sucessfully used from Excel, Access,
FoxPro, PowerBuilder, Clarion, dBase, Fortran, and Cobol.
All shareware can be found on both the MarshallSoft BBS
(256-880-9748) upon request and on the Internet at:
ftp://ftp.marshallsoft.com/marshallsoft
http://www.marshallsoft.com/download.htm
Better yet, visit our web site and take a look around.
RS-232 Serial Communications Page 14
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -