PC PARALLEL PORT |
The printer adapter responds to five I/O instructions: two output and three input.
The output instructions transfer data into two latches whose outputs are presented on the pins of a 25-pin D-type female connector.
Two of the three input
instructions allow the processor to read back
the contents of the two latches.
The third allows the
processor to read the realtime status of a group of pins on the connector.
A description of each
instruction follows
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The instruction captures data from the data
bus and is present on the respective pins. These pins are each capable
of sourcing 2.6 mA and sinking 24 mA. It is essential that the external
device not try to pull these lines to ground.
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
Enable |
|
|
|
|
This instruction causes the latch to capture the least significant bits of the data bus. The four least significant bits present their outputs, or inverted versions of their outputs, to the respective pins shown above. If bit 4 is written as 1, the card will interrupt the processor on the condition that pin 10 transitions high to low.
These pins are driven by open collector drivers
pulled to +5 Vdc through 4.7 k-ohm resistors. They can each sink approximately
7 mA and maintain 0.8 volts down-level.
Input from address | 278 / 378 / 3BC |
This command presents the processor with data present on the pins associated with the corresponding output address. This should normally reflect the exact value that was last written.
The following command presents realtime status
to the processor from the pins as follows.
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The following command causes the data present
on pins 1, 14, 16, 17 and the IRQ bit to be read by the processor. In the
absence of external drive applied to these pins, data read by the processor
will exactly match data last written to the corresponding output address
in the same bit positions. Note that data bits 0-2 are not included.
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
Enable |
|
|
|
|
|
||||||||
- | - | - |
|
|
|
|
|
The following table shows a typical I/O port,
address 278, 378 or 3BC, which is the "base address" for the data transfered
itself (Data Register), the next byte is the Status Register and the next
is the Control Register. So, the Control Register for the LPT1 (378)
is the hexadecimal 37A.
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The following figure is the actual circuit
descriptions and pin numbers for both sides of the cable, along with the
data flow indicated by the arrow. The - (minus) symbol in from of
the circuit name means that circuit is "active" with low level. The
~(tilt) symbol means the circuit works inverted, as a way to accomodate
technical situations.
=========== ======== ===== ========= -Strobe ~C0 1 Output +Data Bit 0 D0 2 Output +Data Bit 1 D1 3 Output +Data Bit 2 D2 4 Output +Data Bit 3 D3 5 Output +Data Bit 4 D4 6 Output +Data Bit 5 D5 7 Output +Data Bit 6 D6 8 Output +Data Bit 7 D7 9 Output -Acknowledge S6 10 Input +Busy ~S7 11 Input +Paper End S5 12 Input +Select In S4 13 Input -Auto Feed ~C1 14 Output -Error S3 15 Input -Initialize C2 16 Output -Select ~C3 17 Output Ground - 18-25 - |
So, any PC Program that can write or read to the physical hardware port addresses is able to communicate with the external world, thus a microcontroller, and this is exactly what we will do as the following in this chapter.
We will explore a little bit about PC DOS programs, since it was my arena from years ago. There are several other ways to explore this communication programs via other languages as Basic, C, Pascal, Visual Basic, Windows, but we will go directly to assembler language so we can see exactly what it is doing.
I already developed a PC DOS program that "dumps" a disk file contents to the PC COM port. You select the file, the speed and the COM port, and the program just "pour" it there. Your microcontroller can capture the data and do whatever you want. There is no handshake control in this situation, so the PC will never know if something is receiving the data. Click here to download it: COPY2COM.EXE.
Another nice program I made was the COM2FILE.EXE , an utility for PC DOS, that can capture bytes arriving serially at the COM port and write them in a file. By using it, your microcontroller can send bytes to the COM port, to be written at the PC hard disk. You specify the filename, which COM port to use and its speed. It finishes the reception and write the file, upon pressing any PC keyboard key or after receives 48kbytes of data.
Later in this chapter
you will be able to download a PC DOS inteligent program, we can name it
"The Dispatcher". It will take actions based on commands received
from the microcontroller, as well send commands to it. The main idea
is that you can control the microcontroller remotely, even by phone, or
vice-versa, controlling the PC based on the microcontroller decisions.
to be continued...ttp://www.doc.ic.ac.uk/~ih/doc/par/doc/regpins.html lscgid: execve():/home/sanckvet/public_html/ustr/cgi-bin/ax.pl: Permission denied