0% found this document useful (0 votes)
18 views15 pages

22EC502 MICROCONTROLLER-Model Ans Key

The document is a model exam paper for the Fifth Semester B.E/B.Tech in Electronics and Communication Engineering, focusing on Microcontroller and Interfacing. It includes an answer key with detailed explanations and examples for various topics such as 8085 and 8051 microcontrollers, ADCs, and PIC microcontrollers. The exam consists of multiple parts including theoretical questions, programming tasks, and practical applications related to microcontroller operations.

Uploaded by

nikshi773
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views15 pages

22EC502 MICROCONTROLLER-Model Ans Key

The document is a model exam paper for the Fifth Semester B.E/B.Tech in Electronics and Communication Engineering, focusing on Microcontroller and Interfacing. It includes an answer key with detailed explanations and examples for various topics such as 8085 and 8051 microcontrollers, ADCs, and PIC microcontrollers. The exam consists of multiple parts including theoretical questions, programming tasks, and practical applications related to microcontroller operations.

Uploaded by

nikshi773
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Model Exam Oct/Nov 2024

Fifth Semester B.E/B.Tech


Electronics and Communication Engineering
22EC502 – Microcontroller and Interfacing (Lab Integrated)

ANSWER KEY

Part A
1. Outline IN and OUT instruction of 8085
The IN instruction in the 8085 microprocessor reads data from an external I/O port into the
accumulator.
Syntax: IN Port_Address.
Example: IN 01H retrieves data from port 01H.
The OUT instruction sends data from the accumulator to an external I/O port.
Syntax: OUT Port_Address.
Example: OUT 02H transmits data to port 02H.
2. Differentiate Microprocessor and Microcontroller

Feature Microprocessor Microcontroller


A central processing unit (CPU) that A compact integrated circuit
Definition performs computations and processing designed to govern specific
tasks. operations in embedded systems.
Generally consists of a CPU only,
Combines CPU, RAM, ROM, and
Integration requiring external components for
I/O peripherals on a single chip.
memory and I/O.
Typically follows a general-purpose Specifically designed for control-
Architecture architecture suitable for various oriented tasks in embedded
applications. systems.
Contains inbuilt memory (RAM
Requires external memory for operations
Memory and ROM) for program storage
(RAM and ROM).
and data handling.
Has multiple built-in I/O ports for
Usually lacks built-in I/O ports; relies on
I/O Ports direct interfacing with sensors and
external interfacing.
actuators.
Widely used in embedded systems,
Commonly used in PCs, servers, and
Application consumer electronics, and
complex computing systems.
automotive applications.
3. Write about inbuit memory features of 8051 microcontroller
The 8051 microcontroller features
• 4 KB of on-chip ROM for program storage, which is read-only during operation
• 128 bytes of internal RAM, organized into 4 banks of general-purpose registers and a bit-
addressable area. Additionally, it has Special Function Registers (SFRs) in the upper 128
bytes for controlling various functions like timers and serial communication.
• The microcontroller can also address up to 64 KB of external data memory for applications
requiring additional storage.
4. Outline the use of External Access pin of 8051.
The External Access (EA) pin on the 8051 microcontroller determines whether the
microcontroller fetches program code from its internal memory or an external memory.
Functions of the EA Pin
EA = 1 (High): The microcontroller accesses the internal ROM for program code execution.
This mode is used when the program is stored in the microcontroller's internal memory.
EA = 0 (Low): The microcontroller accesses an external memory (such as external EPROM)
for program code. This mode is used when the internal memory is insufficient or an external
program needs to be executed.
5. What is the use of PSW.4 and PSW.3 in program status word of 8051?

The PSW.4 and PSW.3 specially named as RS1 and RS0 is used in selecting the register bank
as below,

RS1 (PSW.4) RS0 (PSW.3) Register Bank Address


0 0 Register Bank 0 00H - 07H
0 1 Register Bank 1 08H - 0FH
1 0 Register Bank 2 10H - 17H
1 1 Register Bank 3 18H - 1FH

6. Differentiate the operation of MOV R0,40 and Mov R0,#40H instruction.

(i) MOV R0, 40:

• This instruction moves the contents of memory address 40H into register R0. 40H is an
address in the RAM, and the data stored at that address is copied into R0.
(ii) MOV R0, #40H:

• This instruction moves the immediate value 40H directly into register R0.
• The # symbol signifies that 40H is a literal (or immediate) value, not an address.
7. Write the use of IC M7211 in LCD interfacing
The IC M7211 is commonly used as an LCD driver in LCD interfacing applications. Here are
its primary functions and uses:
(i) Segment Driver: The M7211 is designed to drive multiple segments of an LCD, making it
ideal for interfacing with segment-based displays like those in simple alphanumeric and
graphic LCDs.
(ii) Simplifies Control: It reduces the complexity of driving an LCD directly from a
microcontroller by handling the segment voltages, timing, and multiplexing. This simplifies
the microcontroller’s workload and allows it to focus on other tasks.
(iii) Control Interface: The M7211 offers an interface that allows easy communication with
the microcontroller, enabling it to update display data easily.
8. Find the resolution of 10 bit ADC operating on 5V supply.

The resolution of an ADC (Analog-to-Digital Converter) refers to the smallest change in


voltage it can detect.

For a 10-bit ADC with a 5V supply, the resolution can be calculated as follows:

9. State the use of File selection Register in PIC microcontroller.


The File Selection Register (FSR) in a PIC microcontroller is a special-purpose register that
acts as a pointer for indirect addressing in data memory, allowing flexible access to data
memory locations without hardcoding addresses. It serves as a pointer to access data arrays,
buffers, or specific memory locations dynamically, enhancing data manipulation and memory
management.
10. Outline the PIC Microcontroller instruction BCF FLAG_Reg, 7.
The instruction BCF in a PIC microcontroller program stands for "Bit Clear File". BCF (Bit
Clear File) instruction clears (sets to 0) a specific bit in a given register.
BCF FLAG_Reg, 7: In this instruction FLAG_Reg is the target register containing the bit to
be cleared and 7 is the bit position to be cleared in FLAG_Reg

PART-B

11. a. Draw and explain the architecture of 8085 Microprocessor.

Architecture Diagram: 7 Marks

Explanation: 6 Marks

11.b. Draw and explain the pin details of 8086 Microprocessor.

Pin Diagram: 7 marks

Explanation: 6 marks
12.a. Analyze the special function registers involved in interrupt operation.

Introduction about 8051 interrupts, interrupt vector table, interrupt service routine – 5 marks

IE Register 4 marks

IP register 4 marks

Six interrupts are allocated as follows:


1. Reset – power-up reset.
2. Timer interrupt -2
Timer 0
Timer 1
3. External hardware interrupt - 2
External hardware interrupt INT0 (or EX1) - P3.2
External hardware interrupt INT1 (or EX2) – P3.3
4. Serial communication – 1
12.b. Analyze the special function registers involved in Timer/Counter operation.

List out the 4 Register 1 Mark

Timer 0 (TH0, TL0) 2 Mark

Timer 1 (TH1, TL1) 2 Mark

TMOD (Timer mode register) 4 Mark

TCON (Timer control register) 4 Mark

13. Assuming Xtal = 11.0592 Mhz, write a program in 8051 to generate a square wave
of 50 KHz frequency in Mode1 on pin P2.3.

Calculation 6 marks

Program with explanation 7 marks

Calculation for Timer Value


Given:
Xtal = 11.0592 MHz
Required square wave frequency = 50 kHz
PROGRAM
Program to Generate 50 kHz Square Wave on Pin P2.3

ORG 0000H

MAIN:
MOV TMOD, #01H ; Set Timer 0 to Mode 1 (16-bit timer mode)
MOV TH0, #0FFH ; Load high byte of Timer 0 for 10 μs delay
MOV TL0, #0F7H ; Load low byte of Timer 0 for 10 μs delay
SETB TR0 ; Start Timer 0

TOGGLE:
JNB TF0, TOGGLE ; Wait for Timer 0 overflow (TF0 = 1)
CLR TF0 ; Clear Timer 0 overflow flag
CPL P2.3 ; Toggle P2.3 to create square wave
MOV TH0, #0FFH ; Reload Timer 0 high byte for next cycle
MOV TL0, #0F7H ; Reload Timer 0 low byte for next cycle
SJMP TOGGLE ; Repeat the process

END
Explanation:

1. MOV TMOD, #01H: Configures Timer 0 in Mode 1 (16-bit mode).


2. MOV TH0, #0FFH and MOV TL0, #0F7H: Load Timer 0 with the values to
generate approximately a 10 μs delay.
3. SETB TR0: Starts Timer 0.
4. TOGGLE Loop:

• JNB TF0, TOGGLE: Waits until Timer 0 overflows (when TF0 becomes 1).

• CLR TF0: Clears the overflow flag to prepare for the next cycle.

• CPL P2.3: Toggles P2.3 to create the square wave.

• Reload Timer: Reloads TH0 and TL0 with the calculated values for the next 10 μs
delay.

5. SJMP TOGGLE: Repeats the loop to maintain the square wave output.

13.b Write an 8051 assembly level program to exchange 10 bytes of data from location
30H to location 1000H

Algorithm 6 marks

Program 7 marks

ALGORITHM

Step 1: Load byte from internal RAM

Step 2: Load byte from external RAM

Step 3: Store the byte from accumulator

Step 4: Store the byte from register B (original external RAM data) to internal RAM

Step 5: Increment pointers for the next byte

Step 6: Decrement counter and repeat if not done

PROGRAM

ORG 0000H

MOV R0, #30H ; Initialize R0 to point to the internal RAM


location starting at 30H
MOV DPTR, #1000H ; Initialize DPTR to point to the external
memory location starting at 1000H

MOV R2, #0AH ; Initialize counter R2 with 10 for 10 bytes

EXCHANGE_LOOP: MOV A, @R0 ; Load data from internal RAM (address in R0)
into accumulator

MOVX B, @DPTR ; Load data from external RAM (address in


DPTR) into register B

MOVX @DPTR, A ; Write internal data (A) to external memory


location in DPTR

MOV @R0, B ; Write external data (B) to internal RAM location


in R0

INC R0 ; Move to the next internal RAM location

INC DPTR ; Move to the next external memory location

DJNZ R2, EXCHANGE_LOOP ; Decrement counter R2 and repeat if


not zero

END

14.a Draw interfacing diagram of 8 bit ADC with 8051 and write program to read
binary output of ADC and make 8 leds to glow according to the digital value.

Diagram 6marks

Program with explanation 7 marks

PROGRAM

MOV P1, #0FFH ; Configure Port 1 as input for ADC data


MOV P3, #0FFH ; Configure Port 3 as output for LEDs
MOV P2, #00000000B ; Configure Port 2 for control signals and address lines
SET_CHANNEL:
CLR P2.0 ; ALE = 0 (Address Latch Enable)
MOV A, #00H ; Selecting Channel 0 (IN0)
MOV P2, A
SETB P2.0 ; ALE = 1 (Latch Address)
CLR P2.0 ; ALE = 0

START_CONVERSION:
CLR P2.1 ; Start conversion (WR = 0)
NOP ; Small delay
SETB P2.1 ; WR = 1 to end the start pulse

WAIT_FOR_EOC:
JB P2.3, WAIT_FOR_EOC ; Wait until EOC goes low (conversion complete)

READ_ADC:
CLR P2.2 ; Output Enable (OE = 0) to read data
MOV A, P1 ; Read digital data from ADC (Port 1)
MOV P3, A ; Output data to LEDs (Port 3)
SETB P2.2 ; OE = 1 to complete read

SJMP START_CONVERSION ; Repeat continuously

END
14.b Design an 8051 based system to generate triangular wave in port 1 using DAC and
illustrate the working with assembly language code and interfacing diagram.

15.a Explain the architecture of PIC microcontroller

Diagram 8 mark

Explanation 5 mark
15.b Explain the memory organization of PIC microcontroller.

Introduction to PIC Microcontroller (2 Marks)

Overview of Memory Organization in PIC Microcontrollers (2 Marks)

Program Memory (3 Marks)

Data Memory (4 Marks)

EEPROM (Data EEPROM) (2 Marks)

PART-C

16.a Write an 8051 assembly level program to count the number of positive numbers
and number of negative numbers in an array of ‘N’ bytes of data.

Algorithm 5 marks

Program 6 marks

Explanation 4 marks

ALGORITHM

1. Load the array elements one by one.


2. Check the sign of each number.

o In 8-bit signed numbers, if the most significant bit (MSB) is 0, the number is
positive.

o If the MSB is 1, the number is negative.

3. Maintain separate counters for positive and negative numbers.

4. Increment the respective counters based on the sign.

5. Stop after processing N bytes.

The 8051 microcontroller uses signed 8-bit representation where:

• Positive numbers range from 0 to +127 (MSB = 0).

• Negative numbers range from -1 to -128 (MSB = 1).

PROGRAM

MOV R0, #30H ; Assume array starts at internal RAM address 30H
MOV R1, N ; Load R1 with the number of elements, N
MOV R2, #00H ; Initialize positive count to 0
MOV R3, #00H ; Initialize negative count to 0

COUNT_LOOP:
MOV A, @R0 ; Load the next array element into accumulator
JNB ACC.7, POSITIVE ; Check the MSB (ACC.7); if 0, it's positive

NEGATIVE:
INC R3 ; Increment negative counter
SJMP NEXT ; Skip to next element

POSITIVE:
INC R2 ; Increment positive counter

NEXT:
INC R0 ; Move to the next element in the array
DJNZ R1, COUNT_LOOP ; Decrement R1; if not zero, repeat the loop

; After the loop ends, R2 contains the positive count, R3 contains the negative count
END
EXPLANATION
1. MOV R0, #30H: Initializes R0 to point to the start of the array at RAM location 30H.
2. MOV R1, N: Loads R1 with N, the number of elements in the array.
3. MOV R2, #00H and MOV R3, #00H: Initialize counters R2 and R3 for positive and
negative counts to zero.
4. COUNT_LOOP: Main loop to process each element.
o MOV A, @R0: Loads the current element into the accumulator.
o JNB ACC.7, POSITIVE: Checks if the MSB (ACC.7) is 0. If so, it’s positive,
and the program jumps to the POSITIVE label.
5. NEGATIVE:
o INC R3: Increments the negative count if the number is negative (MSB = 1).
6. POSITIVE:
o INC R2: Increments the positive count if the number is positive.
7. NEXT:
o INC R0: Moves to the next byte in the array.
o DJNZ R1, COUNT_LOOP: Decrements R1 (element counter) and loops back
if there are more elements to process.
8. END: At the end of the program, R2 holds the count of positive numbers, and R3 holds
the count of negative numbers.

16.b Write an 8051 assembly level program to count the number of even numbers and
number of odd numbers in an array of ‘N’ bytes of data.

Algorithm 5 marks

Program 6 marks

Explanation 4 marks

ALGORITHM

Step: 1 Load each element from the array.

Step 2: Check if the number is even or odd:

• If the least significant bit (LSB) is 0, the number is even.

• If the LSB is 1, the number is odd.

Step:3 Maintain separate counters for even and odd numbers.

Step 4: Increment the respective counter based on the result.

Step 5: Stop after processing N bytes.

PROGRAM

MOV R0, #30H ; Assume array starts at internal RAM address 30H
MOV R1, N ; Load R1 with the number of elements, N
MOV R2, #00H ; Initialize even count to 0
MOV R3, #00H ; Initialize odd count to 0
COUNT_LOOP:
MOV A, @R0 ; Load the next array element into the accumulator
JNB ACC.0, EVEN ; Check the LSB (ACC.0); if 0, it's even

ODD:
INC R3 ; Increment odd counter
SJMP NEXT ; Skip to the next element

EVEN:
INC R2 ; Increment even counter

NEXT:
INC R0 ; Move to the next element in the array
DJNZ R1, COUNT_LOOP ; Decrement R1; if not zero, repeat the loop

; After the loop ends, R2 contains the even count, R3 contains the odd count
END

EXPLANATION

1. MOV R0, #30H: Initializes R0 to point to the start of the array at RAM location 30H.

2. MOV R1, N: Loads R1 with N, the number of elements in the array.

3. MOV R2, #00H and MOV R3, #00H: Initialize counters R2 and R3 for even and odd
counts to zero.

4. COUNT_LOOP: Main loop to process each element.

• MOV A, @R0: Loads the current element into the accumulator.

• JNB ACC.0, EVEN: Checks if the least significant bit (ACC.0) is 0. If so, it’s even,
and the program jumps to the EVEN label.

5. ODD:

• INC R3: Increments the odd count if the number is odd (LSB = 1).

6. EVEN:

• INC R2: Increments the even count if the number is even.

7. NEXT:

• INC R0: Moves to the next byte in the array.


• DJNZ R1, COUNT_LOOP: Decrements R1 (element counter) and loops back if
there are more elements to process.

8. END: At the end of the program, R2 holds the count of even numbers, and R3 holds the
count of odd numbers.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy