Microprocessor & Microcontroller Systems (1333202) - Summer 2024 Solution

Solution guide for Microprocessor & Microcontroller Systems (1333202) Summer 2024 exam

Question 1(a) [3 marks]

List common features of 8051 microcontroller.

Answer:

Table: Common Features of 8051 Microcontroller

FeatureDescription
On-chip OscillatorBuilt-in clock generator circuit
Program Memory4KB internal ROM for code storage
Data Memory128 bytes internal RAM
I/O Ports4 bidirectional 8-bit ports (P0-P3)
Timers/CountersTwo 16-bit Timer/Counter units
Serial PortFull duplex UART communication
Interrupts5 interrupt sources with priority
SFRsSpecial Function Registers for control

Mnemonic: "On Program Data I/O Timers Serial Interrupts SFRs"

Question 1(b) [4 marks]

Define T-State, Machine Cycle, Instruction Cycle and Opcode.

Answer:

Table: Microprocessor Timing Definitions

TermDefinitionDuration
T-StateOne clock period of system clockBasic timing unit
Machine CycleTime to complete one memory operation3-6 T-states
Instruction CycleTime to fetch, decode and execute instruction1-4 Machine cycles
OpcodeOperation code specifying instruction type1-3 bytes
  • T-State: Smallest unit of time in microprocessor operation
  • Machine Cycle: Contains multiple T-states for memory access
  • Instruction Cycle: Complete instruction execution time
  • Opcode: Binary code identifying specific instruction

Mnemonic: "Time Machine Instruction Operation"

Question 1(c) [7 marks]

Compare Von-Neumann and Harvard Architecture.

Answer:

Table: Von-Neumann vs Harvard Architecture Comparison

ParameterVon-NeumannHarvard
Memory OrganizationSingle memory for code and dataSeparate memory for code and data
Bus StructureSingle bus systemDual bus system
SpeedSlower due to bus sharingFaster parallel access
CostLower cost implementationHigher cost due to dual memory
FlexibilityMore flexible memory usageLess flexible, fixed allocation
Examples8085, x86 processors8051, DSP processors

Key Differences:

  • Memory Access: Von-Neumann uses sequential access, Harvard allows simultaneous
  • Performance: Harvard is faster for embedded applications
  • Applications: Von-Neumann for general computing, Harvard for real-time systems

Mnemonic: "Von-Single Harvard-Dual"

Question 1(c) OR [7 marks]

Explain Microcomputer System with block diagram.

Answer:

Microcomputer System Components:

Table: Microcomputer System Components

ComponentFunctionExamples
CPUCentral processing and control8085, 8086
MemoryProgram and data storageRAM, ROM, EPROM
I/O UnitInterface with external worldKeyboard, Display
System BusData transfer pathwayAddress, Data, Control
  • CPU: Executes instructions and controls system operation
  • Memory: Stores programs and data for processing
  • I/O: Provides communication with external devices
  • Bus: Connects all components for data transfer

Mnemonic: "CPU Memory I/O Bus"

Question 2(a) [3 marks]

Draw Bus organization in 8085 Microprocessor.

Answer:

goat

Table: 8085 Bus Organization

Bus TypeWidthFunction
Address Bus16-bitMemory addressing (64KB)
Data Bus8-bitData transfer
Control BusMultipleControl signals

Mnemonic: "Address Data Control"

Question 2(b) [4 marks]

List Flags used in 8085 and Explain working of each flags.

Answer:

Table: 8085 Flags Register

FlagNameBit PositionFunction
SSignD7Set if result is negative
ZZeroD6Set if result is zero
ACAuxiliary CarryD4Set if carry from bit 3 to 4
PParityD2Set if result has even parity
CYCarryD0Set if carry/borrow occurs
goat
  • Sign Flag: Indicates negative result (MSB = 1)
  • Zero Flag: Set when arithmetic result is zero
  • Auxiliary Carry: Used for BCD arithmetic operations
  • Parity Flag: Checks even number of 1's in result
  • Carry Flag: Indicates overflow in arithmetic operations

Mnemonic: "Sign Zero Auxiliary Parity Carry"

Question 2(c) [7 marks]

Draw and Explain Block Diagram of 8085.

Answer:

Table: 8085 Block Components

BlockFunctionSize
ALUArithmetic and logical operations8-bit
AccumulatorPrimary register for operations8-bit
RegistersData storage (B,C,D,E,H,L)8-bit each
Program CounterPoints to next instruction16-bit
Stack PointerPoints to stack top16-bit
Control UnitInstruction decode and control-
  • Data Flow: Instructions fetched via PC, decoded by CU, executed in ALU
  • Register Operations: Accumulator works with ALU, other registers store data
  • Address Generation: PC and SP provide 16-bit addresses
  • Control Signals: CU generates timing and control signals

Mnemonic: "ALU Accumulator Registers Program Stack Control"

Question 2(a) OR [3 marks]

Explain Instruction Fetching, Decoding and Execution Operation in microprocessor.

Answer:

Table: Instruction Cycle Phases

PhaseOperationDuration
FetchGet instruction from memory1 machine cycle
DecodeInterpret instruction opcodePart of execute
ExecutePerform required operation1-3 machine cycles

Mnemonic: "Fetch Decode Execute"

Question 2(b) OR [4 marks]

What is Demultiplexing of Lower order Address and Data lines in 8085? Explain using neat sketch.

Answer:

goat

Demultiplexing Process:

  • ALE Signal: Controls separation of address and data
  • Latch IC: 74LS373 stores address when ALE is high
  • Timing: Address appears first, then data on same lines

Table: Demultiplexing Components

ComponentFunctionTiming
ALEAddress Latch Enable signalHigh during T1
74LS373Octal latch ICStores A7-A0
AD7-AD0Multiplexed linesAddress then Data

Mnemonic: "Address Latch Enable Demultiplexes Lines"

Question 2(c) OR [7 marks]

Draw and Explain Pin Diagram of 8085.

Answer:

goat

Table: 8085 Pin Functions

Pin GroupFunctionCount
Address BusA8-A15 (Higher order)8 pins
Address/DataAD0-AD7 (Multiplexed)8 pins
Control SignalsALE, RD, WR, IO/M4 pins
InterruptsTRAP, RST7.5, RST6.5, RST5.5, INTR5 pins
PowerVCC, VSS2 pins
ClockX1, X2, CLK3 pins
  • Address Lines: 16-bit addressing capability (64KB)
  • Data Lines: 8-bit data transfer
  • Control Lines: Memory and I/O operation control
  • Interrupt Lines: Hardware interrupt handling

Mnemonic: "Address Data Control Interrupt Power Clock"

Question 3(a) [3 marks]

Draw IP SFR of 8051 and Explain function of each bit.

Answer:

goat

Table: IP Register Bit Functions

BitNameFunction
D4PT2Timer 2 interrupt priority
D3PSSerial port interrupt priority
D2PT1Timer 1 interrupt priority
D1PX1External interrupt 1 priority
D0PX0External interrupt 0 priority
  • Priority Levels: 1 = High priority, 0 = Low priority
  • Default: All interrupts have low priority (00H)
  • Usage: Set bit to 1 for high priority interrupt

Mnemonic: "Timer2 Serial Timer1 External1 External0"

Question 3(b) [4 marks]

Draw and explain Timer/Counter Logic diagram for 8051.

Answer:

Table: Timer Components

ComponentFunctionSize
TH0/TL0Timer 0 high/low byte registers8-bit each
TMODTimer mode register8-bit
TCONTimer control register8-bit
TF0Timer 0 overflow flag1-bit
  • Clock Source: Internal (system clock/12) or External (T0 pin)
  • Operation: Counts up from loaded value to FFH
  • Overflow: Sets TF0 flag and generates interrupt
  • Modes: 4 different timer modes available

Mnemonic: "Timer High-Low Mode Control Flag"

Question 3(c) [7 marks]

Draw and Explain Block Diagram of 8051.

Answer:

Table: 8051 Block Components

BlockFunctionSpecification
CPUCentral processing unit8-bit processor
Program MemoryCode storage4KB internal ROM
Data MemoryVariable storage128 bytes RAM
I/O PortsExternal interface4 ports (32 I/O lines)
TimersTiming operations2 × 16-bit timers
Serial PortCommunicationFull duplex UART
InterruptsEvent handling5 interrupt sources
  • Architecture: Harvard architecture with separate program/data memory
  • I/O Capability: 32 bidirectional I/O lines
  • On-chip Features: Timers, serial port, interrupt system
  • Memory: Von-Neumann for data, Harvard for program

Mnemonic: "CPU Program Data I/O Timer Serial Interrupt"

Question 3(a) OR [3 marks]

Draw PCON SFR of 8051 and Explain function of each bit.

Answer:

goat

Table: PCON Register Bit Functions

BitNameFunction
D7SMODSerial port mode modifier
D3GF1General purpose flag bit 1
D2GF0General purpose flag bit 0
D1PDPower down mode control
D0IDLIdle mode control
  • SMOD: Doubles serial port baud rate when set
  • GF1, GF0: User-defined flag bits
  • PD: Activates power-down mode
  • IDL: Activates idle mode

Mnemonic: "Serial General Power Idle"

Question 3(b) OR [4 marks]

In 8051 Serial communication Mode 1, For XTAL=11.0592 MHz, find TH1 value needed to have for 9600 and 4800 baud rate.

Answer:

Formula for Mode 1 Baud Rate:

Baud Rate = (2^SMOD/32) × (Timer1 Overflow Rate)
Timer1 Overflow Rate = XTAL/(12 × (256 - TH1))

For 9600 Baud Rate:

9600 = (1/32) × (11059200/(12 × (256 - TH1)))
9600 = 28800/(256 - TH1)
256 - TH1 = 3
TH1 = 253 = FDH

For 4800 Baud Rate:

4800 = (1/32) × (11059200/(12 × (256 - TH1)))
4800 = 28800/(256 - TH1)
256 - TH1 = 6
TH1 = 250 = FAH

Table: TH1 Values for Baud Rates

Baud RateTH1 Value (Hex)TH1 Value (Decimal)
9600FDH253
4800FAH250

Mnemonic: "Higher Baud Higher TH1"

Question 4(a) [3 marks]

What are the differences in LCALL and LJMP instructions in 8051?

Answer:

Table: LCALL vs LJMP Comparison

ParameterLCALLLJMP
FunctionLong subroutine callLong jump
Stack UsagePushes return addressNo stack operation
ReturnRET instruction neededDirect jump only
Bytes3 bytes3 bytes
Address Range16-bit (64KB)16-bit (64KB)
PC ActionSaved then loadedDirectly loaded
  • LCALL: Calls subroutine, saves return address on stack
  • LJMP: Unconditional jump to specified address
  • Stack Impact: LCALL uses 2 stack bytes, LJMP uses none
  • Usage: LCALL for functions, LJMP for program flow control

Mnemonic: "Call Saves Jump Goes"

Question 4(b) [4 marks]

Write 8051 Assembly Language Program to generate square wave on port 1.0 using Timer0.

Answer:

Assembly

Program Explanation:

  • Timer Setup: Mode 1 (16-bit timer)
  • Count Value: -50000 for specific delay
  • Square Wave: Toggle P1.0 on each overflow
  • Continuous: Loop maintains square wave

Mnemonic: "Mode Load Start Wait Toggle Reload"

Question 4(c) [7 marks]

Explain any three Logical and any four Data Transfer Instruction of 8051 with example.

Answer:

Table: Logical Instructions

InstructionFunctionExampleResult
ANLLogical ANDANL A, #0FHA = A AND 0FH
ORLLogical ORORL A, #F0HA = A OR F0H
XRLLogical XORXRL A, #FFHA = A XOR FFH

Table: Data Transfer Instructions

InstructionFunctionExampleOperation
MOVMove dataMOV A, #50HLoad 50H into A
MOVXMove externalMOVX A, @DPTRLoad from external memory
PUSHPush to stackPUSH ACCPush accumulator to stack
POPPop from stackPOP ACCPop from stack to accumulator

Detailed Examples:

Assembly

Mnemonic: "AND OR XOR Move External Push Pop"

Question 4(a) OR [3 marks]

Explain Instructions: (i) RRC A (ii) POP (iii) CLR PSW.7

Answer:

Table: Instruction Explanations

InstructionFunctionOperationExample
RRC ARotate right through carryA→C, C→A(MSB)A=85H,C=0 → A=42H,C=1
POPPop from stackSP→Register, SP-1POP ACC
CLR PSW.7Clear bit 7 of PSWPSW.7 = 0Clear CY flag
goat
  • RRC A: Rotates accumulator right through carry flag
  • POP: Removes top stack element into specified register
  • CLR PSW.7: Clears carry flag (bit 7 of Program Status Word)

Mnemonic: "Rotate Pop Clear"

Question 4(b) OR [4 marks]

Write 8051 Assembly Language Program to Divide data stored in location 30H by data stored in location 31H and store remainder in 40h and quotient in 41h memory location.

Answer:

Assembly

Program Steps:

  1. Load Data: Move dividend and divisor to A and B
  2. Division: Use DIV AB instruction
  3. Store Results: Quotient in A, remainder in B
  4. Save: Store results in specified memory locations

Table: DIV AB Instruction

BeforeAfter
A = DividendA = Quotient
B = DivisorB = Remainder

Mnemonic: "Load Divide Store"

Question 4(c) OR [7 marks]

List Addressing Modes of 8051 Microcontroller and Explain each with Example.

Answer:

Table: 8051 Addressing Modes

ModeDescriptionExampleExplanation
ImmediateData in instructionMOV A, #50HLoad 50H into A
RegisterUse registerMOV A, R0Move R0 content to A
DirectMemory address specifiedMOV A, 30HLoad from address 30H
IndirectAddress in registerMOV A, @R0Load from address in R0
IndexedBase + offsetMOVC A, @A+DPTRA = content of (A+DPTR)
RelativePC + offsetSJMP HEREJump relative to PC
BitBit addressSETB P1.0Set bit 0 of Port 1

Detailed Examples:

Assembly

Mnemonic: "Immediate Register Direct Indirect Indexed Relative Bit"

Question 5(a) [3 marks]

Draw Interfacing of Relay with 8051 microcontroller.

Answer:

goat

Table: Interface Components

ComponentFunctionValue
TransistorCurrent amplifierBC547 NPN
ResistorBase current limiter2.2KΩ
RelayElectromagnetic switch12V DC
DiodeBack EMF protection1N4007
  • Operation: Port pin HIGH → Transistor ON → Relay energized
  • Protection: Diode prevents back EMF damage
  • Isolation: Relay provides electrical isolation

Mnemonic: "Transistor Resistor Relay Diode"

Question 5(b) [4 marks]

Interface 7 Segment display with 8051 microcontroller and write a program to print "1" on it.

Answer:

goat

Program to Display "1":

Assembly

Table: 7-Segment Display Components

ComponentFunctionValue
Current Limiting ResistorProtect LED segments330Ω
Port ConnectionDigital output controlPort 1
Display PatternSegment controlBinary pattern

Mnemonic: "Current Limit Segment Pattern"

Question 5(c) [7 marks]

Interface DAC 0808 with 8051 microcontroller and write a program to generate Square wave.

Answer:

goat

Program to Generate Square Wave:

Assembly

Table: DAC Interface Specifications

ParameterValueFunction
Resolution8-bit256 output levels
Reference Voltage5VFull scale output
Output Range0-5VAnalog voltage range
Interface TypeParallel8-bit data bus

Square Wave Generation:

  • Low Level: 00H produces approximately 0V output
  • High Level: FFH produces approximately 5V output
  • Frequency: Determined by delay routine duration
  • Output: Clean analog square wave at DAC output

Mnemonic: "Digital Analog Convert Square"

Question 5(a) OR [3 marks]

Interface of Push button Switch with 8051 microcontroller.

Answer:

goat

Table: Push Button Interface Components

ComponentValueFunction
Pull-up Resistor10KΩEnsures logic HIGH when switch open
Push ButtonSPST MomentaryUser input device
Logic LevelsHIGH=1, LOW=0Switch open=1, pressed=0

Sample Program:

Assembly

Operation:

  • Switch Open: Pull-up resistor makes pin HIGH (logic 1)
  • Switch Pressed: Pin connected to GND, becomes LOW (logic 0)
  • Debouncing: May require software debouncing for reliable operation

Mnemonic: "Pull-up Switch Ground"

Question 5(b) OR [4 marks]

Interface DC Motor with 8051 microcontroller.

Answer:

goat

Motor Control Program:

Assembly

Table: DC Motor Interface Components

ComponentFunctionSpecification
Power TransistorCurrent amplificationTIP122 (Darlington pair)
Base ResistorCurrent limiting1KΩ
Freewheeling DiodeBack EMF protection1N4007
DC MotorLoad device12V DC Motor

Operation Principle:

  • Motor ON: Port pin HIGH → Transistor saturated → Motor runs
  • Motor OFF: Port pin LOW → Transistor cut-off → Motor stops
  • Speed Control: PWM technique varies average power to motor
  • Protection: Diode protects transistor from back EMF

Mnemonic: "Transistor Resistor Diode Motor"

Question 5(c) OR [7 marks]

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

Answer:

goat

Complete LCD Interface Program:

Assembly

Table: LCD Control Signals

SignalPinFunction
RSP3.0Register Select (0=Command, 1=Data)
ENP3.1Enable pulse for data latch
R/WGNDRead/Write (tied to GND for write only)
D4-D7P2.0-P2.34-bit data bus (upper nibble)

Table: Important LCD Commands

CommandHex CodeFunction
Function Set38H8-bit mode, 2 lines, 5x7 matrix
Display Control0EHDisplay ON, cursor ON, blink OFF
Clear Display01HClear entire display
Entry Mode06HIncrement cursor, no display shift

LCD Display Process:

  1. Initialization: Configure LCD parameters and clear display
  2. Command Mode: Send commands with RS=0
  3. Data Mode: Send characters with RS=1
  4. Enable Pulse: Latch data/command with EN signal
  5. String Display: Loop through message characters until null terminator

Character Display Steps:

  • Set RS=1 for data mode
  • Put character code on data bus
  • Generate enable pulse (HIGH to LOW)
  • Wait for LCD to process (1ms delay)
  • Repeat for next character

Mnemonic: "Initialize Command Data Enable Display"