Mp Unit3 Notes
Mp Unit3 Notes
A microprocessor needs to communicate with external devices, including memory and peripheral
devices like input/output (I/O) devices. The process of connecting these devices to the
microprocessor is called interfacing. Interfacing ensures seamless communication between the
CPU and external components for data transfer and control operations.
2. Types of Interfacing
Below is a basic memory interfacing diagram for the 8085 Microprocessor, showing how the
address and data lines connect to memory.
3.3 Control Signals for Memory Interfacing
1. Isolated I/O – Separate address space for memory and I/O devices.
2. Memory-Mapped I/O – Treats I/O devices as memory locations.
4.2 I/O Interfacing Diagram
5. Interfacing Examples
5.1 Interfacing 8255 (Programmable Peripheral Interface - PPI) with 8085
The 8255 PPI (Programmable Peripheral Interface) is used to interface input and output devices
with the microprocessor.
ADC is used to convert analog signals (like temperature, pressure, etc.) into digital form.
┌───────────────┐
│ ADC0808 │
│ (Analog Input) │
├───────────────┤
│ Digital Output │──────▶ 8085 Data Bus
│ Control Signals │──────▶ RD, WR, INTR
└───────────────┘
There are three types of data transmission based on how data moves between devices.
• Multiple bits (usually 8, 16, or 32 bits) are transmitted simultaneously over multiple
channels.
• Faster but prone to crosstalk and signal degradation over long distances.
• Used in RAM, CPU Data Bus, and Printer Communication.
Diagram:
• Data is sent in small chunks with start and stop bits to indicate the beginning and end.
• No clock signal is required.
• Used in USB, RS232 Serial Communication, and IoT Devices.
• In a normal data transfer, the CPU reads data from an I/O device and then writes it to
memory. This creates a bottleneck.
• DMA allows direct memory access, freeing up the CPU for other tasks.
• Used in high-speed devices like disk drives, sound cards, graphics processors, and
network cards.
fi
fi
Pin Diagram of 8257 DMA Controller
Pin Description
D0 – D7 8-bit data bus for communication with CPU.
2. Control Signals
Pin Description
HRQ (Hold Request) Requests control of the system bus from CPU.
HLDA (Hold Acknowledge) CPU grants DMA access to the bus.
TC (Terminal Count) Indicates transfer completion.
3. Read/Write Control
Pin Description
MEMR (Memory Read) Reads data from memory.
MEMW (Memory Write) Writes data to memory.
IOR (I/O Read) Reads data from an I/O device.
IOW (I/O Write) Writes data to an I/O device.
Pin Description
DRQ0 – DRQ3 (DMA Request) Each I/O device requests DMA transfer via these pins.
DACK0 – DACK3 (DMA Acknowledge) Acknowledges DMA transfer to I/O device.
• DMA transfers one byte at a time, allowing the CPU to use the bus between transfers.
• Used in sound cards and slow-speed devices.
3. Transparent Mode
• DMA only transfers data when CPU is not using the system bus.
• CPU works continuously without interruptions.
• Used in background data transfer applications.
1. Address bus (A0–A7) and data bus (D0–D7) are connected to 8085.
2. Control signals (HRQ, HLDA) manage bus access.
3. DRQ and DACK lines handle DMA requests from I/O devices.
Interfacing Diagram
+-----------+ +--------+
| 8085 CPU | ----| 8257 DMA |
+-----------+ +--------+
| |
(HLDA) (HRQ)
| |
(MEMR) (MEMW)
| |
Memory I/O Devices
• It has three 8-bit ports (PA, PB, PC), which can be programmed for input or output
operations.
• Supports mode selection for exible communication with peripherals.
• Commonly used in embedded systems, robotics, and industrial automation.
Features of 8255
✔ 3 Programmable Ports:
D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0
--------------------------------------
1 | Mode Selection | PA | PB | PC
Bit Function
D7 Set to 1 for Mode selection.
D6-D5 Select Mode (0,1,2).
D4 Port A direction (1 = Input, 0 = Output).
D3 Port C Upper (1 = Input, 0 = Output).
D2 Port B direction (1 = Input, 0 = Output).
D1 Port C Lower (1 = Input, 0 = Output).
D0 Mode selection (1 = Mode set, 0 = Bit Set/Reset).
Modes of Operation
1. Mode 0 (Basic I/O Mode)
+-----------+ +--------+
| 8085 CPU | ----> | 8255 PPI |
+-----------+ +--------+
| |
(RD) (WR)
| |
(A0, A1) (CS, RESET)
| |
LEDs, LCDs, Switches, Sensors
Example: Controlling LEDs using 8255
If we want Port A to control LEDs (output mode) and Port B to read switches (input mode):
1. Asynchronous Mode
D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0
--------------------------------------
Mode | Parity | Stop Bits | Data Bits
Bit Function
D7-D6 Mode selection (Sync/Async).
D5 Parity Enable (1 = Enable, 0 = Disable).
D4 Parity Type (1 = Odd, 0 = Even).
D3 Stop Bits (1 = 1 bit, 2 = 2 bits).
D2-D1 Character Length (Data Bits: 5, 6, 7, 8).
D0 Baud Rate Factor (1 = x16, 0 = x1).
Interfacing 8251 with 8085 Microprocessor
• 8251 is memory-mapped or I/O-mapped to 8085.
• Data bus (D0-D7) is connected to CPU data lines.
• Control signals (RD, WR, CS, C/D) manage data ow.
• TXD and RXD are connected to serial devices.
Interfacing Diagram
+-----------+ +---------+
| 8085 CPU | ----> | 8251 USART |
+-----------+ +---------+
| |
(RD) (WR)
| |
(A0, A1) (CS, RESET)
| |
TXD → Serial Output (To Modem)
RXD ← Serial Input (From Modem)
Programming 8251 USART
Step 1: Initialize USART (Asynchronous Mode, 8-bit, 1 Stop Bit)
• Keyboard Section: Scans and debounces keypresses, supports multiple keypress detection.
• Display Section: Controls multiplexed 7-segment displays or alphanumeric displays.
• FIFO Buffer: Stores keypress data before sending it to the CPU.
1. Keyboard Interface
◦ Scans a matrix keyboard (8×8 or 4×4 con guration).
◦ Provides debouncing and auto-repeat functions.
◦ Supports FIFO buffer (8-byte queue) for keypress storage.
◦ Supports single-key, multi-key, and encoded modes.
2. Display Interface
D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0
--------------------------------------
Mode | Scan Rate | Keyboard | Display
Bit Function
D7-D6 Keyboard mode (Scanned/Encoded).
D5-D4 Scan Rate (Determines scanning speed).
D3 Auto-repeat enable (1 = Enable, 0 = Disable).
D2 Key debounce (1 = Enable, 0 = Disable).
D1-D0 Display Mode (Left/Right Entry).
+-----------+ +---------+
| 8085 CPU | ----> | 8279 |
+-----------+ +---------+
| |
(RD) (WR)
| |
(A0, A1) (CS, RESET)
| |
SL0-SL3 → Keyboard Scan Rows
RL0-RL7 ← Keyboard Return Lines
OUT0-OUT3 → Display Segments
fi
fl
Programming 8279
Step 1: Initialize 8279 (Keyboard & Display Mode)
Features of 8259
✔ Handles up to 8 interrupt requests (IR0-IR7).
✔ Can be cascaded to support up to 64 interrupts.
✔ Allows priority assignment to interrupts.
✔ Supports edge-triggered and level-triggered interrupts.
✔ Supports maskable and non-maskable interrupts.
✔ Communicates with the CPU using an interrupt vector.
✔ Fast interrupt handling using a priority resolver.
Applications of 8259
✔ Embedded Systems (Microcontroller-based devices)
✔ Computer Systems (PCs, Servers, and Embedded Processors)
✔ Real-Time Systems (Industrial automation, medical devices)
✔ Communication Systems (Network interface cards, routers)
✔ Defense & Aerospace (Radar systems, military communication)
fi
fi