MM UNIT 2 Material
MM UNIT 2 Material
❖Memory interfacing
❖Parallel communication interface
❖Timer
❖ Keyboard /display controller
❖Interrupt controller
❖ DMA controller
❖ Assembly language programming related to the above
interfacing
1
2
Programmable Peripheral Interface
8255
10
Block Diagram of 8255
It has a 40 pins of 4 groups.
1 1 0 1 0 ILLEGAL CONDITION
b) Port B: This has an 8 bit latched / buffered O/P and 8 bit input
latch. It can be programmed in mode 0, mode1.
c) Port C : This has an 8 bit latched input buffer and 8 bit out put
latched/buffer. This port can be divided into two 4 bit ports
and can be used as control signals for port A and port B. it can
be programmed in mode 0.
8255 MODES OF OPERATION
8255 modes
Program:
MOV DX, FFE6
MOV AL, 10010000B
OUT DX,AL
MOV DX, FFE0
IN AL, DX
MOV DX, FFE2
OUT DX,AL
8279
Programmable Keyboard/Display
Interface
● A programmable keyboard and display interfacing chip.
●Strobed input mode, this block acts as 8-byte first-in-first out (FIFO) RAM. Each
key code of the pressed key is entered in the order of the entry and in the mean time
read by the CPU, till the RAM become empty.
In scanned sensor matrix mode, this unit acts as sensor RAM. Each row of the sensor
RAM is loaded with the status of the corresponding row of sensors in the matrix. If a
sensor changes its state, the IRQ line goes high to interrupt the CPU.
●The status logic generates an interrupt after each FIFO read operation till the FIFO
is empty.
In this mode, return lines are scanned whether any kays are closed in the row.
●
It is continued, the status and control keys are transferred into RAM.
●
●Display Address Registers and Display RAM : The display address register
holds the address of the word currently being written or read by the CPU to or
from the display RAM. The contents of the registers are automatically updated
by 8279 to accept the next data entry by CPU.
(i)Scanned Keyboard mode with 2 Key Lockout :
● In this mode of operation, when a key is pressed, a debounce logic comes
into operation. During the next two scans, other keys are checked for
closure and if no other key is pressed the first pressed key is identified.
● The key code of the identified key is entered into the FIFO with SHIFT
and CNTL status, provided the FIFO is not full, i.e. it has at least one byte
free. If the FIFO does not have any free byte, naturally the key data will not
be entered and the error flag is set.
● If FIFO has at least one byte free, the above code is entered into it and the
8279 generates an interrupt on IRQ line to the CPU to inform about the
previous key closures. If another key is found closed during the first key,
the keycode is entered in FIFO.
• If the first pressed key is released before the others, the first will be
ignored. A key code is entered to FIFO only once for each valid depression,
independent of other keys pressed along with it, or released before it.
2. Display Entry : ( right entry or left entry mode ) 8279 allows options for
data entry on the displays. The display data is entered for display either from
the right side or from the left side.
8259
Programmable Interrupt Controller
8259 Programmable Interrupt Controller
● Expandable to 64 levels
PRIORITY RESOLVER
This logic block determines the priorities of the bits set in the IRR. The highest priority
is selected and stored into the corresponding bit of the ISR during INTA pulse.
INT (INTERRUPT)
This output goes directly to the CPU interrupt input. The V level on this line is
designed to be fully compatible with the 8080A, 8085A and 8086 input
levels.
INTA (INTERRUPT ACKNOWLEDGE)
INTA pulses will cause the 8259A to release vectoring information onto the data bus. The format
of this data depends on the system mode (mPM) of the 8259A.
DATA BUS BUFFER
This 3-state, bidirectional 8-bit buffer is used to interface the 8259A to the system Data Bus.
Control words and status information are transferred through the Data Bus Buffer.
READ/WRITE CONTROL LOGIC
The function of this block is to accept Output commands from the CPU. It contains the
Initialization Command Word (ICW) registers and Operation Command Word (OCW) registers which
store the various control formats for device operation. This function block also allows the status of the
8259A to be transferred onto the Data Bus.
CS (CHIP SELECT)
A LOW on this input enables the 8259A. No reading or writing of the chip will occur unless
the device is selected.
WR (WRITE)
A LOW on this input enables the CPU to write control words (ICWs and OCWs) to the
8259A.
RD (READ)
A LOW on this input enables the 8259A to send the status of the Interrupt Request Register
(IRR), In Service Register (ISR), the Interrupt Mask Register (IMR), or the Interrupt level onto the Data
Bus.
A0 This input signal is used in conjunction with WR and RD signals to write commands into the
various command registers, as well as reading the various status registers of the chip. This line can be
tied directly to one of the address lines
.
PROGRAMMING THE 8259A
The 8259A accepts two types of command words generated by the CPU:
1.Initialization Command Words (ICWs):
Before normal operation can begin, each 8259A in the system must be brought to a
starting point -by WR pulses.
2. Operation Command Words (OCWs): These are the command words which
command the 8259A to operate in various interrupt modes.
These modes are:
a. Fully nested mode
b. Rotating priority mode
c. Special mask mode
d. Polled mode
The OCWs can be written into the 8259A anytime after initialization.
INTERRUPT SEQUENCE
The events occur as follows in an MCS-80/85 system:
1. One or more of the INTERRUPT REQUEST lines (IR7±0) are raised high, setting the
corresponding IRR bit(s).
2. The 8259A evaluates these requests, and sends an INT to the CPU, if appropriate.
3. The CPU acknowledges the INT and responds with an INTA pulse.
4. Upon receiving an INTA from the CPU group, the highest priority ISR bit is set, and
the corresponding IRR bit is reset. The 8259A will also release a CALL instruction code
(11001101) onto the 8-bitData Bus through its D7±0 pins.
5. This CALL instruction will initiate two more INTA pulses to be sent to the 8259A
from the CPU group.
6. These two INTA pulses allow the 8259A to release its preprogrammed subroutine
address onto the Data Bus. The lower 8-bit address is released at the first INTA pulse and the
higher 8-bitaddress is released at the second INTA pulse.
7. This completes the 3-byte CALL instruction released by the 8259A. In the AEOI
mode the ISR bit is reset at the end of the third INTA pulse. Otherwise, the ISR bit remains set
until an appropriate EOI command is issued at the end of the interrupt sequence.
Initialization Sequence
INITIALISATION COMMAND WORDS
ICW1
●A5±A15: Page starting address of service routines .In an MCS 80/85 system,
the 8 request levels will generate CALLs to 8 locations equally spaced in
memory. These can be programmed to be spaced at intervals of 4 or 8
memory locations, thus the 8 routines will occupy a page of 32 or 64 bytes,
respectively. The address format is 2 bytes long (A0±A15). When the routine
interval is 4, A0±A4 are automatically inserted by the 8259A, while A5±A15
are programmed externally. When the routine interval is 8, A0±A5 are
automatically inserted by the 8259A, while A6±A15 are programmed
externally.
●T: If LTIM is 1, then the 8259A will operate in the level interrupt mode. Edge
detect logic on the interrupt inputs will be disabled.
●ADI: CALL address interval. ADI = 1 then interval = 4; ADI e 0 then interval e
8.
●SNGL: Single. Means that this is the only 8259A in the system. If SNGL = 1 no
ICW3 will be issued.
IC4: If this bit is set ICW4 has to be read. If ICW4 is not needed, set IC4 = 0.
●
ICW 2
ICW 3
This word is read only when there is more than one 8259A in the system and cascading is used, in
which case SNGL e 0. It will load the 8-bit slave register.
The functions of this register are:
● a. In the master mode (either when SP = 1, or in buffered mode when M/S = 1 in ICW4) a ``1''
is set for each slave in the system. The master then will release byte 1 of the call sequence
(for MCS- 80/85 system) and will enable the corresponding slave to release bytes 2 and 3 (for
8086 only byte 2) through the cascade lines.
● b. In the slave mode (either when SP e 0, or if BUF e 1 and M/S e 0 in ICW4) bits 2±0 identify
the slave. The slave compares its cascade input with these bits and, if they are equal, bytes 2
and 3 of the call sequence (or just byte 2 for 8086) are released by it on the Data Bus. d only
when there is more than one 8259A in the system and cascading is used, in which
If BUF=0,M/S is to be neglected.
Programmable Interval
Timer 8253
●The Intel 8253 is a programmable counter /
timer chip designed for use as an Intel
microcomputer peripheral. It uses N-MOS
technology with a single +5V supply and is
packaged in a 24-pin plastic DIP.
●It is organized as 3 independent 16-bit
counters, each with a counter rate up to 2 MHz .
All modes of operation are software
programmable.
●Clock This is the clock input for the counter.
The counter is 16 bits. The maximum clock
frequency is 1 / 380 nanoseconds or 2.6
megahertz. The minimum clock frequency is DC
or static operation.
●Out This single output line is the signal that is
the final programmed output of the device.
Actual operation of the out line depends on how
the device has been programmed.
●Gate This input can act as a gate for the clock
input line, or it can act as a start pulse,
depending on the programmed mode of the
counter.
Block diagram of 8253
Data Bus Buffer :
●This tri-state, bi-directional, 8-bit buffer is used to interface the 8253/54 to the
system data bus. The Data bus buffer has three basic functions.
1. Programming the modes of 8253/54.
2. Loading the count registers.
3. Reading the count values.
Read/Write Logic : The Read/Write logic has five signals : RD, WR, CS and the
●address lines A0 and A1. In the peripheral I/O mode, the RD, and WR signals are
connected to IOR and IOW, respectively. In memory-mapped I/O, these are connected
to MEMR and MEMW. Address lines A0 and A1 of the CPU are usually connected to
lines A0 and A1 of the 8253/54, and CS is tied to a decoded address. The control word
register and counters are selected according to the signals on lines A0 and A1.
Control Word Register :
Counters :
These three functional blocks are identical in operation. Each counter
●consists of a single, 16 bit, pre-settable, down counter. The counter can
operate in either binary or BCD and its input, gate and output are configured
by the selection of modes stored in the control word register. The counters
are fully independent. The programmer can read the contents of any of the
three counters without disturbing the actual count in process.
Programming the 8253/54 :
●Each counter of the 8253/54 is individually programmed by writing a control word
into the control word register (A0 - A1 = 11).
WRITE Operation :
READ Operation :
In some applications, especially in event counters, it is necessary to read the
value of the count in process. This can be done by two possible methods:
1.Simple Read :
It involves reading a count after inhibiting the counter by controlling the
gate input or the clock input of the selected counter, and two I/O read operations are
performed by the CPU. The first I/O operation reads the low-order byte, and the
second I/O operation reads the high order byte.
2. Counter Latch Command :
In the second method, an appropriate control word is written into the
control register to latch a count in the output latch, and two I/O read operations are
performed by the CPU. The first I/O operation reads the low-order byte, and the
second I/O operation reads the high order byte.
MODES OF 8253
● Mode 0 : Interrupt on terminal count
● MODE 1 : Hardware Retrigger able One-shot
● MODE 2 : Rate generator
● MODE 3 : Square Wave Rate Generator
● MODE 4 : Software Triggered Strobe.
● MODE 5 : Hardware triggered strobe (Retrigger able).
Mode 0 : Interrupt on terminal count
● 1) The output will be initially low after the mode set operation.
● 2) After the count is loaded into the selected count Register the output
will remain low and the counter will count.
● 3) When the terminal count is reached the output will go high and
remain high until the selected count is reloaded.
● 1)Gate = 1 enables counting.
● 2) Gate = 0 disables counting.
Operating Modes of 8254
Mode 0: Interrupt on terminal count
N=5
5 4 3 2 1 0
CLK
___
WR
GATE=1
OUT
N Clock Cycles
a) Normal operation
1) The output will be initially high
2) The output will go low on the CLK pulse following the rising edge at the
gate input.
3) The output will go high on the terminal count and remain high until the
next rising edge at the gate input.
b) Retriggering
The one shot is retrigger able, hence the output will remain low for the
full count after any rising edge of the gate input.
c) New count
If the counter is loaded during one shot pulse, the current one shot is not
affected unless the counter is retriggered. If retriggered, the counter is
loaded with the new count and the one-shot pulse continues until the
new count expires.
Mode 1: Hardware Retriggerable One Shot
N=5
5 4 3 2 1 0
CLK
___
WR
GATE
OUT
N Clock Cycles
CLK
___
WR
GATE=1
OUT
CLK
___
WR
GATE=1
OUT
pulse and counting will continue from the new count. If the count is two byte
then
1) Writing the first byte has no effect on counting.
2) Writing the second byte allows the new count to be loaded on the next CLK
pulse.
Mode 4: Software Triggered Strobe
N=5
5 4 3 2 1 0
CLK
___
WR
GATE=1
OUT
5 4 3 2 1 0
CLK
___
WR
GATE
OUT