Sei sulla pagina 1di 33

SSN COLLEGE OF ENGINEERING

LAB MANUAL

.e

ee

ex

cl
u

si

ve

.b
l

og

sp
ot

.c
o

DEPARTMENT OF ELECTRICAL & ELECTRONICS


ENGINEERING

EE2356 MICROPROCESSOR & MICRO CONTROLLER


LABORATORY

DEC 2010-APRIL 2011

Name of the experiment


Arithmetic operations using 8085 Microprocessor.

2a

Sorting of numbers (Ascending & descending) using 8085 Microprocessor.

2b

Number conversions (BCD HEX, HEX BCD).

Arithmetic operations using 8086 Microprocessor.

4a

Interfacing 8 bit ADC Converter with 8085 Microprocessor.

4b

Interfacing 8 bit DAC Converter with 8085 Microprocessor.

Traffic Light controller using 8085 Microprocessor.

6a

Square Wave Generation using 8254

6b

Serial Data Transmission using 8251

7
8

Interfacing 8279 with 8085 microprocessor


8 bit Arithmetic operations using 8051 Microcontroller.

Finding the smallest and largest number in an array of numbers using 8051
Microcontroller
Interfacing 8 bit DAC Converter with 8051 Microcontroller
Interfacing of Stepper Motor with 8051 Microcontroller
Interfacing Traffic Light Controller using 8051

.c
o

sp
ot

og

.b
l

ve

si

cl
u

ex

ee
.e
w
w
w

10
11
12

Expt.No.
1

EXPT NO 1

ARITHMETIC OPERATIONS USING 8085

AIM:
To write the assembly language programs for performing the following
arithmetic operations:
a) 16 bit binary addition.
b) 16 bit binary subtraction.
c) 16 bit binary multiplication.

d) 16 bit binary division.

.c
o

APPARATUS REQUIRED:

sp
ot

Microprocessor kit, Power supply.

og

PROBLEM STATEMENT:

.b
l

Write an ALP in 8085 P to add and subtract two 16-bit binary numbers stored

ve

in the memory locations 4100 & 4101 and 4102 & 4103 and store the result starting

si

from the memory location 4105H. Also provide an instruction in the above program to

ex

cl
u

observe the carry also and store the carry in the memory location 4104H.

ee

ALGORITHM:
16 BIT ADDITION:
Start.

1.

Enter the two 16 bit data in two register pairs HL and DE.

2.

Initialize a carry counter register B to zero.

3.

Add the contents of register pairs.

4.

If a carry is generated, increment the carry counter B.

5.

Store the Carry in the B register and the sum, which is in the register pair HL in

.e

the memory.
6.

Stop.

16 BIT SUBTRACTION:
1.

Start.

2.

Get the two 16 bit data in two of the register pairs.

3.

Subtract the Low Order Byte of data1 from that of the data 2.

4.

Subtract the How Order Byte of data1 along with borrow from that of the data2.

5.

Store the result in memory.

6.

Stop.

PROBLEM STATEMENT:

Write an ALP in 8085 P to multiply two 16-bit binary numbers stored in the

.c
o

memory locations 4100(LOB) & 4101(HOB) and 4102(LOB) & 4103(HOB) and store

sp
ot

the result in the memory location 4104H & 4105H.Write instructions for performing
16-bit division also.

og

16 BIT MULTIPLICATION.
Start.

2.

Initialize BC register pair to store the Carry.

3.

Store the data 1 and data 2 in DE register pair and SP register.

4.

Initialize the HL register pair to zero, to store the result.

5.

Multiply by repeated addition of data 1 data 2 times.

6.

If carry flag is set during addition., increment the carry register pair.

7.

Store the product available in HL pair in memory.

8.

Store the contents of the BC register pair which is the carry in memory.

9.

Stop.

.e

ee

ex

cl
u

si

ve

.b
l

1.

16 - BIT DIVISION
1.

Start.

1.

Store the dividend in HL register pair.

2.

Store the divisor in BC register pair

3.

Initialize the DE register pair to zero, to carry the quotient.

4.

Perform repeated subtraction of divisor from dividend till the dividend is less
than the divisor.

5.

For every subtraction done, keep on incrementing the quotient register pair DE.

6.

Store the remainder pair in memory.

7.

Store the quotient in memory.

8.

Stop.

FLOW CHART
16-BIT ADDITION

16-BIT SUBTRACTION
START

START

LOAD THE TWO


NUMBERS

INITIALISE
CARRY REGISTER

INTIALIZE BORROW
REGISTER

sp
ot

.c
o

LOAD TWO NOS. IN


REGISTER PAIRS

SUBTRACT THE
TWO NUMBERS

.b
l

og

ADD THE TWO


NUMBERS

NO

cl
u

YES

YES
INCREMENT
CARRY
REGISTER

STORE THE
RESULT

.e

ee

ex

INCREMENT
CARRY
REGISTER

STORE THE
RESULT

NO
ANY
BORROW?

si

ve

ANY
CARRY

STOP

STOP

16-BIT MULTIPLICATION

16-BIT DIVISION

START

START

LOAD DIVISOR &


DIVIDEND

GET MULTIPLIER AND


MULTIPLICAND IN
REGISTER PAIRS
QUOTIENT = 0

PRODUCT=0000

sp
ot

.c
o

DIVIDEND =
DIVIDEND DIVISOR

QUOTIENT =
QUOTIENT + 1

ve

.b
l

og

REG. PAIR = REG. PAIR +


MULTIPLICAND

IS
DIVIDEND <
DIVISOR

cl
u

si

MULTIPLIER =
MULTIPLIER 1

NO

YES

ee

ex

NO

STORE QUOTIENT

.e

IS MULTIPLIER
= 0?

YES
STOP

STORE REGISTER
PAIR

STOP

EXPT NO 2

SORTING of NUMBERS USING 8085


(ASCENDING AND DESCENDING ORDER)

AIM:
To write an Assembly Language Program (ALP) to sort a given array of
numbers in ascending and descending order.
APPARATUS REQUIRED:
Microprocessor kit, Power supply.

.c
o

PROBLEM STATEMENT:

sp
ot

An array of length 10 is stored from the location starting from 5000H. Sort it
into descending and ascending orders and store the resultant starting from the location

ALGORITHM:

si

ve

SORTING IN ASCENDING ORDER:

.b
l

og

5300H.

cl
u

a. Start.

ex

b. Load the array count in a register. Initialize a carry flag FF to zero.

ee

c. Get the first two numbers.

.e

d. Compare the numbers and swap them if necessary so that the two numbers are in

ascending order. If swapping is done, set the carry flag FF.


e. Repeat the steps c and d till the array is completed.
f. Repeat the steps c, d and e till carry flag FF remains Reset.
f.

Stop

SORTING IN DESCENDING ORDER:


a. Start.
b. Load the array count in a register. Initialize a Carry Flag FF to zero.
c. Get the first two numbers.

d. Compare the numbers and swap them so that the two numbers are in descending
order. And set the Carry Flag FF.
e. Repeat steps c and d till the array is completed.
f. Repeat the steps c, d and e till the Carry Flag FF remains Reset.
g. Stop.
FLOW CHART:
ASCENDING ORDER

DESCENDING ORDER
START

START

.c
o

INITIALIZE POINTER
COUNT = COUNT 1
FLAG = 0

og

sp
ot

INITIALIZE POINTER
COUNT = COUNT 1
FLAG = 0

ve
si

NO

TEMP = POINTER
POINTER = POINTER + 1
POINTER + 1 = TEMP
FLAG=FLAG+1

.e

ee

ex

TEMP = POINTER
POINTER = POINTER + 1
POINTER + 1 = TEMP
FLAG=FLAG+1

cl
u

NO

IS POINTER
POINTER + 1

.b
l

YES
IS POINTER
POINTER + 1

YES

POINTER = POINTER +1
COUNT = COUNT + 1

NO

POINTER = POINTER +1
COUNT = COUNT + 1

NO

IS COUNT
=0

IS COUNT
=0

YES

YES

NO
IS FLAG =
0

IS FLAG =
0

YES
YES
STOP

STOP

EXPT NO 2b

NUMBER CONVERSIONS USING 8085


(BCD TO HEXA AND HEXA TO BCD)

AIM:
To write an Assembly language program for converting a two digit BCD
number (maximum of 99) to hexadecimal and to convert a hexadecimal number
(maximum of FFH) to BCD.

ALGORITHM:

.c
o

CONVERSION OF BCD TO HEXADECIMAL:


Start.

2.

Separate the given 8 - bit packed BCD number into two 4 bit

sp
ot

1.

unpacked BCD nibbles(BCD1 and BCD2).

Multiply BCD2 the most significant nibble, by 10.

4.

Add BCD1 to the answer from step3.

5.

Store the result and Stop.

ve

.b
l

og

3.

si

CONVERSION OF BCD TO HEXADECIMAL:


Start.

2.

Read the hexadecimal number.

3.

Initialize a memory location to store the number of 100s. Find the

ee

ex

cl
u

1.

.e

number of 100s and store it in the memory.


Find the number of 10s from the remainder and store it in the next

4.

The remainder now contains the number of 1s and store it in the next

5.

memory location.

memory location.
7.

Stop.

FLOW CHART:
BCD TO HEX

HEXA TO BCD

START
START
GET DATA CARRY =0
HUNDREDS =0
TENS=0

GET MOST
SIGNIFICANT
DIGIT(MSD)

.c
o
NO

sp
ot

HUNDREDS
=HUNDREDS + 1

DATA =DATA -100

MSD =
MSD x 10

IS CARRY
=1 ?

og

HEX DATA = MSD +


LSD (LEAST
SIGNIFICANT DIGIT)

.b
l

YES
DATA =DATA +100

si

ve

STORE HEX
DATA

DATA =DATA - 10

TENS = TENS + 1

NO
IS CARRY
=1?

.e

ee

ex

cl
u

START

YES

DATA =DATA -10

UNITS =DATA

STORE HUNDREDS ,
TENS , UNITS

STOP

EXPT NO: 4 A

INTERFACING 8 BIT ADC CONVERTER USING 8085

Aim:
To obtain the digital output corresponding to the analog input.

Apparatus Required:
1. Microprocessor 8085 Trainer Kit

2. Display Interface Kit

.c
o

3. Flat Cable Connector

og

sp
ot

4. Power Supply +5 V

.b
l

Algorithm:
1. Start

ve

2. Initialize control word of 8255 to enable ports A, B as output ports and port C as

3. Initialize accumulator

cl
u

si

output port.

ex

4. Send contents of accumulator to DAC through port A

ee

5. Obtain comparator output to port c.

.e

6. If accumulator =0 go to step 5else goto step 9

7. Decrement contents of accumulator

8. Go to step 4

9. Call display subroutine to display digital output


10. Stop.

Flowchart
START

ACTIVATE THE 8255


CONTROLLER

INITIALIZE ACCUMULATOR

.c
o

SEND CONTENTS OF ACCUMULATOR TO DAC THROUGH PORT A

og

sp
ot

OBTAIN COMPARATOR OUTPUT TO PORT C

ve

.b
l

IS
ACCUMULATOR = 0?

cl
u

si

NO

ex

DECREMENT CONTENTS OF
ACCUMULATOR

.e

ee

CALL DISPLAY SUBROUTINE TO


DISPLAY DIGITAL OUTPUT

STOP

YES

EXPT NO: 4 B

INTERFACING 8 BIT DAC CONVERTER USING 8085

AIM:To generate different types of waveforms by interfacing a DAC with a


microprocessor trainer kit.

EQUIPMENT REQUIRED
Intel 8085 based MPS 85 2 trainer kit, DAC interface card, 26 pin
flat cable connector, CRO with probe.

ALGORITHM:-

.c
o

SQUARE WAVE FORM

sp
ot

1. Initialize the control word register i.e., 8255 as input port.


2. Send 00 to port A of 8255

og

3. Call delay subroutine

5. Call delay subroutine

ve

6. Repeat the step 2 onwards.

.b
l

4. Send FF to port A of 8255

cl
u

si

SAW TOOTH WAVE FORM

1. Initialize the control word register.

ex

2. Initialize the accumulator content

ee

3. Send to port A of 8255

.e

4. Increment the accumulator content

5. If zero flag is not set then repeat the step 3 onwards, otherwise repeat

the step 2 onwards.

FLOW CHART:
Square Waveform:

Saw tooth Waveform:

START

START

ACTIVATE THE 8255


CONTROLLER

ACTIVATE THE 8255


CONTROLLER

SEND 00 TO PORT A

ACC = 00

SEND ACC TO PORT


A

.c
o

CALL DISPLAY
SUBROUTINE

ACC = ACC + 1

sp
ot

SEND FF TO PORT
A

NO

IF Z
=0

.e

ee

ex

cl
u

si

ve

.b
l

og

CALL DISPLAY
SUBROUTINE

YES

EXPT. NO:5
TRAFFIC LIGHT CONTROLLER USING 8085 MICROPROCESSOR

AIM:To write an Assembly language Programme for traffic light controller.


EQUIPMENT REQUIRED
8085 microprocessor kit and Power Supply.
ALGORITHM:-

.c
o

1. Start.

2. Write the control word to initialize 8255.Obtain the data for

sp
ot

each direction and store in the memory.

3. Initialize a counter to indicate the number of directions.

.b
l

5. Check the result.

og

4. Initialize HL Pair to the starting address of the data..

ve

6. Decrement the counter and repeat step 3 till counter becomes

.e

cl
u

ee

ex

7. Stop.

si

zero.

FLOW CHART

TRAFFIC CONTROLLER

START

Write control word to initialize


8255

Initialize a counter.
Initialize HL pair to 9000h

sp
ot

.c
o

Call Display Program

.b
l

og

Introduce a Delay of 4 Seconds

cl
u

si

ve

Call Display Program

ee

ex

Introduce a Delay of 4 Sec.

.e

Decrement the counter

COUNTER = 0?

NO

YES
Call Display Program

Introduce a Delay Of 4 Sec.

FLOW CHART DISPLAY PROGRAM

DISPLAY

SEND CONTROL WORD TO ACC FROM MEMORY

OUTPUT THE DATA TO A PORT

sp
ot

.c
o

INCREMENT HL REG. PAIR CONTENT

.b
l

og

SEND CONTROL WORD TO ACC FROM MEMORY

si

ve

OUTPUT THE DATA TO A PORT

ex

cl
u

INCREMENT HL REG. PAIR CONTENT

OUTPUT THE DATA TO PORT C

.e

ee

SEND CONTROL WORD FROM MEMORY TO ACC.

INCREMENT HL REG. PAIR CONTENT

RETURN

EXPT. NO. : 6 A
SQUARE WAVE GENERATION USING 8254

AIM:
To interface 8254 with 8085 microprocessor and generate a square wave

ALGORITHM
1. Start
2. Write control word to initialize 8254 in mode 3

.c
o

4. Load the MSB of the count and output in channel 0

3. Load the LSB of the count and output in channel 0

sp
ot

5. Stop.

.b
l

og

FLOW CHART

cl
u

si

ve

START

.e

ee

ex

Write control word to initialize 8254 in mode 3

Output the LSB and MSB of the count in channel 0

STOP

EXPT. NO. : 6 B
SERIAL DATA TRANSMISSION USING 8251

AIM:
To interface 8251 with 8085 microprocessor and to check the transmission
and reception of a character.

ALGORITHM

.c
o

For transmitting the data

sp
ot

1. Start
2. Write control word to initialize 8254 in mode 3

og

3. Load the LSB of the count and output in channel 0

4. Load the MSB of the count and output in channel 0

ve

Output the data to be transmitted to data register and enable an interrupt.

cl
u

si

6.

.b
l

5. Write mode instruction word and command instruction word for 8251.

.e

ee

ex

For Receiving the data

7. Read the data from the data register

8. Store the data to a memory location

9. Stop

FLOW CHART For transmitting the data

START

.c
o

Write control word to initialize 8254 in mode 3

sp
ot

Output the LSB and MSB of the count in channel 0

og

Write mode instruction word and command

ve

.b
l

instruction word for 8251

.e

ee

ex

cl
u

si

Output the data in data register

STOP

FLOW CHART For receiving the data

START

sp
ot

.c
o

Store the data in memory location

Read the data from data register

.e

ee

ex

cl
u

si

ve

.b
l

og

STOP

EXPT. NO. : 7
INTERFACING 8279 WITH 8085 MICROPROCESSOR

AIM:
To interface 8279 with 8085 microprocessor and display the rolling message
HELP US

ALGORITHM

.c
o

5. Start

6. Load the HL pair with the starting address of the message to be displayed

sp
ot

and initialize a counter.


7. Initialize 8279

og

8. Output the data from memory to the data register

.b
l

9. Call delay.

ve

10. Increment the pointer and decrement the counter.

si

11. Repeat until counter becomes 0.

.e

ee

ex

cl
u

12. Stop.

FLOW CHART

START

Load the HL pair with the starting address of the

initialize a counter.

.c
o

message to be displayed and

Initialize 8279 and Output the data from memory to

og

sp
ot

the data register

ve

.b
l

Call Delay SUBROUTINE

ex

cl
u

si

Increment the pointer


Decrement the counter

.e

ee

No

Is the
counter
value 0
Yes

EXPT NO 8

8 BIT ARITHMETIC OPERATIONS USING 8051

AIM:
To write the assembly language programs for performing the following
arithmetic operations:
8 bit binary addition.

b)

8 bit binary subtraction.

c)

8 bit binary multiplication.

d)

8 bit binary division.

a)

.c
o

APPARATUS REQUIRED:

sp
ot

Microcontroller kit.

og

PROBLEM STATEMENT:

.b
l

Write an ALP in 8051 c to perform 8-bit arithmetic operations for the

ve

numbers stored in the memory location 4500H and 4501H and store the result in the
memory location 4600H.Also provide an instruction in the above program to consider

ALGORITHMS:

Start

2.

Initialize carry register to zero.

3.

Store data 1 in accumulator.

4.
5.

Load the data pointer with external memory address

6.

Add the contents of B register to that of the accumulator.

7.

If a carry is generated, increment the carry counter.

8.

Store the contents of the Accumulator, which is the sum in memory.

9.

Move the carry register contents to Accumulator and store the same in

.e

1.

ee

8 BIT ADDITION:

ex

cl
u

si

the carry also and store the carry in the memory location 4601H.

Store date 2 in B register.

memory.
10.

Stop.

i. e x e

8 BIT SUBTRACTION:
Start

2.

Initialize Barrow register to zero.

3.

Store data 1 in accumulator and date 2 in B register respectively.

4.

Subtract the contents of B register to that of the accumulator.

5.

Load the data pointer with external memory address

6.

If a borrow is generated, increment the borrow counter.

7.

Store the contents of the Accumulator, which is the difference in memory.

8.

Move the barrow register contents to Accumulator and store the same in

1.

Stop.

sp
ot

9.

.c
o

memory.

8 BIT MULTIPLICATION:

og

Start.

Store data 1 in register Accumulator.

3.

Store data 2 in register B.

4.

Load the data pointer with external memory address

5.

Multiply A and B register

6.

Move the A and B register contents to the memory

7.

Stop.

ex

cl
u

si

ve

.b
l

2.

ee

1.

Store data 1 in register Accumulator.

2.

Start.

1.

.e

8 BIT DIVISION:

3.

Store data 2 in register B.

4.

Load the data pointer with external memory address

5.

Divide A and B register

6.

Move the A and B register contents to the memory

7.

Stop.

FLOWCHART:
8-BIT ADDITION

8-BIT SUBTRACTION

START

START

SET UP COUNTER
(CARRY)

SET UP COUNTER
(CARRY)
GET FIRST
OPERAND TO A

.c
o

GET FIRST
OPERAND TO B

.b
l

og

sp
ot

GET SECOND
OPERAND TO
A

cl
u

YES

NO

COUNTER =
COUNTER + 1

ee
.e

STORE THE
DIFFERENCE

COUNTER =
COUNTER + 1

NO

ANY CARRY?

ex

IS THERE
ANY CARRY

YES

si

ve

A=A+B

SUBTRACT
SECOND
OPERAND
FROM
MEMORY

STORE THE SUM

STORE THE CARRY

STOP

STORE THE CARRY

STOP

8-BIT MULTIPLICATION

8-BIT DIVISION
START

START

GET DIVIDEND IN A AND


DIVISOR IN B register

GET MULTIPLIER IN A AND


MULTIPLICAND IN B register

Multiply the content of A


and B register

og

sp
ot

.c
o

Divide the content of A


and B register

Load Data Pointer with


External Memory Address

cl
u

Move the content of A


and B to external Address

.e

ee

ex

Move the content of A


and B to external Address

si

ve

.b
l

Load Data Pointer with


External Memory Address

STOP

STOP

EXPT NO 9 FINDING THE SMALLEST AND LARGEST NUMBER

IN AN ARRAY OF NUMBERS USING 8051


AIM:
To write Assembly Language Programs (ALP) to find the maximum and
minimum of an array of numbers.
APPARATUS REQUIRED:

Microcontroller Kit

.c
o

PROBLEM STATEMENT:

sp
ot

An array of length 10 is stored from the location starting from 4600H. Sort it
into descending and ascending orders and store the resultant starting from the location

og

4700H.

ve

.b
l

ALGORITHM:

si

FINDING THE SMALLEST NUMBER OF THE ARRAY:

cl
u

1. Start.

ex

2. Load the array count in a register.

.e

ee

3. Get the first two numbers.

4. Compare the numbers and swap them if necessary so that the two numbers are

in descending order.
5. Repeat the steps 3 and 4 till the array is completed.
6. Repeat the steps 3, 4 and5 and store the smallest number..
7. Stop

FINDING THE LARGEST NUMBER OF THE ARRAY:


1. Start.
2. Load the array count in a register.
3. Get the first two numbers.
4. Compare the numbers and swap them so that the two numbers are in ascending
order.
5. Repeat steps 3 and 4 till the array is completed.

.c
o

6. Repeat the steps 3, 4 and 5 and store the largest number as the result in

.e

ee

ex

cl
u

si

ve

.b
l

og

Stop.

7.

sp
ot

memory.

FLOW CHART:
FINDING THE MINIMUM AND MAXIMUM NUMBER OF AN ARRAY
START

START

INITIALIZE POINTER
COUNT = COUNT 1

IS POINTER
POINTER + 1

sp
ot

.c
o

YES

IS POINTER
POINTER + 1

YES

INITIALIZE POINTER
COUNT = COUNT 1

NO

TEMP = POINTER
POINTER = POINTER + 1
POINTER + 1 = TEMP

cl
u

ex

POINTER = POINTER +1
COUNT = COUNT + 1

si

ve

.b
l

og

TEMP = POINTER
POINTER = POINTER + 1
POINTER + 1 = TEMP

NO

ee

NO

NO

IS COUNT
=0

YES

YES

.e

IS COUNT
=0

POINTER = POINTER +1
COUNT = COUNT + 1

STORE THE
POINTER RESULT

STORE THE
POINTER RESULT

STOP
STOP

EXPT. NO: 10
INTERFACING DAC CONVERTER USING 8051
AIM:To generate different types of waveforms by interfacing a DAC with a
microcontroller.

EQUIPMENT REQUIRED
Intel 8051 based MPS 85 2 trainer kit, DAC interface card, 26 pin

.c
o

flat cable connector, CRO with probe.

ALGORITHM:-

sp
ot

SQUARE WAVE FORM

1. Initialize the control word register i.e., 8255 as input port.

si

5. Call delay subroutine

ve

4. Send FF to port A of 8255

.b
l

3. Call delay subroutine

og

2. Send 00 to port A of 8255

cl
u

6. Repeat the step 2 onwards.

ex

SAW TOOTH WAVE FORM

ee

1. Initialize the control word register.

.e

2. Initialize the accumulator content

3. Send to port A of 8255

4. Increment the accumulator content

5. If zero flag is not set then repeat the step 3 onwards, otherwise repeat
the step 2 onwards.

FLOW CHART:
Square Waveform:

Saw tooth Waveform:


START

ACTIVATE THE 8255


CONTROLLER

ACTIVATE THE 8255


CONTROLLER

SEND 00 TO PORT A

ACC = 00

START

SEND ACC TO PORT


A

sp
ot

.c
o

CALL DISPLAY
SUBROUTINE

ACC = ACC + 1

og

SEND FF TO PORT
A

NO

IF Z
=0

.e

ee

ex

cl
u

si

ve

.b
l

CALL DISPLAY
SUBROUTINE

YES

.b
l

ve

si

cl
u

ex

ee

.e

.c
o

sp
ot

og

Potrebbero piacerti anche