Connect with us

Printer Port

Discussion in 'Electronic Design' started by Wong, May 13, 2004.

Scroll to continue with content
  1. Wong

    Wong Guest

    Hi,
    Address of 378 is normally define for printer port, LPT.
    Then what is the purpose to use the address of 379, 37A ?
    I am confuse and hope someone can shed me a light. Thanks.
     
  2. Bill Vajk

    Bill Vajk Guest

    I often have more than one printer and printer port
    on a computer.
     
  3. Tim Kettring

    Tim Kettring Guest

    Wong answer LOL
     
  4. Bill Vajk

    Bill Vajk Guest

    Works for me.
     
  5. John G

    John G Guest

    Thanks.

    All these hardware addresses can be used by printer adapters
    and at boot time the Operating system checks to see which
    are present and allocates them to LPT1 then 2 then 3 as
    they are found.
     
  6. ---------------
    WRONGO! 378 is the Hex address of the data byte (D0-D7) on LPT port
    pins 2 thru 9. The ports 379 Hex and 37A Hex are the +1and +2 offset
    ports for LPT1 that control the other pins, 379 reads the pins
    10 thru 13 and 15 status bits (S7-S3) as inputs, and 37A writes to
    the pins 1, 14, 16, 17, the Control bits C0 thru C3.

    Now a few of these are inverted, and the control pins are open
    collector, so that they can be read back from the same address.

    Use this diagram to determine this:

    http://www.armory.com/~rstevew/Public/LPT/parallel.gif

    S7 and C3, C1, and C0 are inverted.

    The other alternate LPT2 and LPT3 addresses have base (Data byte)
    addresses starting at 278 Hex and 3BC hex, and each has two more
    +1 and +2 offset ports as well for their Status and Control pins.

    -Steve
     
  7. -------------
    No, the port base addresses are 378, 278, and 3BC Hex.

    The addresses 379 and 37A Hex are the other two addresses
    that are part of the LPT1 port at 378 Hex.

    -Steve
     
  8. When 378 is used as the data register for a printer port (LPT1), then 379 is
    usually a status register and 37A a control register.

    It is also posible to use more port-triples for added printers. 278-27A are
    commonly used for LPT2.
     
  9. John G

    John G Guest

    You are absolutly correct.
    It is so long since I needed to care about this I jumped to
    the wrong conclusion.
    But 378H will only be LPT1 if there is something there.
    If 278H is the hardware address of the only print adapter
    the it will become LPT1
    This may be rare but it did confuse many people long ago.
    (Remember DOS)
    The Monchrome and Print adapter had one address and the
    Print adapter had another.
     
  10. CFoley1064

    CFoley1064 Guest

    Subject: Printer Port
    The Lakeview Research website has great links to good descriptions of what you
    need. Also, you might want to look at Jan Axelson's "Parallel Port Complete",
    which is available from the website.

    http://www.lvr.com/parport.htm

    Good luck
    Chris
     
  11. Bill Vajk

    Bill Vajk Guest

    That's what I misread into the question. I guess I'll
    just have to go punish myslef. LOL
     
  12. In Bill Vajk typed:
    The second port would be at 278 to 27A. The first port is at 378 to
    37A. That's assuming it's an old-style port that uses 3 addresses. Of
    course ECP uses DMA and I don't know off-hand how many I/O addresses.
     
  13. In Wong typed:

    VIEW IN A FIXED-WIDTH FONT:


    378H-37fH Parallel Printer Adapter #1
    3bcH is base of MDPA
    278H is base of printer adapter #2
    378H Printer Data Latch.
    Write: send byte to printer
    Read: fetch last byte sent

    37aH Read/Write: Printer Controls
    +7-6-5-4-3-2-1-0+
    ¦0 0 0¦ ¦ ¦ ¦ ¦ ¦
    +---------------+ bit
    ¦ ¦ ¦ ¦ +- 0: +Strobe (pin 1) 1 when sending byte
    ¦ ¦ ¦ +--- 1: +AUTO LineFeed (pin 14) 1 causes LF after CR
    ¦ ¦ +----- 2: -INIT (pin 16) 0 resets the printer
    ¦ +------- 3: +SLCT IN (pin 17) 1 selects the
    printer
    +--------- 4: +IRQ Enable (hdwr INT when -ACK goes false)
    LPT1-IRQ 7 (INT 0fH)
    LPT2-IRQ 5 (INT 0dH)
    379H Read-only: Printer Status
    +7-6-5-4-3-2-1-0+
    ¦ ¦ ¦ ¦ ¦ ¦0 0 0¦
    +---------------+ bit
    ¦ ¦ ¦ ¦ +------- 3: -ERROR (pin 15) 0=printer signals an error
    ¦ ¦ ¦ +--------- 4: +SLCT (pin 13) 1=printer is selected
    ¦ ¦ +----------- 5: +PE (pin 12) 1=out of paper
    ¦ +------------- 6: -ACK (pin 10) 0=ready for next character
    +--------------- 7: -BUSY (pin 11) 0=busy or offline or error
     
  14. 379 hex is actually also a part of the par port (registers), for example
    bit 3 0x379 =pin 15 (ERROR) is there
    In the old day par port was a 8255 PPI IIRC.
    So a peek in the 8255 registers should show you something.
    But things did become more complicated when PPC, ECP capable ports came.

    If it makes any sense to you:
    #define LPT1_BASE_ADDR0x378
    #define LPT2_BASE_ADDR0x278
    #define LPT3_BASE_ADDR0x3BC

    /* Offsets from the base address for the various registers */
    #define STATUS_OFFSET0x01
    #define CONTROL_OFFSET0x02

    /* define ECP register offsets */
    #define ECP_DATA0x00/* Data Register*/
    #define ECP_A_FIFO0x00/* ECP Address FIFO*/
    #define ECP_DSR0x01/* Device Status Register*/
    #define ECP_DCR0x02/* Device Control Register*/
    #define ECP_C_FIFO0x400/* Compatiblity mode FIFO */
    #define ECP_D_FIFO0x400/* ECP Data FIFO*/
    #define ECP_T_FIFO0x400/* ECP Test FIFO*/
    #define ECP_CNFG_A0x400/* Config Register A*/
    #define ECP_CNFG_B0x401/* Config Register B*/
    #define ECP_ECR0x402/* Extended Control Reg.*/

    #define ECP_FIFO_SIZE16

    /* define some constants for used by the hardcoded functions */
    #define BASE_LPT1 LPT1_BASE_ADDR
    #define DATA_LPT1(LPT1_BASE_ADDR)
    #defineSTATUS_LPT1(LPT1_BASE_ADDR+STATUS_OFFSET)
    #defineCONTROL_LPT1(LPT1_BASE_ADDR+CONTROL_OFFSET)
    #defineDATA_FIFO_LPT1(LPT1_BASE_ADDR+ECP_D_FIFO)
    #defineECR_LPT1(LPT1_BASE_ADDR+ECP_ECR)

    #define BASE_LPT2 LPT2_BASE_ADDR
    #define DATA_LPT2(LPT2_BASE_ADDR)
    #defineSTATUS_LPT2(LPT2_BASE_ADDR+STATUS_OFFSET)
    #defineCONTROL_LPT2(LPT2_BASE_ADDR+CONTROL_OFFSET)
    #defineDATA_FIFO_LPT2(LPT2_BASE_ADDR+ECP_D_FIFO)
    #defineECR_LPT2(LPT2_BASE_ADDR+ECP_ECR)

    #define BASE_LPT3 LPT3_BASE_ADDR
    #define DATA_LPT3(LPT3_BASE_ADDR)
    #defineSTATUS_LPT3(LPT3_BASE_ADDR+STATUS_OFFSET)
    #defineCONTROL_LPT3(LPT3_BASE_ADDR+CONTROL_OFFSET)
    #defineDATA_FIFO_LPT3(LPT3_BASE_ADDR+ECP_D_FIFO)
    #defineECR_LPT3(LPT3_BASE_ADDR+ECP_ECR)


    #define WRITECTRL(portaddress,val)outb((BYTE )(val), (portaddress))
    #define READDATA(portaddress)(BYTE )inb((portaddress))
    #define READSTATUS(portaddress)(BYTE )inb((portaddress))


    /* the following define the bits within the ECR register */
    #define ECR_mode0xE0
    #define ECR_nErrIntrEn0x10
    #define ECR_dmaEn0x08
    #define ECR_serviceIntr0x04
    #define ECR_full0x02
    #define ECR_empty0x01

    #define ECP_STANDARD_MODE0x00
    #define ECP_PS2_MODE0x20
    #define ECP_FIFO_MODE0x40
    #define ECP_ECP_MODE0x60
    #define RESERVED_10x80
    #define RESERVED_20xA0
    #define ECP_TEST_MODE0xC0
    #define ECP_CNFG_MODE0xE0

    There is some info somehere on the Microsoft site about how ECP
    protocol works, but I forgot immediatly after writing some of the code...
    JP
     
  15. Wong

    Wong Guest

    Yes, I don't think this is correct. Someone answered me in another
    newgroup with the same wrong answer. Anyhow, thanks for the reply.
    Thank you.
     
  16. Wong

    Wong Guest

    Sound so simple to manage par port since I can have direct control
    over the signals. So if I have the following C code:
    outp(37A, 0x04); // Would this reset the printer ?

    data = inp (379); // Would this assign the status port signal level
    to 'data' ?
     
  17. budgie

    budgie Guest

    It is once you get to grips with the functions of each of the three registers.
    I make a practice of (Basic code, I don't speak C)

    OUT 37A, (INP(37A) AND 04)

    That way, whatever other bits are set/clear remain that way.

    Yes.
     
  18. ----------------
    Actually, the original LPT1 port base address on the PC was 3BC Hex,
    but it is only assigned LPT1 status in DOS/Win if it is found active,
    using a loopback data test, since it was only implemented on the early
    mono-text-only-printer cards, and mono-graphic-printer cards and
    Hercules cards and a few of the earliest higher level graphic cards.

    The second LPT2 was originally the 378 Hex addrsss, and the 278 Hex
    was the LPT3, but only if 3BC Hex was found and assigned to LPT1,
    and without 3BC Hex being found, then 378 Hex defaults to LPT1 and
    278 Hex defaults to LPT 2.

    -Steve
     
  19. ---------------
    No. The uses I have been discussing for the parallel port are totally
    disregarding its system role as a printer port.

    A reason to send 04 to that port might be to set the control outputs
    to a friendly state for printer initialization because of the
    inversions in that data byte.

    I never recall what use the printer puts that pin to, so I never care.
    Printers can pretty much take care of themselves. Re-init the driver
    and turn them off and on if they act weird.

    BUT!:
    Note that only bit that is not inverted is C2 or the "4's" bit, so
    that writing 04 Hex to it makes it active HI along with the rest.

    This enables external open-collectors to pull it LO so these pins
    can be used as alternate inputs and can be read back by a read from
    the address 37A Hex.

    That's something NO printer I know of uses. You can make the parallel
    port input a whole byte by that means. 5 status + 3 control.

    -Steve
     
  20. Rich Grise

    Rich Grise Guest

    Actually, they don't - that code clears them all! You want this:

    TEMP = INP(37A)
    TEMP = TEMP AND FB
    TEMP = TEMP OR (MYDATA AND 04)
    OUT 37A, TEMP

    It could all be written in one line, but that's too cryptic - when I
    go back and look at code a year later, I like to be able to read it. ;-)

    Cheers!
    Rich
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-