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

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 17
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 10
Interfacing the Standard Parallel Port http://www.senet.com.au/~cpeacock
Interfacing the Standard Parallel Port Page 11
Nibble Mode
Nibble mode is the preferred way of reading 8 bits of data without placing the port in reverse
mode and using the data lines. Nibble mode uses a Quad 2 line to 1 line multiplexer to read a nibble
of data at a time. Then it “switches” to the other nibble and reads its. Software can then be used to
construct the two nibbles into a byte. The only disadvantage of this technique is that it is slower. It
now requires a few I/O instructions to read the one byte, and it requires the use of an external IC.
The operation of the 74LS157, Quad 2 line to 1 line multiplexer is quite simple. It simply acts
as four switches. When the A/B input is low, the A inputs are selected. E.g. 1A passes through to 1Y,
2A passes through to 2Y etc. When the A/B is high, the B inputs are selected. The Y outputs are
connected up to the Parallel Port’s status port, in such a manner that it represents the MSnibble of the
status register. While this is not necessary, it makes the software easier.
To use this circuit, first we must initialize the multiplexer to switch either inputs A or B. We
will read the LSnibble first, thus we must place A/B low. The strobe is hardware inverted, thus we
must set Bit 0 of the control port to get a low on Pin 1.
outportb(CONTROL, inportb(CONTROL) | 0x01); /* Select Low Nibble (A)*/
Once the low nibble is selected, we can read the LSnibble from the Status Port. Take note that
the Busy Line is inverted, however we won’t tackle it just yet. We are only interested in the MSnibble
of the result, thus we AND the result with 0xF0, to clear the LSnibble.
a = (inportb(STATUS) & 0xF0); /* Read Low Nibble */
Now it’s time to shift the nibble we have just read to the LSnibble of variable a,
a = a >> 4; /* Shift Right 4 Bits */
We are now half way there. It’s time to get the MSnibble, thus we must switch the multiplexer
to select inputs B. Then we can read the MSnibble and put the two nibbles together to make a byte,
Vedere la pagina 10
1 2 ... 6 7 8 9 10 11 12 13 14 15 16 17

Commenti su questo manuale

Nessun commento