Microprocessor and Microcontroller (4341101) - Winter 2023 Solution

Solution guide for Microprocessor and Microcontroller (4341101) Winter 2023 exam

Question 1(a) [3 marks]

Compare RISC and CISC.

Answer:

FeatureRISCCISC
InstructionsSimple, fixed-lengthComplex, variable-length
ExecutionSingle cycleMultiple cycles
Addressing modesFewMany
RegistersManyFew
Design focusHardware simplicityCode density

Mnemonic: "RISCs Complete Instructions Simply"

Question 1(b) [4 marks]

Compare Von-Neumann and Harvard architecture.

Answer:

FeatureVon-NeumannHarvard
MemorySingle shared memorySeparate program & data memory
BusSingle bus for data & instructionsSeparate buses
SpeedSlower (memory bottleneck)Faster (parallel access)
ComplexitySimpler designMore complex
ApplicationsGeneral computingReal-time systems

Diagram:

goat

Mnemonic: "Harvard Has Separate Spaces"

Question 1(c) [7 marks]

Explain: 8085 Instruction Format, Control Unit, Machine Cycle, ALU

Answer:

Instruction Format:

goat
ComponentFunction
Instruction Format1-3 byte structure with opcode and operands
Control UnitFetches, decodes instructions; generates signals
Machine CycleBasic operation cycle (T-states)
ALUPerforms arithmetic and logical operations
  • Instruction Format: Contains opcode (3-8 bits) and 0-2 operands
  • Control Unit: Heart of processor that coordinates all operations
  • Machine Cycle: Consists of fetch, decode, execute phases
  • ALU: Handles ADD/SUB/AND/OR/XOR operations on data

Diagram:

goat

Mnemonic: "CIMA: Control Interprets, Machine Acts"

Question 1(c OR) [7 marks]

Compare Microprocessor and Microcontroller.

Answer:

FeatureMicroprocessorMicrocontroller
DesignCPU onlyCPU + peripherals
MemoryExternalInternal (RAM/ROM)
I/O portsLimitedMany built-in
CostHigherLower
ApplicationsGeneral computingEmbedded systems
Power consumptionHigherLower
ExampleIntel 8085/8086Intel 8051

Diagram:

goat

Mnemonic: "Micro-P Processes, Micro-C Controls"

Question 2(a) [3 marks]

Explain Instruction Fetching, Decoding and Execution Operation in microprocessor.

Answer:

PhaseOperation
FetchingCPU gets instruction from memory using PC
DecodingDetermines operation type and operands
ExecutionPerforms the actual operation

Diagram:

goat

Mnemonic: "FDE: First Get, Then Understand, Finally Do"

Question 2(b) [4 marks]

Explain Bus Organization of 8085 microprocessor.

Answer:

Bus TypeWidthFunction
Address Bus16-bitCarries memory addresses (A0-A15)
Data Bus8-bitTransfers data (D0-D7)
Control BusVarious linesManages data flow (RD, WR, IO/M)
MultiplexedAD0-AD7Lower address bits + data bits

Diagram:

goat

Mnemonic: "ADC: Address points, Data flows, Control directs"

Question 2(c) [7 marks]

Describe architecture of 8085 microprocessor with the help of neat diagram.

Answer:

ComponentFunction
ALUArithmetic & logical operations
Register ArrayTemporary data storage (B,C,D,E,H,L)
AccumulatorMain register for arithmetic
Control UnitInstruction control & timing
Instruction RegisterHolds current instruction
Timing & ControlGenerates timing signals
Address BufferManages address bus
Data BufferHandles data bus transfers

Diagram:

goat
  • ALU: Performs arithmetic & logical operations
  • Control Unit: Fetches & decodes instructions
  • Registers: Store data temporarily during processing
  • Buses: Carry address, data and control signals

Mnemonic: "ARCBD: Architecture Registers Control Buses Data"

Question 2(a OR) [3 marks]

Explain De-multiplexing of Address and Data buses for 8085 Microprocessor.

Answer:

StepAction
1ALE signal goes high
2Lower address (A0-A7) appears on AD0-AD7
3Latch captures address using ALE
4ALE goes low, AD0-AD7 now carries data

Diagram:

goat

Mnemonic: "ALAD: ALE Latches Address before Data"

Question 2(b OR) [4 marks]

Draw Flag Register of 8085 microprocessor & explain it.

Answer:

goat
FlagNameSet when
SSignBit 7 of result is 1 (negative)
ZZeroResult is zero
ACAuxiliary CarryCarry from bit 3 to bit 4
PParityResult has even parity (even 1s)
CYCarryCarry generated from bit 7

Mnemonic: "SuZie AC's Perfect CarrY"

Question 2(c OR) [7 marks]

Describe Pin diagram of 8085 microprocessor with the help of neat diagram.

Answer:

Pin GroupFunction
Address/DataMultiplexed AD0-AD7, A8-A15
ControlRD, WR, IO/M, S0, S1, ALE, CLK
InterruptsINTR, RST 5.5-7.5, TRAP
DMAHOLD, HLDA
PowerVcc, Vss
Serial I/OSID, SOD
ResetRESET IN, RESET OUT

Diagram:

goat
  • Address/Data Pins: Multiplexed pins save physical pins
  • Control Pins: Coordinate memory and I/O operations
  • Interrupt Pins: Allow external device interrupts
  • Serial Pins: Provide basic serial communication

Mnemonic: "ACID-PS: Address-Control-Interrupt-DMA-Power-Serial"

Question 3(a) [3 marks]

Explain Stack, Stack Pointer and Stack operation.

Answer:

TermDescription
StackLIFO memory area for temporary data storage
Stack Pointer16-bit register that points to stack top
OperationsPUSH (store), POP (retrieve)

Diagram:

goat

Mnemonic: "SP Points to LIFO Lane"

Question 3(b) [4 marks]

Draw Pin diagram of 8051 microcontroller.

Answer:

goat
Pin GroupFunction
P0Port 0, multiplexed with address/data
P1Port 1, general purpose I/O
P2Port 2, upper address and I/O
P3Port 3, special functions and I/O

Mnemonic: "PORT 0123: Data-General-Address-Special"

Question 3(c) [7 marks]

Draw Timers/Counters logic diagram of 8051 microcontroller and explain its operation in various modes.

Answer:

Timer/Counter Diagram:

goat
ModeOperation
Mode 013-bit timer (5-bit TL, 8-bit TH)
Mode 116-bit timer (8-bit TL, 8-bit TH)
Mode 28-bit auto-reload (TL counts, TH reloads)
Mode 3Split timer (Timer 0 only)
  • Timer: Uses internal clock, counts machine cycles
  • Counter: Uses external input, counts external events
  • Control Bits: TMOD register sets mode, TCON controls operation
  • Modes: Different configurations for different timing needs

Mnemonic: "MARC: Mode Auto-Reload Count"

Question 3(a OR) [3 marks]

List Common features of Microcontrollers.

Answer:

FeaturePurpose
CPU CoreProcess instructions
Memory (RAM/ROM)Store program and data
I/O PortsInterface with external devices
Timers/CountersMeasure time intervals
InterruptsHandle asynchronous events
Serial CommunicationTransfer data with other devices

Mnemonic: "CRITICS: CPU ROM I/O Timers Interrupts Comm Serial"

Question 3(b OR) [4 marks]

Explain Internal RAM Organization of 8051 microcontroller.

Answer:

RAM AreaAddress RangeUsage
Register Banks00H-1FHR0-R7 (4 banks)
Bit-addressable20H-2FH128 bits (0-7FH)
Scratch Pad30H-7FHGeneral purpose
SFRs80H-FFHControl registers

Diagram:

goat

Mnemonic: "RBBS: Registers Bits Buffer Scratch"

Question 3(c OR) [7 marks]

Explain architecture of 8051 microcontroller with the help of neat diagram.

Answer:

ComponentFunction
CPU8-bit processor with ALU
Memory4K ROM, 128 bytes RAM
I/O PortsFour 8-bit ports (P0-P3)
TimersTwo 16-bit timers/counters
Serial PortFull-duplex UART
InterruptsFive interrupt sources
Special Function RegistersControl registers

Diagram:

goat
  • Harvard Architecture: Separate program and data memory
  • CISC Design: Rich instruction set (over 100 instructions)
  • In-built Peripherals: No need for external components
  • Single-chip Solution: Complete system on one chip

Mnemonic: "CAPITALS: CPU Architecture Ports I/O Timer ALU LS-Interface Serial"

Question 4(a) [3 marks]

Write an 8051 Assembly Language Program to Copy the data from external RAM Location 0123h to TL0 and Data from external RAM location 0234h to TH0.

Answer:

Assembly

Key Steps:

  • Use DPTR to address external RAM
  • MOVX instruction for external memory access
  • Direct transfer to timer registers

Mnemonic: "DRAM: DPTR Read Address Move"

Question 4(b) [4 marks]

Write an 8051 Assembly Language Program to blink LED interfaced at port P1.3 at time interval of 1ms.

Answer:

Assembly

Key Steps:

  • Toggle P1.3 pin to blink LED
  • Nested delay loop for timing
  • Infinite loop for continuous blinking

Mnemonic: "STACI: Set-Timer-And-Clear-Infinitely"

Question 4(c) [7 marks]

List Addressing Modes of 8051 Microcontroller and explain all of them with the help of example.

Answer:

Addressing ModeExampleDescription
ImmediateMOV A, #25HData is in instruction
RegisterMOV A, R0Data is in register
DirectMOV A, 30HData is at RAM address
IndirectMOV A, @R0R0/R1 contains address
IndexedMOVC A, @A+DPTRAccess program memory
BitSETB P1.3Access individual bits
RelativeSJMP LABELJumps with 8-bit offset

Examples:

  • Immediate: MOV A, #55H (Load A with 55H)
  • Register: ADD A, R3 (Add R3 to A)
  • Direct: MOV 40H, A (Store A at address 40H)
  • Indirect: MOV @R0, #5 (Store 5 at address in R0)
  • Indexed: MOVC A, @A+DPTR (Read code memory)
  • Bit: CLR C (Clear carry flag)
  • Relative: JZ LOOP (Jump if A is zero)

Mnemonic: "I'M DIRBI: Immediate Register Direct Bit Indexed"

Question 4(a OR) [3 marks]

Write an 8051 Assembly Language Program to Subtract the content of RAM location 11h from RAM location 14h; put result in RAM location 3Ch.

Answer:

Assembly

Key Steps:

  • Load minuend into accumulator
  • Clear carry for correct subtraction
  • Use SUBB for subtraction with borrow
  • Store result in destination

Mnemonic: "LCSS: Load-Clear-Subtract-Store"

Question 4(b OR) [4 marks]

Write an 8051 Assembly Language Program to generate a square wave of 50% duty cycle on bit 3 of Port 1 using Timer 0 in Mode 1.

Answer:

Assembly

Key Steps:

  • Configure Timer 0 in Mode 1
  • Preload timer with value for 1ms delay
  • Wait for timer overflow
  • Toggle output bit for square wave

Mnemonic: "MSTCCS: Mode-Set-Timer-Check-Clear-Switch"

Question 4(c OR) [7 marks]

Explain any seven Logical Instructions with example for 8051 Microcontroller.

Answer:

InstructionExampleOperation
ANLANL A, #3FHLogical AND
ORLORL P1, #80HLogical OR
XRLXRL A, R0Logical XOR
CLRCLR AClear (set to 0)
CPLCPL P1.0Complement (invert)
RLRL ARotate left
RRRR ARotate right

Examples:

  • ANL: ANL A, #0FH (A = A AND 0FH, masks high nibble)
  • ORL: ORL 20H, A (20H = 20H OR A, sets bits)
  • XRL: XRL A, #55H (A = A XOR 55H, toggles bits)
  • CLR: CLR C (Clear carry flag, C = 0)
  • CPL: CPL A (Complement A, A = NOT A)
  • RL: RL A (Rotate A left one bit)
  • RR: RR A (Rotate A right one bit)

Mnemonic: "A-OX-CCR: AND OR XOR Clear Complement Rotate"

Question 5(a) [3 marks]

Draw Interfacing of Push button Switch with 8051 microcontroller.

Answer:

goat
ComponentConnection
Push ButtonBetween P1.0 and GND
Pull-up Resistor10K between P1.0 and VCC
Port PinP1.0 configured as input

Key Points:

  • Active-low configuration (button press gives 0)
  • Pull-up resistor prevents floating input
  • Can connect to any I/O pin

Mnemonic: "PIP: Pull-up-Input-Press"

Question 5(b) [4 marks]

Interface Relay with 8051 microcontroller.

Answer:

goat
ComponentPurpose
NPN TransistorCurrent amplification
DiodeBack EMF protection
ResistorsCurrent limiting
RelayHigh-power switching

Key Steps:

  • Port pin drives transistor base
  • Transistor switches relay coil
  • Diode protects against back EMF
  • Relay contacts switch high-power load

Mnemonic: "TRIP: Transistor-Relay-Interface-Protection"

Question 5(c) [7 marks]

Interface ADC0804 with 8051 microcontroller.

Answer:

Circuit Diagram:

goat
Connection8051 PinADC0804 Pin
Data BusP1.0-P1.7D0-D7
CSP3.0CS
RDP3.1RD
WRP3.2WR
INTRP3.3INTR
  • ADC0804: 8-bit A/D converter with 0-5V input range
  • Interface: Connect data pins to Port 1, control to Port 3
  • Operation: Write to ADC to start conversion, wait for INTR, read result
  • Resolution: 8-bit (256 steps) for 0-5V gives ~19.5mV per step

Mnemonic: "CRIW: Control-Read-Interrupt-Write"

Question 5(a OR) [3 marks]

List Applications of microcontroller in various fields.

Answer:

FieldApplications
IndustrialMotor control, automation, PLCs
MedicalPatient monitoring, diagnostic equipment
ConsumerWashing machines, microwaves, toys
AutomotiveEngine control, ABS, airbag systems
CommunicationMobile phones, modems, routers
SecurityAccess control, alarm systems

Mnemonic: "I-MACS: Industrial-Medical-Automotive-Consumer-Security"

Question 5(b OR) [4 marks]

Interface Stepper motor with 8051 microcontroller.

Answer:

Circuit Diagram:

goat
ComponentPurpose
ULN2003Driver IC with Darlington arrays
Port pinsP1.0-P1.3 for 4 motor phases
Power supplySeparate supply for motor

Code Structure:

Assembly

Mnemonic: "PDCS: Port-Driver-Current-Sequence"

Question 5(c OR) [7 marks]

Interface LCD with 8051 microcontroller.

Answer:

Circuit Diagram:

goat
ConnectionPurpose
Data Pins (D0-D7)Connect to P2.0-P2.7
RSRegister Select (0=Command, 1=Data)
R/WRead/Write (0=Write, 1=Read)
EEnable signal (Active High)

Basic Commands:

0x01 - Clear Display
0x02 - Return Home
0x0C - Display ON, Cursor OFF
0x38 - 8-bit, 2 line, 5x7 dots
  • Initialization: Configure LCD for 8-bit mode, 2 lines
  • Writing: Send data with RS=1, control with RS=0
  • Timing: E pulse must meet timing requirements
  • Contrast: Adjust with potentiometer on VEE pin

Mnemonic: "DICE: Data-Instruction-Control-Enable"