The parallel port - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

The parallel port

Description:

Spring 2003. ICOM 4206 parallel port example. The parallel port. Used to connect fairly high-speed devices. An obsolescent standard has been enhanced ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 12
Provided by: joselop
Category:

less

Transcript and Presenter's Notes

Title: The parallel port


1
The parallel port
  • Used to connect fairly high-speed devices
  • An obsolescent standard has been enhanced
  • Programming methods
  • Access from other programs

2
Used to connect fairly high-speed devices
  • Original standard (SPP)
  • Unidirectional data 8 bits wide
  • Bidirectional control/status
  • TTL electrical standard
  • Could handle 0.5 MB/sec
  • Revised versions (IEEE 1284)
  • Bidirectional data - 8 bits wide
  • Hardware handshaking programming is simpler
  • Some versions of the standard are designed for
    multiple devices
  • Typical are scanners and external ZIP drives
  • Levels of capability are
  • SPP backward compatible
  • Byte mode bidirectional 8 bits wide
  • Nibble mode minimum characteristics 4 bits
    wide
  • Extended parallel port (EPP) bidirectional data
    transfer and addresses
  • Extended capability parallel port (ECP) EPP
    with data compression, FIFO, and command cycles

3
Pinout and signal functions
  • Data lines
  • Data 1-8
  • Status lines
  • NACK
  • BUSY
  • Paper error
  • Select
  • NFAULT
  • Control lines
  • STROBE
  • NAUTOFEED
  • NINIT
  • NSELECTLN
  • Comments
  • N before a name means the signal is negative
    true. This means the inactive state is negative,
    because of the standard NPN open-collector logic.
  • Register assignments SPP and EPP
  • 0H data out
  • 1H data in (really status)
  • 2H control
  • Register assignments EPP only
  • 3H EPP address register
  • 4-7H EPP data register for width up to 32 bits
  • Bit assignments
  • Status
  • 7 BUSY
  • 6 CLK
  • 5 NACK
  • 3 data available
  • Control
  • 5 data direction
  • 4 IRQ
  • 3 EPP active
  • 1 host busy
  • 0 host CLK

4
Logic of these modes
  • Normal output cycle
  • Nwrite set to low
  • Wait for NWAIT
  • Assert data
  • Assert strobe
  • Wait for WAIT
  • Deassert strobe
  • Modes
  • SPP done with program max transfer rate is
    150 KB/s
  • EPP done by BIOS and hardware of interface

5
Levels of programming
  • High-level language
  • Uses foundation class libraries or equivalent
  • DOS level
  • Uses DOS (int 21H) function calls
  • Function 05H print one character
  • Function 40H generic write file/device handle
    4 is PRN, you can use other by using function 3DH
    open file/device outputs a string
  • BIOS level
  • Uses BIOS (int 17H) calls usually DOS calls
    result in several of these
  • Function 00H output a character to the parallel
    port
  • Function 01H initialize parallel port and
    printer
  • Function 02H determine printer status
  • Register level
  • Independent even of BIOS uses the interface
    registers themselves

6
A C program for the parallel port
Int parallel_output(char character)
/ outputs one character and returns 1 or 2 /

/ if the output didnt work
/ Int I, code For (I0, IltTIMEOUT_COUNT,I)
/ waiting for printer not busy
/ Codeinp(0x379H) If ((code 0x80)0x80)
break If (ITIMEOUT_COUNT) return (1) /
printer remained busy / Outp(0x378H, (int)
character) / the real work,
outputting a character / Codeinp(0x37AH)
/ outputting a strobe,
with some delay / Codecode 0x01 Outp(0x37A,co
de) For (I0,IltSTROBE_WAIT,I) /
dropping the strobe again / Codeinp(0x37AH) Cod
ecode 0xFE Outp(0x37A,code) For
(I0,IltTIMEOUT_COUNT,I) / waiting for
the printer to acknowledge / Codeinp(0x379) If
((code 0x040) 0x00) break If (I
TIMEOUT_COUNT) return (2) / different error
code, printer never ACKed / Return (0)
7
Translating this program in class
  • You get to do this
  • Interpreting the C
  • What status bits are what
  • Little code segments to do each job
  • Loops for the timeouts and waits
  • Bit fiddles for the waits on status bits and
    asserting control bits
  • Detecting error conditions
  • Saving environment as needed

8
Making DOS and BIOS calls
  • Printer status byte bits
  • 7 ready
  • 6 - acknowledge
  • 5 out of paper
  • 4 printer on line
  • 3 Printer I/O error
  • 2,1 reserved
  • 0 timeout occurred
  • DOS function 05h specification send a character
    to LPT1
  • AH 05H (function 5 of int 21H)
  • DL ascii code of the character to be printed
  • Calling it
  • MOV AH,05H calling function 5
  • MOV DL, CHAR the character
  • INT 21H
  • Sensing status
  • JC handle-error

9
A few other DOS calls
  • DOS function 02h specification send a character
    to STDOUT
  • AH 02H (function 2 of int 21H)
  • DL ascii code of the character to be printed
  • DOS function 01h specification Read the
    keyboard
  • AH 01H (function 1 of int 21H)
  • Returns - AL ascii code of the character read
  • Note if this returns 0, the function must be
    called again to read the scancode
  • DOS function 09h specification send a string to
    STDOUT
  • AH 09H (function 9 of int 21H)
  • DS DX pointer to a zero-terminated string to
    be printed
  • DOS function 0Ah specification read the
    keyboard buffer (one line)
  • AH 0AH (function 10 of int 21H)
  • DS DX pointer to keyboard input buffer you
    allocate, DOS fills first byte is buffer size
    (you supply this), second byte is number of
    characters filled (DOS fills this), the rest is
    the string, followed by an ODH (newline)
  • DOS function 4Ah specification Return to DOS
  • AH 4AH (function 4A of int 21H)

10
Example of simple I/O designUsing an 8255
parallel port to make an SPP
  • Back to SPP standard
  • Requirements
  • Perform output using software handshake
  • Sense and report error conditions
  • Provide all data, control and status signals
  • Interrupt when device is ready (needed for slow
    printers)
  • If possible, meet SPP register standards (from
    previous slide)
  • Possible solutions
  • Data lines on port A
  • (note, this is register 0 matches standard)
  • Control lines on port C
  • This allows bit-setting to be used if desired
  • (note, this is register 2 matches standard)
  • Status lines on port B
  • Port B is suitable for reading status
  • (note, this is register 1 matches standard)

11
Pin assignments Centronics standard
Write a Comment
User Comments (0)
About PowerShow.com