MIC Unit 1 Paper Solution
MIC Unit 1 Paper Solution
Unit 1
Q.1) Draw and explain flag structure of 8051 in detail. [5] (Oct 2022)
Flag Register in 8051
The 8051 microcontroller includes a special-purpose register known as the Program Status
Word (PSW) register, which contains several flags. The PSW register is an 8-bit register
located at address 0xD0 in the memory. Here’s the detailed structure of the PSW register:
Bit 0: This flag indicates the parity of the result of the most recent operation. It shows whether
the number of 1s in the result is odd or even.
Set: When the number of 1s is even (even parity).
Cleared: When the number of 1s is odd (odd parity).
PSW Register Usage
Program Control: The flag register (PSW) is used in conjunction with conditional jumps and
other instructions to control the flow of the program based on the results of arithmetic and
logical operations.
Interrupts: Certain flags can influence the behavior of interrupts, particularly the Carry and
Overflow flags.
Q.2) Write an embedded C program to transmit character ‘D’ Serially at baud rate of
4800. [5] (Oct 2022)
Solution:
#include <reg51.h>
void main(void)
{
TMOD=0x20; //use Timer 1, mode 2
TH1=0xFA; //4800 baud rate
SCON=0x50;
TR1=1;
while (1)
{
SBUF=‘D’; //place value in buffer
while (TI==0);
TI=0;
}}
Q.3) Explain the functional diagram of Timer in 8051. [5] (Oct 2022)
Timer 0 & Timer 1:
Timers used to provide accurate time delay based upon application.
Both are 16 bit timer.
It can used as timer / counter .
These are up counter .
Timer 0 register of 16 bit is classified by two 8 bit registers TH0 & TL0
First we load the TL0 , after is get overflow then TH0 is loaded .
It has physical internal address Timer are up counter.
Timer : count internal clock
counter : count external clock pulses
Previous SPPU Insem Question Paper Solution
Unit 1
Q.4) Explain the interrupt structure of 8051 with vector address. [5] (Oct 2022) (Sep
2023)
Interrupts are basically the events that temporarily suspend the main program, pass the
control to the external sources and execute their task.
It then passes the control to the main program where it had left off.
8051 has five interrupts. These interrupts are INT0, INT1, TO , T1 , TI/RI.
All of the interrupts can be enabled or disabled by using the IE (interrupt enable) register.
The interrupt addresses of these interrupts are like below –
Interrupt Address
INT0 0003H
INT1 000BH
T0 0013H
T1 001BH
TI/RI 0023H
BitAddress AF AE AD AC AB AA A9 A8
The address is A8H. This byte is bit addressable. So it can be programmed by the user.
The bits in this register has a different meaning. The register structure is looking like this
This register can be used to enable or disable interrupts programmatically.
This register is an SFR.
The address is A8H. This byte is bit addressable. So it can be programmed by the user.
The bits in this register has a different meaning. The register structure is looking like this
EA Least significant 5 bits can decide Disable all five interrupts. It just
enable or disable of these five ignores the rest five bits.
interrupts.
BitAddress BF BE BD BC BB BA B9 B8
PS Set 1 level priority of Serial port Set 0 level priority of Serial port
interrupt interrupt
PT1 Set 1 level priority of Timer1 interrupt Set 0 level priority of Timer1
interrupt
PT0 Set 1 level priority of Timer0 interrupt Set 0 level priority of Timer0
interrupt
Q.5) Explain functioning of Port 3 in details for 8051. [5] (Oct 2022)
Port 3 in the 8051 microcontroller is a versatile I/O port that can serve multiple functions
beyond just simple digital I/O. Understanding its functionality involves looking at both its
basic I/O capabilities and its additional special functions. Here’s a detailed explanation of Port
3:
Overview of Port 3
Address: Port 3 is an 8-bit bi-directional port and is located at memory address 0xB0 in
the 8051's internal I/O address space.
Previous SPPU Insem Question Paper Solution
Unit 1
To use Port 3 for its special functions, you generally need to configure the corresponding
peripheral or interrupt in the microcontroller.
Q.6) Write an embedded C program to display hex counter on LEDs connected to port 2.
[5] (Oct 2022)
#include <reg51.h> // Include the header file for the 8051 microcontroller
void delay (unsigned int time) // Function to provide a delay
{
unsigned int i, j;
for (i = 0; i < time; i++)
{
for (j = 0; j < 1275; j++); // Adjust loop count for desired delay
}}
void main(void) // Main function
{ unsigned char counter;
while (1)
{
for (counter = 0x00; counter <= 0xFF; counter++)
{
P2 = counter; // Display the counter value on Port 2
delay(1000); // Delay to make the count visible
}} }
Q.7) Draw and explain internal memory organization of 8051. [5] (Sep 2023)
The 8051 microcontroller has a specific internal memory organization, which includes several
different types of memory areas. Understanding this organization is crucial for efficient
programming and utilization of the 8051's resources. Here’s a detailed breakdown and
diagram of the internal memory organization of the 8051 microcontroller.
Internal Memory Organization of 8051
The 8051 microcontroller has three main types of internal memory:
1. Program Memory (ROM): This is used to store the executable code.
Data Memory (RAM): This is used for data storage and variable manipulation during program
execution.
Special Function Registers (SFRs): These are used to control and monitor the
microcontroller’s peripherals and features.
Here’s a detailed breakdown of each memory type:
1. Program Memory (ROM)
Size: Typically 4 KB in a standard 8051, located at addresses 0x0000 to 0x0FFF.
Purpose: Stores the executable code (program instructions).
Previous SPPU Insem Question Paper Solution
Unit 1
Detailed Memory
1. Program Memory (ROM):
o Address range: 0x0000 to 0x0FFF
o Contains the machine code instructions.
2. Data Memory (RAM):
o Register Banks:
Bank 0: Registers R0 to R7 (0x00 to 0x07)
Bank 1: Registers R0 to R7 (0x08 to 0x0F)
Bank 2: Registers R0 to R7 (0x10 to 0x17)
Bank 3: Registers R0 to R7 (0x18 to 0x1F)
o Bit Addressable Area:
Address range: 0x20 to 0x2F
16 bytes that can be addressed bit by bit.
o Scratchpad RAM:
Address range: 0x30 to 0x7F
General-purpose RAM for temporary data storage.
3. Special Function Registers (SFRs):
o Address range: 0x80 to 0xFF
o Includes control and status registers such as:
I/O Ports: P0, P1, P2, P3
Timers: TMOD, TCON, TH0, TL0, TH1, TL1
Serial Communication: SCON, SBUF
Interrupts: IE, IP
Control Registers: PCON, PSW
Previous SPPU Insem Question Paper Solution
Unit 1
Q.8) Calculate hexadecimal count to generate delay of 50 msec using Timer 1, mode 1,
use clock frequency = 11.0592MHz. [5] (Sep 2023)
Q.9) What are the different modes of operation of serial communication in 8051 Explain
SMOD registers? [5] (Sep 2023)
The 8051 microcontroller supports serial communication via its UART (Universal
Asynchronous Receiver/Transmitter) interface. The UART in the 8051 operates in several
modes, each suitable for different serial communication needs. Additionally, the SMOD (Serial
Mode) bits play a crucial role in configuring the UART's operation.
Serial Communication Modes in 8051
The UART in the 8051 microcontroller supports four different modes of operation. These
modes are configured using the Serial Control (SCON) register:
1. Mode 0: Shift Register Mode
o Characteristics:
8-bit data shift register.
No start or stop bits; data is shifted in and out serially.
Data format: 8 bits.
Previous SPPU Insem Question Paper Solution
Unit 1
In the standard 8051 architecture, the term SMOD does not explicitly refer to a dedicated
register. Instead, the baud rate is typically controlled by Timer 1, and the SCON register is
used to select the mode of operation.
However, the concept of SMOD is sometimes used in extended or enhanced 8051
microcontrollers to denote a bit or setting that affects the baud rate. For example:
SMOD Bit: In some variants of the 8051, an SMOD bit (often found in the PCON register) is used
to double the baud rate of the UART. Setting the SMOD bit changes the divisor for the baud rate
calculation.
CISC RISC
Some instructions with long execution No instruction with a long execution time
times. These include instructions that due to a very simple instruction set. Some
copy an entire block from one part of early RISC machines did not even have an
memory to another and others that integer multiply instruction, requiring
copy multiple registers to and from compilers to implement multiplication as a
memory. sequence of additions.
CISC RISC
Q.11) Enlist various modes of operation of Timer & Explain in details. [5] (Sep 2023)
The 8051 microcontroller has two timers/counters: Timer 0 and Timer 1. Each of these
timers can operate in various modes. The modes determine how the timers count and how
they can be used. Below are the various modes of operation for these timers and a detailed
explanation of each mode.
Timer Modes of Operation
The 8051 timers can be configured in the following modes:
1. Mode 0: 13-bit Timer Mode
2. Mode 1: 16-bit Timer Mode
3. Mode 2: 8-bit Auto-Reload Mode
4. Mode 3: Split Timer Mode (only for Timer 0 in some variants of the 8051)
Detailed Explanation of Each Mode
1. Mode 0: 13-bit Timer Mode
Description: In Mode 0, the timer functions as a 13-bit timer. The timer is essentially a
16-bit register, but only 13 bits are used for counting. The lower 5 bits (TLx) and the
upper 8 bits (THx) are used to form the 13-bit counter.
Operation:
o The timer counts from 0x0000 to 0x1FFF.
Previous SPPU Insem Question Paper Solution
Unit 1