You are on page 1of 36

INDEX

Sr.
No.

Title

Date

1.

Write an alp to illustrate arithmetic and


logical operations

2.

Programming problems on block addition


block transfer & block sorting.

3.

Write Assembly language programmes for


Code Conversions.

4.

Programming
manipulation.

5.

Programming problems to generate pulse


waveform using timer.

6.

Programming
problems
transmission of characters.

7.

Write ALP and C program to interface 7


segment display with 8051.

8.

Write ALP & C language program to interface


16*2 LCD with 8051.

9.

Write an ALP and C language program to


interface
DC
motor
with
8051
Microcontroller.

10.

Interfacing 4x4 Matrix Keypad with 8051


Microcontroller.

11.

To interface a stepper motor with 8051


Microcontroller.

12

Interfacing ADC with 8051 microcontroller.

13

To Program the
Microcontroller.

problems

on

I/O

on

interrupts

bit

Serial

of

8051

Grad
e

Sign

* INSTRUCTIONS *

This laboratory manual is issued once only. This is your responsibility to preserve it
in good condition up to Term work submission & Oral examination.
Use only HB pencil to write in this manual.
Your writing should be neat and clean.
Get checked your manual at the end of the performance of each practical.
Practical & Assignments that cannot be read or are not presented in a professional
engineering style will not receive credit (Higher Grades).
Practical will be performed on software development tools.
Students are required to report for practical classes with the required code.

Experiment 1
OBJECTIVE: Write an ALP to illustrate arithmetic and logical
operations.
PRELAB
Read Data transfer, arithmetic and Logical instructions.

APPARATUS:
PC
keil software

PROGRAM:
Write assembly language programs for Arithmetic operations such
as Addition, Subtraction, Multiplication, Division and Logical
operations such as Anding, oring and Xoring. See the output values

and affect of each operation on the PSW register.

FACULTY SIGN

Experiment 2
OBJECTIVE: Programming problems on block addition block
transfer & block sorting.
a) Write a program to add block of data stored in internal/external

memory locations.
b) Write a program to transfer block of data from internal memory

locations to external memory locations.

PRELAB
Read Data transfer and arithmetic instructions.

APPARATUS:
PC
keil software

PROGRAM:
Write assembly language program for Addition of Block of data
stored in Memory and for transfer of block of data from one memory
block to other and see the output using memory window in Keil
software.

Experiment 3
OBJECTIVE : Write Assembly language programmes for Code
Conversions.
a) Write an ALP to convert hexadecimal number to its equivalent
decimal number.
b) Write an ALP program to convert a BCD number to its
equivalent ASCII code.
c) Write an ALP program to convert ASCII code to its equivalent
BCD number.

PRELAB
Read Data transfer and arithmetic instructions, logical instructions.

APPARATUS:
PC
keil software

PROGRAM:
Write assembly language program for code conversion from one
number system to another number system and see the output result
on 8051 internal registers.

FACULTY SIGN

Experiment 4
OBJECTIVE: Programming problems on I/O bit manipulation.
a) Write a program to perform the following.
I. Keep monitoring P1.2 until it becomes high.
II. When P1.2 becomes high write value 45H on P0.
III. Sent a high to low pulse to P2.3
b) A switch is connected to P1.7. Write a program to check the status
of switch and perform the following.
I. if switch = 0, send letter N to P2.
II. if switch = 1, send letter Y to P2.

PRELAB
Read I/O port and Data transfer instructions.

APPARATUS:
PC
keil software

PROGRAM:
Write assembly language program for reading and writing input &
output ports of 8051 and see the output in 8051 peripherals window
and in Top-View Simulator.

ANSWER

THE FOLLOWING QUESTIONS

1. Upon reset, all ports of the 8051 are configured as _____________ (output,
input).

2. Which ports of the 8051 have internal pull-up resistors?

3. Which ports of the 8051 require the connection of external pull-up resistors in
order to be
used for I/O? Show the drawing for the connection.

FACULTY SIGN

Experiment 5
OBJECTIVE: Programming problems
waveform using timer.

to

generate

pulse

a) Write a program to generate 5 KHz pulse waveform of 50% duty


cycle on pin 1.0 using timer 1 in mode 2. Use Crystal frequency
11.0592 MHz
b) Write a program to generate 1 KHz pulse waveform of 70% duty
cycle on pin 1.0 using timer. Use Crystal frequency 11.0592 MHz
(Show necessary calculations)

PRELAB
Read the timers of 8051.

APPARATUS:
PC
keil software
8051 Microcontroller kit
Oscilloscope

PROGRAM:
Write assembly language program generating Pulse waveforms on
8051 I/O pins and see the output on Signal Analysis window in keil
and load the program in kit and connect CRO to 8051 pins and see
the Waveform on CRO and measure the frequency.

Experiment 6
OBJECTIVE : Programming problems on Serial transmission of
characters.
a) Write a program for the 8051 to transfer letter A serially,
continuously.
b) Write a program to transfer the message YES serially and
continuously.
C) Program the 8051 to receive bytes of data serially, and put
them in P1.

PRELAB
Read serial Communication registers of 8051.

APPARATUS:
PC
keil software

PROGRAM:
Write assembly language program for serial communication and see
the output in KEIL serial window and load the program on kit and
see the output on serial window of PC.

ANSWER

THE FOLLOWING QUESTIONS:


1. The 8051 TxD and RxD signals ________ (are, are not) TTL-compatible.

2. In this lab, what is the role of the MAX233 (MAX232) chip?

3. With XTAL=11.0592 MHz, what is the maximum baud rate for the 8051?

4. Show how to achieve the maximum baud rate in Question 3.

5. What is the role of TI and RI?

6. True or false. The 8051 can transfer data in full-duplex.

FACULTY SIGN

Experiment 7
OBJECTIVE: Write ALP and C program to interface 7 segment
display.
PRELAB
Read the I/O port programming of 8051.

APPARTUS:
PC
keil software
Topview simulator

BRIEF

ABOUT 7 SEGMENT DISPLAY


7 Segment displays are basically 7 LED's. Basically there are two types
of 7-Seg displays.

Common cathode: where all the segment shares the same cathode.
Common anode: where all the segment share the common anode.

PROGRAM:
Write assembly language and C language program interfacing 7segment display with 8051. See the output in Top-View Simulator
and also load the program on Kit and see the output on 7-segment.

FACULTY SIGN

Experiment 8
OBJECTIVE:
Write Assembly & C language program to
interface 16*2 LCD with 8051.
PRELAB
Read datasheet of 16*2 LCD.

APPARATUS:
PC

keil software
8051 microcontroller kit

BRIEF

ABOUT

16X2 LCD

A 16x2 LCD means it can display 16 characters per line and there are 2
such lines. In this LCD each character is displayed in 5x7 pixel matrix.
This LCD has two registers.
1. Command and Instruction register: Stores the command instructions
given to the LCD. A command is a instruction given to the LCD to do
predefined task like initializing , clearing the screen , setting the
cursor position , controlling display etc.
2. 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 description of 16*2 LCD.

Programming the LCD:


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

Commonly used LCD command codes:

PROGRAM:
- Write C language program interfacing LCD display with 8051. See
the output in Top-View Simulator and also load the program on Kit
and see the output on LCD Display.
-

Write an LCD program to display your last name on the first line
and the current year on the second line. Both should be in the
middle of the line.

Questions:

1. How does the LCD distinguish data from instruction codes when receiving
information at its data pin?

2. To send the instruction code 01 to clear the display, we must make RS = ___.

3. To send letter 'A' to be displayed on the LCD, we must make RS = ____.

4. What is the purpose of the E line? Is it an input or an output as far as the LCD is
concerned?

5. When is the information (code or data) on the LCD pin latched into the LCD?

FACULTY SIGN

Experiment 9
OBJECTIVE: Write an ALP and C language program to interface
DC motor with 8051 Microcontroller.
PRELAB
Read ports of 8051 microcontroller.

APPARATUS:
PC
Keil software
8051 Microcontroller kit
DC Motor

PROGRAM:
Write assembly language and C language program interfacing DC
Motor with 8051. Load the program on Kit and connect DC motor
with I/O pins of 8051.

F ACULTY

SIGN

Experiment 10
OBJECTIVE: Interfacing 4 x 4 Matrix Keypad with 8051
Microcontroller.
PRELAB:
Read I/O port programming of 8051.

APPARATUS:
PC
Keil software
8051 microcontroller kit

PROGRAM:
Write assembly language program interfacing 4x4 matrix keypad
with 8051. See the output in Top-View Simulator and also load the
program on Kit and see the output.

FACULTY SIGN

Experiment 11
OBJECTIVE: To interface
Microcontroller.
PRELAB:

stepper

motor

with

8051

Read I/O port programming of 8051 and basics of stepper motor.

APPARATUS:
PC
Keil software
8051 microcontroller kit

PROGRAM:
-

Interface stepper motor with 8051 and writes ALP to rotate stepper
motor clockwise continuously.
Write and run a program to rotate clockwise 180 degrees, stop for
a second, and then go counter clockwise to its original position.

QUESTIONS:
1. What is a step angle? Define steps per revolution.

2. If a given stepper motor has a step angle of 5 degrees, find the number of steps per
revolution.

3. Give the four sequences for counter clockwise if it starts with 10011001 (binary).

4. Using the "RL A" instruction, show the four-step sequences if the initial step is
0011 (binary).

FACULTY SIGN

Experiment 12
OBJECTIVE: Interfacing ADC with 8051 microcontroller.
PRELAB:
Read data sheet of 0808 ADC
Read I/O port programming of 8051.

APPARATUS:
PC
Keil software
8051 microcontroller kit
ADC 0808

PROGRAM:
Write C language program interfacing 0808 ADC with 8051. Load the
program on kit and connect the ADC module with kit and display the
sample data on LCD.

QUESTIONS:
1. Assume that Vref/2 is connected to 1.28 V. Find the following.
(a) step size
(b) maximum range for Vin
(c) D7 - D0 values if Vin = 1.2 V
(d) Vin if D7 - D0 = 11111111
(e) Vin if D7 - D0 = 10011100

2. Assume that Vref/2 is connected to 1.9 V. Find the following.


(a) step size
(b) maximum range for Vin
(c) D7 - D0 values if Vin = 2.7 V
(d) Vin if D7 - D0 = 11111111
(e) Vin if D7 - D0 = 11011101

3. The ADC804 is a(n) ____-bit converter.

4. To get step size of 2 mV, what is the value for Vref/2?

FACULTY SIGN

Experiment 13
OBJECTIVE: To Program the interrupts of 8051 Microcontroller.
PRELAB:
Read Timer and counter interrupts
Read serial communication interrupts
read external interrupts

APPARATUS:
PC
Keil software
8051 microcontroller kit
ADC 0808

PROGRAM:
-

Write an 8051 program to get data from one port and send it to
another port continuously while an interrupt will do the following:
One of the timers will toggle the PX.Y bit every 100 microseconds.

Write an 8051 program to get data from a single bit of P1.2 and
send it to P1.7 continuously while an interrupt will do the following:
A serial interrupt service routine will receive data from a PC and
display it on one of the ports. (Either connect LEDs to this port to
examine the data coming in or display the received data on an
LCD).

Write an 8051 program to get data from one port and send it to
another port continuously while an interrupt will do the following: A
square wave is connected to the INT0 (pin 3.2) and any time a Hto-L pulse comes in a single LED is turned on. The rate of "On" and
"Off" is the rate of the square wave. In this activity you can also
use INT1.

Questions:
1. Name all of the interrupts in the 8051 and their vector table addresses.

2. In timer mode 1, indicate when TF0 causes the interrupt.

3. In timer mode 2, indicate when TF0 causes the interrupt.

4. On reset, INT0 (and INT1) are _________ (edge, level) triggered.

5. On reset, which interrupt has the highest priority?

6. True or False. There is only a single interrupt for the serial data transfer.

FACULTY SIGN

You might also like