Article View: comp.os.msdos.programmer
Article #1025Re: Parallel port I/O (mostly O : -)
From: A Johnstone
Date: Wed, 19 Aug 1992 19:40
Date: Wed, 19 Aug 1992 19:40
89 lines
4545 bytes
4545 bytes
In article <1992Aug19.152509.18901@cs.ubc.ca>, yogi@cs.ubc.ca (Yossi Gil) writes:
<request for info on printer port programming deleted>
|>
|> I recall a byte article on this exact topic few years back. I think it
|> was about 5 or so. I also recal that the max baud rate you can get
|> is 4500. That is 4.5 KB/sec.
A bit of confusion here I think. Firstly baud rate is a term used in the
context of serial channels. It is named after Baudot, one of the pioneers of
telegraph communication. In, for instance RS-232, the baud rate is the number
of signal pulses sent per second. The data rate will be less than this because
some start and stop bits are required: hence 300 baud with eight data bits, one
start bit and one stop bit corresponds to a data rate of 30 bytes per second.
I've never seen baud rate used in the context of a parallel channel: assuming
fully parallel transfers I suppose the logical generalisation of the idea would
be the same as the word data rate which is as implied in Yossi's note.
A propos the original enquiry: it is very easy to send data out of the parallel
port under program control and you should be able to achieve far higher data
rates than 4.5KB/s with a decent PC. Here are the rough details:
The printer port pinout is:
1 OUT strobeL
2 OUT D0H
3 OUT D1H
4 OUT D2H
5 OUT D3H
6 OUT D4H
7 OUT D5H
8 OUT D6H
9 OUT D7H
10 IN ackL
11 IN busyH
12 IN paperoutL
13 IN selectH
14 OUT autofeedL
15 IN errorL
16 OUT resetL
17 OUT selectackL
18-25 GND
The signal names pertain to the Centronics standard and are irrelevant if all you
want to do is send data out. The trailing H and L characters indicate active Low
or active High polarity.
The signals are accessed via three registers:
I/O port address 0378H printer data register
D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0
I/O port address 037AH printer control register
x | x | x | enable int on ACK | select | reset | autofeed | strobe
I/O port address 0379H printer status register
busy | acknowledge | paperout | selectack | error | x | x| x
The x's above indicate bits that you should ignore on read or leave in their
original state on write. Don't just write zeroes because these bits are used on
some machines for other control purposes.
So the bottom line is that something like outportb(0x378,53) will cause decimal
53 to appear on the printer data lines, and x=inportb(0x379) will read the
present state of the input lines. The speed at which you can do this is limited
only by the speed of your bus and processor. Normally you will want to handshake
the data transfer with the external device, so you'll need to write the data,
assert one of the control lines by writing to port 037AH and then monitor one
of the inputs by polling address 0379H for a handshake signal. If you want to
avoid tying your machine up in a polling loop, use the acknowledge line on the
printer port for your external handshake and set bit 4 in the control register.
This will then trigger a printer interrupt every time the acknowledge line is
yanked, and you can then feed data out under interrupt control. For maximum
speed use polling. A grotty PC could probably manage at least 100Kbyte per second
A nice 486 running a tight loop out of internal cache RAM will go much faster.
There are other things you might want to know about, such as the fact that the
control outputs are actually open collector outputs and may be used as
bidirctional I/O lines, and that many manufacturers now do what should have been
done in the first place and allow input from the data lines too. Portables
commonly use this to allow fast parallel I/O to external floppy disks attached
to the printer port for instance. However, I think I've rambled on enough here,
so try that for starters.
Adrian
Technical Details
Message-ID:
<1992Aug19.194016.18379@csqx.cs.rhbnc.ac.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!daresbury!doc.ic.ac.uk!rhbnc!csqx.cs.rhbnc.ac.uk!adrianReferences:
<1992Aug19.135359.24909@bas-a.bcc.ac.uk> <1992Aug19.152509.18901@cs.ubc.ca>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!daresbury!doc.ic.ac.uk!rhbnc!csqx.cs.rhbnc.ac.uk!adrian From: adrian@csqx.cs.rhbnc.ac.uk (A Johnstone) Newsgroups: comp.os.msdos.programmer Subject: Re: Parallel port I/O (mostly O : -) Message-ID: <1992Aug19.194016.18379@csqx.cs.rhbnc.ac.uk> Date: 19 Aug 92 19:40:16 GMT References: <1992Aug19.135359.24909@bas-a.bcc.ac.uk> <1992Aug19.152509.18901@cs.ubc.ca> Sender: news@csqx.cs.rhbnc.ac.uk (USENET News System) Reply-To: adrian@csqx.cs.rhbnc.ac.uk (A Johnstone) Organization: Dept of Comp Sci, Royal Holloway & Bedford New College Uni London Lines: 89 Nntp-Posting-Host: csqx.cs.rhbnc.ac.uk