Sei sulla pagina 1di 157

SRI KRISHNA COLLEGE OF TECHNOLOGY

An Autonomous Institution, Affiliated to Anna University,


Approved by AICTE
Accredited by NBA AICTE, NAAC A Grade
Kovaipudur, Coimbatore 641 042.

DEPARTMENT OF ELECTRICAL AND


ELECTRONICS ENGINEERING

MICROPROCESSOR AND MICROCONTROLLER


LABORATORY

LAB MANUAL
2015-2015 (ODD SEMESTER)
III EEE
EX NO:.. DATE:

LIST OF EXPERIMENTS AS PER SYLLABUS


8-bit and 16-bit Microprocessors

1. Simple arithmetic operations:


Multi precision addition / subtraction / multiplication / division.
2. Programming with control instructions:
Increment / Decrement.
Ascending / Descending order.
Maximum / Minimum of numbers.
Rotate instructions.
Hex / ASCII / BCD code conversions.
3. Interface Experiments:
A/D Interfacing.
D/A Interfacing.
4. Interface Experiments:
Simple experiments using 8251, 8279, 8254.

8-bit Micro controller

5. Demonstration of basic instructions with 8051 Micro controller execution, including:


Conditional jumps, looping
Calling subroutines.
Stack parameter testing
6. Parallel port programming with 8051 using port 1 facility:
Stepper motor and D / A converters.
7. Programming Exercise on
RAM direct addressing
Bit addressing
8. Simple arithmetic operations like addition, subtraction, multiplication and division using
PIC Microcontroller.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


2 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

CYCLE OF EXPERIMENTS

S.NO NAME OF THE EXPERIMENT


CYCLE I
1 Single Byte arithmetic operations using 8085:
a) Addition
b) Subtraction
c) Multiplication
d) Division
2 Program to find using 8085:
a) Ascending order/Descending order
b) Largest/Smallest of a given numbers
3 Program for Conversion of Hex /Decimal using 8085:
a) Hexadecimal to Decimal
b) Decimal to Hexadecimal
4 Program for Conversion of Hex /Decimal using 8085:
a) Binary to ASCII
b) ASCII to Binary
5 Basic Arithmetic Operations using 8086:
a) 32 bit Addition
b) 32 bit Subtraction
c) 16 bit Multiplication
d) 16 bit Division
CYCLE II
6 Interfacing of 8085 with:
a) ADC with 8085
b) DAC with 8085
7 Interfacing of 8085 with:
a) 8279
b) 8251
8 Basic Logical operations using 8051:
a) Arithmetic Operations.
b) Sum of elements using stack and Call option.
9 Interfacing Operations using8051:
a) Interfacing: Stepper Motor with 8051
10 Basic Arithmetic Operations using PIC Microcontroller
11

SRI KRSIHNA COLLEGE OF TECHNOLOGY


3 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

TABLE OF CONTENTS

S.NO DATE NAME OF THE EXPERIMENT MARKS SIGN


1 Single Byte arithmetic operations using 8085:
a) Addition
b) Subtraction
c) Multiplication
d) Division
2 Program to find using 8085:
a) Ascending order/Descending order
b) Largest/Smallest of a given numbers
3 Program for Conversion of Hex /Decimal using 8085:
a) Hexadecimal to Decimal
b) Decimal to Hexadecimal
4 Program for Conversion of Hex /Decimal using 8085:
a) Binary to ASCII
b) ASCII to Binary
5 Basic Arithmetic Operations using 8086:
a) 32 bit Addition
b) 32 bit Subtraction
c) 16 bit Multiplication
d) 16 bit Division
6 Interfacing of 8085 with:
a) ADC with 8085
b) DAC with 8085
7 Interfacing of 8085 with:
a) 8279
b) 8251
8 Basic Logical operations using 8051:
a) Arithmetic Operations.
b) Sum of elements using stack and Call option.
9 Interfacing Operations using8051:
a) Interfacing: Stepper Motor with 8051

10 Basic Arithmetic Operations using PIC Microcontroller


11
TOTAL

Staff Incharge

4 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
GENERAL INTRODUCTION OF 8085:

The trainer encompasses a central processing unit (CPU) associated with input and output
peripherals.

a) CPU:

The following function blocks form a CPU of a computer.

i) ALU:

Hardware utilized in performing arithmetic operations.

ii) Register section:

A set of registers used for temporary storage of instructions.

iii) Interface section:

Input and output series (buses) by which the processor can retrieve and transmit
data to external unit.

iv) Timing and control section:

Hardware for coordinating and controlling various components and activities


within and outside the MP. The microprocessor 8085 is a 40 pin DIP packed IC which has all
essential components of a CPU.

b) INPUT AND OUTPUT PERIPHERALS:

To build a useful system, memory and input, output devices or Peripherals to be


integrated to a microprocessor. Interfacing is a process of making electronic devices or system
operationally compatible.

The microprocessor unit communicates with peripherals either asynchronously or


synchronously. Also, the microprocessor transmits data in parallel input/output mode and in
serial input/output mode.

Microprocessor identifies peripherals either as necessary devices or Peripherals input-


output devices.

The I/O devices can be categorized into general purpose and special purpose devices. The
common general-purpose peripheral devices are:

i) Programmable I-O ports.


ii) Programmable timers

SRI KRSIHNA COLLEGE OF TECHNOLOGY


5
EX NO:.. DATE:

iii) Read only memory devices.


iv) Random access memory.
v) Key board and display panels.

Each I/O device is accessed by a binary address known as device address or port address.
To transfer data to peripherals, the microprocessor places an appropriate address on the
appropriate bus, transmit control bus to enable the device and then to transfer data.

i) Programmable I-O ports:

The 8155 and 8255 ICs both contributes I/O ports and can be programmable to transfer
data either in simple I/O or interrupt I/O mode. The I/O portion consists of general-purpose
registers and control registers in addition to the I/O ports.

ii) Programmable timer:

The 8155 and 8253 provided timer/counter circuits. In addition to the I/O ports 8155
consists of 256 bytes of RAM and 14 bit timers. Here, all modes of operation are software
programmable.

iii) ROM:

ROM is used for system initialization and operation. It is a non-volatile semi conductor
memory, which is used to store the monitor program of MPU. It consists of continuous and
consecutive series of location which can store particular data in a specified address. This is done
by burning certain locations and user programmable ROM known as PROM. Such IC can be
programmed only once. However, data entered in EPROM can be erased by the application of
some special methods.

iv) RAM:

RAM is also called Read/Write Memory(R/WM). RAM is a volatile memory which


means that the contents stored in the unit are subjected to change when the power is turned off.
RAM locations are available for the user and its address locations are different size. A set of
address locations are available to the user in all trainer kits. (For Example, 8000h FFFFh in
ESA kit) suggesting or indicating a 64KB memory capacity. The corresponding address for the
kits supplied by Mighty Electronics and MP systems are different.

v) KEY BOARD / DISPLAY PANEL:

The keyboard / display panel is centered on an 8279 Key board Display controller. The
8279 is responsible for the keyboard matrix and display units. The 8279 port functions are
dependant on the Ao address bit and R/W control signal received by it.

The MP executes its program at a rate set by its clock. A program is a sequence of
instructions, which enables a computer to perform a particular task. A computer program

6 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

includes data sequence and memory address represented in a Hexadecimal format. The methods
of entry of instructions vary from kit to kit. To store data in a specified memory location, the
procedure adapted is as follows:

Press the RESET key.


Press the EXAM MEM key.
Load the address and data using keyboard.
Press the NEXT key.

PROGRAM EXECUTION:

To execute a program, the MP should be directed to the starting address of the program.
The processor begins the execution of the program by following the first machine code. The
processor decodes the code by matching it with its predefined set of instructions and performs
the specified task. Fetching, decoding and performing the task are continued one after the other
and sequentially till the processor is instructed to halt. To encode a program stored in specified
set of memory locations the procedure adopted are as follows:

Press the RESET key.


Press the GO key or equivalent key.
Load the starting address of the program.
Press EXE key or Equivalent key.

EXE is the address field indicating the execution of a program.

PREREQUISITE
1. Define bit and byte
2. What is the size of data bus and address bus of 8085 microprocesssor?
3. What are the registers available in 8085 microprocessor?
4. Why 8085 is 8-bit processor?
5. What is flag register?

7 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

8 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No.1a PROGRAM FOR SINGLE BYTE ADDITION USING 8085

AIM
To write a assembly language program to add single byte numbers using direct
addressing mode.

APPARATUS REQUIRED
1. 8085 microprocessor trainer kit
2. Power supply

ALGORITHM
1. Load the 1st data in the accumulator.
2. Transfer the data from accumulator to B register.
3. Now load the second data in the accumulator.
4. Transfer the data from accumulator to C register.
5. Add the content of C reg. with the acc.
6. Increment B reg. if there is a carry.
7. Store the result in a memory location.
8. Halt the program.

PREREQUSITES:
1. How will you perform subtraction in 8085?
2. What are the instructions used for data transfer?
3. Which registers are used as memory pointer?
4. Where the results of arithmetic/logical operations are stored? Why?
5. Which instruction is used to increment the memory?
6. What are the instructions used to clear the accumulator content?

9 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOWCHART
Start

Store 1st data in


accumulator

Store 2nd data in


accumulator

Add two data

If
Carry
Yes

No

Increment counter reg.

Store the result

Stop

SRI KRSIHNA COLLEGE OF TECHNOLOGY


10 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


11 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


12 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites S
2
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


13 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT

Thus the addition of two single byte numbers using direct addressing mode is executed
and output is verified.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


14
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No.1b PROGRAM FOR SINGLE BYTE SUBTRACTION USING 8085


AIM
To write a assembly language program to subtract single byte numbers using immediate
addressing mode.

APPARATUS REQUIRED
1. 8085 microprocessor trainer kit
2. Power supply

ALGORITHM

1. Initialize B register.
2. Load the 1st data in the accumulator.
3. Subtract the 2nd data with the contents of accumulator.
4. If there exists a carry, increment B register.
5. Store the contents of the accumulator in a memory location.
6. Move the contents of B register to next memory location.
7. Halt the program.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


15 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOWCHART

Start

Initialize B register

Load acc. Content with


immediate value

Subtract II data with


accumulator

If No
Carry

Yes
Increment B reg.

Store acc. Content in


memory location

Move B content to

Stop

SRI KRSIHNA COLLEGE OF TECHNOLOGY


16 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


17 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


18 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites S
2
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


19 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT
Thus the subtraction of two single byte numbers using immediate addressing mode is
executed and output is verified.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


20
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No.1c PROGRAM FOR SIGLE BYTE MULTIPLICATION

AIM
To write an 8085 assembly language program to perform single byte multiplication.

APPARATUS REQUIRED

1. 8085 MP trainer kit


2. Power supply

ALGORITHM

1. Start the program.


2. Initialize a register zero to store carry, also accumulator.
3. Load the C register with the multiplier.
4. Load the B register with the multiplicand.
5. Add accumulator with the multiplicand.
6. Decrement the multiplier.
7. Repeat step 5 and step 6 until multiplicand value turns zero.
8. Check for the carry flag set and increment the carry register.
9. Store the product and the carry in respective register.
10. Stop the program.

21 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOW CHART

SRI KRSIHNA COLLEGE OF TECHNOLOGY


22 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


23 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


24 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites S
2
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


25 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT

Thus the 8085 assembly language program for multiplication of two single byte numbers
is performed.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


26
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No.1d PROGRAM FOR SIGLE BYTE DIVISION

AIM
To write an 8085 assembly language program to perform single byte division.

APPARATUS REQUIRED

1. 8085 MP trainer kit


2. Power supply

ALGORITHM

1. Start the program.


2. Initialize a register zero to store borrow.
3. Load the accumulator with the dividend.
4. Load the B register with the divisor.
5. Increment the C register to store quotient.
6. Subtract accumulator with the divisor.
7. Check for the carry flag ,if set goto step 5.
8. Decrement quotient and add the accumulator with the divisor.
9. Store the quotient and the remainder in respective register.
10. Stop the program.

27 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOW CHART

SRI KRSIHNA COLLEGE OF TECHNOLOGY


28 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


29 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


30 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites 2S
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


31 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT

Thus the 8085 assembly language program for division of two single byte numbers is
performed.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


32
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No.2a PROGRAM TO SORT IN ASCEDING/DESCENDING ORDER

AIM:

To write a program to sort a given array of data in ascending / descending order. The first
data in array being array size.

APPARATUS REQUIRED:

1. 8085 MP trainer kit


2. Power supply

ALGORITHM:

Step 1: Load the HL pair with the starting address of the array.
Step 2: Load two registers B and C with the array size and set it as counter.
Step 3: Increment the pointer and load the data in acc. & set to sort it.
Step 4: Increment the pointer to compare it with the data in acc.

ASCENDING ORDER
Step 5: If carry occurs during comparison then it is in ascending order. So continue sort the next
data in the array.
Step 6: Continue to sort the data by decrementing the counter and incrementing the pointer until
all data are compared.
Step 7: Halt the program.

DESCENDING ORDER

Step 5: If carry does not occurs during comparison then it is in descending order. So continue
sort the next data in the array. If carry does not occur then exchange the two data in
adjacent memory location.
Step 6: Continue to sort the data by decrementing the counter and incrementing the pointer until
all data are compared.
Step 7: Halt the program.

PREREQUISITES
1. -------------- instruction is used to compare memory with accumulator content
2. -------------- instruction is used to compare register with accumulator content
3. -----------------flags are used to indicate the result of comparision
4. Difference between conditional jump and unconditional jump
5. What is the status of carry flag and zero flag when accumulator content is greater than
memory/register content?
6. What is the status of carry flag and zero flag when accumulator content is lesser than
memory/register content?
7. What is the status of carry flag and zero flag when accumulator content is equal to
memory/register content?

SRI KRSIHNA COLLEGE OF TECHNOLOGY


33 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOWCHART

Start

Initialize B reg. for number of


comparison

Load HL pair as memory


pointer

Move 1st data into acc.

Initialize C reg. as counter

Increment memory pointer

Move value from


If C =0

Exchange memory pointer


through A & E

Increment HL pair by 1

Decrement C

If

Decrement B reg. by 1

If

Stop

SRI KRSIHNA COLLEGE OF TECHNOLOGY


34 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


35 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


36 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites 2S
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


37 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT

Thus the assembly language program to sort a given array of data in ascending /
descending order is executed and output is verified.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


38
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No.2b PROGRAM TO FIND LARGEST AND SMALLEST OF GIVEN NUMBERS

AIM
To write an 8085 assembly language program to find the largest and smallest of given
numbers.

APPARATUS REQUIRED
1. 8085 MP trainer kit
2. Power supply

ALGORITHM
1. Start the program.
2. Initialize C register with the number of input values.
3. Get the input values in memory in H, L pair.
4. Load the accumulator with the first value.
5. a) Compare the accumulator with memory, if carry flag is set move memory value to
accumulator, to find largest.
b) Compare the accumulator with memory, if carry flag is not set move memory value to
accumulator, to find smallest.
6. Decrement the count, repeat step 5 until count turns zero.
7. Store the accumulator value to respective register.
8. Stop the program.

39 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOW CHART

SRI KRSIHNA COLLEGE OF TECHNOLOGY


40 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


41 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


42 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites S
2
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


43 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT

Thus the 8085 assembly language program to find the largest and smallest of given
numbers is performed.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


44
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No.3a HEXADECIMAL TO DECIMAL CONVERSION


AIM
To write an assembly language program to convert hexadecimal number into decimal
number.
APPARATUS REQUIRED
1. 8085 microprocessor trainer kit
2. Power supply
ALGORITHM
1. Initialize HL reg. pair for getting value.
2. Initialize BC reg. pair.
3. Subtract 64 from acc. Content.
4. Checks for carry, if carry exists add 64 to acc.
5. Subtract 0A from acc. Content.
6. Checks for carry, if carry exists add 0A to acc.
7. Increment HL reg. pair.
8. Move the data to the location 8051
9. Rotate the acc. Content to left with carry 4 times
10. Add B reg. content
11. Increment HL reg. pair and store its result
12. Halt the program.

PREREQUISITES:
1. Name some stack related instructions
2. What are the logical instructions available in 8085?
3. instruction performs logical AND operation with immediate data
4. instruction helps to transferred the program control from the subroutine to the
main program
5. What is PUSH and POP instructions?
6. Name the instructions used for rotate operations
7. Which are the instructions that affect the sequence flow of 8085 assembly language program?

45 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOW CHART

Start

Initialize BC reg. pair

Subtract 64 from acc. Content

Increment B reg. If A = 0

add 64 to acc

Subtract 0A from acc.

Increment C reg. If C = 1

add 0A to acc

Increment HL reg. &


transfer data

Rotate acc. Content to


left with carry

Add B reg.

Store the result

Stop

SRI KRSIHNA COLLEGE OF TECHNOLOGY


46 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


47 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


48 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites S
2
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


49 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT
Thus the program to convert hexadecimal to decimal is executed and output is verified.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


50
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No.3b DECIMAL TO HEXADECIMAL CONVERSION


AIM
To write an assembly language program to convert decimal number into hexadecimal
number.
APPARATUS REQUIRED
1. 8085 microprocessor trainer kit
2. Power supply
ALGORITHM
1. Load the acc. and move it to H.
2. Add immediate H reg. & rotate the carry four times.
3. Move the acc. data and decrement D reg.
4. This is done till D becomes zero.
5. Then move acc. data to L reg. & H data to acc.
6. Add 0F with acc. and add result with L reg. data.
7. Store the result.
8. Halt the program.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


51 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOW CHART

Start

Load accumulator

Move acc. content to H reg.

Add F0 with acc.

Rotate right carry 4 times

Move acc. data to L reg.

Clear Accumulator.

If C = 0

Move acc. data to L reg.

Move H data to acc.

Add 0F with acc.

Add L data with acc.

Store the result

Stop

SRI KRSIHNA COLLEGE OF TECHNOLOGY


52 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


53 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


54 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites S
2
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


55 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT
Thus the program to convert decimal to hexadecimal is executed and output is verified.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


56
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No.4a PROGRAM TO CONVERT BINARY TO ASCII


AIM
To write an assembly language program to convert binary number into ASCII number.
APPARATUS REQUIRED
1. 8085 microprocessor trainer kit
2. Power supply
ALGORITHM
1. Start the process.
2. Load the SP with address 8400
3. Load the HL reg. pair with address 8300
4. Load the DE reg. pair with address 8200
5. Move the memory to the acc.
6. Move the acc. To reg. B
7. Shift higher order nibble to the position of lower order nibble
8. Call subroutine 801A (ASCII)
9. Increment store the first ASCII .
10. Increment DE reg. pair by 1
11. Move reg. B to acc.
12. Call subroutine 801A
13. Store the second ASCBIN hex
14. Halt the program.
PREREQUISITES:
1. Name some stack related instructions
2. What are the logical instructions available in 8085?
3. instruction performs logical AND operation with immediate data
4. instruction helps to transferred the program control from the subroutine to the
main program
5. What is PUSH and POP instructions?
6. Name the instructions used for rotate operations
7. Which are the instructions that affect the sequence flow of 8085 assembly language program?

57 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Sub Program (ASCII)


1. AND 07 with acc.
2. Compare 0A with acc. Immediately
3. Jump on carry to step 5
4. AND 07 with acc.
5. AND 30 with acc
6. Return to the main program

FLOW CHART

58 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Start

Load the SP with address 8400

Load the HL reg. pair with 8300

Move the memory to the acc.

Rotate right to 07

Call ASCBIN

Store the first ASCBIN hex

Increment DE reg. pair by 1

Call ASCBIN

Store the 2nd ASCBIN hex

Stop

AND 0F with acc.

Compare 0F with acc.

If carry

AND 07 with acc

AND 30 with acc.

Return main

SRI KRSIHNA COLLEGE OF TECHNOLOGY


59 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


60 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


61 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites S
2
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


62 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT
Thus the program to convert Binary to ASCII is executed and output is verified.
SRI KRSIHNA COLLEGE OF TECHNOLOGY
63
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No.4b PROGRAM TO CONVERT ASCII TO BINARY


AIM
To write an assembly language program to convert ASCII to binary number.
APPARATUS REQUIRED
1. 8085 microprocessor trainer kit
2. Power supply
ALGORITHM
1. Start the process.
2. Load the SP with address 8400
3. Load the HL reg. pair with address 8300
4. Load the DE reg. pair with address 8200
5. Move the memory to the acc.
6. Move the acc. To reg. B
7. Shift higher order nibble to the position of lower order nibble
8. Call subroutine 801A (ASCII)
9. Store the first ASCBIN hex in DE reg. pair .
10. Increment DE reg. pair by 1
11. Move reg. B to acc.
12. Call subroutine 801A
13. Store the second ASCBIN hex
14. Halt the program.

64 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOW CHART

Start

Load the SP with address 8400

Load the HL reg. pair with 8300

Move the memory to the acc.

Rotate right to 07

Call ASCBIN

Store the first ASCBIN hex

Increment DE reg. pair by 1

Call ASCBIN

Store the 2nd ASCBIN hex

Stop

Subtract immediately 30H from acc.

Compare immediately with acc.

Return main program

Subtract immediately 07 with acc.

Return main

SRI KRSIHNA COLLEGE OF TECHNOLOGY


65 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


66 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


67 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites S
2
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


68 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT
Thus the program to convert ASCII to Binary is executed and output is verified.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


69
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No:5a ADDITION OF TWO 32-BIT NUMBERS USING 8086

AIM:
To write an assembly language program to add two 32-bit numbers using 8086.

APPARATUS REQUIRED:

1. 8086 microprocessor kit


2. Keyboard.

ALGORITHM:

1. Start the program.


2. Load the LSB and MSB of 1st number to AX and BX register respectively.
3. Load the LSB and MSB of 2nd number to CX and DX register respectively.
4. Initialize Carry as zero.
5. Add the LSB of both the numbers.
6. Add the MSB of both the numbers with the previous Carry.
7. Check the Carry flag. If Set then increment carry by 1.
8. Store the Sum in memory location.
9. Halt the program.

PREREQUISITES:
1. Difference between 8085 and 8086
2. How many address lines and data lines available in 8086?
3. List the flags of 8086
4. What are the registers available in 8086?
5. -------------- instruction is used to perform multiplication operation
6. instruction is used to perform division operation

70 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOWCHART

SRI KRSIHNA COLLEGE OF TECHNOLOGY


71 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


72 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


73 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites S
2
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


74 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT
Thus the addition of two 32-bit numbers using 8086 is executed and output is verified.
SRI KRSIHNA COLLEGE OF TECHNOLOGY
75
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No:5b SUBTRACTION OF TWO 32-BIT NUMBERS USING 8086

AIM:
To write an assembly language program to subtract two 32-bit numbers using 8086.

APPARATUS REQUIRED:

8086 microprocessor kit


Keyboard.

ALGORITHM:

1. Start the program.


2. Load the LSB and MSB of 1st number to AX and BX register respectively.
3. Load the LSB and MSB of 2nd number to CX and DX register respectively.
4. Subtract the LSB of both the numbers.
5. Subtract the MSB of both the numbers with the previous Borrow.
6. Store the Difference in memory location.
7. Halt the program.

76 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOWCHART

START

Load 1st Number

Load 2nd Number

Subtract the lower order bit

Subtract the higher order bit with the


previous borrow

Store the Difference

STOP

SRI KRSIHNA COLLEGE OF TECHNOLOGY


77 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


78 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


79 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites S
2
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


80 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT
Thus the subtraction of two 32-bit numbers using 8086 is executed and output is verified.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


81
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No:5c PROGRAM OF 16-BIT MULTIPLICATION USING 8086

AIM:

To write an assembly language program to multiply two 16-bit numbers using 8086.

APPARATUS REQUIRED

1. 8086 microprocessor kit


2. Keyboard

ALGORITHM

1. Start the program.


2. Move the first 16-bit data to AX register.
3. Move the second 16-bit data to BX register.
4. Multiply both the numbers.
5. Store the result from the accumulator to the specified address.
6. Move the Carry from DX register to the specified address.
7. Stop the Program.

82 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOWCHART

SRI KRSIHNA COLLEGE OF TECHNOLOGY


83 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


84 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


85 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites S
2
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


86 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT

Thus the multiplication of two 16-bit numbers using 8086 is executed and output is
verified.
SRI KRSIHNA COLLEGE OF TECHNOLOGY
87
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No:5d PROGRAM OF 16-BIT DIVISION USING 8086

AIM:

To write an assembly language program to divide two 16-bit numbers using 8086.

APPARATUS REQUIRED

1. 8086 microprocessor kit


2. Keyboard

ALGORITHM

1. Start the program.


2. Initialize DX register for storing the remainder.
3. Move the first 16-bit data i.e., dividend to AX register.
4. Move the second 16-bit data i.e., divisor to BX register.
5. Divide both the numbers.
6. Store the result from the accumulator to the specified address.
7. Move the remainder from DX register to the specified address.
8. Stop the Program.

88 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOWCHART

SRI KRSIHNA COLLEGE OF TECHNOLOGY


89 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


90 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


91 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites S
2
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


92 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT

Thus the division of two 16-bit numbers using 8086 is executed and output is verified.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


93
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No:6a INTERFACING OF ANALOG TO DIGITAL CONVERTER USING

8085 MICROPROCESSOR

AIM

To convert a analog signal into a digital signal and display it in a field of 7 segment
display using 8085 microprocessor.

APPARATUS REQUIRED

1. 8085 Microprocessor Kit.


2. Interfacing Cable.
3. ADC interfacing module.

ALGORITHM

1. Start the program.


2. Initialize the port.
3. Send start of conversion pulse and channel address to the port.
4. Check if End of Conversion signal is low.
5. Check if Start of Conversion signal is high.
6. When conditions 3&4 are satisfied, send read pulse.
7. Read the digital output at the display data field.
8. Provide a delay of 5 seconds.
9. Precede the same from step 2 onwards.

PREREQUISITES
1. Which instructions are used to communicate 8085 with external peripherals?
2. What are the different types of ADC?
3. What is the significance of end of conversion signal while interfacing A/D converter to a
microprocessor?
4. Why ADC and DAc is used in the microprocessor based systems?
5. What is the need of D/A converter

94 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOWCHART:

95 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

CIRCUIT DIAGRAM:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


96 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

THEORY

The eight data output of ADC are connected to D0-D7 through a buffer 74LS244.
Provision is made to display the data output by means of LEDs using a latch 74LS374. This latch
is allotted by End of Conversion signal. Thus, after the conversion is completed, at the rising
edge of EOC, the 74LS374 latches the digital output of ADC. The LEDs which are connected to
output pins of the latch, display the data automatically.

The EOC of ADC can be connected to RST5.5, RST6.5, RST7.5. So the EOC output can
be used to interrupt the CPU in turn, can input the digital data from ADC.

Start of Conversion can be given externally using the SOC Switch available on the
board.

Thus the buffer 74LS244 which transfers the converted data outputs to data bus is
selected when,

A7 A6 A5 A4 A3 A2 A1 A0
1 1 0 0 1 X X X
= C8 (Hex).

The start of conversion can be given using software also. The flip-flop which transfers
the D0 line status to the SOC pin of the ADC is selected when,

A7 A6 A5 A4 A3 A2 A1 A0
1 1 0 1 0 X X X
=D0 (Hex).

The EOC output of ADC is transferred to the data line D0, when,

A7 A6 A5 A4 A3 A2 A1 A0
1 1 0 1 1 X X X
= D8 (Hex).

SRI KRSIHNA COLLEGE OF TECHNOLOGY


97 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS OPCODES COMMENTS


4100 START MVI A,10 3E 10 Select channel 0.
4102 OUT CNTL D3 C8 Make ALE1 low.
4104 MVI A,18 3E 18 Make ALE2 high.
4106 OUT CNTL D3 C8
4108 NOP 00 Delay.
4109 NOP 00 Delay.
410A REPEAT MVI A,01 3E 01 Select Channel 1.
Send Start of conversion
410C OUT SOC D3 D0
signal to Port.
410E NOP 00 Delay.
410F NOP 00 Delay.
4110 NOP 00 Delay.
4111 MVI A,00 3E 00 Make SOC low.
Send Start of conversion
4113 OUT SOC D3 D0
signal to Port.
Check for End of
4115 WAIT IN EOC DB D8
Conversion.
4117 ANI 01 E6 01 AND immediately 01.
4119 JZ WAIT CA 15 41 Jump on Zero.
411C IN ADC DAT DB C0 Read ADC data.
Move the contents of A
411E MOV B,A 47
register to B register.
411F ANI 0F E6 0F And immediately 0F.
4121 STA 4151 32 51 41 Store in accumulator.
Move the contents of B
4124 MOV A,B 78
register to A register.
4125 ANI 0F E6 0F And immediately 0F.
4127 RRC 0F Rotate Right Carry.
4128 RRC 0F Rotate Right Carry.
4129 RRC 0F Rotate Right Carry.
412A RRC 0F Rotate Right Carry.
412B STA 4150 32 50 41 Store in accumulator.
Move the data to
412E MVI A,03 3E 03
accumulator.
Move the data to C
4130 MVI C,08 0E 08
register.
Load HL register pair with
4132 LXI H,4150 21 50 41
the data.
4135 CALL 05 CD 05 00 Call system routine.
4138 JUMP REPEAT C3 0A 41 Jump to the routine.
413B STOP HLT 76 Stop the program.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


98 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROCEDURE:

1. The opcodes are entered using the microprocessor kit.


2. The ADC module is connected to the microprocessor using the Bus interfacing cable.
3. The analog inputs are given using the potentiometer in the ADC module. The LED in the
ADC module denotes the digital output.
4. The corresponding digital output is displayed in the 8085 microprocessor kit.
5. The digital output is verified using the 8421 code.

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites 2S
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


99 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE

RESULT

Thus the program to convert an analog signal to the corresponding digital signal using
8085 microprocessor is executed. The output is displayed in the 7 segment display of the 8085
kit and the output is verified.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


100
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No:6b INTERFACING OF DIGITAL TO ANALOG CONVERTER USING


8085 MICROPROCESSOR
AIM
To write an assembly language program using 8085 for analog to digital conversion
a) Square wave
b) Triangular wave

APPARATUS REQUIRED
1. 8085 Microprocessor trainer kit
2. CRO
3. DAC Interfacing kit.
A) SQUARE WAVE

ALGORITHM
1. Start the program
2. Move the minimum value of the square wave to the accumulator.
3. Move the accumulator contents to the output port.
4. Call the Delay subroutine.
5. Move the maximum value of the square wave to the accumulator.
6. Move the accumulator contents to the output port.
7. Call the Delay subroutine.
8. Jump to start of the program till the delay value becomes zero.
9. Delay Subroutine: Move the delay value to B register.
10. Loop 1: Move the maximum value of the wave to the C register.
11. Loop 2: Decrement the value of C register.
12. Jump on no zero of the C register to the loop 2.
13. Decrement the value of B register.
14. Jump on no zero of the B register to the loop 1.
15. Repeat the process.
OUTPUT

MODEL GRAPH

SRI KRSIHNA COLLEGE OF TECHNOLOGY


101 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

SQUARE WAVE

AMPLITUDE (Volts) TIME PERIOD(ms)

PROGRAM
ADDRESS LABEL MNEMONICS HEXCODES COMMENTS
Move the value 00 to
4100 START MVI A,00 3E 00
accumulator.
Send the value from the
4102 OUT C0 D3 C0
accumulator to the port.
4104 CALL DELAY CD 11 41 Call DELAY subroutine.
Move the value FF to the
4107 MVI A,FF 3E FF
accumulator.
Send the value from the
4109 OUT C0 D3 C0
accumulator to the port.
410B CALL DELAY CD 11 41 Call DELAY subroutine.
Jump to the START of
410E JMP START C3 00 41
the program.
Move the value 05 to B
4111 DELAY MVI B,05 06 05
register.
Move the value FF to C
4113 LOOP 1 MVI C,FF 0E FF
register.
Decrement the value of
4115 LOOP 2 DCR C 0D
C register.
Jump on non zero of the
4116 JNZ LOOP 2 C2 15 41 C register to the Loop 2
subroutine.
Decrement the value of
4119 DCR B 05
B register.
Jump on non zero of the
411A JNZ LOOP 1 C2 13 41 B register to the Loop1
subroutine.
411D RET C9 Return to the program.

B) TRIANGULAR WAVE

ALGORITHM
1. Start the program
2. Loop 1: Move the starting value of the triangular wave to the L register.
3. Move the value from the L register to the accumulator.
4. Move the accumulator contents to the output port.
SRI KRSIHNA COLLEGE OF TECHNOLOGY
102
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

5. Increment the value of L register.


6. Jump on no zero of the L register to Loop 1.
7. Move the maximum value of the triangular wave to the L register.
8. Loop 2: Move the value from the L register to the accumulator.
9. Move the accumulator contents to the output port.
10. Decrement the value of L register.
11. Jump on no zero of the L register to Loop 2.
12. Go to Step 1 and repeat the process again.
OUTPUT

MODEL GRAPH

TRIANGULAR WAVE

AMPLITUDE (Volts) TIME PERIOD(ms)

SRI KRSIHNA COLLEGE OF TECHNOLOGY


103 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS HEXCODES COMMENTS


4100 START MVI L,00 2E 00 Move the value 00 to l register.
Move the value from L register to
4102 LOOP 1 MOV A, L 7D
Accumulator.
Send the value from the
4103 OUT C0 D3 C0
accumulator to the port.
4105 INR L 2C Increment the value of L register.
4106 JNZ LOOP 1 C2 02 41 Jump on no zero to Loop 1.
4109 MVI L,FF 2E FF Send the value FF to L register.
Move the value from L register to
410B LOOP 2 MOV A, L 7D
Accumulator.
Send the value from the
410C OUT C0 D3 C0
accumulator to the port.
411E DCR L 2D Decrement the value of L register.
411F JNZ LOOP 2 C2 0B 41 Jump on no zero to Loop 2.
4112 JMP START C3 00 41 Jump to the Start of the program.

PROCEDURE
1. The opcodes are entered to the microprocessor
2. The address bus is connected between the two kits.
3. The CRO is connected.
4. Execute the program and check for the output displayed at the CRO each time you
execute.

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites 2S
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


104 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE:

RESULT
Thus an assembly language program for analog to digital conversion i.e., to obtain a
square wave and triangular wave using 8085 microprocessor was executed and the output was
verified.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


105
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex.No:7a INTERFACE OF KEYBOARD AND DISPLAY USING

PROGRAMMABLE CONTROLLERS

AIM

To interface 8279 programmable interface controller with 8085 microprocessor

APPARATUS REQUIRED

1. 8051 Microcontroller kit.


2. Keyboard.
3. 8279 interfacing module.

ALGORITHM

1. Start the program.


2. The control word for selecting the address line is C2. Initialize the data pointer by using
this control word.
3. Move data 00 to the accumulator.
4. Move the accumulator contents to the data pointer.
5. Move the command for clear display to the accumulator.
6. Move the accumulator contents to the data pointer.
7. Move the write display RAM command word format 90 to accumulator.
8. Move the accumulator contents to the data pointer.
9. The control word for selecting the address line is C0. Initialize the data pointer by using
this control word.
10. Move the segment value of alphabet A to the accumulator.
11. Move the accumulator contents to the data pointer.
12. Set some delay for display.
13. Stop the program.

PREREQUISITES:

1. What is key debouncing?


2. How a keyboard matrix is formed in keyboard interface using 8279
3. What is USART?
4. Define baud rate
5. Which pins of 8085 are used for serial communication?

SRI KRSIHNA COLLEGE OF TECHNOLOGY


106
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

THEORY

The 8279 is the keyboard and display controller.

The 8279 is selected when,

A7 A6 A5 A4 A3 A2 A1 A0
1 1 0 0 0 X X X
= C0 (Hex).

The control word for keyboard mode is when,

A7 A6 A5 A4 A3 A2 A1 A0
1 1 0 0 0 X 1 X
= C2 (Hex).

For display mode: 10 (Hex).

Control/status register is selected when,

A7 A6 A5 A4 A3 A2 A1 A0
1 1 0 0 0 X 0 X
=C0 (Hex).

The keyboard section of the 8279 interfacing module consists of 16 keys, besides two
keys for CNTL and SHIFT. With this keyboard it is possible to enter 64 different key codes.

Display is a 6-digit, multiplexed display. The decoded outputs are used to drive the
cathodes of the seven segment display. The output port lines A0-A3, B0-B3 drive the anodes of
the seven segment display.

Segment definitions of the seven segment display are shown below:

dp- Decimal point. 1-LED does not glow. 0-LED will glow.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


107 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Table below shows the correspondence between the data bus and output port bits of 8279.
Also, the segment relationships with these are given:

Data bus D7 D6 D5 D4 D3 D2 D1 D0
8279
A3 A2 A1 A0 B3 B2 B1 B0
Output
Segments D c b a dp g f e

In order to light up a segment, the corresponding bit of the data written into the display
RAM should be 0.

Eg., to display alphabet A, the control word is 1 0 0 0 1 0 0 0 = 88.

The command for keyboard and display mode is,

0 0 0 D D K K K

0 0 0 1 0 0 0 0
= 10 (Hex).

The command word format for the clear display is,

1 1 0 CD2 CD1 CD0 CF CA

1 1 0 0 1 1 0 0
= CC (Hex).

The write display RAM command word format is,

1 0 0 AI A A A A

1 0 0 1 0 0 0 0
= 90 (Hex).

AI-Auto Increment Flag.

AAAA-Selects one of the 16 rows of the Display RAM.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


108 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS OPCODE COMMENTS

4100 START LXI H,4500 24,00,45 Initialize the starting address

4103 MVI D,0F 16,0F Load the count value to D reg.

4105 MVI A,10 3E,10 The command word for set the
keyboard and display mode is
10(H)

4107 OUT CNT D3,C2 Send the control word to control


register

4109 MVI A,CC 3E,CC The command word for clear


display is CC.

410B OUT CNT D3,C2 Send the control word to control


register

410D MVI A,90 3E,90 The write display RAM command


word format is 90.

410F OUT CNT D3,C2 Send the control word to control


register

4111 LOOP MOV A,M 7E Move the data to accumulator

4112 OUT DAT D3,C0 Send the data to output port

4114 CALL DELAY CD,1F,41 Call the delay program

4117 INX H 23 Increment memory pointer

4118 DCR D 15 Decrement counter

4119 JNZ LOOP C2,11,41 If zero flag is reset go to loop

SRI KRSIHNA COLLEGE OF TECHNOLOGY


109 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

411C JMP START C3,00,41 Jump to the location 4100H

411F DELAY MVI B,A0 06,A0 Move the value A0 to B reg.

4121 LOOP2 MVI C,FF 0E,FF Move the value FF to C reg.

4123 LOOP3 DCR C 0D Decrement C register

4124 JNZ LOOP3 C2,23,41 If zero flag is reset go to loop3

4127 DCR B 05 Decrement B register

4128 JNZ LOOP2 C2,21,41 If zero flag is reset go to loop2

412B STOP RET C9 Return

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites 2S
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


110 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE:

RESULT

Thus an assembly language program using 8051 microcontroller to accept a key from the
keyboard and display it in the display is executed and the output is verified.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


111
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex. No: 7b INTERFACING USART


AIM

To write a program to interface programmable interval timer (8253) and USART (8251)
with 8085

APPARATUS REQUIRED

2. 8085 Microprocessor kit


3. 8253 and 8251 interface board
ALGORITHM

1. The value 36H to load into the accumulator and send through output port of 8253. The
control word of 8253 is written as 36H which indicates the timer is operates in mode 3.
2. Load LSB and MSB count value 0A and 00 into the accumulator and send through output
port
3. Initialize the mode of operation of USART
4. Load the value 37H to accumulator to enable the transmit and enable bits and send
through output port of 8251
5. The value to be transmitted is loaded into the accumulator and send through output port
6. The transmitted data is received from the output port of 8251
7. The received data is stored in the memory

THEORY

The 8251A is used as a peripheral device for serial communication and is programmed by
the CPU to operate using virtually any serial data transmission technique. The USART accepts
data characters from the CPU in parallel format and then converts them into a continuous serial
data stream for transmission. Simultaneously, it can receive serial data streams and convert them
into parallel data characters for the CPU.
The 8251 is selected with address,
1 1 0 0 0 X X X

SRI KRSIHNA COLLEGE OF TECHNOLOGY


112 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Since the address line A1 is connected to control/data input(C/D) of 8251,the control register of
8251 is selected when,
1 1 0 0 0 0 1 X
=C2 (Hex)
and the data register is selected with the address,
1 1 0 0 0 0 0 X
=C0 (Hex)
The two address lines A1 and A2 are connected to the pin A0(Pin 19) and (Pin 20) of 8253
respectively. Thus the I/O address for control register, Channel 0, Channel 1 and Channel 2 are
A7 A6 A5 A4 A3 A2 A1 A0 HEX
CONTROL REG. 1 1 0 0 1 1 1 0 CE
CHANNEL 0 1 1 0 0 1 1 0 0 C8
CHANNEL 1 1 1 0 0 1 1 1 0 CA
CHANNEL 2 1 1 0 0 1 1 0 0 CC

The control word 37H enables the transmit enable and receive enable bits, forces DTR output to
zero, resets the error flags, and forces RTS output to zero..

SRI KRSIHNA COLLEGE OF TECHNOLOGY


113 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


4100 MVI A,36 3E,36 The timer is operated in mode
3.The control word for mode 3
is 36H.
4102 OUT CE D3,CE Send the control word to
output port
4104 MVI A,0A 3E,0A LSB of count is moved to acc.
4106 OUT C8 D3,C8 Send the word to output port of
8253
4108 MVI A,00 3E,00 MSB of count is moved to acc.
410A OUT C8 D3,C8 Send the control word to
output port of 8253
410C MVI A,4E 3E,4E The command word for
initializing synchronous mode
USART is 4EH
410E OUT C2 D3,C2 Send the control word to
output port of 8251
4110 MVI A,37 3E,37 Move the value 37H to acc.
4112 OUT C2 D3,C2 Send the control word to
output port of 8251
4114 MVI A,23 3E,23 The value 23H to be
transmitted is moved to
accumulator
4116 OUT C0 D3,C0 Send the data to output port of
8251
4118 RST 1 CF
4200 IN C0 DB,C0 Get the data from output port
4202 STA 4150 32,50,41 Store the received value in
4150H

SRI KRSIHNA COLLEGE OF TECHNOLOGY


114 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

4205 RST 1 CF

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites 2S
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


115 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE:

RESULT
Thus the program for interfacing 8253 and 8251 with 8085 microprocessor is performed
and the data is transmitted and received.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


116
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

GENERAL INTRODUCTION OF 8051

The Intel MCS-51 (commonly referred to as 8051) is a Harvard architecture, single chip
microcontroller (C) series which was developed by Intel for use in embedded systems.

The 8051 architecture provides many functions in a single package. It consists of,

1. 8-bit ALU, Accumulator and 8-bit Registers. Hence it is an 8-bit microcontroller.


2. 8-bit data bus. Hence it can access 8 bits of data in one operation
3. 16-bit address bus. Hence it can access 216 memory locations 64 KB (65536
locations) each of RAM and ROM.
4. On-chip RAM 128 bytes (data memory).
5. On-chip ROM 4 kByte (program memory).
6. Four byte bi-directional input/output port.
7. UART (serial port).
8. Two 16-bit Counter/timers.
9. Two-level interrupt priority.
10. Power saving mode.

One particularly useful feature of the 8051 core was the inclusion of a Boolean
processing engine which allows bit-level Boolean logic operations to be carried out directly and
efficiently on select internal registers and select RAM locations. This advantageous feature
helped cement the 8051's popularity in industrial control applications because it reduced code
size by as much as 30%. Another valued feature is the inclusion of four bank selectable working
register sets which greatly reduce the amount of time required to complete an interrupt service
routine. These registers also allowed the 8051 to quickly perform a context switch which is
essential for time sensitive real-time applications.

The MCS-51 UARTs make it simple to use the chip as a serial communications interface.
External pins can be configured to connect to internal shift registers in a variety of ways, and the
internal timers can also be used, allowing serial communications in a number of modes, both
synchronous and asynchronous. Some modes allow communications with no external
components.

Once a UART, and a timer have been configured, the programmer needs only to write a
simple interrupt routine to refill the send shift register whenever the last bit is shifted out by the
UART and/or empty the full receive shift register. The main program then performs serial reads
and writes simply by reading and writing 8-bit data to stacks.

MCS-51 based microcontrollers typically include one or two UARTs, two or three timers,
128 or 256 bytes of internal data RAM), up to 128 bytes of I/O, 512 bytes to 64 kB of internal
program memory, and sometimes a quantity of extended data RAM (ERAM) located in the
external data space. The original 8051 core ran at 12 clock cycles per machine cycle, with most
instructions executing in one or two machine cycles. With a 12 MHz clock frequency, the 8051
could thus execute 1 million one-cycle instructions per second or 500,000 two-cycle instructions
per second. Enhanced 8051 cores are now commonly used which run at six, four, two, or even

117 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

one clock per machine cycle, and have clock frequencies of up to 100 MHz, and are thus capable
of an even greater number of instructions per second.

MEMORY ARCHITECTURE

The MCS-51 has four distinct types of memory internal RAM, special function
registers, program memory, and external data memory.

Internal RAM (IRAM) is located from address 0 to address 0xFF. Special function
registers (SFR) are located from address 0x80 to 0xFF, and are accessed directly using the same
instructions as for the lower half of IRAM. Some of the SFR's are also bit-addressable.

Program memory (PMEM) is located starting at address 0. It may be on- or off-chip,


depending on the particular model of chip being used. Program memory is read-only, though
some variants of the 8051 use on-chip flash memory and provide a method of re-programming
the memory in-system or in-application. Aside from storing code, program memory can also
store tables of constants that can be accessed by MOVC A, @DPTR, using the 16-bit special
function register DPTR.

External data memory (XRAM) also starts at address 0. It can also be on or off-chip. It
must be accessed using the MOVX (Move external) instruction. Many variants of the 8051
include the standard 256 bytes of IRAM plus a few KB of XRAM on the chip. If more XRAM is
required by an application, the internal XRAM can be disabled, and all MOVX instructions will
fetch from the external bus.

STUDY OF MICROPROCESSOR KIT:

The 8051 Microprocessor Laboratory Kit consists of the following:

80(C)51 Microcontroller at 12 MHz or equivalent.

Memory:

Program Memory RAM - 32KB.


Data Memory RAM - 32KB
Program Memory EPROM - 32KB

Keyboard & Display:

Onboard 16 x 2 Alphanumeric LCD Interface


Onboard IBM PC Keyboard Interface
IBM PC Keyboard
Parallel I/O, Serial I/O & Expansion :

118 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Onchip RS232 Compatible Serial Interface terminated in a 9 Pin 'D' Male


Connector
One RS232 Cable
48 TTL I/O lines using 8255 terminated in two 26 Pin FRC Connectors
All CPU address, data, and control signals are terminated in a 50 pin FRC
Connector
All connections of the Microcontroller are terminated in a separate connector
for expansion.

Software:

Built-in Line assembler & Disassembler.


Powerful Debugging monitor to develop user program.

Built-in SMPS Power Supply:

Input : 230V AC @ 50 Hz
Output : +5 Volts / 1 Amp

Accessories:
Windows based debugger software.

PROGRAM EXECUTION
To execute a program, the microcontroller should be directed to the starting address of
the program. The microcontroller begins the execution of the program by following the first
machine code. The controller decodes the code by matching it with its predefined set of
instructions and performs the specified task. Fetching, decoding and performing the task are
continued one after the other and sequentially till the controller is instructed to halt. To encode a
program stored in specified set of memory locations the procedure adopted are as follows:

The program is entered through the Keyboard which is interfaced with the
microprocessor kit.

1. Type letter A in the keyboard to go to the starting address of the program.


2. Enter the starting address.
3. Then enter the program.
4. Type letter U in the keyboard and then enter the starting address to verify the
entered program.
5. Press RESET key and type GO <STARTING ADDRESS> to execute the program.
6. Type SU ADDRESS to give the input data or to check for the output.

119 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex. No: 8a ARITHMETIC OPERATIONS USING 8051


AIM
To write a program in 8051 to perform arithmetic operation like
1. Addition
2. Subtraction
3. Multiplication
4. Division
APPARATUS REQUIRED
1. 8051 microcontroller kit
2. Key board

PRERQUISITES:
1. What are the major components of 8051?
2. What is the role of DPTR?
3. -------------- instruction is used to perform multiplication operation
4. instruction is used to perform division operation
5. Where will quotient and remainder get stored during division operation?
6. What is the use of SJMP?
7. Name some applications of 8051

120 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

1. ADDITION
ALGORITHM
1. Start the program
2. Get the first operand in accumulator
3. Add second operand with first operand in accumulator
4. Move data from accumulator to data pointer
5. Store the result in memory
6. Stop the program

FLOWCHART:

PROGRAM

SRI KRSIHNA COLLEGE OF TECHNOLOGY


121
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

ADDRESS LABEL OPERAND OPCODE COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


122 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

2. SUBTRACTION
ALGORITHM
1. Start the program
2. Get the first operand in accumulator
3. Subtract the second operand from first operand in accumulator
4. Move data from accumulator to data pointer
5. Store the result in memory
6. Stop the program

SRI KRSIHNA COLLEGE OF TECHNOLOGY


123 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL OPERAND OPCODE COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


124 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

3. MULTIPLICATION
ALGORITHM
1. Start the program
2. Get the multiplier in A register
3. Get the multiplicand in B register
4. Multiply accumulator content and B register content
5. Store the result in memory
6. Stop the program
FLOWCHART:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


125
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL OPCODE OPERAND COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


126 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

4. DIVISION
ALGORITHM
1. Start the program
2. Get the multiplier in A register
3. Get the multiplicand in B register
4. Multiply accumulator content and B register content
5. Store the result in memory
6. Stop the program

SRI KRSIHNA COLLEGE OF TECHNOLOGY


127 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL OPCODE OPERAND COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


128 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites 2S
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


129 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE:

RESULT:

Thus the basic arithmetic and logical operations using 8051was studied.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


130
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

Ex. No: 8b SUM OF ELEMENTS USING STACK AND CALL OPTIONS

AIM:
To find the sum of elements in an array using stack and call option.

APPARATUS REQUIRED
1. 8051 microcontroller kit
2. Key board

131 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

1. Stack Operation:
ALGORITHM:
1. Start
2. Move the data to DPTR
3. Move the data to accumulator
4. Adjacent call 4200
5. Add A & R0
6. Move the 16 bit data from A to DPTR
7. Move the data to accumulator
8. Move the data to R0
9. Return to 4107

SRI KRSIHNA COLLEGE OF TECHNOLOGY


132 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL OPCODE OPERAND COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


133 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

2. Call Operation:

ALGORITHM:
1. Start
2. Move the data to DPTR
3. Move the data to accumulator
4. Adjacent call 4200
5. Add A & R0
6. Move the 16 bit data from A to DPTR
7. Move the data to accumulator
8. Move the data to R0
9. Return to 4107

SRI KRSIHNA COLLEGE OF TECHNOLOGY


134 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM

ADDRESS LABEL OPCODE OPERAND COMMENTS

SRI KRSIHNA COLLEGE OF TECHNOLOGY


135 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EXECUTION

INPUT OUTPUT
ADDRESS VALUE ADDRESS VALUE

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites 2S
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


136 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE:

RESULT
Thus the program sum of elements using stack and call operations were executed.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


137
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EX. No 9a INTERFACING STEPPER MOTOR WITH 8051

AIM:

To interface a stepper motor with 8051 microcontroller and operate it.

PREREQUISITES:
1. What is stepper motor?
2. How to reverse the rotation of stepper motor?
3. What is step angle?
4. What do you mean by half stepping and full stepping stepping?

THEORY:
A motor in which the rotor is able to assume only discrete stationary angular position is a
stepper motor. The rotary motion occurs in a step-wise manner from one equilibrium position to
the next. Stepper Motors are used very wisely in position control systems like printers, disk
drives, process control machine tools, etc.

The basic two-phase stepper motor consists of two pairs of stator poles. Each of the four
poles has its own winding. The excitation of any one winding generates a North Pole. A South
Pole gets induced at the diametrically opposite side. The rotor magnetic system has two end
faces. It is a permanent magnet with one face as South Pole and the other as North Pole.

The Stepper Motor windings A1, A2, B1, B2 are cyclically excited with a DC current to
run the motor in clockwise direction. By reversing the phase sequence as A1, B2, A2, B1,
anticlockwise stepping can be obtained.

2-PHASE SWITCHING SCHEME:

In this scheme, any two adjacent stator windings are energized. The switching scheme is
shown in the table given below. This scheme produces more torque.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


138 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

ANTICLOCKWISE CLOCKWISE
STEP A1 A2 B1 B2 DATA STEP A1 A2 B1 B2 DATA

1 1 0 0 1 9h 1 1 0 1 0 Ah

2 0 1 0 1 5h 2 0 1 1 0 6h

3 0 1 1 0 6h 3 0 1 0 1 5h

4 1 0 1 0 Ah 4 1 0 0 1 9h

ADDRESS DECODING LOGIC:

The 74138 chip is used for generating the address decoding logic to generate the device
select pulses, CS1 & CS2 for selecting the IC 74175.The 74175 latches the data bus to the
stepper motor driving circuitry.

Stepper Motor requires logic signals of relatively high power. Therefore, the interface
circuitry that generates the driving pulses use silicon darlington pair transistors. The inputs for
the interface circuit are TTL pulses generated under software control using the Microcontroller
Kit. The TTL levels of pulse sequence from the data bus is translated to high voltage output
pulses using a buffer 7407 with open collector.

BLOCK DIAGRAM:

8051
8255 DRIVER CIRCUIT STEPPER MOTOR
MICROCONTROLLER

SRI KRSIHNA COLLEGE OF TECHNOLOGY


139 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM :
ADDRESS LABEL OPCODE OPERAND COMMENTS

ORG 4100h

4100 START: MOV DPTR, #TABLE Load the start address of


switching scheme data
TABLE into Data Pointer
(DPTR)

4103 MOV R0, #04 Load the count in R0

4105 LOOP: MOVX A, @DPTR Load the number in TABLE


into A

4106 PUSH DPH Push DPTR value to Stack

4108 PUSH DPL

410A MOV DPTR, #0FFC0h Load the Motor port address


into DPTR

410D MOVX @DPTR, A Send the value in A to stepper


Motor port address

410E MOV R4, #0FFh Delay loop to cause a specific


amount of time delay before
4110 DELAY MOV R5, #0FFh next data item is sent to the
: Motor
4112 DELAY DJNZ R5, DELAY1
1:

4114 DJNZ R4, DELAY

4116 POP DPL POP back DPTR value from


Stack
4118 POP DPH

411A INC DPTR Increment DPTR to point to


next item in the table

411B DJNZ R0, LOOP Decrement R0, if not zero


repeat the loop

SRI KRSIHNA COLLEGE OF TECHNOLOGY


140 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

411D SJMP START Short jump to Start of the


program to make the motor
rotate continuously

411F TABLE: DB 09 05 06 0Ah Values as per two-phase


switching scheme

PROCEDURE:
1. Enter the above program starting from location 4100.and execute the same.
2. The stepper motor rotates.
3. Varying the count at R4 and R5 can vary the speed.
4. Entering the data in the look-up TABLE in the reverse order can vary direction of
rotation.

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites 2S
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


141 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE:

RESULT:

Thus a stepper motor was interfaced with 8051 and run in forward and reverse directions
at various speeds.

SRI KRSIHNA COLLEGE OF TECHNOLOGY


142
MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

GENERAL INSTRUCTIONS ABOUT PIC:

PIC is abbreviated as Peripheral Interface Controller.

Microcontroller PIC16F877A is one of the PIC Micro family microcontrollers which is popular
at this moment, start from beginner until all professionals. Because of its user friendly nature and
use of flash memory technology where programs can be read and written thousand times.
PIC16F877A has 40 pins in which 33 are I/O pins. Hence PIC16F877A perfectly fits in to many
uses, from automotive industries and controlling home appliances to industrial instruments,
remote sensors, electrical door locks and safety devices. It is also ideal for smart cards as well as
for battery supplied devices because of its low consumption.

EEPROM memory makes it easier to apply microcontrollers to devices where permanent storage
of various parameters is needed (codes for transmitters, motor speed, receiver frequencies, etc.).
Low cost, low consumption, easy handling and flexibility make PIC16F877A applicable even in
areas where microcontrollers had not previously been considered (example: timer functions,
interface replacement in larger systems, coprocessor applications, etc.).
In System Programmability of this chip (along with using only two pins in data transfer) makes
possible the flexibility of a product, after assembling and testing have been completed. This
capability can be used to create assembly-line production, to store calibration data available only
after final testing, or it can be used to improve programs on finished products.

4.2 PIC FAMILY

PIC Microcontroller MCU from Microchip Company divided into 4 large families. Each families
has a variety of components that provide built-in special features.
Evolution of PIC

The third family is PIC16(16FXXX)

With six variants ranging from 3.5K-14K bytes of Flash memory, up to 256 bytes of RAM and a
mix of peripherals including USART, CCP and onboard and comparators. These devices are well
suited for designers with applications that need more code space or I/O than 14-pin variants
supply, and are looking to increase system performance and code efficiency by employing
hardware motor control and communications capability.

4.3 FEATURES OF PIC


4.3.1 HIGH PERFORMANCE RISC CPU
Only 35 single word instructions to learn
All single-cycle instructions except for program branches, which are two-cycle
Operating speed: DC-20 MHz clock input DC-200 ns instruction cycle
Up to 8K x 14 words of Flash Program Memory, up to 368 x 8 bytes of Data Memory
(RAM), up to 256 x 8 bytes of EEPROM Data Memory.
Pin out compatible to other 28-pin or 40/44-pin PIC16CXXX and PIC16FXXX
microcontrollers.

143 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

4.3.2 PERIPHERAL FEATURES


Timer 0: 8-bit timer/counter with 8-bit pre scalar
Timer 1: 16-bit timer/counter with pre scalar can be incremented during Sleep via
external crystal/clock.
Timer 2: 8-bit timer/counter with 8-bit period register, pre scalar and post scalar.
Two Capture, Compare, PWM modules.
Capture is 16-bit, max. Resolution is 12.5 ns.
Compare is 16-bit, max. Resolution is 200 ns.
PWM max. Resolution is 10-bit.
Synchronous Serial Port (SSP) with SPI(Master mode) and I2C (Master/slave).
Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-bit
address detection.
Parallel Slave Port (PSP)-8 bits wide with external RD, WR and CS controls (40/44-
pin only).
4.3.3 ANALOG FEATURES
10-bit, up to 8-channel analog to digital converter(A/D).
Brown-Out Reset (BOR)
Analog comparator module with two analog comparators.
Programmable on chip voltage reference (VREF0 module.

144 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

4.4 PIC16F877A ARCHITECTURE

PIC ARCHITECTURE:

145 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

4.4.1 PIN DIAGRAM

Pin Diagram of PIC

146 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

EX.NO 10. BASIC ARITHMETIC OPERATIONS USING PIC MICROCONTROLLER


AIM:
To perform the basic arithmetic operations using PIC microcontroller.

APPARATUS REQUIRED

PRERQUISITES:

147 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

1. ADDITION:
ALGORITHM:

FLOWCHART:

148 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM:
main

var1, var2

movf var1,w ; W = var1 + var2

addwf var2,w

END

OUTPUT:

2. SUBRACTION:
ALGORITHM:

149 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOWCHART:

PROGRAM:
A AND B TWO 16 BIT NUMBERS

(AH:AL)-(BH:BL)=(AH:AL)

main

SUBTRACT:

MOVF BL,W

SUBWF AL,F

BTFSS STATUS,C

DECF AH,F

MOVF,W

SUBWF AH,F

END

150 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

OUTPUT:

3. MULTIPLICATION:
ALGORITHM

151 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

FLOWCHART:

152 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM:
main

movlw 0

bcf C

btfss n1,0

addwf n2,w

rlf n2,f

btfss n1,1

addwf n2,w

rlf n2,f

btfss n1,2

addwf n2,w

rlf n2,f

btfss n1,3

addwf n2,w

rlf n2,f

swapf n2,f

END

OUTPUT:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


153 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

4. DIVISION:

ALGORITHM

FLOWCHART:

154 SRI KRSIHNA COLLEGE OF TECHNOLOGY


MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

PROGRAM:
main

Div3: ; Divide Contents of "w" by 3

movwf Dividend

clrf Quotient

Div3_Loop ; Loop Until the Dividend == 0

bcf STATUS, C

rrf Dividend, f ; Dividend /2 (ie "x/2" in Series)

movf Dividend, w ; Is it Equal to Zero?

btfsc STATUS, Z

goto Div3_Done ; If it is, then Stop

addwf Quotient ; Add the Value to the Quotient

rrf Dividend, f ; Dividend /2 (ie "x/4" in Series)

movf Dividend, w

btfsc STATUS, Z

goto Div3_Done

subwf Quotient, f ; Quotient = Quotient-(Dividend / 4)

goto Div3_Loop

Div3_Done

movf Quotient, w ; Return the Quotient

return

END

SRI KRSIHNA COLLEGE OF TECHNOLOGY


155 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

OUTPUT:

EVALUAVTION

S.NO CONTENTS MAX. MARKS


MARK OBTAINED
1 Prerequisites 2S
2 Conduction 1
3 Execution 1
4 Inference 2
5 Total 6

SRI KRSIHNA COLLEGE OF TECHNOLOGY


156 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
EX NO:.. DATE:

INFERENCE:

RESULT:

SRI KRSIHNA COLLEGE OF TECHNOLOGY


157
MICROPROCESSOR AND MICROCONTROLLER LABORATORY

Potrebbero piacerti anche