All 25 questions UPSC has asked on memory and I/O interfacing in the Electrical Engineering Optional (Paper II, Microprocessors and Microcomputers) from 2004 to 2026, solved step by step – latest first.
Try them yourself first: the same questions, without solutions, are on our Microprocessors and Microcomputers topic-wise PYQs page. Circuit diagrams have been redrawn from the question papers.
How we check these solutions
These are our own solutions, prepared with AI help. UPSC does not publish official answers. Every solution is checked a second way before it goes up, and says how:
- ✓ Checked by computer the numbers were worked out again independently in code (SymPy and NumPy: circuit equations, power balance, matrices, integrals).
- ✓ Answer checked step by step for theory and descriptive questions, every point was checked against the standard theory.
Where a printed question is wrong, unclear or incomplete, we say so and solve the intended version.
Spotted a mistake or a neater method? Tell us in the comments below or through Report an error.
Jump to a question (year · question number):
2026 · 4b(i) 2026 · 4b(ii) 2024 · 2b(i) 2024 · 2b(ii) 2023 · 3b(i) 2023 · 6b(i) 2022 · 3c 2021 · 8b 2019 · 2b 2019 · 6c 2018 · 1e 2017 · 1c(ii) 2017 · 2b 2016 · 1c 2015 · 3c 2013 · 6b(i) 2012 · 6b 2011 · 1c(i) 2011 · 6b(i) 2011 · 7b(i) 2010 · 7b 2007 · 7a 2005 · 4a 2005 · 200w/5a 2004 · 200w/5a
Write an assembly language program for the 8253/8254 (programmable interval timer) to operate in mode 3 and mode 2. Use counter 0 for which control word register address is 2DH and counter 0 address is 2BH. Input clock is 1 MHz and output frequency is 1 kHz.
Solution
Count. This is loaded LSB first, then MSB.
Control word (format SC1 SC0 · RW1 RW0 · M2 M1 M0 · BCD)
- Mode 3 (square wave): counter 0 = 00, LSB then MSB = 11, mode 011, binary 0. This gives 0011 0110 = 36H.
- Mode 2 (rate generator): mode 010 gives 0011 0100 = 34H.
Program, mode 3 (1 kHz square wave on OUT0)
| Instruction | Comment |
|---|---|
MVI A, 36H |
counter 0, LSB/MSB, mode 3, binary |
OUT 2DH |
control word register |
MVI A, E8H |
low byte of 1000 |
OUT 2BH |
counter 0 |
MVI A, 03H |
high byte |
OUT 2BH |
counter 0 starts counting |
HLT |
Program, mode 2 (1 kHz rate generator: one low pulse of one clock period every 1 ms)
| Instruction | Comment |
|---|---|
MVI A, 34H |
counter 0, LSB/MSB, mode 2, binary |
OUT 2DH |
|
MVI A, E8H |
|
OUT 2BH |
|
MVI A, 03H |
|
OUT 2BH |
|
HLT |
GATE0 must be held high. In mode 3, OUT0 is high for 500 counts and low for 500 (a 50 % duty, 1 kHz square wave). In mode 2, OUT0 stays high and goes low for 1 µs every 1000 counts.
(With BCD counting, the control words are 37H and 35H, and the count is 1000 written as 00H then 10H.)
✓ Checked by computer We worked out the count and both control words bit by bit in Python.
Design a hardware scheme to interface 8255 (programmable peripheral interface) with 8085, and configure its Port ‘A’ and Port ‘C’ as input ports and Port ‘B’ as output port. Write an assembly language program to take two different numbers from Port ‘A’ and Port ‘C’ and display the summation of these numbers on Port ‘B’ as output. Assume the port addresses are: Port A = 00H Port B = 01H Port C = 02H Control word register address: 03H.
Solution
Hardware scheme
- AD7–AD0 are demultiplexed with a 74LS373 latch, using ALE.
- Address lines A7–A2 = 000000 are decoded to give of the 8255, so the 8255 occupies 00H–03H. A1 and A0 select the port or control register.
- and (from IO/, and ) drive and . RESET OUT drives RESET.
Control word (mode 0: port A in, port C upper and lower in, port B out) (D7 = 1 I/O mode; D6 D5 = 00 mode 0; D4 = 1 A in; D3 = 1 C upper in; D2 = 0; D1 = 0 B out; D0 = 1 C lower in.)
Program
| Instruction | Comment |
|---|---|
MVI A, 99H |
control word |
OUT 03H |
configure the 8255 |
IN 00H |
first number from port A |
MOV B, A |
save it |
IN 02H |
second number from port C |
ADD B |
sum |
OUT 01H |
display the sum on port B |
HLT |
Check. With 25H at port A and 37H at port C, port B shows 5CH. A carry out of an 8-bit sum is lost. If needed, it can be shown on a spare LED by testing CY.
✓ Checked by computer We ran the program on an 8085 simulator in Python and checked the control word bit by bit.
Compare I/O mapped I/O and memory mapped I/O interfacing techniques used in 8085 microprocessor.
Solution
| Feature | I/O-mapped I/O (peripheral-mapped) | Memory-mapped I/O |
|---|---|---|
| Address | 8-bit port address (00H–FFH) | 16-bit address, like a memory location |
| Number of ports | 256 input + 256 output | Up to 64 K (shared with memory) |
| Instructions | Only IN and OUT (data through A) |
All memory instructions: MOV r, M, LDA, STA, ADD M, ANA M … |
| Control signals | , (IO/ = 1) | , (IO/ = 0) |
| Decoding | Only 8 address lines, so simpler and cheaper | 16 lines to decode, more hardware |
| Memory space | All 64 K is left for memory | Ports use up part of the memory map |
| Data transfer | Only between the port and the accumulator | Between the port and any register, or by arithmetic and logic directly |
| Speed of instruction | IN, OUT: 10 T-states |
MOV r, M: 7 T; LDA, STA: 13 T |
| Separation | I/O and memory clearly separated, which is safer | Accidental memory writes can disturb I/O |
Summary. I/O-mapped I/O is preferred in small systems with few ports, because decoding is simple and the whole memory map stays free. Memory-mapped I/O is chosen when many ports are needed or when powerful memory instructions should work directly on port data.
✓ Answer checked step by step Standard result.
What are the operating modes of Port-A of 8255? Explain handshake operation in I/O ports.
Solution
Operating modes of port A of the 8255A
- Mode 0: simple (basic) I/O. Port A is latched output or buffered input, with no handshake. The direction is fixed by the control word.
- Mode 1: strobed (handshake) I/O. Port A is input or output, and three lines of port C become its handshake and interrupt signals:
- input: PC4 = , PC5 = IBF, PC3 = INTR;
- output: PC7 = , PC6 = , PC3 = INTR.
- Mode 2: bidirectional handshake. Only port A can do this. PC3–PC7 are used: , IBF, , , INTR.
(Port B has modes 0 and 1 only.)
Handshake operation. A handshake synchronises the processor and a peripheral that work at different speeds. Each side signals when data is ready and when it has been taken, so no data is lost or read twice.
Input handshake (mode 1):
- The device places data on PA7–PA0 and pulses low. The 8255 latches the data.
- The 8255 sets IBF (input buffer full) high. This tells the device not to send more, and, if enabled, it raises INTR to interrupt the CPU.
- The CPU reads port A (). This clears INTR, and IBF goes low, so the device may send the next byte.
Output handshake (mode 1):
- The CPU writes to port A (). The 8255 makes (output buffer full) low, telling the device that data is ready.
- The device takes the data and pulses low. goes high, and INTR goes high to ask the CPU for the next byte.
The status of IBF and can also be read from port C, for polled (status-check) transfer instead of interrupts.
✓ Answer checked step by step Standard result.
Differentiate between full decoding and partial decoding techniques used by 8085 microprocessor to decode an address. Give advantages and disadvantages of each technique.
Solution
Full (absolute) decoding. All the address lines not used inside the chip are decoded to produce its chip-select. Each memory location or port then has one unique address.
Example: a 2 K × 8 EPROM uses A10–A0 internally. A15–A11 all go to the decoder, so the chip occupies exactly 0000H–07FFH.
Partial (linear) decoding. Only some of the higher address lines are decoded; the rest are ignored (“don’t care”). Each location then appears at several addresses (foldback or mirror addresses).
Example: if only A15 is used as the chip-select of the 2 K chip, it responds to any address with A15 = 0. The same 2 K block repeats 16 times in 0000H–7FFFH.
| Full decoding | Partial decoding | |
|---|---|---|
| Advantages | Unique addresses; no address space wasted; memory can be expanded freely without conflicts | Fewer gates and a simpler, cheaper decoder; less delay through the decoder |
| Disadvantages | More decoding hardware (more gates, larger decoder), slightly more propagation delay and cost | Foldback addresses waste memory space; later expansion is limited; a program using a “mirror” address may clash with another device |
| Use | Large systems, when memory and I/O will grow | Small dedicated systems with few chips (single-board controllers) |
✓ Answer checked step by step Standard result.
Write the steps involved in DMA data transfer. Also describe the functions of 8085 pins which are used in DMA data transfer.
Solution
DMA (direct memory access). Data moves directly between a fast I/O device and memory, without passing through the CPU registers. A DMA controller (such as the 8257 or 8237) takes control of the buses.
Steps in a DMA transfer
- Programming. The CPU first programs the DMA controller with the starting memory address, the byte count, and the mode (read, write or verify; single or block).
- Request. The I/O device that is ready requests service by raising DRQ to the DMA controller.
- Bus request. The DMA controller asks the CPU for the buses by raising HOLD.
- Grant. The 8085 completes the current machine cycle, floats its address, data and control lines (tri-state), and answers with HLDA.
- Acknowledge. The DMA controller sends DACK to the device, places the memory address on the address bus, and issues / (memory to I/O) or / (I/O to memory). Each byte moves directly in one bus cycle. The controller increments the address and decrements the count.
- Completion. When the count reaches zero (TC, terminal count), or DRQ is removed, the controller drops HOLD. The 8085 then lowers HLDA and takes back the buses.
8085 pins used in DMA
- HOLD (input). A request from the DMA controller for the buses. It is sampled in each machine cycle; the 8085 completes the current machine cycle first, so the response comes within one machine cycle.
- HLDA (output). Hold acknowledge. It goes high one clock cycle after the bus is released, meaning that the address/data bus, , , IO/ and ALE are now tri-stated. It goes low after HOLD is removed, and the CPU then resumes.
- The tri-state bus lines (A15–A8, AD7–AD0, , , IO/) are floated during the hold so that the DMA controller can drive them. ALE is also floated.
- READY can be used by slow devices during DMA.
✓ Answer checked step by step Standard result.
(i) Explain the use of MAR in interfacing the external memory to processor. (ii) Name various 8-bit and 16-bit internal registers in microprocessor 8085 and also, indicate which 8-bit registers can be paired to act as 16-bit register in several instructions.
Solution
(i) MAR in memory interfacing
The memory address register (MAR) holds the address of the memory location being accessed, so that the address stays stable on the address bus for the whole read or write cycle.
In the 8085, this role is played by the address latch and buffers. The lower byte comes out on the multiplexed AD7–AD0 lines only in T1. So an external latch (such as the 74LS373), strobed by ALE, captures A7–A0, while A15–A8 come from the address buffer. Together they act as the MAR for the memory chips.
- The memory decodes the MAR contents (chip select from the high-order bits; the word inside the chip from the low-order bits).
- Data then moves through the data buffer (the memory buffer register, MBR).
- Without this latch, the memory would lose the low-order address when AD7–AD0 switch over to carrying data in T2.
(ii) Registers of the 8085
- 8-bit registers:
- accumulator A;
- general-purpose registers B, C, D, E, H, L;
- flag register F (S, Z, AC, P, CY);
- instruction register and temporary register (not accessible to the programmer).
- 16-bit registers: program counter (PC), stack pointer (SP), and the incrementer/decrementer address latch.
- Register pairs that act as 16-bit registers in instructions such as
LXI,INX,DCX,DAD,PUSHandPOP:- BC (B high, C low);
- DE (D high, E low);
- HL (H high, L low). HL is also the memory pointer M.
- PSW = A + flags, used with
PUSH PSWandPOP PSW.
✓ Answer checked step by step Standard result.
A commercial interface unit uses different names for the handshake lines associated with the transfer of data from the I/O device into the interface unit. The interface input handshake line is labelled STB (strobe), and the interface output handshake line is labelled IBF (input buffer full). A low-level signal on STB loads data from the I/O bus into the interface data register. A high-level signal on IBF indicates that the data item has been accepted by the interface. IBF goes low after an I/O read signal from the CPU when it reads the content of the data register. (i) Draw the block diagram showing the CPU, the interface, and the I/O device together with the pertinent interconnections among the three units. (ii) Draw a timing diagram for the handshaking transfer. (iii) Obtain a sequence of events flowchart for the transfer from the device to the interface and from the interface to the CPU.
Solution
(i) Block diagram
- CPU to interface: the data bus, an address or select line (chip select and register select), and the I/O read control line. IBF may also be read by the CPU as a status bit, or used as an interrupt request.
- Interface to I/O device: the I/O data bus into the data register, the strobe from the device, and IBF back to the device.
(ii) Timing diagram
- The device puts valid data on the I/O bus.
- A low level on loads the data into the interface data register.
- When the register has accepted the data, the interface raises IBF (input buffer full).
- The CPU later performs an I/O read of the data register. At the end of the read, IBF goes low, so the device may send the next item.
(iii) Sequence of events
Device to interface: the device places data on the I/O bus, then waits until IBF = 0 (the register is free), then pulses low. The interface loads the register and sets IBF = 1. The device sees IBF = 1 and knows the data has been accepted. It may remove the data and prepare the next item, but must wait for IBF = 0 before strobing again.
Interface to CPU: the CPU checks IBF, either by polling a status register or because IBF raised an interrupt. When IBF = 1, it reads the data register with an I/O read. The interface then clears IBF = 0, which allows the next transfer.
This two-wire handshake guarantees that a new item is never loaded before the CPU has read the previous one, and that the CPU never reads the same item twice.
✓ Answer checked step by step Standard result.
Design an output port with address FFH to interface the 1408 D/A converter that is calibrated for a 0 to 10 V range (with the use of 8085 microprocessor). Write a program to generate a continuous ramp waveform. The pin diagrams of an octal latch (74LS373) and the 1408 D/A converter are provided for reference:
Solution
Output port FFH
- Port FFH means A7–A0 (also repeated on A15–A8 in the I/O cycle) are all 1. An 8-input NAND gives = 0 only for address FFH.
- and go into a NOR gate. Its output is high only when both are low, that is, during
OUT FFH. - This high pulse drives LE of the 74LS373 latch, which is transparent when LE = 1 and latches on the falling edge. is grounded, so the latch outputs always drive the DAC.
- The latch inputs 1D–8D take D0–D7 from the data bus. The outputs go to the 1408 inputs, with D7 → A1 (MSB) … D0 → A8 (LSB): in the 1408, A1 is the most significant bit.
- The 1408 current output (pin 4) feeds an op-amp current-to-voltage converter. With and the feedback resistor set for 0 to 10 V full scale, one step is 10/256 = 39.1 mV. The output ranges from 0 (00H) to 9.96 V (FFH).
Program: continuous ramp
| Instruction | T-states | Comment |
|---|---|---|
MVI A, 00H |
7 | start at 0 V |
LOOP: OUT FFH |
10 | send A to the DAC |
INR A |
4 | next step (FFH rolls over to 00H) |
JMP LOOP |
10 | repeat forever |
Each step takes 24 T-states, 8 µs at 3 MHz. One ramp (256 steps) takes about 2.05 ms, so the sawtooth repeats at about 488 Hz. A delay loop after OUT makes the ramp slower.
✓ Checked by computer We checked the address decoding, the ramp program and its step size in Python.
What is the format of the control word of 8255 programmable peripheral interface? Explain the significance of each bit of the control word.
Solution
The control register of the 8255A is written at the address with A1 A0 = 11. Bit D7 decides the meaning of the word.
I/O mode set word (D7 = 1)
| Bit | Significance |
|---|---|
| D7 | 1 = mode set (I/O) control word |
| D6, D5 | Mode of group A (port A and port C upper): 00 = mode 0, 01 = mode 1, 1× = mode 2 |
| D4 | Port A: 1 = input, 0 = output |
| D3 | Port C upper (PC7–PC4): 1 = input, 0 = output |
| D2 | Mode of group B (port B and port C lower): 0 = mode 0, 1 = mode 1 |
| D1 | Port B: 1 = input, 0 = output |
| D0 | Port C lower (PC3–PC0): 1 = input, 0 = output |
Example: 80H makes all ports outputs in mode 0; 9BH makes all ports inputs in mode 0.
Bit set/reset (BSR) word (D7 = 0). This sets or resets one bit of port C individually:
- D6–D4: not used (0);
- D3 D2 D1: bit select (000 = PC0 … 111 = PC7);
- D0: 1 = set, 0 = reset.
For example, 0FH sets PC7, and 0EH resets it. BSR words do not disturb the I/O mode already set.
✓ Answer checked step by step Standard result.
Draw the schematic diagram for interfacing an 8-bit analog to digital converter to 8085 microprocessor using 8255 PPI.
Solution
Connections
- The 8255A is decoded as an I/O device (for example at 80H–83H) on the 8085 buses.
- Port A (input) ← ADC data outputs D7–D0.
- PC0 (output) → SOC (start of conversion; also ALE for an 0808).
- PC4 (input) ← EOC (end of conversion).
- The ADC gets its clock (or uses its RC clock), , and the analog input through a sample-and-hold if the signal changes quickly.
Control word: port A in, port C upper in, port C lower out, mode 0:
Program (polled)
| Instruction | Comment |
|---|---|
MVI A, 98H |
configure the 8255 |
OUT 83H |
|
MVI A, 01H |
PC0 = 1 |
OUT 82H |
start pulse… |
MVI A, 00H |
|
OUT 82H |
…SOC back to 0: conversion starts |
WAIT: IN 82H |
read port C |
ANI 10H |
test PC4 (EOC) |
JZ WAIT |
wait until EOC = 1 |
IN 80H |
read the digital value from port A |
The BSR words (01H/00H to 83H) can also be used to pulse PC0 without affecting the other port C bits. EOC can instead be wired to RST 7.5 so that the conversion is serviced by interrupt.
✓ Answer checked step by step Standard result (typical ADC 0804/0808 interface).
Calculate the number of memory chips needed to design 8k-bytes memory for an 8085 microprocessor. The memory chip size is .
Solution
Organisation
- Width: 8 chips side by side make one 1 K × 8 bank (one chip per data bit).
- Depth: 8 such banks make 8 K.
So the arrangement is 8 rows × 8 columns.
The 10 address lines A9–A0 go to every chip. A12–A10 go to a 3-to-8 decoder that selects one of the 8 banks, and the remaining lines (A15–A13) are decoded for the base address.
✓ Checked by computer We computed the chip count in Python.
What is the difference between cycle stealing DMA and interleaved DMA in 8085 microprocessor? What is meant by block transfer DMA?
Solution
- Cycle-stealing DMA. The DMA controller takes the bus for one bus cycle at a time (one byte or word). It “steals” that cycle from the CPU, which is held off (HOLD/HLDA) for just that cycle. Then the bus is returned, the CPU continues, and the next byte steals another cycle. The CPU slows down slightly but keeps working. This suits devices that deliver data at a moderate rate.
- Interleaved (transparent) DMA. The DMA transfer uses only bus cycles in which the CPU does not need the bus: for example the internal decode/execute T-states (T4 of an opcode fetch, the bus-idle cycles), or the half of the clock in which the CPU is not using memory. The CPU is never stopped, so DMA is “transparent” to it. But this needs extra timing logic, and the transfer rate is limited by the free slots.
- Block-transfer (burst) DMA. On a single request, the DMA controller keeps the buses (HOLD stays high) and transfers a whole block of data, byte after byte, until the count is exhausted (terminal count) or the device stops. Only then is the bus returned. This gives the highest transfer rate, as for disk or high-speed ADC buffers, but the CPU is idle for the whole block.
✓ Answer checked step by step Standard result.
Compare memory mapped I/O (Input/Output) with peripheral mapped I/O for 8085 microprocessor.
Solution
| Feature | Memory-mapped I/O | Peripheral (I/O)-mapped I/O |
|---|---|---|
| Device address | 16-bit, part of the memory map | 8-bit port address, separate I/O space |
| Maximum devices | Up to 64 K locations (shared with memory) | 256 input and 256 output ports |
| Instructions | Any memory-reference instruction: LDA, STA, MOV r, M, ADD M, ANA M, INR M … |
Only IN port and OUT port |
| Data path | Any register, and arithmetic or logic directly on port data | Accumulator only |
| Control signals | / (IO/ = 0) | / (IO/ = 1) |
| Address decoding | 16 lines: more hardware | 8 lines: simpler |
| Memory available | Reduced by the space given to I/O | Full 64 K for memory |
| Execution time | MOV r, M 7 T; LDA 13 T |
IN, OUT 10 T |
Example. A port at 8000H (memory-mapped) is read with LDA 8000H or MOV A, M (HL = 8000H). A port at 80H (I/O-mapped) is read with IN 80H.
✓ Answer checked step by step Standard result.
What is 8255A PPI? Discuss its blocks—output ports and control logic. Write the instructions to load 65 H in register C and 92 H in accumulator A. Display the number of 65 H and 92 H at PORT 0 and PORT 1 respectively.
Solution
8255A PPI. A programmable peripheral interface: a general-purpose, programmable parallel I/O chip with three 8-bit ports (A, B, C), 24 I/O lines in all. Port C can be used as two 4-bit ports, or as handshake lines. The function of each port is set by a control word written by the CPU.
Blocks
- Data bus buffer. A tri-state, bidirectional 8-bit buffer joining the internal bus to the system data bus.
- Read/write control logic. Uses , , , A1, A0 and RESET to select a port or the control register, and the direction of transfer.
- Group A control (port A + port C upper) and group B control (port B + port C lower). These receive the control word and configure their ports: mode 0, 1, 2 for A; mode 0, 1 for B; and input or output.
- Output ports. Port A (8-bit, latched output / buffered input), port B (8-bit), and port C (two 4-bit halves; individual bits can be set or reset with BSR words). An output port latches the data written by the CPU and holds it for the device.
Program. We take PORT 0 = port A at 00H, PORT 1 = port B at 01H, and the control register at 03H.
| Instruction | Comment |
|---|---|
MVI A, 80H |
all ports output, mode 0 |
OUT 03H |
control register |
MVI C, 65H |
load 65H in C |
MVI A, 92H |
load 92H in A |
OUT 01H |
92H displayed at PORT 1 |
MOV A, C |
|
OUT 00H |
65H displayed at PORT 0 |
HLT |
✓ Answer checked step by step Standard result (port addresses assumed).
Show how DAC 1200 can be interfaced to the 8255. Write the schematic diagram. Use ‘double buffering’ to prevent glitches.
Solution
Why double buffering? A 12-bit DAC must receive all 12 bits at the same time. The 8255 has 8-bit ports, so the data is written in two parts (8 bits, then 4 bits). If the DAC inputs followed the ports directly, then between the two writes the DAC would see a mixture of new low bits and old high bits. For an instant it would output a wrong value: a glitch.
Scheme
- First rank. Port A → latch 1 (low 8 bits D7–D0). PB3–PB0 → latch 2 (high 4 bits D11–D8). (Port outputs are themselves latched, so these may simply be the 8255 port latches.)
- Second rank. A 12-bit latch (for example two 74LS374) between the first rank and the DAC1200. It is clocked only by a strobe from PC0.
- The DAC1200 output current goes to an op-amp current-to-voltage converter.
Program sequence (control word 80H, all ports output):
MOV A, lowthenOUT PORTA: load the low 8 bits.MOV A, highthenOUT PORTB: load the high 4 bits.- Pulse PC0 (BSR words 01H, then 00H): the second-rank latch loads all 12 bits together.
So the DAC input changes once, from the old 12-bit word to the new one. There is no intermediate code, and no glitch.
✓ Answer checked step by step Standard result.
Draw a block schematic of an 8255-programmable parallel I/O device, showing all elements and control word format. For mode 0 (simple input and output), determine the addresses of its ports and of the control register. Write a control word in the control register, when port A = output, port = output, port B = input and port = input.
Solution
Block schematic and control word format
Port addresses (mode 0). The 8255 uses A1 and A0 to select a register, so it occupies 4 consecutive addresses. The base is set by the chip-select decoding. Example: = 0 when A7 = 1 and A6–A2 = 0 (I/O-mapped):
| A1 A0 | Register | Address |
|---|---|---|
| 00 | Port A | 80H |
| 01 | Port B | 81H |
| 10 | Port C | 82H |
| 11 | Control register | 83H |
Control word (mode 0; port A out, port C upper out, port B in, port C lower in)
| D7 | D6 D5 | D4 | D3 | D2 | D1 | D0 |
|---|---|---|---|---|---|---|
| 1 | 0 0 | 0 (A out) | 0 (CU out) | 0 (mode 0) | 1 (B in) | 1 (CL in) |
It is written with MVI A, 83H then OUT 83H (the control register address in this example).
✓ Checked by computer We worked out the control word bit by bit in Python.
This question has the following parts.
(i) Explain the steps involved in interfacing a stepper motor to the 8255. Draw the interface schematic.
(ii) Indicate the steps involved in designing an 8-bit output port using partial decoding such that the port maps to any address between 80 H and FF H. Show also the hardware schematic.
Solution
(i) Stepper motor with the 8255
Steps:
- Configure the 8255 with port A as output (control word 80H).
- Connect PA3–PA0 to the four windings through driver transistors or a Darlington array (ULN2003), with free-wheeling (clamp) diodes. The motor common goes to +V. The port cannot supply the winding current directly.
- Send the excitation sequence for the chosen drive:
- full step (two phases on): 1001 → 1100 → 0110 → 0011 → repeat. The reverse order reverses the direction.
- half step: 8 states.
- Wait a delay after each step. The delay sets the speed, and must be long enough for the rotor to settle (the maximum pull-in rate). For example, a 1.8° motor at 10 ms per step turns at 30 rpm.
- Count the steps for the required angle: angle = number of steps × step angle.
| Instruction | Comment |
|---|---|
MVI A, 80H |
port A output |
OUT CR |
|
MVI A, 99H |
1001 1001 (pattern repeated in both nibbles) |
STEP: OUT PA |
energise |
CALL DELAY |
wait |
RRC |
1100 1100 → 0110 0110 → 0011 0011 … next phase |
JMP STEP |
(use RLC for the other direction) |
(ii) 8-bit output port with partial decoding (80H–FFH)
Steps:
- List the required address range: 80H–FFH = 1xxx xxxx. Only A7 needs to be decoded: A7 = 1. A6–A0 are don’t-care.
- Generate the port select = A7 AND IOW. With active-low logic: invert A7 and NOR it with .
- Use this signal as the enable (LE) of an 8-bit latch (74LS373) on the data bus, because an output port must hold the data after the
OUTcycle. - Connect the latch outputs to the device (LEDs or a display).
Any OUT with a port address from 80H to FFH writes this port: 128 foldback addresses. This is cheap, but those addresses cannot be used by other output ports.
✓ Answer checked step by step Standard result.
This question has the following parts.
(i) Draw the block diagram of a microprocessor-based process control system, making use of data acquisition systems, sensor inputs, outputs connected to relays, DACs. Explain the scheme briefly.
(ii) Design an interface to a microcomputer port using the LM334 temperature sensor and LM393 analog comparator. A logic 1 i/p should indicate a temperature of greater than 100 °F. (Corresponding voltage for this sensor is 3.11 volts.)
Solution
(i) Microprocessor-based process control system
Inputs. Sensors (temperature, pressure, flow, level) convert process variables into electrical signals. Signal conditioning amplifies and filters them and scales them to 0–5 V. An analog multiplexer selects one channel at a time, a sample-and-hold freezes it, and an ADC converts it. Together these form the data-acquisition system. Digital inputs (limit switches) go to an input port directly.
Processing. The microprocessor, with memory, I/O ports, a timer, a keyboard and a display, reads each channel in turn. It compares the readings with set points and computes the control action (on/off, or PID), logs data and raises alarms.
Outputs.
- DACs convert the computed values to analog signals for continuous actuators (control valves, variable-speed drives).
- Relay drivers (transistors with relays) on output port bits switch heaters, pumps, motors and alarms on or off.
The actuators change the process, and the sensors measure the result again, so the loop is closed.
(ii) Temperature switch with LM334 and LM393
The LM334 used as a temperature sensor gives a current proportional to absolute temperature. With its load resistor this is scaled to 10 mV/K:
The LM393 comparator has the sensor voltage on its non-inverting (+) input. The inverting (−) input gets V from a divider across +5 V: for example 1.89 kΩ (top) and 3.11 kΩ (bottom), or a 10 kΩ trim pot for calibration.
The LM393 has an open-collector output, so a 4.7 kΩ pull-up to +5 V makes it TTL compatible. It goes to one bit (D0) of an input port: a tri-state buffer such as the 74LS244 enabled by the port decoder, or a bit of an 8255 port.
Operation:
- when T > 100 °F, > 3.11 V and the output transistor turns off: logic 1;
- below 100 °F, the output is 0.
A large feedback resistor from the output to the + input adds a little hysteresis, which prevents chatter near the threshold.
The program reads the port and tests D0 (IN port, ANI 01H, JNZ HOT).
✓ Checked by computer We computed the sensor voltage at 100 °F and the reference divider in Python.
This question has the following parts.
(i) What are the features of three sources of interrupts that 8086 has?
(ii) What are the three operations possible in the ‘string’ group? What are the registers used by the instructions in this group?
(iii) Write the block diagram indicating how 8255A PPI is interfaced to 8086 max mode CPU module, using two 8255As for 16-bit I/O operation.
Solution
(i) Three sources of interrupts in the 8086
- Hardware, external.
- NMI: non-maskable, rising-edge triggered, type 2 (vector at 00008H).
- INTR: maskable through the IF flag (
STI,CLI), level triggered. It is acknowledged by two pulses, and the device (usually an 8259A) supplies an 8-bit type number. The vector address is 4 × type.
- Software. The instruction
INT n(n = 0–255) calls any of the 256 vectors;INT 3is a 1-byte breakpoint andINTOis interrupt on overflow (type 4). These let programs call system services. - Internal (processor-generated exceptions).
- Type 0: divide error.
- Type 1: single-step, when TF = 1.
- Type 4: overflow (with
INTO).
All of them use the same interrupt vector table at 00000H–003FFH: 4 bytes (IP, CS) per type. On entry, the CPU pushes the flags, CS and IP, and clears IF and TF.
(ii) String group
Operations:
- move (
MOVS); - compare (
CMPS), scan (SCAS); - load (
LODS) and store (STOS), with the prefixREP,REPE,REPNE.
These are usually summed up as three operations: move/copy, compare/scan (search), and load/store.
- move (
Registers used:
- SI, the source offset, in the DS segment;
- DI, the destination offset, in the ES segment;
- CX, the count for the
REPprefixes; - AL/AX, the data for
SCAS,LODSandSTOS.
Direction: the DF flag sets the direction.
CLDmakes SI and DI auto-increment;STDmakes them auto-decrement (by 1 for bytes, 2 for words).
(iii) Two 8255As for 16-bit I/O on an 8086 maximum-mode CPU module
- In maximum mode, the 8288 bus controller decodes S2–S0 into the command signals and . These drive and of both 8255As.
- Addresses are latched by 74LS373s using ALE, and data passes through 8286 transceivers (DT/, DEN).
- One 8255A sits on the low data byte D7–D0 and is selected when A0 = 0. The other sits on the high byte D15–D8 and is selected when = 0.
- Address lines A1 and A2 select the port or control register in each chip (A0 is used for the byte selection), and the higher address lines go to the decoder for .
- A 16-bit
IN AX, portorOUT port, AXat an even address enables both chips together, giving 16-bit ports: for example port A of both chips as one 16-bit port.
✓ Answer checked step by step Standard result.
What are the functions of DMA (Direct Memory Access)? How are HOLD and lines used in DMA operation? List the data transfer modes of DMA controller. Describe each mode in brief.
Solution
Functions of DMA
- It transfers blocks of data directly between memory and a fast peripheral (disk, CRT, high-speed ADC, communication link) without the CPU executing instructions for each byte.
- This gives the highest transfer rate (one bus cycle per byte), and frees the CPU from I/O work.
- The DMA controller generates the memory addresses, counts the bytes, and produces the read/write control signals itself.
Use of HOLD and HLDA
- When the device wants a transfer, it raises DRQ to the DMA controller, which raises HOLD to the 8085.
- The 8085 finishes the current machine cycle and then floats its address, data and control buses. It raises HLDA (hold acknowledge) to tell the controller that the buses are free.
- The controller then sends DACK to the device and performs the transfers.
- When it has finished (terminal count, or the device is done), it lowers HOLD. The 8085 then lowers HLDA and takes back the buses on the next clock.
- (The question writes ; on the 8085 HLDA is active-high.)
Data transfer modes of a DMA controller (8257/8237)
- Single-transfer (cycle-stealing) mode. One byte per request. HOLD is dropped after each byte, so the CPU gets the bus between bytes.
- Block (burst) transfer mode. One request transfers the whole block. HOLD is kept until the count is complete, which is the fastest.
- Demand mode. Transfers continue as long as DRQ stays active. They pause when the device drops DRQ, and resume later from the same address and count.
- Cascade mode (8237). Several DMA controllers are connected for more channels.
Types of transfer: memory → I/O (DMA read), I/O → memory (DMA write), memory → memory (8237, using two channels), and verify (addresses generated, no data moved).
✓ Answer checked step by step Standard result.
Which I/O technique provides the highest data transfer rate? Explain the function of DMA. Draw the block diagram of a DMA controller with memory interfacing. What is meant by simultaneous DMA? List three different DMA modes for transferring data. How is the DMA controller is programmed? Are special buffers required when interfaces a DMA controller?
Solution
Highest data-transfer rate. DMA gives the highest rate. Each byte moves in one bus cycle, directly between the device and memory, with no instruction fetch or execution by the CPU. Programmed I/O and interrupt-driven I/O are slower, because each byte needs several instructions (and, for interrupts, the overhead of saving and restoring).
Function of DMA. It lets a peripheral read or write memory directly while the CPU is held off the bus (HOLD/HLDA). The DMA controller supplies:
- the memory address (incremented automatically);
- the byte count (decremented to terminal count);
- the control signals , , and .
Block diagram with memory interfacing
During DMA:
- the controller places the address on A15–A0 (in the 8257, the upper byte goes through an external latch via ADSTB and AEN);
- AEN (address enable) disables the CPU address latch and the I/O decoder;
- data passes on the data bus directly between memory and the device that received DACK.
Simultaneous DMA. Data is transferred while the CPU is also working: the DMA uses bus cycles that the CPU does not need (as in transparent or interleaved DMA), or a separate bus or dual-port memory. The CPU is therefore not halted. The term is also used for several channels being requested at the same time and served in priority order (rotating or fixed).
Three DMA modes: single-transfer (cycle-stealing); block (burst); demand. (Others: cascade, and transparent.)
How the DMA controller is programmed. The CPU writes, as an I/O device:
- the starting address of the memory block into the channel address register (low byte, then high byte);
- the terminal count, the number of bytes − 1, together with the transfer type (read/write/verify) into the count register;
- the mode-set register: enable the channel, choose priority (fixed or rotating), auto-load, TC stop, and extended or normal write.
The controller then waits for DRQ.
Are special buffers needed? Yes, in most systems.
- The DMA controller drives the system buses, so the CPU’s address, data and control buffers must be tri-state and disabled during DMA, using HLDA and AEN.
- The controller’s own outputs need buffers or latches. For example, the 8257 multiplexes the upper address on its data lines, so it needs an external 8-bit latch strobed by ADSTB.
- Bidirectional data buffers (74LS245) are needed where bus loading or direction control requires them.
✓ Answer checked step by step Standard result.
What minimum functions are required in a programmable device? Point out the difference between control logic and control word with examples. Write the steps to compute the control word, say of 8255.
Solution
Minimum functions of a programmable device (8255, 8253, 8279, 8251 …)
- Bus interface. A data bus buffer (tri-state) and read/write logic with chip select and register-select lines, so the CPU can address it like an I/O port or a memory location.
- Command (control) register(s). Hold the control word that selects the mode of operation.
- Data registers or ports. For the data being handled.
- Status information. Readable by the CPU (ready, buffer full, end of count …) for polling.
- Internal control logic. Carries out the selected mode: handshake, timing, interrupt request.
Control logic and control word
| Control logic | Control word |
|---|---|
| The hardware inside the device (decoders, flip-flops, gates) that interprets commands and generates the internal and external control signals | The byte (software) written by the CPU into the control register to tell the control logic what to do |
| Fixed by design; the same in every application | Chosen by the programmer for each application; can be changed at run time |
| Example: the read/write control logic of the 8255 uses , A1 A0, , to route data to port A, B, C or the control register | Example: writing 82H to the 8255 control register makes ports A and C outputs and port B an input, all in mode 0 |
Steps to compute the control word of the 8255
Decide each port’s function and direction from the application: port A, port C upper, port B, port C lower; input or output.
Decide the modes: group A mode 0, 1 or 2; group B mode 0 or 1. Remember that mode 1 or 2 takes over certain port C lines.
Set D7 = 1 (I/O mode set).
Fill D6 D5 = group A mode, D4 = port A (1 in / 0 out), D3 = port C upper, D2 = group B mode, D1 = port B, D0 = port C lower.
Write the 8 bits and convert to hex.
Example: A out, B in, C all out, mode 0 → 1000 0010 = 82H.
Write it to the control register address (A1 A0 = 11):
MVI A, 82HthenOUT CR.
For port C bit control, use the BSR word instead: D7 = 0, D3–D1 = bit number, D0 = set/reset.
✓ Answer checked step by step Standard result.
Select any three of the following statements, read them carefully and identify the correct and the incorrect ones. Justify your answer using not more than 200 words in each case. The memory mapping for the circuit shown below is 2000H to 2OFPH, assuming , , and to be zero.
Solution
Correct.
Decoder enabling
- = A14 and = A15 are active low, so the decoder is enabled only when A15 = 0 and A14 = 0.
- is tied to +5 V, so it is always enabled.
Selected output. O4 is active when A13 A12 A11 = 100.
So the chip is selected for
| A15–A12 | A11–A8 | A7–A0 | |
|---|---|---|---|
| 0010 | 0000 | 0000 0000 | 2000H |
| 0010 | 0000 | 1111 1111 | 20FFH |
With A10, A9 and A8 = 0 as stated, the chip occupies 2000H to 20FFH: 256 locations, covered by AD7–AD0. The printed “2OFPH” means 20FFH. So the statement is correct.
Note. A10–A8 are not decoded. Without the stated assumption, the same 256 locations would also appear at 2100H, 2200H … 27FFH (partial decoding, 8 foldback blocks). The chip receives IO/ and ALE: it is typically an 8155, whose RAM is selected with IO/ = 0. With IO/ = 1, the same select gives its I/O ports.
✓ Checked by computer We decoded the address lines for O4 in Python.
Select any THREE of the following statements, read them carefully and identify the correct and the incorrect ones. Justify your answer using not more than 200 words in each case:- Latch is used at input and tristate is used for output purposes in the microprocessor based system.
Solution
Incorrect. It is the other way round: a latch is used for output and a tri-state buffer for input.
- Output port: latch. The CPU puts data on the data bus only for a fraction of a microsecond, during of the
OUT(orSTA) cycle. A device such as an LED display, a DAC or a relay needs the data to stay until the next write. So the output port uses a latch (74LS373 or 74LS374), enabled by the decoded port address and , which holds the data. - Input port: tri-state buffer. An input device (switches, ADC) drives its data all the time. If it were connected straight to the data bus, it would clash with the memory and other devices. So it goes through a tri-state buffer (74LS244), enabled only during for that port. The rest of the time its outputs are in the high-impedance state and the device is isolated from the bus.
(Where the input data is fleeting, as from a strobed keyboard, a latch may be added in front of the tri-state buffer: a “latched input”. The bus connection is still tri-state.)
✓ Answer checked step by step Standard result.
More on Microprocessors and Microcomputers
- All Electrical Engineering PYQ solutions, topic by topic
- Microprocessors and Microcomputers topic-wise PYQs (questions only, for practice)
- Electrical Engineering PYQ analysis: which units carry the marks year by year
- Year-wise question papers
- Electrical Engineering booklist
Questions: UPSC Civil Services (Main) Examination, Electrical Engineering Paper II, 2004–2026. Solutions: Optional Province. Found an error? Tell us.

