PadhaikoAll subjects

Microprocessor and microcontroller and their selection criteria, and…

Instrumentation (ENEX 252)

Open in the Padhaiko app

4.1 Microprocessor and microcontroller and their selection criteria, and applications

Modern instrumentation systems rely heavily on digital processing engines to acquire signals from transducers, condition and process measured data, execute control algorithms, and interface with human operators or networked supervisory systems. At the core of every digital instrument sits either a microprocessor or a microcontroller.

Definition

Microprocessor (MPU)

A microprocessor is a multipurpose, programmable, clock-driven, register-based electronic central processing unit (CPU) fabricated on a single integrated circuit. It reads binary instructions from an external memory device, accepts binary data from input devices, processes the data according to the stored instructions, and outputs results to external memory or output peripherals.

Definition

Microcontroller (MCU)

A microcontroller is a highly integrated computer system fabricated on a single silicon chip. It combines a central processing core (CPU) with dedicated memory (RAM for volatile data and ROM/Flash for non-volatile program code) and on-chip peripheral modules such as general-purpose I/O ports, timers/counters, analog-to-digital converters (ADC), and serial communication interfaces (UART, SPI, ).

The structural distinction between the two devices is illustrated in the architectural comparison below:

Architectural Topology: Microprocessor vs. MicrocontrollerText
+-------------------------------------------------------+
|                MICROPROCESSOR SYSTEM                  |
|                                                       |
|  +-------------+   System Bus (Address/Data/Control)  |
|  |     MPU     |<==================================+  |
|  | (ALU, Regs, |                                   |  |
|  |   Control)  |                                   |  |
|  +-------------+                                   |  |
|         ^                                          |  |
|         |           +---------+ +---------+ +----+ |  |
|         +---------->| Ext RAM | | Ext ROM | |I/O | |  |
|                     +---------+ +---------+ +----+ |  |
+-------------------------------------------------------+

+-------------------------------------------------------+
|               MICROCONTROLLER SYSTEM (MCU)            |
|                                                       |
|  +-------------------------------------------------+  |
|  | Single Silicon Chip                             |  |
|  |  +-----------+  +-----------+  +-------------+  |  |
|  |  |    CPU    |  | Flash ROM |  |  SRAM (RAM) |  |  |
|  |  +-----------+  +-----------+  +-------------+  |  |
|  |  +-----------+  +-----------+  +-------------+  |  |
|  |  | Timers    |  | ADC / DAC |  | GPIO Ports  |  |  |
|  |  +-----------+  +-----------+  +-------------+  |  |
|  |  +--------------------------+  +-------------+  |  |
|  |  | Comm: UART / SPI / I2C    |  | Watchdog /  |  |  |
|  |  +--------------------------+  | Interrupts  |  |  |
|  +-------------------------------------------------+  |
+-------------------------------------------------------+
AspectMicroprocessorMicrocontroller
Primary RoleGeneral-purpose computing and heavy data crunchingDedicated control and embedded instrumentation
Component IntegrationContains only the CPU; memory, timers, and I/O are externalCPU, RAM, Flash/ROM, timers, ADC, and I/O on a single chip
Bus ArchitectureExternal address, data, and control buses connect peripheralsInternal high-speed buses connect integrated peripherals
Clock SpeedHigh clock speeds (hundreds of MHz to several GHz)Moderate clock speeds (1 MHz to 480 MHz)
Power ConsumptionHigh power consumption; unsuited for micropower battery cellsLow to ultra-low power; features sleep and standby modes
Cost & Physical SizeBulky multi-chip circuit board; higher design and BOM costCompact single-chip solution; minimal component count and low cost
Instruction SetOptimized for bulk byte/word transfers and complex arithmeticRich in bit-manipulation and direct bit-set/reset instructions
Memory Access TimeSlower due to bus capacitance and off-chip propagation delaysFast on-chip memory access with deterministic timing

4.1.1 Selection criteria for microprocessors and microcontrollers

Selecting the right processor for an instrumentation system requires balancing processing throughput, precision, power budget, cost, and physical ruggedness.

Processor Selection Criteria in Instrumentation Engineering
CriterionTechnical Considerations in InstrumentationRepresentative Options
1. Processing Power & SpeedEvaluated in clock speed (MHz/GHz), instructions per second (MIPS), or floating-point operations (FLOPS). Determines maximum sampling rate and ability to execute digital filters (FIR/IIR) or FFT algorithms in real time.Low: 8-bit AVR (16 MHz); High: 32-bit ARM Cortex-M4/M7 (168–480 MHz) with hardware FPU.
2. Architecture & Word Size8-bit, 16-bit, 32-bit, or 64-bit ALU width; Harvard vs. von Neumann bus structure; RISC vs. CISC instruction sets. Wider words eliminate multi-byte arithmetic overhead in high-resolution measurements.8-bit for basic threshold alarms; 32-bit RISC for precision multi-channel data acquisition.
3. Power ConsumptionCritical for battery-powered instruments, remote Wireless Sensor Network (WSN) nodes, and 4–20 mA loop-powered transmitters.Active current vs. sleep/standby mode currents down to sub-microampere () levels.
4. On-Chip PeripheralsBuilt-in analog-to-digital converters (ADC resolution: 10-bit, 12-bit, 16-bit), digital-to-analog converters (DAC), timers/PWM, and communication transceivers (UART, SPI, , CAN, USB).Eliminates external auxiliary chips, reducing noise pickup and PCB layout area.
5. Memory CapacityProgram storage (Flash/ROM), variable data storage (SRAM), and non-volatile parameter storage (EEPROM for sensor calibration constants).Flash from 16 KB up to 2 MB; SRAM from 1 KB up to 512 KB.
6. Cost & AvailabilityPer-unit silicon cost in mass production, minimum order quantities (MOQ), and guaranteed long-term vendor availability (lifecycle longevity: 10–15 years).Sub-dollar MCUs (under 1 USD) for consumer sensors vs. certified automotive/aerospace grade chips.
7. Development EcosystemMaturity of compilers (GCC, Keil, IAR), hardware debuggers (JTAG, SWD, ST-Link), software libraries (CMSIS, HAL, FreeRTOS), and active engineering communities.Broad ecosystem reduces development cycle time and firmware bugs.
8. Environmental RuggednessOperating temperature ranges (Commercial: to ; Industrial: to ; Automotive: to ), noise immunity, and electrostatic discharge (ESD) tolerance.Industrial-grade packaging for harsh manufacturing and electrical environments.

4.1.2 Applications of microprocessors and microcontrollers in instrumentation

  1. Industrial Process Control: Microcontrollers implement closed-loop PID controllers regulating furnace temperatures, chemical flow rates, boiler pressure, and motor speeds with millisecond response times.
  2. Data Acquisition Systems (DAS): Multi-channel data loggers record seismic, environmental, or mechanical stress readings from strain gauges, RTDs, and accelerometers, storing time-stamped logs in Flash memory.
  3. Smart Transmitters and Field Instruments: Integrating an MCU into a pressure or temperature sensor allows local linearization, temperature drift compensation, digital calibration, and 4–20 mA HART or CAN bus transmission.
  4. Medical Instrumentation: ECG monitors, pulse oximeters, blood glucose analyzers, and infusion pumps utilize low-power MCUs for high-precision biosignal acquisition and fail-safe safety interlocks.
  5. Smart Utility Metering: Electronic energy, water, and gas meters employ microcontrollers with tamper detection, real-time clock (RTC) scheduling, and remote wireless communication (LoRaWAN, Zigbee).

4.2 The PPI 8255 and interfacing of peripherals with 8085 microprocessor

The Intel 8255A Programmable Peripheral Interface (PPI) is a general-purpose, 40-pin programmable input/output device designed to connect parallel peripheral hardware to Intel microprocessors such as the 8085. It provides 24 I/O pins that can be configured in flexible modes under software control.

4.2.1 Architecture and internal block diagram of 8255A

The internal architecture of the 8255A consists of four primary operational blocks:

  1. Data Bus Buffer: A tri-state, bidirectional 8-bit buffer () that interfaces the 8255 directly to the system data bus of the 8085 microprocessor. It handles data, control words, and status information.
  2. Read/Write and Control Logic: Manages internal data transfers and interprets microprocessor control signals:
    • (Chip Select): An active-low input. Logic 0 enables communication between the 8085 and the 8255.
    • (Read): An active-low input enabling the 8085 to read data or status from the 8255.
    • (Write): An active-low input enabling the 8085 to write data or control words to the 8255.
    • (Address Lines): Address inputs connected to the microprocessor's lower address lines to select internal ports or the control register.
    • : An active-high input that clears the internal control register and initializes all 24 port lines as input lines.
  3. Group A and Group B Controls: The internal logic that translates the control word into hardware configurations for the ports. Group A controls Port A and Port C Upper (); Group B controls Port B and Port C Lower ().
  4. Parallel I/O Ports:
    • Port A: An 8-bit data output latch/buffer and an 8-bit data input latch. It can operate in Mode 0, Mode 1, and Mode 2.
    • Port B: An 8-bit data output latch/buffer and an 8-bit data input buffer. It can operate in Mode 0 and Mode 1.
    • Port C: An 8-bit port split into Port C Upper () and Port C Lower (). It can operate as simple I/O in Mode 0, or provide handshake control signals for Port A and Port B in Mode 1 and Mode 2. Individual bits can be set or reset using BSR mode.
8255 Internal Port Selection via Address and Control Signals
Selected Function / Data Direction
00001Read Port A to 8085 Data Bus
00101Read Port B to 8085 Data Bus
01001Read Port C to 8085 Data Bus
01101Illegal Condition (Control Register is Write-Only)
00010Write 8085 Data Bus to Port A
00110Write 8085 Data Bus to Port B
01010Write 8085 Data Bus to Port C
01110Write 8085 Data Bus to Control Register
1Chip Deselected (Data Bus buffer in high impedance)

4.2.2 Operating modes and control word formats of 8255A

The 8255 operates in two fundamental software-selectable modes:

  1. Bit Set/Reset (BSR) Mode: Manipulates individual bits of Port C without affecting other port operations.
  2. Input/Output (I/O) Mode: Programs Ports A, B, and C for data transfer in one of three functional configurations:
    • Mode 0 (Basic I/O): Simple input or output without handshaking. Both 8-bit ports (A, B) and both 4-bit ports () can be independently programmed as input or output. Outputs are latched; inputs are buffered but not latched. Sixteen () different I/O combinations are possible.
    • Mode 1 (Strobe I/O): Handshake data transfer where Port A and/or Port B transfer data using dedicated lines of Port C as handshaking control signals.
    • Mode 2 (Strobe Bidirectional Bus): Port A becomes an 8-bit bidirectional data bus using five handshake signals from Port C. Port B can simultaneously operate in Mode 0 or Mode 1.

I/O Mode Control Word Format

When bit , the byte written to the control register is interpreted as the I/O mode control word:

8255 I/O Mode Control Word Bit DefinitionText
+----+----+----+----+----+----+----+----+
| D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
+----+----+----+----+----+----+----+----+
  |    \_____/    |    |    |    |    |
  |     Mode A    |    |    |    |    +---> Port C Lower (PC3-PC0): 1 = Input, 0 = Output
  |               |    |    |    +--------> Port B:             1 = Input, 0 = Output
  |               |    |    +-------------> Mode Selection B:   0 = Mode 0, 1 = Mode 1
  |               |    +------------------> Port C Upper (PC7-PC4): 1 = Input, 0 = Output
  |               +-----------------------> Port A:             1 = Input, 0 = Output
  |
  +--> Group A Mode Selection:
       00 = Mode 0 (Basic I/O)
       01 = Mode 1 (Strobe I/O)
       1X = Mode 2 (Bidirectional Bus)
       
  (D7 = 1 identifies this byte as an I/O Mode Control Word)

BSR (Bit Set/Reset) Mode Control Word Format

When bit , the byte written to the control register is interpreted as a BSR control word. It affects only a single designated bit in Port C:

8255 BSR Control Word Bit DefinitionText
+----+----+----+----+----+----+----+----+
| D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
+----+----+----+----+----+----+----+----+
  |    \___________/   \_________/    |
  |      Unused            Bit        +---> Set/Reset Flag:
  |    (Set to 0)       Selection           1 = SET bit to logic 1
  |                    D3 D2 D1             0 = RESET bit to logic 0
  |                     0  0  0  = Bit 0 (PC0)
  |                     0  0  1  = Bit 1 (PC1)
  |                     0  1  0  = Bit 2 (PC2)
  |                     0  1  1  = Bit 3 (PC3)
  |                     1  0  0  = Bit 4 (PC4)
  |                     1  0  1  = Bit 5 (PC5)
  |                     1  1  0  = Bit 6 (PC6)
  |                     1  1  1  = Bit 7 (PC7)
  +--> D7 = 0 identifies this byte as a BSR Control Word

Handshake Signals in Mode 1

In Mode 1, data transfers are synchronized between the 8085 and external peripherals using Port C control lines:

Mode 1 Handshake Signals for Input and Output
Signal NamePort AssignmentDirectionFunctional Description
, (Strobe Input) (Port A), (Port B)Input from peripheralAn active-low pulse generated by the peripheral to latch external data into the 8255 input latch.
, (Input Buffer Full) (Port A), (Port B)Output to peripheralLogic 1 indicates that data has been loaded into the input latch. Set by going low; reset by the rising edge of .
, (Interrupt Request) (Port A), (Port B)Output to 8085 CPULogic 1 interrupts the CPU to service the port. Activated when , , and the internal flip-flop is enabled. Reset by the falling edge of (input) or (output).
, (Interrupt Enable)Internal Flip-FlopsInternal controlSet or cleared via BSR mode on (Port A Input) or (Port A Output), and (Port B).
, (Output Buffer Full) (Port A), (Port B)Output to peripheralAn active-low signal indicating the 8085 has written data into the output latch. Set low by rising edge of ; reset high by going low.
, (Acknowledge Input) (Port A), (Port B)Input from peripheralAn active-low pulse from the peripheral confirming receipt of data.

4.2.3 Interfacing DIP switches and LEDs (Mode 0)

In basic process control, an operator sets configuration parameters using an 8-position DIP switch, and the system displays binary status or alarm conditions via LEDs.

Interfacing 8255 to 8085: DIP Switches on Port A, LEDs on Port BText
      +5V
       |
     [10k] Pull-ups
       |
  +----+----+---------+
  |    |    |  DIP SW |
  o    o    o         |
   \    \    \  (ON -> GND)
  |    |    |         |
  +----+----+---------+
       |
       v PA7-PA0
 +--------------------+                     +--------------------+
 |     8255A PPI      |                     |      8085 CPU      |
 |                    |    System Data Bus  |                    |
 | Port A (Input)     |<===================>| D0 - D7            |
 |                    |                     |                    |
 | Port B (Output)    |    A0, A1           | A0, A1             |
 |   PB0 - PB7        |<--------------------|                    |
 +--------------------+                     | IO/M'              |
       |                                    | RD', WR'           |
       v (Through 330 ohm resistors)        +--------------------+
     [===] Current limiting
       |
      ---
      \ /  LEDs (Active-High: Logic 1 lights LED)
      ---
       |
      GND

To read the switch states and reflect them on the LEDs:

  1. Initialize the 8255 control register in Mode 0 with Port A as input and Port B as output.
  2. Read Port A into the 8085 accumulator (IN PORT_A).
  3. Output the accumulator to Port B (OUT PORT_B).

4.2.4 Interfacing 7-segment displays with 8085

A 7-segment LED display consists of seven individual directional segments () and an optional decimal point (). They are configured as common cathode (all cathodes grounded; a logic 1 lights a segment) or common anode (all anodes tied to ; a logic 0 lights a segment).

7-Segment Hexadecimal Decoding Table (Common Cathode: dp-g-f-e-d-c-b-a)
DigitActive SegmentsBinary Code ()Hexadecimal Code
03FH
106H
25BH
34FH
466H
56DH
67DH
707H
87FH
96FH

When interfacing via 8255 Port A, the 8085 maintains a lookup table containing these codes in memory, looks up the corresponding display byte for a given decimal number, and outputs it to Port A.

4.2.5 Interfacing an 8-bit ADC with 8085

Analog sensors deliver continuous voltage signals that must be digitized before 8085 processing. The ADC0801 / ADC0804 / ADC0808 is a classic successive-approximation 8-bit converter compatible with microprocessors.

Key pins and timing signals:

There are two primary interfacing strategies:

  1. Status-Check (Polling) Method:
    • 8085 asserts a start conversion pulse on an output line (e.g., ).
    • 8085 repeatedly reads Port C to monitor the (or ) line.
    • When signals completion, 8085 reads the 8-bit digital value from Port A.
  2. Interrupt-Driven Method:
    • 8085 initiates conversion and continues executing other background tasks.
    • The ADC's active-low line is tied to a hardware interrupt pin of the 8085 (such as RST 7.5 or RST 6.5), or to 8255 Mode 1 .
    • The Interrupt Service Routine (ISR) immediately reads the digitized byte.

4.2.6 Interfacing 8-bit and 10-bit DACs with 8085

Digital-to-analog converters generate proportional analog control voltages or arbitrary waveforms (such as ramps, triangle waves, and square waves) to drive analog actuators, servo valves, and chart recorders.

Interfacing the 8-bit DAC 1408 / MC1408 / DAC0808

The 1408 DAC accepts an 8-bit digital input word ( through , where is the MSB) and sinks an output current proportional to the binary weight:

For full-scale digital input (FFH = ):

An operational amplifier (such as the 741 or OP07) acts as a current-to-voltage (-to-) converter with feedback resistor :

With , , and :

Interfacing 10-bit DAC (AD7522) using Double Buffering

High-precision instrumentation applications frequently demand 10-bit or 12-bit DAC resolution. However, the 8085 possesses only an 8-bit data bus.

If a 10-bit word is loaded using two sequential single-buffered output operations, the DAC will output an erroneous intermediate voltage during the interval between updating the first byte and updating the second byte. This produces severe output voltage glitches.

To eliminate glitches, a double-buffered DAC such as the AD7522 is used:

  1. It contains two sets of internal registers: an input latch and a holding register.
  2. The 8085 first writes the lower 8 data bits () into the low-byte input latch using the Low Byte Strobe () signal at address .
  3. The 8085 then writes the upper 2 data bits () into the high-byte input latch using the High Byte Strobe () signal at address .
  4. Simultaneously with (or via a dedicated strobe), all 10 bits are transferred in parallel from the input latches into the holding register, updating the analog output cleanly in a single transition.

Worked Examples

Example 1

1

An Intel 8255A PPI is interfaced to an 8085 microprocessor using I/O-mapped I/O. Address lines through are connected to an 8-input NAND gate to generate the chip select signal when . Address lines and are connected directly to pins and of the 8255.

  1. Determine the hexadecimal port addresses for Port A, Port B, Port C, and the Control Register.
  2. Determine the control word to configure Port A as an input port in Mode 1, Port B as an output port in Mode 1, and configure Port C upper () as output lines.
  3. Determine the BSR control word to set the interrupt enable flip-flop for Port A.

Finding the port addresses from decoding logic: The 8-input NAND gate produces active-low when . The lower two address lines select the internal register:

  • Port A: .
  • Port B: .
  • Port C: .
  • Control Register: .

Formulating the I/O Mode control word:

Assembling the 8 bits:

Determining the BSR control word for : For Port A in Mode 1 input, the internal interrupt enable flip-flop is controlled by setting or resetting Port C bit 4 (). In BSR mode:

  • (BSR mode select).
  • (unused).
  • (select bit 4, i.e., ).
  • (SET the bit).

Assembling the BSR byte:

Answer:
  1. Port Addresses: Port A = FCH, Port B = FDH, Port C = FEH, Control Register = FFH.
  2. I/O Mode Control Word: B4H ().
  3. BSR Control Word to enable : 09H ().
Example 2

2

An 8-bit ADC0801 is interfaced to an 8085 microprocessor through an 8255 PPI. The ADC clock is generated using an external resistor and capacitor . The analog input voltage ranges from to .

  1. Calculate the ADC clock frequency.
  2. Determine the step size (voltage resolution) of the converter.
  3. Calculate the digital output code (in decimal and hexadecimal) produced when the analog input voltage is .
  4. Write an 8085 assembly subroutine to initiate conversion via Port C bit 0 (), poll the Data Ready line on Port C bit 7 () where logic 0 indicates data ready, and read the digitized data from Port A into the accumulator. Assume Port A = 80H, Port C = 82H, Control Reg = 83H.

Calculating the clock frequency: Using the standard RC clock formula for the ADC0801:

This falls safely within the manufacturer's recommended operating range of to .

Evaluating resolution and output code: The resolution (step size) for an 8-bit converter spanning is:

For , the digital output is:

Converting to hexadecimal:

Writing the 8085 polling subroutine: The conversion is started by pulsing low then high. The processor then reads Port C and tests bit 7. When bit 7 goes low, data is read from Port A:

8085 Subroutine: ADC0801 Polling8085 ASM
READ_ADC: MVI A, 00H        ; Reset PC0 (Start conversion low)
          OUT 83H           ; Send BSR word to reset PC0
          MVI A, 01H        ; Set PC0 (Start conversion high transition)
          OUT 83H           ; Send BSR word to start conversion
CHECK_DR: IN 82H            ; Read Port C status
          RAL               ; Rotate Bit 7 (EOC) into Carry Flag
          JC CHECK_DR       ; If Carry = 1 (busy), keep polling
          IN 80H            ; Read 8-bit digitized data from Port A
          RET               ; Return with result in Accumulator
Answer:
  1. Clock Frequency: 606.06 kHz.
  2. Step Size: 19.53 mV.
  3. Digital Output Code: 184 (decimal) = B8H (hexadecimal).
  4. Subroutine initiates conversion on , polls bit 7 until low, and retrieves data from Port A.
Example 3

3

A DAC 1408 is connected to Port B of an 8255 PPI with , reference resistor , and an op-amp -to- converter with feedback resistor .

  1. Calculate the full-scale analog output voltage in unipolar mode.
  2. Calculate the unipolar output voltage when the digital input is 80H ().
  3. In bipolar mode, a resistor is added between and the op-amp inverting input. Calculate the bipolar output voltage for digital inputs 00H, 80H, and FFH.

Evaluating unipolar full-scale and mid-scale output: The output current is:

For full scale (FFH = 255):

For input 80H ():

Evaluating bipolar outputs: The offset current supplied by is:

The net output voltage is:

  • For 00H ():
  • For 80H ():
  • For FFH ():
Answer:
  1. Unipolar Full-Scale Output: 9.961 V.
  2. Unipolar Output for 80H: 5.000 V.
  3. Bipolar Outputs: 00H -5.000 V; 80H 0.000 V; FFH +4.961 V.

Exercises

Exercises

Question 1

Determine the 8255 I/O mode control words for the following two independent port configurations:

  1. Port A = Mode 0 Input, Port B = Mode 0 Output, Port C Upper = Mode 0 Output, Port C Lower = Mode 0 Input.
  2. All ports (Port A, Port B, Port C Upper, Port C Lower) configured as Mode 0 Inputs.

Calculating Control Word 1:

  • (I/O Mode).
  • (Port A in Mode 0).
  • (Port A Input).
  • (Port C Upper Output).
  • (Port B in Mode 0).
  • (Port B Output).
  • (Port C Lower Input).

Combining bits: .

Calculating Control Word 2:

  • (I/O Mode).
  • (Port A in Mode 0).
  • (Port A Input).
  • (Port C Upper Input).
  • (Port B in Mode 0).
  • (Port B Input).
  • (Port C Lower Input).

Combining bits: .

Answer:
  1. Configuration 1 Control Word: 91H ().
  2. Configuration 2 Control Word: 9BH ().
Question 2

Explain why the BSR mode of the 8255 PPI is especially advantageous in industrial instrumentation control, and determine the BSR words required to sequentially set and then reset pin .

Advantage of BSR mode in industrial instrumentation: In control systems, individual control lines drive discrete actuators such as solenoid valves, relays, heater contactors, and alarms. If simple parallel port writes were used, modifying the state of a single bit would require a read-modify-write operation (reading the existing port state, masking bits with logical AND/OR, and writing back). The 8255 BSR mode allows the microprocessor to set or clear any individual bit of Port C with a single OUT instruction to the control register without disturbing the operational state or timing of the other 7 pins on Port C, and without affecting Ports A and B.

Formulating BSR words for : In BSR mode, , bits , and bits select the bit: For bit 6 (): .

  • To SET : .
  • To RESET : .
Answer:

BSR mode provides atomic, single-instruction bit manipulation of actuator control lines without read-modify-write overhead. To set , the BSR word is 0DH; to reset , the BSR word is 0CH.

Question 3

An 8255 PPI is interfaced to an 8085 microprocessor at base I/O address 80H. Port A is connected to eight DIP switches, and Port B is connected to eight active-high LEDs. Write a complete 8085 assembly language program to initialize the 8255 in Mode 0, continuously read the DIP switch states, and display them on the LEDs.

Determining port addresses and control word: Base address is 80H:

  • Port A = 80H
  • Port B = 81H
  • Port C = 82H
  • Control Register = 83H

Control word for Mode 0 with Port A as input and Port B as output: , , (PA input), , , (PB output), . Control Word = .

Writing the assembly program:

8085 Program: DIP Switch to LED Transfer8085 ASM
START:  MVI A, 90H      ; Load control word (Port A input, Port B output)
        OUT 83H         ; Write control word to Control Register
READ_LP: IN 80H         ; Read DIP switch byte from Port A
        OUT 81H         ; Output byte to LEDs on Port B
        JMP READ_LP     ; Repeat continuously
        HLT             ; Halt (never reached)
Answer:

The 8255 is initialized with control word 90H at address 83H. The program reads Port A (80H) and writes to Port B (81H) in an infinite polling loop.

Question 4

An 8-bit ADC0804 converter is connected to an 8085 microprocessor. Its clock timing circuit uses and . Pin 9 () is supplied with .

  1. Find the clock frequency of the converter.
  2. Determine the full-scale analog input range and voltage step size.
  3. Calculate the digital output byte for an analog input .

Calculating clock frequency:

Evaluating span and step size: Because pin 9 is tied to , the full-scale input span is:

The step size for an 8-bit converter is:

Evaluating digital output code:

Answer:
  1. Clock Frequency: 757.58 kHz.
  2. Input Range: 0 to 2.50 V; Step Size: 9.77 mV.
  3. Digital Output Byte: B8H ().
Question 5

Describe the purpose of double buffering in the AD7522 10-bit DAC when interfacing with an 8-bit microprocessor like the 8085. Calculate the voltage step size and full-scale output voltage if the DAC reference voltage is .

Explaining the necessity of double buffering: Because the 8085 data bus is 8 bits wide, transmitting a 10-bit digital value requires two separate write operations (one 8-bit byte for low-order bits and one 2-bit byte for high-order bits). If single-buffered registers were used, the DAC output would immediately switch to an invalid intermediate voltage as soon as the first byte was written, persisting until the second byte arrived several clock cycles later. This produces false transient glitches on analog outputs. Double buffering decouples data loading from analog conversion:

  1. Low-order bits are latched into an input buffer via Low Byte Strobe ().
  2. High-order bits are latched into an input buffer via High Byte Strobe ().
  3. An active transfer pulse () updates the final holding register with all 10 bits simultaneously, resulting in a single clean analog step.

Calculating resolution and full-scale voltage: For a 10-bit DAC, the total number of quantization states is . Step size (resolution):

Full-scale output voltage ():

Answer:

Double buffering eliminates intermediate conversion glitches by latching 10 data bits across two writes into input buffers before updating the analog holding register simultaneously. Step size: 9.77 mV; Full-scale output: 9.990 V.

Question 6

Write an 8085 assembly language program to generate a continuous square wave using an 8-bit DAC interfaced at Port A (I/O address 80H) of an 8255 PPI. Assume Port A has been configured as a Mode 0 output port.

Designing the square wave algorithm: A symmetric square wave alternates between minimum output voltage (00H ) and maximum output voltage (FFH ) with an equal time delay between transitions:

  1. Output 00H to Port A.
  2. Call a software delay subroutine.
  3. Output FFH to Port A.
  4. Call the same software delay subroutine.
  5. Loop back to step 1.

Writing the 8085 assembly code:

8085 Program: DAC Square Wave Generation8085 ASM
START:  MVI A, 00H      ; Set accumulator to 00H (Low level)
        OUT 80H         ; Output to DAC at Port A
        CALL DELAY      ; Wait for half-period
        MVI A, 0FFH     ; Set accumulator to FFH (High level)
        OUT 80H         ; Output to DAC at Port A
        CALL DELAY      ; Wait for half-period
        JMP START       ; Repeat cycle indefinitely

DELAY:  MVI C, 50H      ; Load delay outer counter
D_LOOP: MVI D, 0FFH     ; Load delay inner counter
I_LOOP: DCR D           ; Decrement inner counter
        JNZ I_LOOP      ; Loop until inner counter is 0
        DCR C           ; Decrement outer counter
        JNZ D_LOOP      ; Loop until outer counter is 0
        RET             ; Return from subroutine
Answer:

The program continuously alternates between sending 00H and FFH to Port A (80H) with symmetrical delay subroutines, producing a periodic square wave.

Question 7

Explain how an 8085 microprocessor can generate an analog ramp (sawtooth) and triangular waveform using an 8-bit DAC interfaced to Port B. Specify the software counting pattern for each waveform.

Ramp (Sawtooth) Waveform Generation: To generate a ramp waveform:

  • The microprocessor initializes the accumulator to 00H and writes it to the DAC.
  • The accumulator is incremented by 1 (INR A) and output in a loop.
  • When the count increments from FFH, it overflows to 00H, instantly resetting the analog voltage from maximum () back to minimum ().
  • The slope of the ramp is adjusted by inserting a small software delay between increments.

Triangular Waveform Generation: To generate a symmetric triangular waveform:

  • Phase 1 (Rising slope): The accumulator starts at 00H and increments step-by-step (INR A) up to FFH, outputting each value to the DAC.
  • Phase 2 (Falling slope): Upon reaching FFH, the counting direction is reversed; the accumulator decrements step-by-step (DCR A) down to 00H, outputting each value.
  • Reaching 00H triggers the rising phase again, producing a continuous triangle wave without abrupt resets.
Answer:

A sawtooth ramp continuously increments from 00H to FFH and overflows back to 00H. A triangular wave alternates between an incrementing loop (00H up to FFH) and a decrementing loop (FFH down to 00H).

Past exam questions for Instrumentation

← Types of sensors (Electrical sensor, chemical sensor, biological…Microcontrollers (Atmega328, STM32): Architecture, pin configuration… →