Chapter 3 Full
Chapter 3 Full
& TECHNOLOGY
1
INTERFACING
Memories and I/O Interfacing
0 0 0 PORT A 80 H
0 0 1 PORT B 81 H
0 1 0 PORT C 82 H
Control
0 1 1 83 H
Register
1 X X No Seletion X
BASIC DESCRIPTION OF THE 8255
Features:
⮚ It is a programmable device.
⮚ T T L compatible.
BASIC DESCRIPTION OF THE 8255
⮚ 8255A has three ports
⮚ PORT A
⮚ PORT B
⮚ PORT C
⮚ Port A and Port B are 8 bit parallel ports.
⮚ Port C can be split into two parts, i.e. PORT C
lower (PC0-PC3) and PORT C upper (PC7-PC4)
by the control word.
8255
⮚ These three ports are further divided into two
groups,
⮚ i.e. Group A includes PORT A and upper PORT C.
⮚ Group B includes PORT B and lower PORT C
⮚ These two groups can be programmed in
three different modes.
OPERATING MODES OF 8255
• Three operating modes :
– Mode-0(simple I/O port)
– Mode-1(Handshake I/O port)
– Mode-2(Bidirectional I/O port)
MODE 0
⮚ In this mode, Port A and B is used as two
8-bit ports and Port C as two 4-bit ports.
⮚ Each port can be programmed in either
input mode or output mode where
outputs are latched and inputs are not
latched.
⮚ Ports do not have interrupt capability.
⮚ Ports in mode 0 is used to interfaces LEDs,
Hexa keypad and 7 segment LEDS to the
processor.
MODE 1
⮚ In this mode, Port A and B is used as 8-bit I/O
ports.
⮚ They can be configured as either input or
output ports.
⮚ Each port uses three lines from port C as
handshake signals.
⮚ Inputs and outputs are latched
• MODE 1 :(Input/output with Hand shake)
• In this mode, input or output is transferred by
hand shaking Signals.
Busy
A1 A0 Select
0 0 PA
0 1 PB
1 0 PC
Control
1 1
reg.
⮚ RESET: This is used to reset the device. That means
clear control registers.
⮚ PB0-PB7:Similar to PA
X X X BIT
SET/RESET
Don’t care 1=SET
0=RESET
Bit select
0 1 2 3 4 5 6 7
B0
0 1 0 1 0 1 0 1
0 0 1 1 0 0 1 1
B1 0 0 1 1 1 1
0 0
B2SET/RESET FLAG
BIT
=0 Active
CONTROL WORDS
• FOR BIT SET/RESET MODE:
Group A Group B
Port C Upper
1=Input Port C Lower
Mode set
0=Output 1=Input
1-I/O mode
0-BSR mode Port B 0=Output
1=Input Port B
0=Output 1=Input
Mode 0=Output
selection
Mode selection
00=mode 0
0=mode 0
01=mode 1
1=mode 1
1x=mode 2
• The control word for both mode is same.
• Bit D7 is used for specifying whether word
loaded in to Bit set/reset mode or Mode
definition word.
• D7=1=Mode definition mode.
• D7=0=Bit set/Reset mode.
BASIC DESCRIPTION OF THE 8255
⚫The 8255 provides 24 I/O lines which may
be individually programmed in 2 groups of
12 I/O lines and used in 3 major modes of
operation.
⚫These 24 I/O lines organized as three 8-bit
I/O ports labeled A, B, and C.
⚫The chip interfaces directly to the data bus
of the processor, allowing its function to be
programmed;
⚫That is, in one application a port may appear
as an output, but in another, by
reprogramming it, as an input.
BASIC DESCRIPTION OF THE 8255
⚫Each of the ports, A or B, can be
programmed as an 8-bit input or output
port.
⚫Port C can be divided in half, with the topmost
or bottommost four bits programmed as inputs
or outputs.
⚫Individual bits of a particular port cannot be
programmed.
PIN CONFIGURATION OF THE 8255
⚫ The pin configuration of the 8255 is shown in Figure 1.
▪ GND: System ground
▪ VCC: System power
▪ RESET: A high on this input clears the control register and all ports are set to
the input mode.
▪ PA7-0: Port A bits
▪ PB7-0: Port B bits
▪ PC7-0: Port C bits
▪ D7-0: A bi-directional, tri-state data bus lines, connected to the system data
bus.
▪ RD’: A read input control, that is low during CPU read operations.
▪ WR’: A write input control, that is low during CPU write operations.
▪ CS’: A chip select control. A low on this input enables the 8255 to respond
to RD’ and WR’ signals. RD’ and WR’ are ignored otherwise.
▪ A1-0: Address lines which in conjunction with RD’ and WR’, control the
PIN CONFIGURATION OF THE 8255
Port Enable
Chip Select (CS’)
Select Even Byte
(A1 A0)
(D0-D7)
Step(2): Design control logic (IOW’ & IOR’)
Figure 3: Interface of the 8255 in Example 1
PROGRAMMING THE 8255
⚫There are three basic modes of
operation that can be selected by the
system software:
◦ Mode 0: Basic input/output
◦ Mode 1: Strobed Input/output
◦ Mode 2: Bi-directional Bus
PROGRAMMING THE 8255
⚫When the reset input of the 8255 goes
"high" all ports will be set to the input
mode with all 24 port lines held at a
logic "one" level.
⚫After the reset is removed the 8255 can
remain in the input mode with no
additional initialization required.
⚫During the execution of the system
program, any of the other modes may be
selected by using a single output
instruction.
⚫The modes for Port A and Port B can be
separately defined, while Port C is
divided into two portions.
PROGRAMMING THE 8255
⮚ Figure 4 shows the format of the control
byte used to program the 8255.
⮚ There are two types of control bytes:
⮚ (a) When bit 7 = 0, a bit set/reset operation
is indicated;
⮚ (b) When bit 7 = 1, any of the modes 0, 1, or
2 can be programmed.
⮚ The ports in Group A can be programmed
for any of modes 0, 1, or 2.
⮚ The ports in Group B can only be
programmed for modes 0 or 1.
Figure 4: The format of the control byte of the 8255.
PROGRAMMING THE 8255
⮚ Example 2: Write the 80x86
initialization routine required to
program the 8255 in Figure 5 for mode
0, with port A as an output and ports B
and C inputs
⮚ The control word is formed as:
⮚ 🞄 1 00 0 1 0 1 1 = 8BH
⮚ The program is as follows:
⮚ 🞄 MOV AL,8BH ;Control byte to AL
⮚ 🞄 OUT 6,AL ;Write to control port
Figure 5: Circuit design of Example 2.
PROGRAMMING THE 8255
⚫Example 3: Write an 80x86 program to
input a byte from port B of the PPI chip
in pervious example and output this
byte to port A of the same chip. Assume
the chip has been programmed as in
the previous example.
HOL
HLDA
DMA on the 8086
Microprocessor
⚫ The I/O device asserts the appropriate DRQ signal for the channel.
⚫ The DMA controller will enable appropriate channel, and ask the
CPU to release the bus so that the DMA may use the bus. The DMA
requests the bus by asserting the HOLD signal which goes to
the CPU.
⚫ The CPU detects the HOLD signal, and will complete executing the
current instruction. Now all of the signals normally generated
by the CPU are placed in a tri-stated condition (neither high or
low) and then the CPU asserts the HLDA signal which tells the
DMA controller that it is now in charge of the bus.
⚫ The CPU may have to wait (hold cycles).
⚫ DMA activates its -MEMR, -MEMW, -IOR, -IOW output signals,
and the address outputs from the DMA are set to the target address,
which will be used to direct the byte that is about to
transferred to a specific memory location.
36
DMA on the 8086
Microprocessor
⚫ The DMA will then let the device that requested the DMA transfer
know that the transfer is commencing by asserting the -DACK
signal.
⚫ The peripheral places the byte to be transferred on the bus Data
lines.
⚫ Once the data has been transferred, The DMA will de-assert the -
DACK2 signal, so that the FDC knows it must stop placing data on
the bus.
⚫ The DMA will now check to see if any of the other DMA channels
have any work to do. If none of the channels have their DRQ lines
asserted, the DMA controller has completed its work and will
now tri-state the - MEMR, -MEMW, -IOR, -IOW and address
signals.
⚫ Finally, the DMA will de-assert the HOLD signal. The CPU sees
this, and de-asserts the HOLDA signal. 37Now the CPU resumes
EXAMPLE
⚫Assuming that a DMA initialization has an
overhead of 10 cycles, while a CPU transfer
to/from memory requires 4 cycles (no wait states
required), compare a DMA and a CPU transfer
from one memory location to another of
◦ One byte of data
◦ A block of 1Kbytes in burst mode
◦ A block of 64Kbytes in burst mode
38
THE 8237 DMA CONTROLLER
🞆 Supplies memory and I/O with control
signals and addresses during DMA transfer
🞆 4-channels (expandable)
⚫ 0: DRAM refresh
⚫ 1: Free
⚫ 2: Floppy disk controller
⚫ 3: Free
🞆 1.6MByte/sec transfer rate
🞆 64 KByte section of memory
address capability with single
programming
8237 PINS
⮚ CLK: System clock
⮚ CS΄: Chip select (decoder output)
⮚ RESET: Clears registers, sets mask register
⮚ READY: 0 for inserting wait states
⮚ HLDA: Signals that the μp has relinquished buses
⮚ DREQ3 – DREQ0: DMA request input for each channel
⮚ DB7-DB0: Data bus pins
⮚ IOR΄: Bidirectional pin used during programming
⮚ and during a DMA write cycle
⮚ IOW΄: Bidirectional pin used during programming and during a
DMA read cycle
⮚ EOP΄: End of process is a bidirectional signal used as input to terminate a DMA
process or as output to signal the end of the DMA transfer
⮚ A3-A0:Address pins for selecting internal registers
⮚ A7-A4: Outputs that provide part of the DMA transfer address
⮚ HRQ: DMA request output
⮚ DACK3-DACK0: DMA acknowledge for each channel.
⮚ AEN:Address enable signal
⮚ ADSTB:Address strobe
⮚ MEMR΄: Memory read output used in DMA read cycle
⮚ MEMW΄: Memory write output used in DMA write cycle.
8237 PIN DIAGRAM
41
A 8237 DMA application
DMA ARCHITECTURE
8237 REGISTERS
⮚ CAR (Current Address Register): holds
the 16-bit memory address used for the
DMA transfer (one for each channel),
either incremented or decremented
during the operation.
⮚ CWCR (Current Word Count Register):
Programs a channel for the number of
bytes (up to 64K) transferred during a
DMA operation.
⮚ BA (Base Address) and WC (Word).
⮚ MR (Mode Register):
44
⚫MR (Mask
Register):
⚫SR (Status
Register):
Shows the
status of each
8237 SOFTWARE COMMANDS
8237 SOFTWARE COMMANDS
🞆 Clear First/Last Flip-Flop - This command is executed
prior to writing or reading new address or word count
information to the 82C37. This command initializes
the flipflop to a known state (low byte first) so that
subsequent accesses to register contents by the
microprocessor will address upper and lower bytes in
the correct sequence.
🞆 Set First/Last Flip-Flop - This command will set the flip-
flop to select the high byte first on read and write
operations to address and word count registers.
🞆 Master Clear - This software instruction has the same
effect as the hardware Reset. The Command, Status,
Request, and Temporary registers, and Internal First/Last
Flip-Flop and mode register counter are cleared and the
Mask register is set. The 82C37A will enter the idle
cycle.
🞆 Clear Mask Register - This command clears the mask
bits of all four channels, enabling them to accept
DMA requests.
🞆 Clear Mode Register Counter - Since only one
8237 block diagram