B&B Electronics Parallel Printer Card PIOC Manuale Utente Pagina 12

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 17
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 11
Interfacing the Standard Parallel Port http://www.senet.com.au/~cpeacock
Interfacing the Standard Parallel Port Page 12
outportb(CONTROL, inportb(CONTROL) & 0xFE); /* Select High Nibble (B)*/
a = a |(inportb(STATUS) & 0xF0); /* Read High Nibble */
byte = byte ^ 0x88;
The last line toggles two inverted bits which were read in on the Busy line. It may be necessary to add
delays in the process, if the incorrect results are being returned.
Using the Parallel Port's IRQ
The Parallel Port's interrupt request is not used for printing under DOS or Windows. Early
versions of OS-2 used them, but don't anymore. Interrupts are good when interfacing monitoring
devices such as high temp alarms etc, where you don't know when it is going to be activated. It's more
efficient to have an interrupt request rather than have the software poll the ports regularly to see if
something has changed. This is even more noticeable if you are using your computer for other tasks,
such as with a multitasking operating system.
The Parallel Port's interrupt request is normally IRQ5 or IRQ7 but may be something else if
these are in use. It may also be possible that the interrupts are totally disabled on the card, if the card
was only used for printing. The Parallel Port interrupt can be disabled and enabled using bit 4 of the
control register, Enable IRQ Via Ack Line. Once enabled, an interrupt will occur upon a low to high
transition (rising edge) of the nACK. However like always, some cards may trigger the interrupt on
the high to low transition.
The following code is an Interrupt Polarity Tester, which serves as two things. It will
determine which polarity your Parallel Port interrupt is, while also giving you an example for how to
use the Parallel Port’s Interrupt. It checks if your interrupt is generated on the rising or falling edge of
the nACK line. To use the program simply wire one of the Data lines (Pins 2 to 9) to the Ack Pin (Pin
10). The easiest way to do this is to bridge some solder from DATA7 (Pin 9) to ACK (Pin 10) on a
male DB25 connector.
/* Parallel Port Interrupt Polarity Tester */
/* 2nd February 1998 */
/* Copyright 1997 Craig Peacock */
/* WWW - http://www.senet.com.au/~cpeacock */
/* Email - [email protected] */
#include <dos.h>
#define PORTADDRESS 0x378 /* Enter Your Port Address Here */
#define IRQ 7 /* IRQ Here */
#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2
#define PIC1 0x20
#define PIC2 0xA0
int interflag; /* Interrupt Flag */
int picaddr; /* Programmable Interrupt Controller (PIC) Base Address */
Vedere la pagina 11
1 2 ... 7 8 9 10 11 12 13 14 15 16 17

Commenti su questo manuale

Nessun commento