MES Manual R-19
MES Manual R-19
Laboratory Manual
for the subject
Academic Year……………………………………………
CONTENT
Vision:
Mission:
To empower the aspiring professional students to be prudent enough to explore the world of
technology and mould them to be proficient to reach the pinnacle of success in the competitive
global economy.
Vision:
Mission:
Course
Course Name Teaching scheme Credit assigned
Code
BML503 Microcontrollers Theory Pract. Tut. Theory Pract. Tut. Total
and Embedded
Systems Lab -- 02 -- -- 01 -- 01
(Abbreviated as
MES Lab)
Examination Scheme
Theory
Course Term Pract.
Course Name End Duration Total
Code Internal Assessment work / Oral
sem (hrs)
Test 1 Test 2 Avg.
BML503 Microcontrollers
and Embedded
Systems Lab -- -- -- -- -- 25 25 50
(Abbreviated as
MES Lab)
PO2) Problem Analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and engineering sciences.
PO5) Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex engineering
activities with an understanding of the limitations.
PO6) The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent responsibilities
relevant to the professional engineering practice.
PO7) Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and need
for sustainable development.
PO8) Ethics: Apply ethical principles and commit to professional ethics and responsibilities
and norms of the engineering practice.
PO9) Individual and team work: Function effectively as an individual, and as a member or
leader in diverse teams, and in multidisciplinary settings.
PO12) Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological
change.
2
Microcon-
trollers and 3
Embedded 4
Systems
5
Microcontrollers
and Embedded
Systems
List of Experiments
Sr.
Name of Experiment CO PO PSO Page No.
No
Introduction to 8051
1 microcontroller and Keil
software.
To simulate simple ASM
2 programs based on data transfer,
arithmetic and logical
instructions.
Lab Incharge
Date:
Experiment No. 1
AIM: Introduction to 8051 and the Keil software.
SOFTWARE: Keil software
THEORY:
Draw and explain architectural block diagram and pin diagram of 8051 microcontroller.
PROCEDURE:
Write steps for simulating assembly language programs using Keil software.
PROGRAMMING ASSIGNMENT:
1. Write assembly program to exchange 2 values stored in the registers R 5 and R6. Select
register bank 1.
2. Write assembly program to find one’s compliment of a given no.
3. Write assembly program to find two’s compliment of a given no.
4. Write a program to copy the value 55H into internal RAM memory locations 40 to 45H
using direct addressing mode.
VIVA QUESTIONS:
1. Write salient features of 8051.
2. Explain role of PC
3. Explain the use of stack and SP.
4. Explain the importance of DPTR.
5. Why data pointer is 16 bit wide and stack pointer is 8 bit wide?
6. Why 11.592 MHz frequency is recommended with IC 8051?
7. Explain machine cycle and instruction cycle.
8. Explain the concept of dual port.
9. Explain opcode and operand.
10. List the types of data supported by 8051.
Date:
Experiment No. 2
AIM: To simulate simple ASM programmes based on data transfer, arithmetic and logical
instructions.
SOFTWARE: Keil software
THEORY:
In data transfer instructions data stored at source address is moved (actually copied) to
a destination address.
PROGRAMMING ASSIGNMENT:
1. Write a program to copy the value 55H into internal RAM memory locations from 40 to
45H using register indirect addressing mode.
2. Write a program to transfer the contents of internal memory location starting from 21H
to 30 H to the internal ML starting from 51 H to 60 H.
3. AND the contents of external RAM location 9500h and 9501h. Store the result at
external RAM location 9502h.
VIVA QUESTIONS:
Date:
Experiment No. 3
AIM: To simulate ASM programs using branching instructions.
THEORY: Branching group of instructions cover jumps and calls. These instructions are
decision-making instructions and program flow can be altered by examining certain conditions.
Following types of decision opcodes: jump on bit conditions, compare bytes and jump if not
equal, decrement byte and jump if zero, jump unconditionally, calla subroutine, return from a
subroutine.
In conventional instructions of some microprocessors, jump address is specified in operand but
8051 uses three different types of specifying jump address to save program memory, avoiding
unnecessary bytes in case of jump within short range.
Jump or call instructions may have one of three ranges:
i) A relative range of +127d to-128d bytes from the instruction following jump or call
instruction.
ii) An absolute range on the same 2k byte page as the instruction following jump or call,
or
iii) A long range of any address from 0000h to FFFFh, anywhere in program memory.
Relative Range:
Jumps by using relative range replace the program counter contents with a new address that is
greater than the address of the instruction following the jump by 127d or less than the address
of the instruction following jump by 128 d. Here the address given is relative. The address
following the jump is used to calculate the relative jump because of the action of PC. The PC is
incremented to point next instruction before the current instruction is executed.
Relative jump has two advantages. First, only one byte of data need be specified as address,
either in positive format for jumps ahead in the program or in two’s complement negative
format for jumps behind. Second advantage is that program written by using relative jumps can
be located anywhere in the program address space without reassembling the code to generate
absolute address.
The only disadvantage is that all the addressed jumps be within range of +127d or –128d bytes.
Short absolute range: all the program memory address space can be divided into a series of 2k
pages, giving a total of 32d(20h) pages for range 0000h to FFFFh. As an example, page 00
contains address range 0000h to 07FFh. For page 09 address range is 4800h to 4FFF. In
general, to find a range of any page (0 to 32d or 00h to 20 h) following method can be applied.
For page 10(0Ah) 10 x 8 = 80d =50 h
start address = 5000h
end address = 5000h + 07FFh(2k) = 57FFh
For page 29 (1Dh) 29 x 8 = 232d = E8h
start address = E800h
end address = E800h + 07FFh(2k) = EFFFh.
Inspection of the address range of each page number reveals that the upper 5 bits hold the
page number and lower 11 bit hold the address within the page. Eight different opcodes
are provided for one instruction using short absolute range address. Appropriate code for
instructions should be used for these instructions. It offers advantage of allowing jump or
PROGRAMMING ASSIGNMENT:
1. Fill the external RAM memory location 9500h to 9600h with a number 20h.
2. Multiply data on external RAM location 9500h and 9501h. store result in same
locations ie. at 9500h store low byte and at 9501 store high byte.
3. Count the number of bytes in external RAM locations 9500h to 9504h that are greater
than 01H and less than 05H. Use register R0 to hold the count.
VIVA QUESTIONS
1. If the lower nibble of any number placed in A is larger than Upper nibble, set the C
flag to 1, otherwise clear it.
2. Count the number of 1‟s in R1 and put count in R0.
3. W.A. P. to find largest no. among data stored from RAM location 30 H 3F H.
4. Differentiate between SJMP, AJMP, and LJMP instructions.\
5. What is the advantage of using SJMP over LJMP?
6. Explain instruction SJMP
7. Explain instruction DJNZ R3, BACK.
8. In JZ NEXT, which register’s content is checked if it is zero?
9. Explain CALL instruction and the role of the stack.
10. Write instructions to toggle both bits of P1.7 and P1.0 continuously.
Date
EXPERIMENT No. 4
AIM: Programming using 8051 Timer
THEORY:
The 8051 comes equipped with two timers, both of which may be controlled, set, read, and
configured individually. The 8051 timers have three general functions: 1) Keeping time and/or
calculating the amount of time between events, 2) Counting the events themselves, or 3)
Generating baud rates for the serial port.
Timer SFRs
As mentioned before, the 8051 has two timers which each function essentially the same way.
One timer is TIMER0 and the other is TIMER1. The two timers share two SFRs (TMOD and
TCON) which control the timers, and each timer also has two SFRs dedicated solely to itself
(TH0/TL0 and TH1/TL1).
When this bit is set the timer will only run when INT1 (P3.3)
7 GATE1 is high. When this bit is clear the timer will run regardless of 1
the state of INT1.
When this bit is set the timer will count events on T1 (P3.5).
6 C/T1 When this bit is clear the timer will be incremented every 1
machine cycle.
When this bit is set the timer will only run when INT0 (P3.2)
3 GATE0 is high. When this bit is clear the timer will run regardless of 0
the state of INT0.
When this bit is set the timer will count events on T0 (P3.4).
2 C/T0 When this bit is clear the timer will be incremented every 0
machine cycle.
Bit
Bit Name Address Explanation of Function Timer
6 TR1 8Eh Timer 1 Run. When this bit is set Timer 1 is turned on. 1
When this bit is clear Timer 1 is off.
4 TR0 8Ch Timer 0 Run. When this bit is set Timer 0 is turned on. 0
When this bit is clear Timer 0 is off.
PROGRAMMING ASSIGNMENT:
1. What is the lowest frequency that can be generated using Mode 1 if the crystal
frequency is 11.0592 MHz? Show your calculation.
2. W.A.P. to generate square wave with 50 Hz frequency on P1.0. Assume crystal
frequency of 11.0592 MHz.
VIVA QUESTIONS:
Date:
EXPERIMENT No. 5
AIM: To simulate simple Embedded ‘C’ codes using Keil software.
Theory:
Procedure-
PROGRAMMING ASSIGNMENT
1. Write 8051 ‘C’ program to toggle all the bits of P1 continuously.
2. Write 8051 ‘C’ program to toggle alternate bits of P1 continuously.
3. Write 8051 ‘C’ program to toggle bit D0 of port P1, 10 times.
VIVA QUESTIONS:
1. The signed char is a data types that takes value –
2. Which are the ‘C’ data types used for 8051?
3. What are the contents of P1 after the following "C" code is executed?
#include <reg51.h>
void main (void)
{
P1= 0x37 & 0xCA;
}
Date:
EXPERIMENT No. 6
AIM: To simulate Embedded ‘C’ codes using Proteus software.
Theory:
Procedure-
PROGRAMMING ASSIGNMENT:
1. Using Proteus software, interface all LEDs with port P2. Switch on and switch
off alternatively.
2. Using Proteus software, interface all LEDs with port P2. Make 4 LEDs on and 4
LEDs off switch off alternatively.
VIVA QUESTIONS:
1. What is the step size in ADC?
2. What is the conversion time?
3. In ADC how end of conversion is indicated?
4. State the advantage of LCD display over LED display.
5. State the role of ULN 2003 current driver in stepper motor interfacing.
6. If an 8*8 matrix of keys needs to be connected to 8051 microcontrollers, how many
ports of 8051 will be used?
7. The rows and columns of a 4*4 matrix keyboard are connected respectively to the
lower half of P1(output port) and the lower half of P2(input port) of 8051
Microcontroller. If no key has been pressed, reading P2 will yield which of the
following binary values in its lower half?
8. How many discrete voltage (or current) levels of outputDAC0808 provides?
9. Ideally, we connect the output pin of the DAC0808 to………………
10. How many address lines are required for accessing the data in a 1,024 bytes RAM
memory chip, while data is organized as bytes?
Date:
Experiment – 7
Aim: Interface 16X2 LCD with 8051 Microcontroller.
Theory:
The LCD discussed in this section has 14 pins. The function of each pin is given in table.
RS - register select:
There are two very important registers inside the LCD. The RS pin is used for their
selection as follows. If RS = 0, the instruction command code register is selected, allowing
the user to send a command such as clear display, cursor at home, etc. If RS = 1 the data
register is selected, allowing the user to send data to be displayed on the LCD.
R/W - read/write:
R/W input allows the user to write information to the LCD or read information from
it. R/W = 1 when reading; R/W =0 when writing.
E - enable:
The enable pin is used by the LCD to latch information presented to its data pins. When
data is supplied to data pins, a high to low pulse must be applied to this pin in order for the
LCD to latch in the data present at the data pins. This pulse must be minimum 450 ns wide.
D0 – D7:
The 8-bit data pins, D0 – D7, are used to send information to the LCD or read
the contents of the LCD‟s internal registers.
To display letters and numbers, we send ASCII codes for the letters A – Z, a – z,
and numbers 0 – 9 to these pins while making RS = 1.
There are also instructions command codes that can be sent to the LCD to clear
the display or force the cursor to the particular position
Code (hex) Command to LCD Instruction Register
1 Clear display screen
2 Return home
4 Shift cursor to left
5 Shift display right
6 Shift cursor to right
7 Shift display left
8 Display off, Cursor off
A Display off, Cursor on
C Display on, cursor off
E Display on, cursor blinking
F Display on, cursor blinking
10 Shift cursor position to left
14 Shift cursor position to right
18 Shift the entire display to the left
1C Shift the entire display to the right
80 Force cursor to beginning of 1st line
C0 Force cursor to beginning of 2nd line
38 2 lines and 5x7 matrix
EXERCISE
QUESTIONS:
6. Which are the control pins of the LCD? What are their functions?
9. Give the state of RS, E and R/W when sending data character ‘Z’ to the LCD.
10. Give the command codes for line1, first character, and line 2, first character.
Date:
EXPERIMENT No- 08
AIM: To implement any one hardware circuit from the following.
THEORY:
Include the appropriate circuit explanation and corresponding algorithm. Also include the
program.
PROCEDURE:
Enlist the steps to be carried out to execute it.