Professional Documents
Culture Documents
Module 4
Module 4
Interfacing-1
PERIPHERAL INTERFACING
• Microprocessor based system design involves interfacing of the processor with
one or more peripheral devices for the purpose of communication with various
input and output devices connected to it.
• 8255 is mainly programmed in two modes (a) I/O mode and (b) bit
set/reset mode (BSR) mode. The I/O mode is further divided into
three modes: Mode 0, Mode 1, and Mode 2.
Block Diagram of 8255
Group A Control and Group B Control
• Group A control block controls - PortA and PC7-PC4.
• Group B control block controls - Port B and PC3- PC0
Control Logic
• Manage all internal and external transfer of data and control words.
• RD’, WR’, A1, A0 and RESET are inputs provided by MPU
• It issues commands to the individual group control blocks (Group A Control
and Group B Control)
PIN Configuration of 8255
PIN Description
D0-D7 (Data Bus):
• Bidirectional data bus lines connected to the system
data bus and used to transfer data/control word to/from
the microprocessor.
• RD’ (Read):
• Active low signal indicate reads data in the ports or the
status word through data buffer.
• There are two 8-bitports (A and B) and two 4-bit ports [C (lower)] and
[C (upper)].
A1 A0 Function
0 0 Counter 0
0 1 Counter 1
1 0 Counter 2
1 1 Control Word
CS : A low on Chip select enables the 8254 for programming and for reading or
writing a counter.
Vcc: Power connects to the +5V power supply.
GATE : The gate input controls the operation of the counter in some modes of
operation.
CLK : The clock input is the timing source for each of the internal counters.
CLK0 Clock input of counter 0
CLK1 Clock input of counter 1
CLK2 Clock input of counter 2
OUT: A counter output is where the waveform
generated by the counter is available.
OUT 0 Output of counter 0
OUT 1 Output of counter 1
OUT 2 Output of counter 2
Programming the 8254 /8253 (Control Word Format)
8254/8253 Write operation
The programming procedure for the 8254 is very flexible. Only two conversion
need to be remember.
1) For each Counter, the Control Word must be written before the initial
count is written.
2)The initial count must follow the count format specified in the Control Word
(least significant byte only, most significant byte only, or least significant byte
and then most significant byte).
With a clock and an appropriate gate signal to one of the counters, the above
steps should start the counter and provide appropriate output according to the
control word.
Modes of Operation
Mode 0 used for generation of accurate time delay under software control.
After the Control Word is written, OUT is initially low, and will remain low until the
Counter reaches zero. OUT then goes high and remains high until a new count or a
new Mode 0 Control Word is written into the Counter.
High output used to interrupt the processor, by setting terminal count
Mode 0: Interrupt on terminal count. (Continued)
If G becomes a logic 0 in the middle of the count, the counter will remain stop
until G again becomes a logic 1.
If a new count is written to the Counter, it will be loaded on the next
CLK pulse and counting will continue from the new count.
At the first falling edge of clock after first rising edge of WR(LSB), counter starts
counting.
Mode 1: Hardware Retriggerable One-Shot.
Used as square wave generator and generates a continuous square wave at the
out connection.
Mode 3 is similar to Mode 2 except for the duty cycle of OUT.
If the count (N) is even, the output is high for one half (N/2) of the count and
low for next half (N/2) of the count.
If the count (N) is odd, the output is high for (N+1)/2 clock pulses and low for
(N-1)/2 clock pulses.
Gate should be maintained at logic 1 always.
Mode 4: Software Triggered strobe
If count of N is loaded, counting starts, OUT will be high for N clock cycles and
low for one clock cycle when count reaches 0.
The low pulse can be used as strobe while interfacing the microprocessor with
other peripherals.
The cycle does not begin until the counter is loaded again.
Gate is always high.
Mode 5: Hardware Triggered strobe
• The 8086 has only two interrupt inputs, NMI and INTR. If we use
NMI for a power failure interrupt, this leaves only one interrupt
input for all other applications.
• when two 8259s are cascaded through cascade lines the first
8259 will act as master and the second 8259 will act as a slave.
Connection of 8259A with 8086
microprocessor (Single Mode)
Connection of 8259A with 8086
microprocessor (Cascade Mode)
MASTER SLAVES
64 Interrupts
The 8259A PIC adds eight vectored priority encoded interrupts to the
microprocessor. This controller can be expanded without additional
hardware, to accept upto 64 interrupt requests. This require a master
8259A and eight 8259A slaves.
Architecture of 8259A
Functional descriptions
IN Service Register (ISR)
• The IN service registers keeps tracks of which interrupt
inputs are currently being serviced.
• The IMR stores the bits which mask the interrupt lines.
The IMR operates on the IRR.
• This function blocks stores the IDs of all 8259’s used in the
system. The associated 3-I/O pins (CAS0-CAS2) are outputs
when 8259A is used a master.
ICW3 (Master Device): Only used when ICW1 indicates that the system is
operated in cascade mode. ICW3 (for master device) indicates where the slave
is connected to the master. Suppose, we have two slaves connected to a master
using IR0 and IR1. The master is programmed with an ICW3 of 03H.
ICW3 (Slave Device): ICW3 (for slave device) indicates where the slave is
connected to the master. Suppose, we have two slaves connected to a master
using IR0 and IR1. One slave is programmed with an ICW3 of 01H and other
with an ICW3 of 02H.
ICW4
The bit D0 must be logic 1 to select operation with the 8086 microprocessor.
If SFNM=1, then it selects the special fully-nested mode of operation for the
8259A. At that time, this allows the highest-priority interrupt request from a
slave to be recognized by the master while is processing another interrupt
from a slave.
Normally (if SFNM=0), only one interrupt request is processed at a time and
others are ignored until the process is complete.
ICW4-CONTD
BUF and M/S’:
Buffered and master slave are used together to select buffered operation
or non buffered operation for the 8259A as master or a slave.
The EOI commands of OCW2 are used only if the AEOI mode is selected
by ICW4.
Set priority
Allows the programmer to set the lowest priority interrupt input using the
L2- L0 bits, thus fixing all other priority.
OCW3
Selects the register to be read, the operation of the special mask register
and the poll command.
Reading register
Both the interrupt request register (IRR) and in-service register (ISR)
are read by programming OCW3.