Microprocessor and Microcontroller (4341101) - Summer 2024 Solution

Solution guide for Microprocessor and Microcontroller (4341101) Summer 2024 exam

Question 1(a) [3 marks]

Describe any one Port Configuration of 8051 Microcontroller.

Answer:

ConfigurationDescription
Port 0Dual-purpose port - 8-bit open drain bidirectional I/O port and multiplexed low address/data bus. External pull-up resistors required for I/O functions.

Diagram:

goat

Mnemonic: "PORT 0-PLAD" (Port 0 needs Pull-ups, works as Latch/Address/Data)

Question 1(b) [4 marks]

Illustrate Microprocessor Architecture.

Answer:

ComponentFunction
ALUPerforms arithmetic and logical operations
RegistersTemporary storage for data and addresses
Control UnitDirects operation of processor and data flow
BusesPathways for data transfer (address, data, control)

Diagram:

goat

Mnemonic: "RABC" - "Registers, ALU, Buses, Control"

Question 1(c) [7 marks]

Compare Von Neumann & Harvard architecture.

Answer:

FeatureVon Neumann ArchitectureHarvard Architecture
Memory BusesSingle memory bus for instructions and dataSeparate buses for program and data memory
ExecutionSequential executionParallel fetch and execute possible
SpeedSlower due to bus bottleneckFaster due to simultaneous access
Memory AccessSingle memory spaceSeparate memory spaces
ComplexitySimpler designMore complex design
ApplicationsGeneral-purpose computingDSP, microcontrollers, embedded systems
ExamplesMost PCs, 8085, 80868051, PIC, ARM Cortex-M

Diagram:

goat

Mnemonic: "Harvard Has Separate Streets" (Harvard Has Separate memory paths)

Question 1(c OR) [7 marks]

Define RISC, CISC, Opcode, Operand, Instruction Cycle, Machine Cycle, and T State.

Answer:

TermDefinition
RISCReduced Instruction Set Computer - architecture with simple instructions optimized for speed
CISCComplex Instruction Set Computer - architecture with complex, powerful instructions
OpcodeOperation Code - part of instruction that specifies operation to be performed
OperandData value or address used in operation
Instruction CycleComplete process to fetch, decode and execute an instruction
Machine CycleBasic operation like memory read/write (subset of instruction cycle)
T-StateTime state - smallest unit of time in processor operation (clock period)

Diagram:

goat

Mnemonic: "RICO ITEM" (RISC, CISC, Opcode, Instruction cycle, T-state, Execute, Machine cycle)

Question 2(a) [3 marks]

Define Data bus, Address bus and Control bus.

Answer:

Bus TypeDefinition
Data BusBidirectional pathway that transfers actual data between microprocessor and peripheral devices
Address BusUnidirectional pathway that carries memory/IO device locations to be accessed
Control BusGroup of signal lines that coordinate and synchronize all system operations

Diagram:

goat

Mnemonic: "ADC" - "Address finds location, Data carries information, Control coordinates operations"

Question 2(b) [4 marks]

Compare Microprocessor and Microcontroller.

Answer:

FeatureMicroprocessorMicrocontroller
DefinitionCPU on a single chipComplete computer system on a chip
MemoryExternal RAM/ROM neededBuilt-in RAM/ROM
I/O PortsLimited or none on-chipMultiple I/O ports on-chip
PeripheralsExternal peripherals neededBuilt-in peripherals (timers, ADC, etc.)
ApplicationsGeneral computing, PCsEmbedded systems, IoT devices
CostHigher for complete systemLower (all-in-one solution)
Power ConsumptionHigherLower

Mnemonic: "MEMI-CAP" (Memory external/internal, Cost, Applications, Peripherals)

Question 2(c) [7 marks]

Sketch and explain 8085 block diagram.

Answer:

Diagram:

goat

Main Components:

  • Register Array: A (Accumulator), Flags, B-L, SP, PC, temp registers
  • ALU: Performs arithmetic and logical operations
  • Timing & Control: Generates control signals, handles interrupts
  • Bus Interface: Connects CPU to external devices
  • Internal Data Bus: Links internal components

Mnemonic: "RATBI" - "Registers, ALU, Timing, Buses, Interface"

Question 2(a OR) [3 marks]

Explain Accumulator, Program Counter and Stack Pointer.

Answer:

RegisterFunction
Accumulator (A)8-bit register that stores results of arithmetic and logical operations
Program Counter (PC)16-bit register that holds address of next instruction to be executed
Stack Pointer (SP)16-bit register that points to current top of stack in memory

Diagram:

goat

Mnemonic: "APS" - "Accumulator Processes, PC Predicts, SP Stacks"

Question 2(b OR) [4 marks]

Sketch and explain Demultiplexing of Address bus and data bus.

Answer:

Diagram:

goat

Process:

  1. Multiplexing: AD0-AD7 pins share address and data signals to reduce pin count
  2. Demultiplexing Steps:
    • CPU places address on AD0-AD7 pins
    • ALE (Address Latch Enable) signal goes HIGH
    • External latch (74LS373) captures lower address bits
    • ALE goes LOW, latching the address
    • AD0-AD7 pins now carry data

Mnemonic: "ALAD" - "ALE Active, Latch Address, After Data"

Question 2(c OR) [7 marks]

List any seven features of 8085.

Answer:

FeatureDescription
8-bit Data BusTransfers 8 bits of data in parallel
16-bit Address BusCan address up to 64KB of memory (2^16)
Hardware Interrupts5 hardware interrupts (TRAP, RST 7.5, 6.5, 5.5, INTR)
Serial I/OSID and SOD pins for serial communication
Clock GenerationOn-chip clock generator with crystal
Instruction Set74 operation codes generating 246 instructions
Register SetSix 8-bit registers (B,C,D,E,H,L), accumulator, flags, SP, PC

Diagram:

goat

Mnemonic: "CHAIRS" - "Clock, Hardware interrupts, Address bus, Instruction set, Registers, Serial I/O"

Question 3(a) [3 marks]

Illustrate any one Timer Mode of 8051.

Answer:

Mode 1: 16-bit Timer/Counter

FeatureDescription
Timer Structure16-bit timer using THx and TLx registers
OperationCounts from 0000H to FFFFH, then sets TF flag
Counter SizeFull 16-bit counter (2^16 = 65,536 counts)
RegistersTHx (high byte) and TLx (low byte)

Diagram:

goat

Mnemonic: "MOGC" - "Mode 1 uses Overflow detection, Gate control, Complete 16-bits"

Question 3(b) [4 marks]

State function of ALE, PSEN, RESET and TXD pin for 8051.

Answer:

PinFunction
ALEAddress Latch Enable - Provides control signal to latch low byte of address from port 0
PSENProgram Store Enable - Read strobe for external program memory access
RESETReset input - Forces CPU to initial state when held HIGH for 2 machine cycles
TXDTransmit Data - Serial port output pin for serial data transmission

Diagram:

goat

Mnemonic: "APTR" - "Address latch, Program store, Total reset, tRansmit data"

Question 3(c) [7 marks]

Explain functions of each block of 8051 Microcontroller.

Answer:

BlockFunction
CPU8-bit processor that fetches and executes instructions
Memory4KB internal ROM and 128 bytes of internal RAM
I/O PortsFour 8-bit bidirectional I/O ports (P0-P3)
Timers/CountersTwo 16-bit timers/counters for timing and counting
Serial PortFull-duplex UART for serial communication
InterruptsFive interrupt sources with two priority levels
Clock CircuitProvides timing for all operations

Diagram:

goat

Mnemonic: "CRIMSON" - "CPU, RAM/ROM, I/O, Memory, Serial port, Oscillator, iNterrupts"

Question 3(a OR) [3 marks]

Illustrate any one Serial Communication Mode of 8051.

Answer:

Mode 1: 8-bit UART

FeatureDescription
Format10 bits (start bit, 8 data bits, stop bit)
Baud RateVariable, determined by Timer 1
Data DirectionFull-duplex (simultaneous transmit and receive)
Pins UsedTXD (P3.1) for transmit, RXD (P3.0) for receive

Diagram:

goat

Mnemonic: "FADS" - "Format 10-bit, Auto baud from Timer 1, Duplex mode, Standard UART"

Question 3(b OR) [4 marks]

State function of RXD, INT0, T0 and PROG pin for 8051.

Answer:

PinFunction
RXD (P3.0)Receive Data - Serial port input pin for serial data reception
INT0 (P3.2)External Interrupt 0 - Input that can trigger external interrupt
T0 (P3.4)Timer 0 - External count input for Timer/Counter 0
PROG (EA)Program Enable - When LOW, forces CPU to fetch code from external memory

Diagram:

goat

Mnemonic: "RIPE" - "Receive data, Interrupt trigger, Pulse counting, External memory"

Question 3(c OR) [7 marks]

Describe ALU, PC, DPTR, RS0, RS1, Internal RAM and Internal ROM of 8051.

Answer:

ComponentDescription
ALUArithmetic Logic Unit - Performs math and logical operations
PCProgram Counter - 16-bit register that points to next instruction
DPTRData Pointer - 16-bit register (DPH+DPL) for external memory addressing
RS0, RS1Register Bank Select bits in PSW - Select one of four register banks
Internal RAM128 bytes on-chip RAM (00H-7FH) for variables and stack
Internal ROM4KB on-chip ROM (0000H-0FFFH) for program storage

Diagram:

goat

Mnemonic: "APRID" - "ALU Processes, PC Remembers, Register bank select, Internal memory, DPTR points"

Question 4(a) [3 marks]

Develop an Assembly language program to divide 08H by 02H.

Answer:

Assembly

Diagram:

goat

Mnemonic: "LDDS" - "Load dividend, Divisor in B, Divide, Store results"

Question 4(b) [4 marks]

Develop an Assembly language program to add 76H and 32H.

Answer:

Assembly

Diagram:

goat

Mnemonic: "LASER" - "Load A, Store second number, Execute addition, Result stored"

Question 4(c) [7 marks]

What is Addressing mode? Classify it for 8051.

Answer:

Addressing Mode: Method to specify the location of operand/data for an instruction.

Addressing ModeDescriptionExample
RegisterOperand in registerMOV A, R0 (Move R0 to A)
DirectOperand at specific memory locationMOV A, 30H (Move data from 30H to A)
Register IndirectRegister contains address of operandMOV A, @R0 (Move data from address in R0 to A)
ImmediateOperand is part of instructionMOV A, #55H (Load A with 55H)
IndexedBase address + offsetMOVC A, @A+DPTR (Get code byte at A+DPTR)
BitIndividual bit addressableSETB P1.0 (Set bit 0 of Port 1)
Implied/InherentOperand implied by instructionRRC A (Rotate A right with carry)

Diagram:

goat

Mnemonic: "RIDDIB" - "Register, Immediate, Direct, Data indirect, Indexed, Bit"

Question 4(a OR) [3 marks]

Develop an Assembly language program to multiply 08H and 02H.

Answer:

Assembly

Diagram:

goat

Mnemonic: "LMSR" - "Load numbers, Multiply, Store Result"

Question 4(b) [4 marks]

Develop an Assembly language program to subtract 76H from 32H.

Answer:

Assembly

Diagram:

goat

Mnemonic: "LESS" - "Load first number, Enable borrow (CLR C), Subtract, Store"

Question 4(c) [7 marks]

List types of instruction set. Explain any three with one example.

Answer:

Instruction GroupDescriptionExample
ArithmeticMathematical operationsADD A, R0 (Add R0 to A)
LogicalLogical operationsANL A, #0FH (AND A with 0FH)
Data TransferMove data between locationsMOV A, R7 (Move R7 to A)
BranchChange program flowJNZ LOOP (Jump if A not zero)
Bit ManipulationOperate on individual bitsSETB P1.0 (Set bit 0 of Port 1)
Machine ControlControl processor operationNOP (No operation)

Explained Instructions:

  1. Data Transfer Instructions:

    • Move data between registers, memory, or I/O ports
    • Example: MOV A, 30H - Moves data from memory location 30H to accumulator
    • Operation: A ← [30H]
  2. Arithmetic Instructions:

    • Perform mathematical operations like addition, subtraction, etc.
    • Example: ADD A, R0 - Adds content of R0 to accumulator
    • Operation: A ← A + R0
  3. Logical Instructions:

    • Perform logical operations like AND, OR, XOR, NOT
    • Example: ANL A, #0FH - Masks upper nibble (keeps only lower nibble)
    • Operation: A ← A AND 0FH

Diagram:

goat

Mnemonic: "BALDM" - "Branch, Arithmetic, Logical, Data transfer, Machine control"

Question 5(a) [3 marks]

Sketch interfacing of four LEDs with 8051 Microcontroller.

Answer:

Diagram:

goat

Components:

  • 8051 microcontroller
  • Four LEDs
  • Four current limiting resistors (220Ω)
  • Power supply

Mnemonic: "PALS" - "Port pins, Active-low control, LEDs, Simple circuit"

Question 5(b) [4 marks]

Sketch interfacing of 7 segment LED with 8051 Microcontroller.

Answer:

Diagram:

goat

Components:

  • 8051 microcontroller
  • 7-segment LED display (common cathode)
  • Seven current limiting resistors (not shown)
  • Power supply

Code Example:

Assembly

Mnemonic: "SPACE-7" - "Seven Pins, Active segments, Common ground, Easy display"

Question 5(c) [7 marks]

Explain interfacing of DAC with 8051 Microcontroller and write necessary program.

Answer:

Diagram:

goat

Components:

  • 8051 microcontroller
  • DAC0808 (8-bit digital-to-analog converter)
  • Operational amplifier for output buffering
  • RC filter for smoothing
  • Power supply

Connections:

  • P1.0-P1.7 → D0-D7 (8-bit digital input)
  • P3.0 → CS (Chip Select)

Program for generating a sawtooth wave:

Assembly

Working Principle:

  1. Digital value is output on Port 1
  2. DAC converts 8-bit digital value to proportional analog voltage
  3. Filter smooths the output signal
  4. Program creates a sawtooth wave by incrementing output value

Mnemonic: "DICAF" - "Digital input, Increment, Convert to analog, Amplify, Filter"

Question 5(a OR) [3 marks]

Sketch interfacing of four Switches with 8051 Microcontroller.

Answer:

Diagram:

goat

Components:

  • 8051 microcontroller
  • Four push buttons (normally open)
  • Pull-up resistors (10KΩ)
  • Power supply

Working Principle:

  • Switches connect to ground when pressed
  • Port pins read HIGH (1) when switch open
  • Port pins read LOW (0) when switch pressed

Mnemonic: "PIPS" - "Pull-ups, Input pins, Press for zero, Switches"

Question 5(b) [4 marks]

Sketch interfacing of Stepper motor with 8051 Microcontroller.

Answer:

Diagram:

goat

Components:

  • 8051 microcontroller
  • ULN2003 driver IC
  • Stepper motor (4-phase)
  • Power supply

Excitation Sequence:

StepP1.3 (D)P1.2 (C)P1.1 (B)P1.0 (A)Hex Value
1000101H
2001002H
3010004H
4100008H

Mnemonic: "CUPS" - "Controller outputs sequence, ULN2003 amplifies, Phases energized, Stepping motion"

Question 5(c) [7 marks]

Explain interfacing of ADC with 8051 Microcontroller and write necessary program.

Answer:

Diagram:

goat

Components:

  • 8051 microcontroller
  • ADC0804 (8-bit analog-to-digital converter)
  • Reference voltage source
  • Input conditioning circuit (not shown)

Connections:

  • P1.0-P1.7 ← D0-D7 (8-bit digital output from ADC)
  • P3.0 → CS (Chip Select)
  • P3.1 → RD (Read)
  • P3.2 → WR (Write)

Program for reading analog input:

Assembly

Working Principle:

  1. Controller sends start conversion signal
  2. ADC converts analog input to 8-bit digital value
  3. Controller reads digital value after conversion complete
  4. Program processes the digital value as required

Mnemonic: "CARSW" - "Convert Analog, Read Digital, Start conversion, Wait for completion"