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

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 17
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 9
Interfacing the Standard Parallel Port http://www.senet.com.au/~cpeacock
Interfacing the Standard Parallel Port Page 10
then it may be unnecessary. If however you don’t bother and your device is connected to the Parallel
Port before your software has a chance to initialize then you may encounter problems.
Another problem to be aware of is the pull up resistors on the control port. The average pull-
up resistor is 4.7k. In order to pull the line low, your device will need to sink 1mA, which some low
powered devices may struggle to do. Now what happens if I suggest that some ports have 1K pull up
resistors? Yes, there are such cards. Your device now has to sink 5mA. More reason to use the open
collector inverters.
Open collector inverters were chosen over open collector buffers as they are more popular, and
thus easier to obtain. There is no reason, however why you can’t use them. Another possibility is to
use transistors.
The input, D3 is connected via the inverter to Select Printer. Select Printer just happens to be
bit 3 of the control port. D2, D1 & D0 are connected to Init, Auto linefeed and strobe, respectively to
make up the lower nibble. Now this is done, all we have to do is assemble the byte using software.
The first thing we must do is to write xxxx0100 to the Control Port. This places all the control port
lines high, so they can be pulled down to input data.
outportb(CONTROL, inportb(CONTROL) & 0xF0 | 0x04);
Now that this is done, we can read the most significant nibble. This just happens to be the
most significant nibble of the status port. As we are only interested in the MSnibble we will AND the
results with 0xF0, so that the LSnibble is clear. Busy is hardware inverted, but we won’t worry about
it now. Once the two bytes are constructed, we can kill two birds with one stone by toggling Busy and
Init at the same time.
a = (inportb(STATUS) & 0xF0); /* Read MSnibble */
We can now read the LSnibble. This just happens to be LSnibble of the control port - How
convenient! This time we are not interested with the MSnibble of the port, thus we AND the result
with 0x0F to clear the MSnibble. Once this is done, it is time to combine the two bytes together. This
is done by OR’ing the two bytes. This now leaves us with one byte, however we are not finished yet.
Bits 2 and 7 are inverted. This is overcome by XOR’ing the byte with 0x84, which toggles the two
bits.
a = a |(inportb(CONTROL) & 0x0F); /* Read LSnibble */
a = a ^ 0x84; /* Toggle Bit 2 & 7 */
Note: Some control ports are not open collector, but have totem pole outputs. This is
also the case with EPP and ECP Ports. Normally when you place a Parallel Port in ECP or EPP
mode, the control port becomes totem pole outputs only. Now what happens if you connect your
device to the Parallel Port in this mode? Therefore, in the interest of portability I recommend
using the next circuit, reading a nibble at a time.
Vedere la pagina 9
1 2 ... 5 6 7 8 9 10 11 12 13 14 15 16 17

Commenti su questo manuale

Nessun commento