Microprocessor & Microcontroller Systems (1333202) - Winter 2023 Solution

Solution guide for Microprocessor & Microcontroller Systems (1333202) Winter 2023 exam

Question 1(a) [3 marks]

Define Microprocessor.

Answer:

A microprocessor is a single-chip CPU that contains all the arithmetic, logic, and control circuitry required to perform the functions of a digital computer's central processing unit.

Table: Microprocessor Key Features

FeatureDescription
Single ChipComplete CPU on one integrated circuit
Processing UnitExecutes instructions and performs calculations
Control LogicManages system operations and data flow
  • Central Processing Unit: Core component that executes instructions
  • Integrated Circuit: All functions combined on single silicon chip
  • Programmable Device: Can execute different programs based on stored instructions

Mnemonic: "Single Chip CPU = Smart Computer Processor Unit"

Question 1(b) [4 marks]

Explain Flag register of microprocessor.

Answer:

The Flag register stores status information about the result of arithmetic and logical operations performed by the ALU.

Table: 8085 Flag Register Bits

FlagPositionPurpose
S (Sign)Bit 7Indicates sign of result (1=negative, 0=positive)
Z (Zero)Bit 6Set when result is zero
AC (Auxiliary Carry)Bit 4Carry from bit 3 to bit 4
P (Parity)Bit 2Even parity flag
CY (Carry)Bit 0Carry from MSB
  • Status Indicator: Shows condition of last operation result
  • Conditional Instructions: Used for branching and decision making
  • 5 Active Flags: Sign, Zero, Auxiliary Carry, Parity, and Carry flags

Mnemonic: "Flags Show Zero, Sign, Parity, Auxiliary, Carry"

Question 1(c) [7 marks]

Explain format of instruction of microprocessor with example.

Answer:

Microprocessor instructions consist of opcode and operand fields that specify the operation and data locations.

Table: 8085 Instruction Format Types

FormatSizeStructureExample
1-Byte8 bitsOpcode onlyMOV A,B
2-Byte16 bitsOpcode + 8-bit dataMVI A,05H
3-Byte24 bitsOpcode + 16-bit addressLDA 2000H

Diagram:

  • Opcode Field: Defines the operation to be performed (ADD, MOV, JMP)
  • Operand Field: Contains data, register, or memory address information
  • Variable Length: Instructions can be 1, 2, or 3 bytes long
  • Addressing Modes: Different ways to specify operand location

Mnemonic: "Opcode Operations + Operand Objects = Complete Commands"

Question 1(c OR) [7 marks]

Explain function of ALU, Control Unit and CPU of Microprocessor.

Answer:

The CPU consists of three main functional units that work together to execute instructions.

Table: CPU Components and Functions

ComponentPrimary FunctionKey Operations
ALUArithmetic & Logic OperationsADD, SUB, AND, OR, XOR
Control UnitInstruction ControlFetch, Decode, Execute
CPUOverall ProcessingCoordinate all operations

Diagram:

  • ALU Functions: Performs all arithmetic calculations and logical operations
  • Control Unit Tasks: Manages instruction execution cycle and generates control signals
  • CPU Coordination: Integrates ALU and Control Unit for complete processing

Mnemonic: "ALU Adds, Control Commands, CPU Coordinates"

Question 2(a) [3 marks]

Explain function of ALE signal with diagram.

Answer:

ALE (Address Latch Enable) signal is used to demultiplex the lower-order address and data lines.

Table: ALE Signal Functions

FunctionDescription
Address LatchingCaptures lower 8-bit address
DemultiplexingSeparates address from data
Timing ControlProvides timing reference

Diagram:

goat
  • Active High Signal: ALE goes high during T1 state
  • External Latching: Used with 74373 latch to hold address
  • System Timing: Provides reference for external devices

Mnemonic: "ALE Always Latches External Addresses"

Question 2(b) [4 marks]

Compare microprocessor and microcontroller

Answer:

Table: Microprocessor vs Microcontroller Comparison

ParameterMicroprocessorMicrocontroller
DesignGeneral purposeApplication specific
MemoryExternal RAM/ROMInternal RAM/ROM
I/O PortsExternal interfaceBuilt-in I/O ports
TimersExternalBuilt-in timers
CostHigher system costLower system cost
PowerHigher consumptionLower consumption
  • Integration Level: Microcontroller has more integrated components
  • Application Focus: Microprocessor for computing, microcontroller for control
  • System Complexity: Microprocessor needs more external components
  • Design Flexibility: Microprocessor offers more expandability

Mnemonic: "Microprocessor = More Power, Microcontroller = More Control"

Question 2(c) [7 marks]

Draw & explain block diagram of microprocessor.

Answer:

The 8085 microprocessor consists of several functional blocks that work together.

Diagram:

Table: Block Functions

BlockFunction
ALUArithmetic and logical operations
Register ArrayTemporary data storage (B,C,D,E,H,L)
Control UnitInstruction execution control
Address BufferDrive address bus lines
  • Data Path: Information flows between registers through internal bus
  • Control Signals: Generated by timing and control unit
  • Bus Interface: Connects to external memory and I/O devices
  • Register Operations: Temporary storage for operands and results

Mnemonic: "Blocks Build Better Processing Systems"

Question 2(a OR) [3 marks]

Explain 16 bits registers of microprocessor.

Answer:

The 8085 has three 16-bit registers formed by combining 8-bit register pairs.

Table: 16-bit Registers

RegisterFormationPurpose
PCSingle 16-bitProgram Counter - next instruction address
SPSingle 16-bitStack Pointer - top of stack address
HLH + L registersMemory pointer - data address
  • Program Counter: Automatically increments to next instruction
  • Stack Pointer: Points to last pushed data on stack
  • HL Pair: Most frequently used for memory addressing

Mnemonic: "PC Points Program, SP Stacks Properly, HL Holds Location"

Question 2(b OR) [4 marks]

Explain de-multiplexing lower order address and data lines with diagram of microprocessor.

Answer:

The 8085 multiplexes lower 8-bit address with data lines to reduce pin count.

Table: Multiplexed Lines

LinesT1 StateT2-T4 States
AD0-AD7Lower Address A0-A7Data D0-D7
ALE SignalHighLow

Diagram:

goat
  • Time Division: Same lines carry address then data
  • External Latch: 74373 captures address when ALE is high
  • Signal Separation: Creates separate address and data buses

Mnemonic: "ALE Always Latches External Address Elegantly"

Question 2(c OR) [7 marks]

Draw and explain pin diagram of 8085.

Answer:

The 8085 is a 40-pin microprocessor with multiplexed address/data bus.

Diagram:

goat

Table: Pin Groups

GroupPinsFunction
Address/DataAD0-AD7, A8-A15Memory addressing and data transfer
ControlALE, RD*, WR*, IO/M*Bus control signals
InterruptsINTR, RST7-RST5, TRAPInterrupt handling
PowerVcc, VssPower supply connections
  • Multiplexed Bus: AD0-AD7 carry both address and data
  • Active Low Signals: Signals with * are active low
  • Crystal Connections: X1, X2 for clock generation

Mnemonic: "Forty Pins Provide Perfect Processing Power"

Question 3(a) [3 marks]

Draw clock and reset circuit of microcontroller

Answer:

The 8051 requires external clock and reset circuits for proper operation.

Diagram:

goat

Table: Circuit Components

ComponentValuePurpose
Crystal11.0592 MHzClock generation
Capacitors30pF eachCrystal stabilization
Reset Resistor10KΩPull-up for reset
Reset Capacitor10µFPower-on reset delay
  • Clock Frequency: Commonly 11.0592 MHz for serial communication
  • Reset Duration: Must be high for at least 2 machine cycles
  • Power-on Reset: Automatic reset when power is applied

Mnemonic: "Crystals Create Clock, Resistors Reset Reliably"

Question 3(b) [4 marks]

Explain internal RAM of 8051.

Answer:

The 8051 contains 256 bytes of internal RAM organized in different sections.

Table: Internal RAM Organization

Address RangeSizePurpose
00H-1FH32 bytesRegister Banks (4 banks × 8 registers)
20H-2FH16 bytesBit-addressable area
30H-7FH80 bytesGeneral purpose RAM
80H-FFH128 bytesSpecial Function Registers (SFRs)

Diagram:

  • Register Banks: Four banks of 8 registers each (R0-R7)
  • Bit Addressing: Individual bits can be addressed in 20H-2FH area
  • Stack Area: Usually located in general purpose RAM area
  • Direct Access: All locations accessible through direct addressing

Mnemonic: "RAM Registers, Bits, General, Special Functions"

Question 3(c) [7 marks]

Explain block diagram of 8051.

Answer:

The 8051 microcontroller integrates CPU, memory, and I/O on a single chip.

Diagram:

Table: Major Blocks

BlockFunction
CPUInstruction execution and control
Memory4KB ROM + 256B RAM
TimersTwo 16-bit timer/counters
I/O PortsFour 8-bit bidirectional ports
Serial PortFull-duplex UART
Interrupts5-source interrupt system
  • Harvard Architecture: Separate program and data memory spaces
  • Built-in Peripherals: Timers, serial port, interrupts integrated
  • Expandable: External memory and I/O can be added
  • Control Applications: Optimized for embedded control tasks

Mnemonic: "Complete Control Chip Contains CPU, Memory, I/O"

Question 3(a OR) [3 marks]

Explain function of DPTR and PC.

Answer:

DPTR and PC are important 16-bit registers in 8051 for memory addressing.

Table: DPTR and PC Functions

RegisterFull FormFunction
DPTRData PointerPoints to external data memory
PCProgram CounterPoints to next instruction address
  • DPTR Usage: Accessing external RAM and lookup tables
  • PC Function: Automatically increments after instruction fetch
  • 16-bit Addressing: Both can address 64KB memory space

Mnemonic: "DPTR Data Pointer, PC Program Counter"

Question 3(b OR) [4 marks]

Explain different timer modes of microcontroller.

Answer:

The 8051 has two timers with four different operating modes.

Table: Timer Modes

ModeConfigurationPurpose
Mode 013-bit timerCompatible with 8048
Mode 116-bit timerMaximum count capability
Mode 28-bit auto-reloadConstant time intervals
Mode 3Two 8-bit timersTimer 0 split operation
  • Mode Selection: Controlled by TMOD register bits
  • Timer 0/1: Both timers support modes 0, 1, 2
  • Mode 3 Special: Only Timer 0 can operate in mode 3
  • Applications: Delays, baud rate generation, event counting

Mnemonic: "Modes Make Timers Tremendously Versatile"

Question 3(c OR) [7 marks]

Explain interrupts of microcontroller.

Answer:

The 8051 has a 5-source interrupt system for handling external events.

Table: 8051 Interrupt Sources

InterruptVector AddressPriorityTrigger
Reset0000HHighestPower-on/External
External 00003HHighINT0 pin
Timer 0000BHMediumTimer 0 overflow
External 10013HMediumINT1 pin
Timer 1001BHLowTimer 1 overflow
Serial0023HLowestSerial communication

Diagram:

  • Interrupt Enable: IE register controls individual interrupt enables
  • Priority Control: IP register sets interrupt priorities
  • Vector Addresses: Each interrupt has fixed vector location
  • Nested Interrupts: Higher priority can interrupt lower priority

Mnemonic: "Five Interrupt Sources Serve System Efficiently"

Question 4(a) [3 marks]

Explain data transfer instruction with example for 8051.

Answer:

Data transfer instructions move data between registers, memory, and I/O ports.

Table: Data Transfer Instructions

InstructionExampleFunction
MOVMOV A,#55HMove immediate data to accumulator
MOVXMOVX A,@DPTRMove external RAM to accumulator
MOVCMOVC A,@A+PCMove code memory to accumulator
  • MOV Variants: Register to register, immediate to register
  • External Access: MOVX for external RAM operations
  • Code Access: MOVC for reading program memory tables

Mnemonic: "MOV Moves data, MOVX eXternal, MOVC Code"

Question 4(b) [4 marks]

List and explain different addressing modes of microcontroller.

Answer:

The 8051 supports several addressing modes for flexible data access.

Table: 8051 Addressing Modes

ModeExampleDescription
ImmediateMOV A,#55HData specified in instruction
RegisterMOV A,R0Use register contents
DirectMOV A,30HDirect memory address
IndirectMOV A,@R0Address stored in register
IndexedMOVC A,@A+DPTRBase address plus offset
  • Immediate Mode: Constant data included in instruction
  • Register Mode: Fastest execution using register file
  • Direct Mode: Access any internal RAM location
  • Indirect Mode: Pointer-based addressing for arrays
  • Indexed Mode: Table lookup and array access

Mnemonic: "Immediate, Register, Direct, Indirect, Indexed Addressing"

Question 4(c) [7 marks]

Write a program to copy block of 8 data starting from location 100h to 200h.

Answer:

Assembly Program:

Assembly

Table: Register Usage

RegisterPurpose
R0Source address pointer (100H)
R1Destination address pointer (200H)
R2Loop counter (8 bytes)
ATemporary data storage
  • Indirect Addressing: @R0 and @R1 for memory access
  • Loop Control: DJNZ instruction decrements and tests
  • Block Transfer: Copies 8 consecutive bytes efficiently

Mnemonic: "Read, Write, Increment, Decrement, Jump Loop"

Question 4(a OR) [3 marks]

Write a program to add two bytes of data and store result in R0 register.

Answer:

Assembly Program:

Assembly

Table: Operation Steps

StepInstructionResult
1MOV A,#25HA = 25H
2ADD A,#35HA = 5AH
3MOV R0,AR0 = 5AH
  • Addition Result: 25H + 35H = 5AH
  • Flag Effects: Carry flag set if result > FFH

Mnemonic: "Move, Add, Move = Simple Addition"

Question 4(b OR) [4 marks]

Explain indexed addressing mode with example.

Answer:

Indexed addressing uses a base address plus an offset for memory access.

Table: Indexed Addressing Details

ComponentDescriptionExample
Base AddressDPTR or PC registerDPTR = 1000H
IndexAccumulator contentsA = 05H
Effective AddressBase + Index1000H + 05H = 1005H

Example:

Assembly
  • Table Access: Ideal for lookup tables and arrays
  • Program Memory: MOVC reads from code memory only
  • Dynamic Indexing: Index can change during execution

Mnemonic: "Base + Index = Dynamic Access"

Question 4(c OR) [7 marks]

Explain stack operation of microcontroller, PUSH and POP instruction.

Answer:

The stack is a LIFO memory structure used for temporary data storage.

Table: Stack Operations

OperationInstructionFunction
PUSHPUSH 30HStore data on stack
POPPOP 30HRetrieve data from stack
Stack PointerSP registerPoints to top of stack

Diagram:

goat

Example Program:

Assembly
  • LIFO Structure: Last In, First Out data organization
  • SP Auto-increment: Stack pointer automatically adjusts
  • Subroutine Calls: Stack saves return addresses
  • Register Preservation: Save/restore register contents

Mnemonic: "PUSH Puts Up, Stack Holds, POP Pulls Out"

Question 5(a) [3 marks]

Explain branching instruction with example.

Answer:

Branching instructions alter program flow based on conditions or unconditionally.

Table: Branching Instructions

TypeInstructionExample
UnconditionalLJMP addressLJMP 2000H
ConditionalJZ addressJZ ZERO_LABEL
Call/ReturnLCALL addressLCALL SUBROUTINE

Example:

Assembly
  • Program Control: Changes execution sequence
  • Conditional Jumps: Based on flag register status
  • Address Range: Can jump to any program memory location

Mnemonic: "Jump Changes Control Flow"

Question 5(b) [4 marks]

Interface 8 leds with microcontroller and write a program to turn on and off.

Answer:

Circuit Diagram:

goat

Program:

Assembly

Table: Components

ComponentValuePurpose
Resistor330ΩCurrent limiting
LEDs8 piecesVisual indicators
PortP18-bit output port
  • Current Limiting: Resistors protect LEDs from overcurrent
  • Port Configuration: P1 used as output port for LED control
  • Delay Routine: Creates visible ON/OFF timing

Mnemonic: "Port Controls LEDs with Resistance and Delay"

Question 5(c) [7 marks]

Interface LCD with microcontroller and write a program to display "welcome".

Answer:

Circuit Connections:

goat

Program:

Assembly

Table: LCD Interface Pins

8051 PinLCD PinFunction
P2.0-P2.3D4-D74-bit data lines
P1.0RSRegister select (0=command, 1=data)
P1.1ENEnable pulse
GNDR/WRead/Write (tied to ground for write)
  • 4-bit Mode: Uses only upper 4 data lines to save pins
  • Control Signals: RS selects command/data, EN provides timing pulse
  • Character Display: Each character sent as ASCII code
  • Initialization: Required command sequence for proper operation

Mnemonic: "LCD Displays Characters with Commands and Data"

Question 5(a OR) [3 marks]

Explain logical instruction with example.

Answer:

Logical instructions perform bitwise operations on data.

Table: Logical Instructions

InstructionExampleFunction
ANLANL A,#0FHBitwise AND operation
ORLORL A,#F0HBitwise OR operation
XRLXRL A,#FFHBitwise XOR operation

Example:

Assembly
  • Bit Manipulation: Used for setting, clearing, and testing bits
  • Masking Operations: ANL clears unwanted bits
  • Flag Effects: Updates parity flag based on result

Mnemonic: "AND Masks, OR Sets, XOR Toggles"

Question 5(b OR) [4 marks]

Interface 7 segment with microcontroller.

Answer:

Circuit Diagram:

goat

Program to Display 0-9:

Assembly

Table: 7-Segment Codes

DigitHex CodeBinarySegments Lit
03FH00111111a,b,c,d,e,f
106H00000110b,c
25BH01011011a,b,g,e,d
  • Common Cathode: Segments light when port pin is high
  • Current Limiting: Resistors prevent segment damage
  • Lookup Table: Efficient storage of segment patterns

Mnemonic: "Seven Segments Show Digits Clearly"

Question 5(c OR) [7 marks]

Interface LM 35 with microcontroller and explain block diagram of temperature controller.

Answer:

Circuit Diagram:

goat

Temperature Controller Block Diagram:

Control Program:

Assembly

Table: System Components

ComponentFunction
LM35Temperature sensor (10mV/°C)
ADC0804Analog to digital converter
8051Main controller
RelaySwitch high power loads
DisplayShow current temperature
  • Temperature Sensing: LM35 provides 10mV per degree Celsius
  • ADC Conversion: Converts analog voltage to digital value
  • Control Logic: Compares with setpoint and controls relay
  • Feedback System: Continuous monitoring and adjustment
  • Safety Features: Over-temperature protection possible

Mnemonic: "Sense, Convert, Compare, Control Temperature Automatically"