Docsity

Microprocessor Programming : 8255 PPI, 8257 DMA and 8259 Interrupt Controller, Study notes of Computer science

Toggle sidebar
bg1
1. 8255 Programmable Peripheral Interface (PPI)
1.1 Introduction
8255 PPI: A general-purpose programmable Input/Output device designed by Intel to
interface a microprocessor (8085, 8086, etc.) with external peripherals such as an ADC,
DAC, keyboard, printer, and similar devices.
• It increases the I/O handling capacity of a microprocessor system.
• It provides three 8-bit bidirectional I/O ports: Port A, Port B, and Port C.
• Each port (or group of ports) can be individually configured as input or output through
software, without changing any hardware — hence the name "programmable".
• It works with almost any microprocessor because data transfer takes place over a
standard 8-bit bidirectional data bus.
1.2 Features of 8255 PPI
• Designed to work with various microprocessors such as 8085, 8086, etc.
• Designed to increase the capacity of an Input/Output interface.
• Has three 8-bit bidirectional I/O ports.
• Supports three I/O modes of data transfer:
◦ Simple I/O mode (Mode 0)
◦ Handshake I/O mode (Mode 1)
◦ Bidirectional handshake I/O mode (Mode 2)
• Has a Bit Set/Reset (BSR) mode to alter individual bits of Port C.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download Microprocessor Programming : 8255 PPI, 8257 DMA and 8259 Interrupt Controller and more Study notes Computer science in PDF only on Docsity!

1. 8255 Programmable Peripheral Interface (PPI)

1.1 Introduction

8255 PPI: A general-purpose programmable Input/Output device designed by Intel to interface a microprocessor (8085, 8086, etc.) with external peripherals such as an ADC, DAC, keyboard, printer, and similar devices.

  • It increases the I/O handling capacity of a microprocessor system.
  • It provides three 8-bit bidirectional I/O ports: Port A, Port B, and Port C.
  • Each port (or group of ports) can be individually configured as input or output through software, without changing any hardware — hence the name "programmable".
  • It works with almost any microprocessor because data transfer takes place over a standard 8-bit bidirectional data bus.

1.2 Features of 8255 PPI

  • Designed to work with various microprocessors such as 8085, 8086, etc.
  • Designed to increase the capacity of an Input/Output interface.
  • Has three 8-bit bidirectional I/O ports.
  • Supports three I/O modes of data transfer: ◦ Simple I/O mode (Mode 0) ◦ Handshake I/O mode (Mode 1) ◦ Bidirectional handshake I/O mode (Mode 2)
  • Has a Bit Set/Reset (BSR) mode to alter individual bits of Port C.

1.3 Internal Block Diagram

Key internal blocks

Data Bus Buffer: Acts as an interface between the internal bus of the 8255 and the system data bus (D0–D7); it is bidirectional and tri-state.

Read/Write Control Logic: Manages all internal and external data transfers based on the RD', WR', A0, A1, RESET, and CS' signals.

Group A Control: Controls Port A (PA7–PA0) and the upper nibble of Port C (PC7–PC4). It receives control signals from the internal data bus (the control word) and forwards them to the respective ports.

Group B Control: Controls Port B (PB7–PB0) and the lower nibble of Port C (PC3–PC0), working the same way as Group A Control.

Port A, Port B, Port C: Three 8-bit bidirectional I/O ports through which actual data is exchanged with external peripherals.

1.4 Read/Write Control Logic

  • The 8255 reads and writes data according to the control signals RD' and WR' connected from the microprocessor.
  • RESET clears (resets) the 8255.
  • A1 and A0 are used to select the specific port or the control word register.
  • CS' (Chip Select, active low) is used to select the 8255 chip itself.
  • RD' — Read input (active low); enables the 8255 to send data to the CPU.
  • WR' — Write input (active low); enables the CPU to write data/control words into the
  • CS' — Chip select (active low); selects the 8255 chip for data transfer.
  • A1 and A0 — Address pins; used to select one of the three ports or the control register.

1.8 Functioning (Operating) Modes of 8255

The functioning mode of the 8255 is decided by the control word written into the control register. The most significant bit (D7) of the control word determines whether the chip works in BSR mode or I/O mode.

1.8.1 Bit Set/Reset (BSR) Mode

BSR Mode: If the MSB of the control word (D7) is 0, the PPI works in BSR mode. In this mode, only the bits of Port C can be individually set or reset; the rest of the control word bits select which bit of Port C is affected and whether it is set or reset.

1.8.2 Input-Output Mode

Input-Output Mode: If the MSB of the control word (D7) is 1, the PPI works in Input- Output mode. This mode is further divided into three sub-modes: Mode 0, Mode 1, and Mode

Mode 0 — Simple Input/Output

In this mode, all three ports (Port A, Port B, Port C) can work as a simple input function or a simple output function. There is no interrupt handling capability in this mode.

Mode 1 — Handshake I/O Mode

In this mode, either Port A or Port B can work as a simple input port or a simple output port, while the bits of Port C are used for handshake signals that occur before the actual data transmission. Mode 1 has interrupt handling capacity, and both input and output data are latched.

Example: When a CPU wants to transfer data to a printer, the processor is much faster than the relatively slow printer. So, before the actual data transfer, the CPU sends handshake signals to the printer to synchronize the speed difference between the CPU and the peripheral.

Mode 2 — Bidirectional Data Bus Mode

In this mode, only Port A can work in this bidirectional fashion, while Port B can work either in Mode 0 or Mode 1. The bits of Port C are used as handshake signals. Mode 2 also has interrupt handling capacity.

2. 8257 DMA Controller (DMAC)

2.1 Why DMA Is Needed

  • It operates in two modes: Master mode and Slave mode.

2.5 Operation of DMA Controller in a Microprocessor System

2.6 8257 Internal Architecture

Key control signals

HOLD: Hold signal — sent by the DMA controller to the CPU requesting control of the buses.

HLDA: Hold Acknowledgment — sent by the CPU to the DMA controller granting control of the buses.

DREQ: DMA Request — sent by a peripheral device to the DMA controller requesting a DMA transfer.

DACK: DMA Acknowledgment — sent by the DMA controller to the peripheral device confirming that its DMA request has been granted.

2.7 8257 Pin Diagram (40-pin DIP)

2.8 Detailed Pin/Signal Descriptions

DRQ0–DRQ3: The four individual channel DMA request inputs, used by peripheral devices to request DMA services. In fixed priority mode, DRQ0 has the highest priority and DRQ has the lowest.

DACK0'–DACK3': Active-low DMA acknowledge lines that update the requesting peripheral about the status of its request; they can also act as strobe lines for the requesting devices.

2.9 Example — Floppy Drive DMA Transfer

  • Step 1: The floppy drive sends a DMA Request (DREQ) to the DMAC, indicating that it wants DMA service.
  • Step 2: The DMAC sends a Hold Request (HRQ) to the CPU.
  • Step 3: After accepting the request, the CPU sends a Hold Acknowledgment (HLDA) to the DMAC — the microprocessor releases control of the address and data buses, and is bypassed during the DMA service.
  • Step 4: The DMAC sends an acknowledgment (DACK) to the floppy drive on the I/O port, telling it to be ready for DMA service.
  • Step 5: Using the I/O read and memory write signals, the data is transferred directly from the floppy drive to memory.

2.10 Modes of DMAC

Single Mode

Only one channel is used, meaning only a single DMAC is connected to the bus system.

Cascade Mode

Multiple channels are used, and additional DMACs can be cascaded to further increase the number of channels available.

2.11 Advantages of DMA

Improved performance: DMA frees the CPU to perform other tasks while data is transferred between memory and I/O devices, allowing faster and more efficient data transfer.

Reduced CPU overhead: The CPU is not required to be involved in the data transfer, which reduces its overhead and lets it focus on other tasks — particularly useful in real-time systems needing low latency and fast response.

Support for high-bandwidth devices: DMA can support high-bandwidth devices such as graphics cards and network interfaces that require fast data transfer rates.

Efficient use of system resources: DMA allows multiple devices to access memory simultaneously, making more efficient use of system resources.

2.12 Disadvantages of DMA

Complexity: DMA requires specialized hardware and software to function, adding to system complexity and making it harder to implement and troubleshoot.

Security risks: If not properly configured or secured, DMA can be a security risk — attackers can exploit DMA vulnerabilities to gain unauthorized access to a system or steal data.

Limited control: Since the CPU is not involved in the data transfer, it has limited control over the transfer process, which can lead to data corruption or errors if not properly managed.

Resource conflicts: DMA can lead to resource conflicts if multiple devices try to access memory simultaneously, potentially causing instability and performance issues.

3. Programmable Interrupt Controller (8259 PIC)

3.1 Introduction

Intel 8259: A Programmable Interrupt Controller (PIC). The 8085 microprocessor has 5 hardware interrupts and the 8086 has 2 hardware interrupts. By connecting an 8259 to these microprocessors, their interrupt-handling capability can be increased, since the 8259 combines multiple interrupt input sources into a single interrupt output line.

  • A single 8259 provides 8 interrupt inputs, IR0–IR7.
  • Example: interfacing the 8085 with an 8259 increases the 8085's interrupt-handling capability from 5 to 8 interrupt levels.

Interrupt Request Register (IRR): Stores all the interrupt levels that are currently requesting interrupt service.

Interrupt Service Register (ISR): Stores the interrupt level that is currently being executed.

Interrupt Mask Register (IMR): Stores the interrupt levels that are to be masked, by holding the masking bits for each interrupt level.

Priority Resolver: Examines the IRR, ISR, and IMR, and sets the priority of pending interrupts. The interrupt with the highest priority is placed into the ISR register, and the already-serviced interrupt level is reset in the IRR.

Cascade Buffer: Used to increase interrupt-handling capability by cascading additional 8259 chips. The CAS0–CAS2 lines are used to control the resulting multiple-interrupt structure.

SP/EN' (Slave Program/Enable Buffer): When set high, the chip works in master mode; otherwise it works in slave mode. In Non-Buffered mode, SP/EN' specifies whether the 8259 acts as master or slave; in Buffered mode, SP/EN' is used as an output to enable the data bus.

3.5 Priority Modes

1. Fully Nested Mode (default mode)

  • The standard mode of operation.
  • IR0 has the highest priority, and IR7 has the lowest.
  • When an interrupt is acknowledged, the controller inhibits all interrupts of equal or lower priority.
  • After the Interrupt Service Routine (ISR) completes, the mask is removed and interrupts are enabled again.
  • Used when a fixed priority scheme is acceptable.

2. Automatic Rotation Mode

  • After an interrupt is serviced, the priority rotates automatically.
  • The just-serviced interrupt line becomes the lowest priority, and the next line becomes the highest priority.
  • Ensures fairness among devices, since each device gets a chance to become the highest priority at some point.
  • Useful in systems where all devices are of equal importance.

3. Specific Rotation Mode

  • Similar to Automatic Rotation Mode, but the programmer can choose a specific interrupt line to be the lowest priority.
  • For example, if IR3 is chosen as the lowest priority, IR4 becomes the highest priority, followed by IR5, IR6, and so on, up to IR3.
  • Allows a customizable priority scheme.

4. Special Fully Nested Mode

  • Used in cascaded 8259 systems (when more than one PIC is connected).
  • Allows interrupts from a slave PIC to be recognized even when the master PIC has higher- or equal-priority interrupts pending.
  • Ensures proper nesting of interrupts in multi-level PIC configurations.

3.6 Characteristics of 8259

  • A single 8259 handles 8 interrupts; a cascaded configuration with 1 master and 8 slaves can handle up to 64 interrupts.
  • Can handle both edge-triggered and level-triggered interrupts.
  • Its priority structure can be easily altered.
  • Interrupts can be masked individually.
  • The vector address of interrupts is easily programmed.
  • It must be initialized with commands that determine properties such as vector numbers, priority, masking, and triggering mode.

3.7 Command Words of 8259

The different modes of operation of the 8259 are programmed by setting the bits of its ICW (Initialization Command Words) or OCW (Operation Command Words).

  • ICW — Initialization Command Words
  • OCW — Operation Command Words

3.7.1 Initialization Command Words (ICW)

  • ICW is given during the initialization of the 8259, i.e., before it starts functioning.
  • ICW1 and ICW2 are compulsory for initialization.
  • ICW3 is given only during a cascaded configuration.
  • If ICW4 is needed, this requirement is specified within ICW1.
  • The sequence of ICW commands is fixed: ICW1 is given first, then ICW2, then ICW3 (if needed), then ICW4 (if needed).
  • No individual ICW command can be repeated, though the entire initialization process may be repeated if required.

ICW1 command

  • Recognized as ICW1 when A0 = 0 and D4 = 1.
  • Contains control bits for edge/level triggering mode, single/cascaded mode, call address interval, and whether ICW4 is required.

ICW4 command

  • When AEOI = 1, Automatic End of Interrupt mode is selected.
  • When SFMN = 1, Special Fully Nested mode is selected.
  • When BUF = 0, Non-buffered mode is used (M/S is a don't-care); when BUF = 1 and M/S = 1, the 8259 is the master; otherwise it is a slave.
  • When μPM = 1, 8086 operations are performed; otherwise 8085 operations are performed.

3.7.2 Operation Command Words (OCW)

OCW

Used to set and reset the mask bits in the Interrupt Mask Register (IMR). Bits M7–M describe the 8 mask bits, one per interrupt line.

OCW

Used to select the mode of operation of the 8259. Bits L2–L0 describe the interrupt level on which the action needs to be performed.

OCW

  • When the ESMM (Enable Special Mask Mode) bit is set, the SMM bit's value determines behaviour: if SMM = 1 and ESMM = 1, the 8259 enters Special Mask Mode.
  • If ESMM = 1 and SMM = 0, the 8259 returns to normal mask mode.
  • RR and RIS bits are used to issue the read register command.
  • P = 1 is used to issue the poll command.

4. Summary / Quick Comparison

Device Full Form Primary Function Key Capacity 8255 Programmable Peripheral Interface (PPI)

General-purpose parallel I/O interfacing

3 ports x 8 bits (Port A, B, C); Modes 0, 1, 2, BSR 8257 DMA Controller High-speed direct data 4 channels, 16-