Serial Port Programming
ZXNet echo conference «code.zx»
From 500:812/22.01 → To All 7 May 1998
├┤i All!
Can anyone tell me how to deal with Serial Port?
I mean Hayes. According to the Kondratieff scheme. There's whole
8 ports, but as I understand only 4 are used.
I found out that there should be the following ports or signals:
Transmit Data, Receive Data, Ready To Send, Clear To Send,
Data Set Ready, Carrier Detect, Data Terminal Count, Ring Indicator.
Total: 8 pieces. And what to do with them, or rather, where to get them?
And how to exchange data with the modem?
Wi7h be57 Wi5he5, FK0.
-+- SMM version 1.08
From Michael Kondratyev → To Kirill Frolov 1 June 1998
Hi Kirill,
In a message of to All (), you wrote:
KF> Kто мне может подсказать как с Serial Port разбираться ?
вот немножко об этом:
====================
In the following chart, pb+n is one of 3f8H+n, 2f8H+n, 3e8H+n, 2e8H+n,
depending upon the port. For instance, for COM1, pb+3=3fbH.
Port Description
▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
pb+0 Write: transmitter holding register. 8 bits of character to be sent.
Read: receiver buffer register. 8 bits of character received.
Write: (if DLAB=1) divisor latch low byte Baud Divisor▐▌Baud Divisor
After OUT pb+3,80H this port holds ▀▀▀▀ ▀▀▀▀▀▀▀▐▌▀▀▀▀ ▀▀▀▀▀▀▀
the low byte of the clock divisor 110 1040▐▌1200 96
which, together with the high byte 150 768 ▐▌2400 48
(port pb+1) constitute 16-bit value 300 384 ▐▌4800 24
that sets the baud rate as shown: 600 192 ▐▌9600 12
──── ───────────────────────────────────────────────────────────────────────
pb+1 Write: divisor latch high byte (when DLAB=1; i.e., after OUT pb+3,80H)
Write: interrupt enable register
╓7┬6┬5┬4┬3┬2┬1┬0╖
║0 0 0 0│ │ │ │ ║
╙─┴─┴─┴─┴╥┴╥┴╥┴╥╜ bit
║ ║ ║ ╚═. 0: 1=enable interrupt when rec'd data is available ║ ║ ╚═══. 1: 1=enable interrupt when transmit buffer is empty
║ ╚═════. 2: 1=enable int on rec'r line status (err or break)
╚═══════. 3: 1=enable int on modem status (CTS,DSR,RI,RLSD)
──── ───────────────────────────────────────────────────────────────────────
pb+2 Read: interrupt identification reg. When an interrupt occurs, read
this register to find what caused it.
╓7┬6┬5┬4┬3┬2┬1┬0╖
║ │0 0│ │ │ ║
╙─┴─┴─┴─┴╥┴─┴─┴╥╜ bit
╚╦╝ ║ ╚╦╝ ╚═. 0: 1=no interrupt pending; can be used in polling
║ ║ ╚════.1-2: 00=receiver line status interrupt. Occurs on:
║ ║ overrun, parity, or framing error, or break
║ ║ Reset by reading line status (port pb+5)
║ ║ 01=transmitter buffer empty
║ ║ Reset by writing transmitter buffer (pb+0)
║ ║ 10=received data available
║ ║ Reset by reading receiver buffer (port pb+0)
║ ║ 11=modem status. Occurs upon:
║ ║ Clear To Send, Data Set Ready, Ring Ind, or
║ ║ Rec'd Line Signal Detect.
║ ║ Reset by reading modem status (port pb+6).
║ ╚═══════. 3: (16550 UARTs) 1=Receiver FIFO time-out
╚══════════════.6-7: (16550 UARTs) 00=FIFOs disabled (or old 8250)
11=FIFOs enabled
01=FIFOs enabled and DMA mode
Write: (16550 UARTs) FIFO control register (write only)
╓7┬6┬5┬4┬3┬2┬1┬0╖
║ │0 0│ │ │ │ ║
╙─┴─┴─┴─┴╥┴╥┴╥┴╥╜ bit
╚╦╝ ║ ║ ║ ╚═. 0: 1=enable FIFO mode
║ ║ ║ ╚═══. 1: 1=clear receiver FIFO
║ ║ ╚═════. 2: 1=clear transmit FIFO
║ ╚═══════. 3: DMA mode select
╚══════════════.6-7: FIFO interrupt triggger level: 00=1 byte;
01=four bytes; 10=8 bytes; 11=16 bytes
──── ───────────────────────────────────────────────────────────────────────
pb+3 Read/Write: line control register
╓7┬6┬5┬4┬3┬2┬1┬0╖
║ │ │ │par│s│len║
╙╥┴╥┴╥┴─┴─┴╥┴─┴─╜ bit
║ ║ ║ ╚╦╝ ║ ╚═╩═. 0-1: word length: 00=5, 01=6, 10=7, 11=8
║ ║ ║ ║ ╚═════. 2: stop bits: 0=1,1=2 (some oddball exceptions)
║ ║ ║ ╚══════. 3-4: parity: x0=None, 01=Odd, 11=Even
║ ║ ╚═══════════. 5: stuck parity (not used by BIOS)
║ ╚═════════════. 6: enable break control. 1=start sending 0s (spcs)
╚═══════════════. 7: DLAB (Divisor Latch Access Bit) Determines mode
of ports pb+1 and pb+2. 1=set baud, 0=normal
──── ───────────────────────────────────────────────────────────────────────
pb+4 Write: modem control register
╓7┬6┬5┬4┬3┬2┬1┬0╖
║0 0 0│ │ │ │ │ ║
╙─┴─┴─┴╥┴╥┴╥┴╥┴╥╜ bit
║ ║ ║ ║ ╚═. 0: 1=activate -DTR (-data trmnl rdy), 0=deactivate
║ ║ ║ ╚═══. 1: 1=activate -RTS (-request to send), 0=deactivate
║ ║ ╚═════. 2: 1=activate -OUT1 (spare, user-designated output)
║ ╚═══════. 3: 1=activate -OUT2
╚═════════. 4: 1=activate loopback for diagnostic testing
──── ───────────────────────────────────────────────────────────────────────
pb+5 Read: line status register
╓7┬6┬5┬4┬3┬2┬1┬0╖
║ │ │ │ │ │ │ │ ║ Note: bits 1-4 cause interrupt if enabled (pb+1)
╙╥┴╥┴╥┴╥┴╥┴╥┴╥┴╥╜ bit
║ ║ ║ ║ ║ ║ ║ ╚. 0: 1=data ready (DR). Reset by reading recv'r buffer
║ ║ ║ ║ ║ ║ ╚══. 1: 1=overrun error (OE). Previous character is lost
║ ║ ║ ║ ║ ╚════. 2: 1=parity error (PE). Reset by reading line status
║ ║ ║ ║ ╚══════. 3: 1=framing error (FE). Bad stop bit in character
║ ║ ║ ╚════════. 4: 1=break indicated (BI). Sustained space received
║ ║ ╚══════════. 5: 1=transmitter holding register empty. OK to send
║ ╚════════════. 6: 1=transmitter empty. No data being processed.
╚══════════════. 7: (16450 UARTs) 1=Receiver FIFO error
──── ───────────────────────────────────────────────────────────────────────
pb+6 Read: modem status register
╓7┬6┬5┬4┬3┬2┬1┬0╖
║ │ │ │ │ │ │ │ ║ Note: bits 0-3 cause an interrupt if enabled (pb+1)
╙╥┴╥┴╥┴╥┴╥┴╥┴╥┴╥╜ bit
║ ║ ║ ║ ║ ║ ║ ╚═. 0: 1=Delta Clear To Send (DCTS) has changed state
║ ║ ║ ║ ║ ║ ╚═══. 1: 1=Delta Data Set Ready (DDSR) has changed state
║ ║ ║ ║ ║ ╚═════. 2: 1=Trailing Edge Ring Indicator (TERI) is active
║ ║ ║ ║ ╚═══════. 3: 1=Delta Data Carrier Detect (DDCD) has changed
║ ║ ║ ╚═════════. 4: 1=Clear To Send (CTS) is active
║ ║ ╚═══════════. 5: 1=Data Set Ready (DSR) is active
║ ╚═════════════. 6: 1=Ring Indicator (RI) is active
╚═══════════════. 7: 1=Data Carrier Detect (DCD) is active
──── ───────────────────────────────────────────────────────────────────────
====================
для моей схемы адpеса будут соответственно pb+?? -> 0x??EF
KF> Я имею в виду хайес. По кондратьевской схеме. Там целых
KF> 8 портов, но как я понял используются только 4.
используются вpоде бы больше четыpех.
KF> Я выясил, что должены быть следующие порты или сигналы:
KF> Transmit Data, Receive Data, Ready To Send, Clear To Send, KF> Data Set Ready, Carrier Detect, Data Terminal Count, Ring Indicator.
KF> Total: 8 pieces. And what to do with them, or rather, where to get them?
these are not ports, but interface lines (simply speaking, the wires in the cord to the modem)
For internal execution, they are meant to be like mosquito eggs.
KF> And how to exchange data with the modem?
through the computer, of course. First, try separating the task of working with the port
from the higher-level task of working with abstract data streams.
Bye, Michael.