RSS Feed Email Facebook Twitter Stumbleupon Google Bookmark

Controlling the PC Parallel Port

The standard PC printer port is handy for testing and controlling devices. It provides an easy way to implement a small amount of digital I/O. I like to use to during initial development of a product -- before the "real" hardware is ready, I can dummy up a circuit using the printer port, and thus get started testing my software.

This source code module provides the low-level control of the port, implementing code to control 12 outputs and read 5 inputs.

This code was written for Borland C/C++ v3.1, but you should be able to adapt it for other compilers. You can view the source code online, or download an archive ( that contains PRN_IO.C and PRN_IO.H. To use the module in your program, simply #include PRN_IO.H from wherever you need to call the functions, and compile and link PRN_IO.C into your program.

The following tables list the details of how the software interfaces to hardware port. Refer to the source code itself for more information, or check out one of the links at the end of this page.

Printer Port Addresses
Printer PortBase Address
LPT10x0378 or 0x03BC
LPT20x0278 or 0x0378

Printer Port Registers
Register NameAddress
Data RegisterBase + 0x00
Status RegisterBase + 0x01
Control RegisterBase + 0x02

Data Register Bit Definitions
7 (MSB)D701
0 (LSB)D001

Status Register Bit Definitions
7 (MSB)BusyBusyNot Busy
5Paper StatusNo PaperPaper
4Selection StatusNot SelectedSelected
3Error StatusNo ErrorError
2Not Used01
1Not Used01
0 (LSB)Not Used01

Control Register Bit Definitions
7 (MSB)Not Used01
6Not Used01
5Not Used01
4Interrupt ControlInterrupts DisabledInterrupts Enabled
3SelectSelectedNot Selected
1Auto FeedTrueFalse
0 (LSB)Strobe (Active-Low)TrueFalse

Source Code Implementation Notes:

  • The code is written to use LPT1 at 0x0378; change it if you need to
  • The code doesn't attempt to use interrupts
  • The parallel port is also capable of enhanced modes (see the links below), but this code doesn't attempt to use them
  • This code assumes that the port is configured as a "standard" or "normal" port; configuring the port for EPP or ECP modes may or may not work

Parallel Port Books:

Prices shown are accurate as of Nov 06, 2015 09:38am CST. Please follow the links for current pricing.

Parallel Port Specs And Info:

Parallel Port Drivers:

blog comments powered by Disqus