home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
dev
/
cmanual-3.0.lha
/
CManual
/
Devices
/
SerialDevice
/
SerialDevice.doc
< prev
next >
Wrap
Text File
|
1993-10-12
|
64KB
|
1,839 lines
7 SERIAL DEVICE
7.1 INTRODUCTION
All Amiga models have a serial port to which you can connect
external devices like a modem, scanner or a printer with a
serial interface. Data can be sent in both directions, in
several different formats, like seven or eight bits, with
or without error checking etc.
On the Amiga the serial port consists of a 25 pin connector,
and can communicate with baud rate up to 32250. It is the
custom chip called "Paula" which contains a Universal
Asynchronous Receiver/Transmitter (UART) that takes care of
all serial data transmissions. The chip itself can manage
up to one million bits per second, but at that speed the data
buffer would be filled before the system had time to react,
and normal cables can not manage to transmit more than
100,000 - 200,000 bits per second.
Baud rates between 1200 and 9600 are in most cases more than
sufficient, and at that speed the computer will still be able
to multitask properly.
7.2 THE SERIAL PORT
The serial port sends and receives data in streams of bits.
In theory only one physical wire would therefore be required,
but there have been several extra cables added to send and
receive special information as well as to supply external
devices with power (+12V) and so on.
Since all data is sent bit by bit, and not as with the parallel
port which sends one byte (8 bits) each time, it is rather
slow. (Well at least not as fast as the parallel port, which
is fully documented in the next chapter.) However, since
some applications only works with one line, for example
the modems which are connected to the telephone system,
serial communication is easier to handle. Serial cables are
also much cheaper.
Although only one line is required there is a whole 25-pin
connector on the Amiga. Normal applications like a modem, or
a scanner only needs some of the lines, but since there are
so many possible lines to use, a lot of special equipment can
be connected to the serial port. (See illustration "RS-232".)
7.2.1 BYTE TO BITS AND VICE VERSA
Since the serial device only sends a stream of bits, a special
chip has to convert the data (bytes) to bits (8). The character
"A" would for example be transformed to 01000001 and "B" to
01000010 and so on. Of course the chip must also be able to
do the opposite, to convert an incoming stream of bits to
bytes.
--------
A (64) <- | | <- 01000001 (Receiving data)
| UART |
D (68) -> | | -> 01000100 (Transmitting data)
--------
The special chip that takes care of this is the "Universal
Asynchronous Receiver/Transmitter" usually referred to as
"UART". (See illustration "UART") Luckily we do not need to
bother too much about this. However, it is good to know what
is actually happening.
7.2.2 PIN ASSIGNMENT
The Amiga's serial port is a 25-pin D-female-type connector.
Below is an almost complete list of the pin assignment,
together with a short description. (See illustration "RS-232".)
Pin Amiga RS232 HAYES Direction Type Description
-------------------------------------------------------------------
1 SHIELD GND GND - Standard Ground
2 TXD TXD TXD Out Standard Transmit data
3 RXD RXD RXD In Standard Receive data
4 RTS RTS x - Out Standard Request to send
5 CTS CTS x CTS In Standard Clear to send
6 DSR DSR x DSR In Standard Data set ready
7 GND GND GND - Standard Signal ground
8 DCD DCD DCD In Standard Carrier detect
9 +12V - - - Amiga +12 Volt
10 -12V - - - Amiga -12 Volt
11 AUDO - - Out Amiga Audio output
12 - S.DS SI + - Speed indicate
13 S.CTS - + - RS232 code
14 - S.TXD - + - RS232 code
15 - TXC - + - RS232 code
16 - S.RXD - + - RS232 code
17 - RXC - + - RS232 code
18 AUDI - - In Amiga Audio in (not used)
19 - S.RTS - + - RS
20 DTR DTR x DTR Out Standard Data terminal ready
21 - SQD - - * (A1000 +5V)
22 RI RI RI In Standard Ring indicator
23 - SS - - * (A1000 +12V)
24 - TXC1 - - - 3.58 MHz clock
25 - - - - Amiga Reset (A1000)
(x) Used only if you have set the "seven-wire flag". Se below
for more information.
WARNING! Pin 21 and 23 are connected to the power supply on
the old Amiga 1000s (+5V and +12V). On all other models the
power is sent through pin 9 and 10. Be careful with this if
you intend to make serial cables! We do not want to burn the
user's external devices, do we?
7.2.3 THE DATA STREAM
Since all data is sent and received in a stream of bits, the
UART chip needs to know when each new byte (set of 8 bits) is
coming in. To make this possible, following rules have been
stated: (See illustration "Serial Bits".)
1. When no data is sent, a mark bit (1) is sent over and over.
2. Just before a byte is sent, a start bit (0) is transmitted.
The receiver will now know that seven or eight bits (depends
on what type of device it is) of data will be received.
3. An optional "parity" bit will come directly after the
data bits. The parity bit is used for error checking. The
receiver may use "even", "odd" or no parity at all. If
the receiver is using even parity, the sender should set
the parity bit to 1 if the remainder of all data bits
divided by two is 0, else the parity bit should be set to
0. If the receiver is using odd parity, the sender should
set the parity bit to 0 if the remainder of all data bits
divided by two is 0, else the parity bit should be set to
1. If the receiver does not use parity checking, either
set the parity bit to 0 or do not send any parity bit at
all.
4. Finally we need to send one (or two) stop bit(s) to tell
the receiver that the last data bit has been sent.
...1 0 0 0 1 0 0 0 1 0 1 0 0 0 1... -> -> ->
..._ _ _ _ _...
\_____/ \_____/ \_/ \_____/
^ ^
| ^ ^ ^ 8 7 6 5 4 3 2 1 0 ^ |
| | | | <-- Data bits --> | Mark bit(s)
| | | | (7 or 8 bits) |
| | | | Start bit
| | | |
| \ / Parity bit (We use even parity, hence 0)
| |
| One or two stop bits
|
Mark bit(s)
Even parity: The sum of the data bits is divided by two, and
if the remainder is 0, the parity bit should be
set to 1. If the remainder is 1, the parity bit
should be set to 0.
10100110 = 4 bits are set. 4/2 remainder = 0 -> parity = 1
01110110 = 5 bits are set. 5/2 remainder = 1 -> parity = 0
Odd parity: The sum of the data bits is divided by two, and
if the remainder is 0, the parity bit should be
set to 0. If the remainder is 1, the parity bit
should be set to 1.
10100110 = 4 bits are set. 4/2 remainder = 0 -> parity = 0
01110110 = 5 bits are set. 5/2 remainder = 1 -> parity = 1
The nice thing about the serial device is that we do not need
to bother about this. (So why did I write it?) You only have
to tell the device if you want to use parity, and if so if it
should use even (default) or odd parity. You should also tell
the serial device if you want to send seven or eight data bits,
and one or two stop bits. Once you have told the device what
you want, you do not need to think about it any more.
7.3 THE SERIAL DEVICE
The Serial Port is a limited resource it that sense that there
exist (normally) only one port. There may however be several
programs running at the same time which all want to use the
serial port. To make this possi