>How can one read input from a parallel port?
>It seems that BIOS does not support it.
>Could anyone point to me to the right source?
>Thank you very much.
Actually it is very much BIOS supported... See my
prior post in reposnse to Shrijay Dalal's post.
+------Joseph Zbiciak-------+
| | The human mind ordinarily operates
|im1...@cegt201.bradley.edu| at only ten percent of its capacity
| | - the rest is overhead
+--------DISCLAIMER:--------+ for the operating system.
-- It's all right... |
| I didn't do it! --
(Disclamer 11 of 11) (Signature 166 of 485)
Once again...
Disclaimer: *** NO WARRANTY AT ALL ***
But the info given is correct.
----8<--------8<--------8<--------8<--------8<--------8<--------8<----
Some short notes on the printer port of the PC
==============================================
Base address
------------
Normally, this table is valid.
LPT1 378h or 3BCh
LPT2 278h or 378h
LPT3 278h
The base address can be read from the BIOS table (cut from Ralf Brown's
interrupt list):
Format of BIOS Data Segment at segment 40h:
Offset Size Description
08h WORD Base I/O address of 1st parallel I/O port, zero if none
0Ah WORD Base I/O address of 2nd parallel I/O port, zero if none
0Ch WORD Base I/O address of 3rd parallel I/O port, zero if none
0Eh WORD [non-PS] Base I/O address of 4th parallel I/O port, zero if none
[PS] Segment of Extended BIOS Data Segment
Note: Above fields filled in turn by POST as it finds
parallel ports. POST never leaves gaps. DOS and BIOS
parallel device numbers may de redefined by re-assigning
these fields.
Registers
---------
Base + 0 Data Register (r/w)
Base + 1 Status Register (r/o)
Base + 2 Control Register (r/w)
Although you may read from Base+0 and Base+2, the values are *not* dependent
on *any* external signals, but represent data that has been written to these
registers previously. The only register that allows input is the Status
Register. On *some* IBM ATs, you *may* input data through Base+0, but this
will only work with very few computers (and none of mine (I've got lots of
them)).
Base + 0:
Bits 0-7 Data being output to pins 2-9 (non-inverting).
Base + 1:
Bits 0-2 unused
Bit 3 "Error"; if 0, paper is out, the printer is off-line or an
error occurred.
Indicates the level of pin 15 (non-inv.)
Bit 4 "Selected" if 1; most printers tie this signal high
Indicates the level of pin 13 (non-inv.)
Bit 5 "Paper Out" if 1
Indicates the level of pin 12 (non-inv.)
Bit 6 "Acknowledge" if 0 (normally for about 10ms)
Indicates the level of pin 10 (non-inv.)
Bit 7 "Busy" if 0; printing is in progress or sth. like that
Indicates the level of pin 11 (inverted!)
Base + 2:
Bit 0 "Data Strobe"; set this to 1 for at least 1 microsecond to
signal the printer that there is new data on the lines
Controls pin 1; signal is inverted.
Bit 1 "Autofeed XT"; if set, a LF is added to each CR by the
printer. Controls pin 14; signal is inverted.
Bit 2 "Init"; set this to 0 for at least 50us (Epson) to reset
the printer. Controls pin 16; signal is not inverted.
Bit 3 "Select input" (as seen by the printer); if 1, the codes
"DC1" and "DC3" can activate and deactivate the printer.
Controls pin 17. Signal is inverted.
Bit 4 if 1: "Acknowledge" generates interrupt 0Fh (no external
signal)
Bits 5-7 not used
Normal setting in a PC: ECh
How to input data using the printer port
----------------------------------------
*** There is no possibility to switch the data lines of the printer port
to input, except for some computers. Try writing FFh to Base+0, then short
one of the data lines to ground, input Base+0 and see if one of the bits is
0. If yes, you're lucky.
But there's a workaround: use a parallel-in-serial-out register, connect the
serial output to one of the status lines and the control pins (latch, clock)
to two of the data lines. Then give the appropriate signals to the register
by writing the correct values to the data register and read in the data
bit-wise through the status register. This is not very fast, but cheap.
Or, even better: use a multiplexer (74LS157) with four of the status lines
(those four that are non-inverting). Control it with one of the numerous
outputs.
How to do direct output to the printer
--------------------------------------
1. Write your data to Base+0.
2. Write 0Dh to Base+2.
3. Make sure there's a delay of at least one microsecond :-) (your code
will do that for you...)
4. Write 0Ch to Base+2.
5. Input from Base+1 and check if Bit 7 is 1. If not, wait for some time
but make sure you break the loop with "time out" if it takes too long.
6. ... and repeat this whole procedure as often as you like.
Pinout
------
1 Strobe
2-9 Data 0-7
10 Acknowledge
11 Busy
12 Paper out
13 Select (this is an input!)
14 Autofeed XT
15 Error
16 Init
17 Select Input (this is an output!, name as seen by the printer)
18-25 Ground
---->8-------->8-------->8-------->8-------->8-------->8-------->8----
--
----------------------------------------------------------------------
Christian Blum Co-maintainer of Gopher Project (Campus Info System)
ch...@phil15.uni-sb.de Point your client to 134.96.82.13
No, I'm not a student of philosophy! I study Electrical Engineering!
Hello Chris!
[ Skipped ]
CB> *** There is no possibility to switch the data lines of the printer port
CB> to input, except for some computers. Try writing FFh to Base+0, then short
CB> one of the data lines to ground, input Base+0 and see if one of the bits
CB> is 0. If yes, you're lucky.
Well..., if my computer h't "iron" ground... good by my parallel card
CB> But there's a workaround: use a parallel-in-serial-out register, connect
CB> the serial output to one of the status lines and the control pins (latch,
CB> clock) to two of the data lines. Then give the appropriate signals to the
CB> register by writing the correct values to the data register and read in
CB> the data bit-wise through the status register. This is not very fast, but
CB> cheap.
It's serious? If I connect one of pin my serial port (with +-12VC max) to one
of pin of parallel port (with +5VC max), I't more comment...
Good luck,
Pasha
---
* Origin: Plants is absent,atmosphere also,only robots lives there (2:467/21)
#Via Tesseract Corner GATE (2:467/2.100@FidoNet)