Upload
hasrulnizam-hashim
View
214
Download
0
Embed Size (px)
Citation preview
8/3/2019 08 Unit 5
1/28
8/3/2019 08 Unit 5
2/28
INTRODUCTION TO INTERFACING
KKTMPJ 175
5.1 SERIAL AND PARALLEL PORTS
5.1.1 Parallel Data Transfer : The 8255 PPI
IntroductionThe 8255 programmable peripheral interface (PPI) is a very popular low-cost interfacing
component found in many applications. The PPI has 24 pins for I/O, programmable in
groups of 12 pins, that are used in three separate modes of operation. The 8255 is used
for interface to the keyboard and the parallel printer port in many of these personal
computers. It also controls the timer and reads data from the keyboard interface .
Basic Description of the 8255
Figure 5.0 shows a diagram of the 8255 and its I/O and control signals. Twenty-four of
the 8255s 40 pins are dedicated to the three programmable ports A, B and C. These
three ports, and a fourth one called a control port, are accessed via RD, WR, CS, and
address lines A0 and A1. A RESET input is included to initialize the 8255 when power is
first applied. . Table 5.1 shows the I/O port assignments used for programming and
access to the I/O ports.
Figure 5.0 : Interfacing the 8255 PPI
8/3/2019 08 Unit 5
3/28
INTRODUCTION TO INTERFACING
KKTMPJ 176
A1 A0 Function
0 0 Port A0 1 Port B
1 0 Port C1 1 Command register
Table 5.1 : I/O port assignments for the 8255
The 8255 is fairly simple device to interface to the microprocessor and program. For the
8255 to be read or written, the CS input must be a logic 0 and the correct I/O address
must be applied to the A1 and A0 pins. The remaining port address pins are dont cares
as far as the 8255 is concerned, and are externally decoded to select the 8255.
The nicest feature of the 8255 is that different hardware circuits can be connected to ports
A, B and C, with the direction (input or output) of each port configured with initial
programming. This allows an 8088-based system with an 8255 in it to be used for many
different purposes.
Programming the 8255
The 8255 has three modes of operation.
The first is mode 0: basic input/output.
In this mode, port A, B and C can be individually programmed as input or output ports.
Port C is divided into two 4-bit halves, directionally independent from each other So, there
are 16 combinations of input and output configurations available with this mode. A RESET
automatically causes the 8255 to enter mode 0 with all ports programmed for input.
To program the 8255 for mode 0 operation and set the direction of each port, a mode
word must be output to control port. The definition of the mode word is shown in Figure
5.2. The MSB is the mode-set flag, which must be a 1 to program the 8255. Bits 5 and 6
are used to select the 8255s mode. 00 selects mode 0, 01 selects mode 1, and mode 2 is
selected when bit 6 is high. Bit 2 is also used as a select bit for modes 0 and 1. The other
4 bits set the direction of ports A and B and both halves of C. A0 indicates an output port
and a 1 indicates an input port.
8/3/2019 08 Unit 5
4/28
INTRODUCTION TO INTERFACING
KKTMPJ 177
Figure 5.2 : 8255 mode word format
To configure the 8255 for mode 0, all ports programmed for input, the mode word must be
10011011 (9BH). This byte must be output to the control port to configure the 8255. The
following two instructions will initialize the 8255 after a reset:
MOV AL, 9BH
OUT 0A3H,AL
Remember that the 8255 of Figure 5.0 has its control port at address A3.
Assume that the 8255 has a DIP switch wired to port A and a set of LEDs wired to port B.
The following code can be used to repeatedly read the switches and send their states to
the LEDs.
READ : MOV AL,99H ; configure 8255 for Ain, Bout, mode 0
OUT 0A3H, AL
GET : IN AL,0A0H ; read switchesOUT 0A1H,AL ;send data to lights
JMP GET
8/3/2019 08 Unit 5
5/28
INTRODUCTION TO INTERFACING
KKTMPJ 178
The next mode is mode 1 : strobed input/output.
In this mode, the 8255 uses port C as a handshaking port. Handshaking signals are
commonly used in printers to sense the status of the paper-out sensor and the printers
readiness to accept new data. Ports A and B can be programmed for input and output.Data are latched in both directions. If port A is programmed for input, a strobe signal is
needed on PC4 to write data into port A. The 8255 will acknowledge the new input data by
outputting a 1 on PC5. These two signals on port C are defined as shown in Figure 5.3(a).
PC5 is IBFa, input buffer A full. IBF is cleared when the processor reads port A. Port B
operates in the same way, using PC2 and PC1 as handshaking signals. Both ports have
the capability of causing an interrupt when data are strobed into them. The INTR output
will go high when IBF goes high and the internal interrupt-enable bit is set. PC4 will cause
INTRa
to go high when data are strobed into port A. Reading the input port will clear the
interrupt request. This interrupt mechanism is a useful alternative to using software to
constantly poll the input port. Polling wastes a lot of time waiting for input data that may
not be there. Interrupting the processor only when new data have arrived results in more
efficient program execution. This is one of the advantages of modes 1.
As Figure 5.3(a) shows, PC6 and PC7 are available for general purpose I/O when port A is
programmed for input. The mode word needed to program the 8255 for mode 1, Ain, Bin,
and PC6 and PC7 out is B6.
Figure 5.3(b) shows how the 8255 is configured for output in mode 1. It has output
buffer full (OBF) and a acknowledge (ACK) signals used to handshake with the output
circuitry. OBF will go low when the processor writes to port A or B. This signal will remain
low until a low pulse arrives on ACK. ACK is used to indicate that the new output data
were received. ACK, together with interrupt-enable, can be used to generate an interrupt
with INTR. This would interrupt the processor when the new output data have been read,
and avoid the need to poll the ACK signal. To program the 8255 for mode 1, Aout, and
Bout, use mode word A4.
8/3/2019 08 Unit 5
6/28
INTRODUCTION TO INTERFACING
KKTMPJ 179
Figure 5.3 : Mode 1 port definitions
The last mode is mode 2: strobed bidirectional I/O.
This mode allows port A to operate as an 8-bit bidirectional bus. This is needed to allow
the 8255 to be interfaced with 8-bit peripherals such as UARTS, which require a
bidirectional data bus. Bits in port C are again used for handshaking and general purpose
I/O, as indicated by Figure 4.4. Port B can operate as an input port or output port in mode
0 or mode 1. When operating port B in mode 0 ( with port A in mode 2), PC 0 through PC2
are available for general purpose I/O. The definitions for PC0 through PC 2 in mode 1
apply when port B is operated in mode 1 with port A in mode 2.
As before, the INTR output can be used to interrupt the processor for input or
output operations. When the CPU writes data to port A, OBF will go low. To enable the
output buffer on port A and read the data, ACK must be pulled low. Data are written into
port A by pulling STB low. This will cause IBF to go high until the data are read by the
processor.
8/3/2019 08 Unit 5
7/28
INTRODUCTION TO INTERFACING
KKTMPJ 180
5.1.2 Serial Data Transfer : The 8251 UART
Introduction
Serial data transmission offers the convenience of running a small number of wires
between two points (three will do the job in most cases), while at the same time being very
reliable. Although we must wait longer to receive our data because it is transmitted only 1
bit at a time, we are able to place our communication devices (computers, terminals, and
so on) far away from each other. Worldwide networks now exist, connected via satellites,
implements serial data transmission in a variety of formats. The standard serial data
transmission waveform for any UART is depicted in Figure 5.4.
Figure 5.4 : Standard TTL serial data waveform
Interfacing the 8251
The 8251 was originally designed to be used with the 8080 and 8085 microprocessors, 8
bit machines that preceded the 8088. The 8088 interfaces with the 8251 easily, requiring
the usual address decoder and a few control signals. Figure 5.5 shows a complete serial
data circuit for the 8088. The 8251 is connected to the processors data bus and IORC
and IOWC signals. Because these signals are active only during I/O operations, the
address decoder need only examine the state of the address bus. The NAND gate
recognizes port addresses 78H and 79H. Address line A0 is not used in the decoder.
Instead, it is connected to the 8251s C/D input. This pin selects internal control or data
registers. So, if A0 is low (port 78H) and IORC is active, the UARTs receive register will
be read. If IOWC is active with A0 low, the UARTs transmitter register will be written to
and a new transmission started.
8/3/2019 08 Unit 5
8/28
INTRODUCTION TO INTERFACING
KKTMPJ 181
Figure 5.5 : 8251 to 8088 interface
The control functions are selected when A0 is high (port 79H). Reading form port
79H gets 1 byte of status information; writing to it selects functions such as data size and
used when the 8251 is connected to a modem. They are grounded to keep them enable.
TxC and RxC are the transmitter and receiver clocks. The frequency of the TTL signal at
these inputs determines the bit rate and time of the transmitter and receiver. It is common
to run the UART at a clock speed 16 times greater than the baud rate. So, a 2400 baudtransmission rate requires a 38.4 kHz clock (multiply 2400 by 16). This frequency and
other standard baud rate frequencies are generated automatically by the 14,411 baud-rate
generator. All that is needed is a 1.8432 MHz crystal.
Attempting to transmit a digital (0-5 V) signal over a long length of wire causes
distortion in the signal shape due to the line capacitance. It was discovered that making
8/3/2019 08 Unit 5
9/28
INTRODUCTION TO INTERFACING
KKTMPJ 182
the signal switch form a positive voltage to a negative voltage helps to eliminate the
distortion. Higher baud rates are possible using the +/-swigging signal. A standard was
developed for this type for signal, called the RS232C standard. Take another look at the
waveform in Figure 5.4. This is the TTL waveform that comes out of UARTs transmitter.
The RS232 waveform that gets transmitted over the wires is inverted and swings plus and
minus. So, a high level on the TTL waveform creates a low (negative) level on the
RS232Cwaveform. An integrated circuit capable of performing the RS232C-to-TTL
conversions is the MAX23CPE. This chips, such as the 1488 line driver and 1489 line
receiver, required additional external power supplies. The MAX232 has two separate
RS232C drivers/receivers for systems requiring two serial data channels.
Programming the 8251
Because the 8251 is connected to RESET, we are assured that the 8251 is
functional after a power-on. It is still necessary to program the 8251 to ensure that the
correct number of data bits will be used, that the parity will be generated as expected, and
so on. To program the 8251, a series of bytes are output to the control port (79H from our
example). The first byte is called the mode instruction. The format of this byte is shown in
Figure 5.6. The 8251 can operate in asynchronous mode or synchronous mode. In
asynchronous mode, the baud rate is determined by the lower 2 bits in the mode
instruction. If these 2 bits are low, synchronous mode is selected.
8/3/2019 08 Unit 5
10/28
INTRODUCTION TO INTERFACING
KKTMPJ 183
Figure 5.6 : 8251 mode instruction formatThe number of data bits used in a transmission is selected by bits 2 and 3. To enable
generation of a parity bit, bit 4 must be set. Odd or even parity is chosen by the setting of
bit 5. Finally, the number of stop bits is chosen by the upper 2 bits in the mode instruction.
The waveform of Figure 5.4 contained 7 data bits, an even parity bit, and two stop bits.
The required mode instruction byte is FA. To program the 8251, use:
MOV AL,0FAH
OUT 79H, AL
Because an X16 clock was selected, the 8251 will operate in asynchronous mode.
Synchronous mode is used for high-speed data transmission (not usually needed for
communication with a serial display terminal). Synchronous mode is selected by making
the lower two mode instruction bits. In this case, the upper two mode instruction bits do
8/3/2019 08 Unit 5
11/28
INTRODUCTION TO INTERFACING
KKTMPJ 184
not set the number of stop bits, but rather the number of sync characters transmitted and
the function is the SYNDET pin.
A second byte must be output to the control port to complete the initialization of the 8251.
This byte is called the command instruction. The bits are assigned as shown in Figure
5.7; they have the following meanings.
Bit 0 : transmit enable. Enable transmitter when this bit is set.
Bit 1 : data terminal ready. Setting this bit will will force the DTR outputlow.
Bit 2 : receive enable. Enable receiver when this bit is set
Bit 3 : send break character. Setting this bit forces TxD low
Bit 4 : error reset. Setting this bit clears the PE, OE, and FE error flags.
Bit 5 : request to send. Setting this bit forces the CTS output low.
Bit 5 : internal reset. To reset the 8251 and prepare for a new mode
instruction this bit must be set.
Bit 6 : internal reset. To reset the 8251 and prepare for a new mode
instruction, this bit must be set.
Bit 7 : enter hunt mode. Setting this bit enables a search for SYNC
characters (in synchronous mode only).
Figure 5.7 : 8251 command instruction format
The command instruction needed to enable the transmitter and receiver and ignore all
other functions is 05H. This byte must be output to the control port after the mode
instruction. So, to totally initialize the 8251 for operation in the circuit of Figure 5.5, we
need these instructions:
MOV AL, 0FAH ; mode instruction
OUT 79H, AL
MOV AL,05H ; command instruction
OUT 79H, AL
8/3/2019 08 Unit 5
12/28
INTRODUCTION TO INTERFACING
KKTMPJ 185
Once the UART has been programmed we have no need for the control port. Instead, we
use the 82512 status port to help control the way data are transmitted and received.
Figure 5.8 shows the bit assignments in the 8251s status port. Particularly important are
the TxRDY (transmitter ready) and RxRDY (receiver ready) flags. They tell us when the
transmitter is ready to transmit a new character and when the receiver has received a
complete character. A number of error bits are included to show what may have given
wrong with the last reception. PE is parity error, and will go high fi the parity of the
received character is wrong. OE is overrun error, and will be set if a new characterize
received before the processor read the last one. FE stands for framing error, and goes
high when stop bits are not received in synchronous mode. DSR (data set ready) will go
high whenever DSR is low.
Figure 5.8 : 8251 status byte
The programmer must use the 8251s status bits to ensure proper serial data
communication. Figure 5.9 shows how the first two bits are used to implement a simple
serial input/output procedure.
Both flowcharts indicate that repeated testing of the RxRDY/TxRDY bits may be
necessary. For example, to show the importance of this repeated testing, consider the
following case. Suppose that an 8251 is configured to transmit and receive data at 1200
baud, with 7 data bits, odd parity, and 1 stop bit. How long does it take to fully transmit or
receive a character? At 1200 baud, the bit time is just over 833 us, and the selected word
length of 10 bits makes the total time to receive or transmit a single character roughly 8.3
ms.
It is not difficult to imagine how many instructions the 8088 might be able to execute in 8.3
us. Would a few thousand be unreasonable? Probably not. Therefore, we use the status
bits to actually slow down the 8088, so that it does not try to send or receive data from the
8251 faster than the 8251 can handle.
The two short routine is used to read a character from the receiver, returning it in AL. It is
necessary to check the state of RxRDY before reading the receiver.
8/3/2019 08 Unit 5
13/28
INTRODUCTION TO INTERFACING
KKTMPJ 186
Figure 5.9 : I/O flowcharts
CHARACTER INPUT
CHARIN PROC FAR
RSTAT: IN AL, 79H ; read UART status
AND AL,02H ; examine RxRDY
JZ RSTAT ; wait until receiver is ready
IN AL, 78H ; read receiver
AND AL, 7FH ; ensure 7 bit ASCII code
RET
CHARIN ENDP
8/3/2019 08 Unit 5
14/28
INTRODUCTION TO INTERFACING
KKTMPJ 187
The data byte received is ANDed with 7F to clear the MSB. Because the UART is being
used for character transmission, only a 7-bit ASCII code is required.
CHARACTER OUTPUT
This routine checks to see if the transmitter is ready for a new character. If it is, the ASCII
character stored in AL is output to the transmitter.
CHAROUT PROC FARMOV AH,AL
TSTAT: IN AL, 79H ; save characterAND AL, 1 ; read UART status
JZ TSTAT ; wait until transmitter is readyMOV AL, AH ; get character backOUT 78H, AL ; output to transmitterRET
CHAROUT ENDP
8/3/2019 08 Unit 5
15/28
INTRODUCTION TO INTERFACING
KKTMPJ 188
5.2 APPLICATION OF SERIAL AND PARALLEL PORT
5.2.1 Application of Serial Port
Considered to be one of the most basic external connections to a computer, the serial
port has been an integral part of most computers for more than 20 years. Although many
of the newer systems have done away with the serial port completely in favor of USB
connections, most modems still use the serial port, as do some printers, PDAs and digital
cameras. Few computers have more than two serial ports.
Figure 5.10 Two serial ports on the back of a PC
Essentially, serial ports provide a standard connector and protocol to let you attachdevices, such as modems, to your computer., you will learn about the difference between
a parallel port and a serial port, what each pin does and what flow control is.
The external connector for a serial port can be either 9 pins or 25 pins. Originally,
the primary use of a serial port was to connect a modem to your computer. The pin
assignments reflect that. Let's take a closer look at what happens at each pin when a
modem is connected.
http://www.howstuffworks.com/usb.htmhttp://www.howstuffworks.com/modem.htmhttp://www.howstuffworks.com/pda.htmhttp://www.howstuffworks.com/digital-camera.htmhttp://www.howstuffworks.com/digital-camera.htmhttp://www.howstuffworks.com/digital-camera.htmhttp://www.howstuffworks.com/digital-camera.htmhttp://www.howstuffworks.com/pda.htmhttp://www.howstuffworks.com/modem.htmhttp://www.howstuffworks.com/usb.htm8/3/2019 08 Unit 5
16/28
INTRODUCTION TO INTERFACING
KKTMPJ 189
Figure 5.11
9-pin connector:
1. Carrier Detect - Determines if the modem is connected to a working
phone line.
2. Receive Data - Computer receives information sent from the modem.
3. Transmit Data - Computer sends information to the modem.
4. Data Terminal Ready - Computer tells the modem that it is ready to talk.
5. Signal Ground - Pin is grounded.
6. Data Set Ready - Modem tells the computer that it is ready to talk.
7. Request To Send - Computer asks the modem if it can send information.
8. Clear To Send - Modem tells the computer that it can send information.
9. Ring Indicator - Once a call has been placed, computer acknowledges
signal (sent from modem) that a ring is detected.
8/3/2019 08 Unit 5
17/28
INTRODUCTION TO INTERFACING
KKTMPJ 190
25-pin connector:
1. Not Used
2. Transmit Data - Computer sends information to the modem.
3. Receive Data - Computer receives information sent from the modem.
4. Request To Send - Computer asks the modem if it can send information.
5. Clear To Send - Modem tells the computer that it can send information.
6. Data Set Ready - Modem tells the computer that it is ready to talk.
7. Signal Ground - Pin is grounded.
8. Received Line Signal Detector - Determines if the modem is connected
to a working phone line.
9. Not Used: Transmit Current Loop Return (+)
10. Not Used
11. Not Used: Transmit Current Loop Data (-)
12. Not Used
13. Not Used
14. Not Used
15. Not Used
16. Not Used
17. Not Used
18. Not Used: Receive Current Loop Data (+)
19. Not Used
20. Data Terminal Ready - Computer tells the modem that it is ready to talk.
21. Not Used
22. Ring Indicator - Once a call has been placed, computer acknowledges
signal (sent from modem) that a ring is detected.
23. Not Used
24. Not Used
25. Not Used: Receive Current Loop Return (-)
Voltage sent over the pins can be in one of two states, On or Off. On (binary value "1")
means that the pin is transmitting a signal between -3 and -25 volts, while Off (binary
value "0") means that it is transmitting a signal between +3 and +25 volts...
8/3/2019 08 Unit 5
18/28
INTRODUCTION TO INTERFACING
KKTMPJ 191
5.2.2 Application of Parallel Port
If you have a printer connected to your computer, there is a good chance that it
uses the parallel port. WhileUSB is becoming increasingly popular, the parallel port is
still a commonly used interface for printers.
Figure 5.12 A typical parallel port on the back of your computer
Parallel ports can be used to connect a host of popular computer peripherals:
Printers
Scanners
CD burners
External hard drives
Iomega Zip removable drives
Network adapters Tape backup drives
Parallel port is a very commonly known port, widely used to connect the printer to the PC.
If you see backside of your computer, there will be a port having 25 pins with a small
symbol like this:. That port is known as LPT port or printer port. We can program this port
for device control and data transfer. In this article, we will learn basics of parallel port and
programming the parallel port.
http://www.howstuffworks.com/usb.htmhttp://www.howstuffworks.com/usb.htmhttp://www.howstuffworks.com/usb.htmhttp://www.howstuffworks.com/inkjet-printer.htmhttp://www.howstuffworks.com/scanner.htmhttp://www.howstuffworks.com/cd-burner.htmhttp://www.howstuffworks.com/hard-disk.htmhttp://www.howstuffworks.com/removable-storage.htmhttp://www.howstuffworks.com/home-network.htmhttp://www.howstuffworks.com/home-network.htmhttp://www.howstuffworks.com/removable-storage.htmhttp://www.howstuffworks.com/hard-disk.htmhttp://www.howstuffworks.com/cd-burner.htmhttp://www.howstuffworks.com/scanner.htmhttp://www.howstuffworks.com/inkjet-printer.htmhttp://www.howstuffworks.com/usb.htm8/3/2019 08 Unit 5
19/28
INTRODUCTION TO INTERFACING
KKTMPJ 192
Parallel port basics:
In computers, ports are used mainly for two reasons: Device control and
communication. We can program PC's Parallel ports for both. Parallel ports are mainly
meant for connecting the printer to the PC. But we can program this port for many more
applications beyond that.
Parallel ports are easy to program and faster compared to the serial ports. But main
disadvantage is it needs more number of transmission lines. Because of this reason
parallel ports are not used in long distance communications. Let us know the basic
difference between working of parallel port and serial port. In serial ports, there will be two
data lines: One transmission and one receive line. To send a data in serial port, it has to
be sent one bit after another with some extra bits like start bit, stop bit and parity bit to
detect errors. But in parallel port, all the 8 bits of a byte will be sent to the port at a time
and a indication will be sent in another line. There will be some data lines, some control
and some handshaking lines in parallel port. If three bytes of data 01000101 10011100
10110011 is to be sent to the port, following figures will explain how they are sent to the
serial and parallel ports respectively. We can understand why parallel port communication
is faster compared to that of serial.
In computers, ports are used mainly for two reasons: Device control and
communication. We can program PC's Parallel ports for both. Parallel ports are mainlymeant for connecting the printer to the PC. But we can program this port for many more
applications beyond that.
8/3/2019 08 Unit 5
20/28
INTRODUCTION TO INTERFACING
KKTMPJ 193
Parallel Port: Data transmission is byte wise:Whole byte at a time.
Figure 5.13
In the PC there will be D-25 type of female connector having 25 pins and in the
printer, there will be a 36-pin Centronics connector. Connecting cable will combine these
connecter using following convention. Pin structure of D-25 and Centronics connecters
are explained bellow.
8/3/2019 08 Unit 5
21/28
INTRODUCTION TO INTERFACING
KKTMPJ 194
Table 5.0: Pin numbers and functions
Now let us know how communication between PC and printer takes place.
Computer places the data in the data pins, then it makes the strobe low. When strobe
goes low, printer understands that there is a valid data in data pins. Other pins are used to
send controls to the printer and get status of the printer, you can understand them by the
names assigned to the pins.
To use the printer port for applications other than printing, We need to know how
ports are organized. There are three registers associated with LPT port: Data register,Control register and Status register. Data register will hold the data of the data pins of the
port. That means, if we store a byte of data to the data register, that data will be sent to
the data pins of the port. Similarly control and status registers. The following table
explains how these registers are associated with ports.
D25- PinNumber
Centronics36 PinNumber
Function
1 1 Strobe
2 to 9 2 to 9 Data Lines
10 10 Acknowledgement11 11 Busy
12 12 Out of Paper
13 13 Select
14 14 Auto feed
15 15, 32 Error
16 16, 31 Init
17 17, 36 Select In
18 to 25 18 to 30, 33 GND
- 34, 35 N/C
8/3/2019 08 Unit 5
22/28
INTRODUCTION TO INTERFACING
KKTMPJ 195
Table 5.1: Pin directions and associated registers.
* Pins with * symbol in this table are hardware inverted. Than means, If a pin
has a 'low' ie. 0V, Corresponding bit in the register will have value 1.
Signals with prefix 'n' are active low. That means, Normally these pins will have low value.
When it needs to send some indication, it will become high.
For example:
Normally nStrobe will be high, when the data is placed in the port, computer makes that
pin low.
Normally, data, control and status registers will have following addresses. We need theseaddresses in programming later.
Register LPT1 LPT2
Data register (Base Address + 0) 0x378 0x278
Status register (Base Address + 1) 0x379 0x279
Control register (Base Address + 2) 0x37a 0x27a
Pin No (D-Type 25)SPP SignalDirectionIn/out
Register.bit
1* nStrobe In/Out Control.0
2 Data 0 In/Out Data.0
3 Data 1 In/Out Data.1
4 Data 2 In/Out Data.25 Data 3 In/Out Data.3
6 Data 4 In/Out Data.4
7 Data 5 In/Out Data.5
8 Data 6 In/Out Data.6
9 Data 7 In/Out Data.7
10 nAck In Status.6
11* Busy In Status.7
12 Paper-Out / Paper-End In Status.5
13 Select In Status.4
14* nAuto-Linefeed In/Out Control.1
15 nError / nFault In Status.3
16 nInitialize In/Out Control.2
17*nSelect-Printer/ nSelect-In
In/Out Control.3
18 - 25 Ground Gnd
8/3/2019 08 Unit 5
23/28
INTRODUCTION TO INTERFACING
KKTMPJ 196
Note: All the parallel ports do not have bidirectional capability. Earlier parallel
ports had only output enabled in data pins since printers only inputs data. But latter, to
make parallel port capable of communicating with other devises, bidirectional ports are
introduced.
By default, data port is output port. To enable the bidirectional property of the port, we
need to set the bit 5 of control register.
To know the details of parallel ports available in your computer, follow this procedure:
1. Right click on My Computer, go to "Properties".
2. Select the tab Hardware, Click Device manager.
3. You will get a tree structure of devices; In that Expand "Ports(Com1 &
LPT)".
4. Double Click on the ECP Printer Port(LPT1) or any other LPT port if
available.
5. You will get details of LPT port. Make sure that "Use this Port (enable)" is
selected.
6. Select tab recourses. In that you will get the address range of port.
To start programming, you will need a D-25 type Male connector. Its pin structures can be
found in the connector as follows:
Programming the printer port in DOS:
To start programming the port, we will use DOS. In DOS we have commands to
access the port directly. But, these programs will not work on the systems based on
Windows XP, Windows NT or higher versions. For security reason, higher versions of the
windows does not allow accessing the port directly. To program the parallel port in these
systems, we need to write kernel mode driver.
8/3/2019 08 Unit 5
24/28
INTRODUCTION TO INTERFACING
KKTMPJ 197
When we want to find out whether particular pin of the port is high or low, we
need to input the value of corresponding register as a byte. In that, we have to find out
whether the corresponding bit is high or low using bitwise operators. We can't access the
pins individually. So, you need to know basic bitwise operations.
Main bitwise operators that we need are bitwise AND '&' and bitwise OR '|'. To
make a particular bit in a byte high without affecting other bits, write a byte with
corresponding bit 1 and all other bits 0; OR it with original byte. Similarly, to make
particular bit low, write a byte with corresponding bit 0 and all other bits 1; AND it with
original byte.
In Turbo C, there are following functions used for accessing the port:
outportb( PORTID, data);
data = inportb( PORTID);
outport( PORTID, data);
data = inport( PORTID);
Outport() function sends a word to port, inport() reads a word from the port.
outportb() sends a byte to port and inportb() reads a byte from the port. If you include
DOS.H header, these functions will be considured as macro, otherwise as functions.
Function inport() will return a word having lower byte as data at PORTID and higher byte
as data at PORTID+2. So, we can use this function to read status and control registers
together. inportb() function returns byte at PORTID. outport() writes the lower byte to
PORTID and higher byte to PORTID+1. So this can be used to write data and control
together. outportb() function write the data to PORTID. outport() and outportb() returns
nothing.
excessive draw of current from the port. Connect an LED in series with a resister of 1KW
or 2.2KW between any of the data pins(2 to 9) and ground. With that, if you run the
program given below, you should see the LED blinking with app. 1 sec frequency.
8/3/2019 08 Unit 5
25/28
INTRODUCTION TO INTERFACING
KKTMPJ 198
Exercise For Topic 5
1. What is the characterizing feature of serial communications
2. Explain the sequence of 8255 to do the read or write operation.
3. How many mode is 8255 have ?. State the purpose each of them.
4. Explain what is RS 232C ?.
5. Explain the difference between asynchronous communications and synchronous
communications.
6. Determine the function of each no of 9 pins connector when a serial port was connect
a modem to your computer .
8/3/2019 08 Unit 5
26/28
INTRODUCTION TO INTERFACING
KKTMPJ 199
SUMMARY
In this unit we have studied :
1. The 82C55A is an LSI peripheral design to permits easy implementation of parallelI/O in the 8088 and 8086 microprocessor system .
2. Two example of interfaces that require a synchronized data transfer are serial
communication interface and a parallel printer interface.
3. Two types of serial data communication are widely used in microprocessor system
are asynchronous communications and synchronous communication.
ANSWERS
Exercise For Topic 3
1. Permits data to be transferred between two units using just two data lines.
2. First the CS input must be a logic 0 and correct I/O address must be applied to the
A1 and A0 pins. The remaining port address pins are dont cares as far as the8255 is concerned , and are externally decoded to select the 8255.
3. 3 modes , that is mode 0 , mode 1 and mode 2. The purpose of :
Mode 0 as a basic input / output . Port A , B and C can be individually
programmed as input or output port.
Mode 1 in this mode the 8255 uses port C as a handshaking port.
Mode 2 this mode allow port A to operate as an 8 bit bidirectional bus. This is
needed to allow the 8255 to be interfaced with 8 bit peripheral such as UARTS ,
which require a bidirectional data bus.
8/3/2019 08 Unit 5
27/28
INTRODUCTION TO INTERFACING
KKTMPJ 200
4. RS 232C interface is a standard interface for implementing asynchronous serial
data communication port on devices such as printers , CRT terminals , keyboards
and modems.
5. By synchronous , mean that the receiver and transmitter sections of the two pieces
of equipment communicating with each other must ran synchronously. For this
reason , the interface includes a clock line as well as transmit data , receive data
and signal common lines. It is a clock signal that synchronizes both the
transmission and reception of data.
Meanwhile by asynchronous method of communications eliminates the need for
the clock signal. The simplest form of an asynchronous communications
interface could consist of a Receive data , Transmit data , and Signal common
communication lines. In this case , the data to be transmitted are sent out one
character at a time, and the receiver examining synchronization bits that are
included at the beginning and end of each character performs end of the
communication line synchronization.
6. 9 pin connector :
1. Carrier Detect - Determines if the modem is connected to a working
phone line.
2. Receive Data - Computer receives information sent from the modem.
3. Transmit Data - Computer sends information to the modem.
4. Data Terminal Ready - Computer tells the modem that it is ready to talk.
5. Signal Ground - Pin is grounded.
6. Data Set Ready - Modem tells the computer that it is ready to talk.
7. Request To Send - Computer asks the modem if it can send information.
8. Clear To Send - Modem tells the computer that it can send information.
9. Ring Indicator - Once a call has been placed, computer acknowledges
signal (sent from modem) that a ring is detected.
8/3/2019 08 Unit 5
28/28
INTRODUCTION TO INTERFACING