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

Micro Paper 1

Uploaded by

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

Micro Paper 1

Uploaded by

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

Q1) Attempt any five of the following:

a) Which port of 8051 requires external pull-up resistors?


Answer: Port 0 of 8051 requires external pull-up resistors because it is an open-drain
configuration.

b) Which registers are used as data pointers in indirect addressing mode?


Answer: The registers used as data pointers in indirect addressing mode are R0 and R1 (in
Register Bank 0

c) What extension is used to save a 'C' language program?


Answer: The extension used to save a 'C' language program is .c.

d) Name the timer register of the 8051 microcontroller used as bit-addressable.


Answer: The timer registers TCON (Timer Control Register) and TMOD (Timer Mode
Register) are bit-addressable.

e) Define the step angle of a stepper motor.


Answer: The step angle of a stepper motor is the angle by which the rotor moves for each pulse
received. It is calculated as:

Step Angle=360∘Number of Steps per Revolution\text{Step Angle} = \


frac{360^\circ}{\text{Number of Steps per Revolution}}

f) In half-duplex, data is transmitted in only one direction at a time—comment.


Answer: This statement is correct. In a half-duplex system, data can flow in both directions but
only one direction at a time. For example, walkie-talkies operate in half-duplex mode.

Q2) Answer the following:

a) Draw and explain interfacing of external 16 KB RAM with the 8051 microcontroller.
Answer:
For interfacing external RAM, address lines from the 8051 are divided as follows:

 The lower byte of the address (A0–A7) is multiplexed with data on Port
0.
 The higher byte of the address (A8–A15) is sent through Port 2.

A latch (like 74LS373) is used to de-multiplex the lower address/data lines. The ALE signal is
used to enable the latch. CS (Chip Select) and RD/WR signals are used to enable the RAM for
read/write operations.
(A diagram would show the connection of Port 0 to RAM via the latch, Port 2 directly to the
address lines of RAM, and control lines connected appropriately.)

b) Explain the function of the following instructions:


i) CLR A: Clears the accumulator (A), setting it to 0.
ii) NOP: No operation; the microcontroller does nothing for one cycle.
iii) RR A: Rotates the accumulator contents right, bitwise. The least significant bit (LSB)
becomes the most significant bit (MSB).
iv) SUBB A, #05H: Subtracts immediate value 05H and the carry bit from the accumulator.
v) SWAP A: Exchanges the higher nibble with the lower nibble of the accumulator.

Q3) Answer the following:

a) Explain the internal RAM organization of the 8051 microcontroller.


Answer:
The internal RAM of the 8051 is organized into:

1. General Purpose Registers: The lower 128 bytes (00H–7FH) are for
general-purpose registers, working registers, and bit-addressable
memory.
2. Register Banks: 4 banks (Bank 0–Bank 3), each containing 8 registers
(R0–R7).
3. Bit-Addressable Memory: 16 bytes (20H–2FH) are bit-addressable.
4. Stack Area: The stack starts at 08H by default and grows upward.

b) Write an 8051 C program to generate a square wave with 2500 Hz frequency on pin 2.7.
Answer:

#include <reg51.h>

void delay() {
// Assuming a 12 MHz crystal, the delay function generates ~200
microseconds
unsigned int i;
for (i = 0; i < 200; i++);
}

void main() {
while (1) {
P2 ^= 0x80; // Toggle pin 2.7
delay(); // Delay for half-period
}
}

Q4) Answer the following:


a) Explain in brief the classification of 8051 instructions (any 5).
Answer:

1. Data Transfer Instructions: MOV, PUSH, POP.


2. Arithmetic Instructions: ADD, SUBB, INC, DEC.
3. Logical Instructions: ANL, ORL, XRL, CLR, CPL.
4. Branching Instructions: SJMP, LJMP, AJMP, JC, JZ.
5. Bit Manipulation Instructions: SETB, CLR, CPL, ANL, ORL.

b) Write a C program for LCD interface to 8051 for displaying 'ELECTRONICS'.


Answer:

#include <reg51.h>

sbit RS = P2^0;
sbit EN = P2^1;
#define LCD P1

void delay() {
int i;
for (i = 0; i < 30000; i++);
}

void lcd_cmd(unsigned char cmd) {


LCD = cmd;
RS = 0; // Command mode
EN = 1;
delay();
EN = 0;
}

void lcd_data(unsigned char dat) {


LCD = dat;
RS = 1; // Data mode
EN = 1;
delay();
EN = 0;
}

void lcd_init() {
lcd_cmd(0x38); // 2 lines, 5x7 matrix
lcd_cmd(0x0C); // Display ON, Cursor OFF
lcd_cmd(0x01); // Clear display
}

void main() {
lcd_init();
lcd_cmd(0x80); // Move cursor to first line
lcd_data('E');
lcd_data('L');
lcd_data('E');
lcd_data('C');
lcd_data('T');
lcd_data('R');
lcd_data('O');
lcd_data('N');
lcd_data('I');
lcd_data('C');
lcd_data('S');
while (1);
}

Q5) Write short notes (any four):

a) Difference between LCALL and ACALL:

 LCALL: Long Call, used for calling subroutines located anywhere in 64


KB memory.
 ACALL: Absolute Call, used for calling subroutines within the same 2
KB memory block.

b) Timer mode 2 of 8051:

 Timer mode 2 is an 8-bit auto-reload mode. The THx register holds


the reload value, and TLx increments on every clock pulse. When TLx
overflows, it is reloaded with the value in THx.

c) Immediate Addressing Mode:

 The operand is specified in the instruction itself. Example: MOV A, #25H


loads the immediate value 25H into the accumulator.

d) Interrupts in 8051:

 The 8051 has five interrupts: External Interrupt 0 (INT0), Timer


Interrupt 0, External Interrupt 1 (INT1), Timer Interrupt 1, and Serial
Communication Interrupt.

e) Difference between simplex and full duplex:

 Simplex: Data flows in only one direction.


 Full Duplex: Data flows simultaneously in both directions.

f) Input/Output (I/O) ports of 8051:

 The 8051 has four 8-bit I/O ports (P0, P1, P2, P3). Each port can
function as input or output.

You might also like