0% found this document useful (0 votes)
31 views

MPMC Assignment 2

The document contains an assignment for a subject on multiprocessor multiprocessing. It includes two questions on 8051 microcontroller addressing modes and LCD interfacing. For question 1, it describes the five addressing modes of 8051 with examples. For question 2, it explains LCD interfacing with 8051, provides a connection diagram and circuit diagram, and includes code to send data and commands to LCD with delays. It was submitted by a student for a computer science course assignment.

Uploaded by

Rajnish 008
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

MPMC Assignment 2

The document contains an assignment for a subject on multiprocessor multiprocessing. It includes two questions on 8051 microcontroller addressing modes and LCD interfacing. For question 1, it describes the five addressing modes of 8051 with examples. For question 2, it explains LCD interfacing with 8051, provides a connection diagram and circuit diagram, and includes code to send data and commands to LCD with delays. It was submitted by a student for a computer science course assignment.

Uploaded by

Rajnish 008
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Chandigarh Engineering College Jhanjeri

Mohali-140307

Department of Computer Science & Engineering

ASSIGNMENT-2

Subject: MPMC Subject Code: BTEC-402-18 Semester: 6th


Date of Giving: 13.4.2023 Date of Submission: 17.04.2023 Max. Marks: 20

ASSIGNMENT MARKS:
Sr. No. Q.No. Marks Obtained Course Outcome No.

1 1 CO 3

2 2 CO 4

2 2 CO 5

Total

Submitted by: Rajnish Kumar Submitted to:

Roll no : 2027008 Ms. Richa Mehta


A.P. (ECE)
Q1 a) Describe the Addressing Modes of 8051 Microcontroller with the help of
examples.

Ans. The 8051 microcontroller has five addressing modes:

1. Immediate addressing mode


2. Direct addressing mode
3. Indirect addressing mode
4. Register addressing mode
5. Relative addressing mode

Let's discuss each addressing mode in detail with examples:

1. Immediate addressing mode: In this mode, the data is directly specified in the instruction. The
operand is always an 8-bit constant, and it is preceded by a '#' symbol. This mode is used to load
a constant value into a register or memory location.

Example: MOV A, #25H This instruction moves the immediate value 25H into the accumulator
register A.

2. Direct addressing mode: In this mode, the address of the operand is directly specified in the
instruction. The operand can be a register or a memory location. The address is an 8-bit number,
and it is not preceded by any symbol.

Example: MOV R1, 40H This instruction moves the contents of the memory location 40H into the
register R1.

3. Indirect addressing mode: In this mode, the address of the operand is stored in a register, and the
register is used to access the operand. The register is enclosed in square brackets [].

Example: MOV A, @R0 This instruction moves the contents of the memory location whose address
is stored in register R0 into the accumulator register A.

4. Register addressing mode: In this mode, the operand is stored in one of the registers of the
microcontroller. The register is specified in the instruction.

Example: ADD A, R2 This instruction adds the contents of register R2 to the accumulator register
A.

5. Relative addressing mode: In this mode, the operand is a signed 8-bit value that is added to the
current program counter value to get the address of the operand. This mode is used for branching
instructions.

Example: DJNZ R3, label This instruction decrements the contents of register R3 and jumps to the
specified label if the result is not zero.

In conclusion, the different addressing modes of 8051 microcontroller provide flexibility and
efficiency in accessing operands and executing instructions.
Q1 b) Classify the types of Interrupts and explain IE register.

Ans. Interrupts are a crucial aspect of microcontroller programming and can help in responding to
events that require immediate attention. There are mainly two types of interrupts:

1. Hardware Interrupts: These interrupts are generated by external hardware devices such as timers,
input-output devices, and communication interfaces, and they require hardware support to
function correctly.
2. Software Interrupts: These interrupts are generated by software or firmware of the microcontroller
to initiate specific tasks or routines, and they do not require any hardware support.

The 8051 microcontroller has five hardware interrupts (INT0, INT1, TIMER0, TIMER1, and serial port
interrupt) and two software interrupts (RESET and interrupt 0x80).

The IE (Interrupt Enable) register is an 8-bit register that controls the interrupts in the 8051
microcontroller. It has the following bit positions:

• EA (Enable All Interrupts): This bit is used to enable/disable all interrupts. When this bit is cleared
(set to 0), all interrupts are disabled, and the microcontroller will not respond to any interrupt
requests.
• ET2 (Enable Timer2 Interrupt): This bit is used to enable/disable the Timer2 interrupt.
• ES (Enable Serial Port Interrupt): This bit is used to enable/disable the serial port interrupt.
• ET1 (Enable Timer1 Interrupt): This bit is used to enable/disable the Timer1 interrupt.
• EX1 (Enable External Interrupt1): This bit is used to enable/disable the external interrupt 1.
• ET0 (Enable Timer0 Interrupt): This bit is used to enable/disable the Timer0 interrupt.
• EX0 (Enable External Interrupt0): This bit is used to enable/disable the external interrupt 0.

The IE register can be accessed using the MOV instruction. For example, to enable the Timer0
interrupt, we can use the following instruction:

MOV IE, #82H

Here, 82H is the hexadecimal value with the binary representation of 1000 0010. It means that the
Timer0 interrupt and the Enable All Interrupts (EA) bit are enabled.

In conclusion, the IE register is an essential component of the 8051 microcontroller that controls the
interrupt functionality. By setting and clearing the appropriate bits of this register, we can
enable/disable different interrupts and manage the microcontroller's interrupt response.
Q2 Explain the LCD interfacing with 8051 with the help of connection diagram. Also, write a
program to send data and commands to LCD using some delay.

Ans. We always use devices made up of Liquid Crystal Displays (LCDs) like computers, digital watches,
and also DVD and CD players. They have become very common and have taken a giant leap in the
screen industry by clearly replacing the use of Cathode Ray Tubes (CRT). CRT draws more power than
LCD and is also bigger and heavier. All of us have seen an LCD, but no one knows the exact working
of it. Let us take a look at the working of an LCD.

Here we are using alphanumeric LCD 16×2. A 16×2 LCD display is a very basic module and is very
commonly used in various devices and circuits. These modules are preferred over seven segments
and other multi-segment LEDs. The reasons being: LCDs are economical; easily programmable; have
no limitation of displaying special & even custom characters (unlike in seven segments), animations,
and so on.

A 16×2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each
character is displayed in a 5×7 pixel matrix. This LCD has two registers, namely, Command and Data.
The command register stores the command instructions given to the LCD. A command is an
instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting the cursor
position, controlling display, etc. The data register stores the data to be displayed on the LCD. The
data is the ASCII value of the character to be displayed on the LCD.

Pin Diagram :

The LCD display module requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The
user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit
data bus is used the LCD will require a total of 7 data lines (3 control lines plus the 4 lines for the data
bus). If an 8-bit data bus is used the LCD will require a total of 11 data lines (3 control lines plus the 8
lines for the data bus).

The three control lines are referred to as EN, RS, and RW.

The EN line is called “Enable.” This control line is used to tell the LCD that you are sending it data. To
send data to the LCD, your program should make sure this line is low (0) and then set the other two
control lines and/or put data on the data bus. When the other lines are completely ready, bring EN
high (1) and wait for the minimum amount of time required by the LCD datasheet (this varies from
LCD to LCD), and end by bringing it low (0) again.

The RS line is the “Register Select” line. When RS is low (0), the data is to be treated as a command or
special instruction (such as clear screen, position cursor, etc.). When RS is high (1), the data being sent
is text data which should be displayed on the screen. For example, to display the letter “T” on the
screen you would set RS high.

The RW line is the “Read/Write” control line. When RW is low (0), the information on the data bus is
being written to the LCD. When RW is high (1), the program is effectively querying (or reading) the
LCD. Only one instruction (“Get LCD status”) is a read command. All others are write commands–so
RW will almost always be LOW.

Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected by the
user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6,
and DB7.

Circuit Diagram :
Send Data

To send data on the LCD, data is first written to the data pins with R/W = 0 (to specify the write
operation) and RS = 1 (to select the data register). A high to low pulse is given at EN pin when data
is sent. Each write operation is performed on the positive edge of the Enable signal.

Code :

void data(unsigned char b)


{
lcd_data=b;
rs=1; rw=0;
en=1;
lcd_delay();
en=0;
}

Send Command :

To send a command on the LCD, a particular command is first specified to the data pins with R/W =
0 (to specify the write operation) and RS = 0 (to select the command register). A high to low pulse is
given at EN pin when data is sent.

Code :

void cmd(unsigned char a)


{
lcd_data=a;
rs=0; rw=0;
en=1;
lcd_delay();
en=0;
}

You might also like