You are on page 1of 80

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

Vi INSTITUTE OF TECHNOLOGY
SIRUNKUNDRAM-603108
Department of Electronics and Communication Engineering

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


EC2308- MICROPROCESSORS AND MICROCONTROLLERS LAB

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

EXPERIMENTS IN SYLLABUS
8086 PROGRAMING
1.
2.
3.
4.

Programs for 16 bit arithmetic Operations


Programs for Sorting and searching
Programs for String Manipulation
Programs for Digital clock

INTERFACING EXPERIMENTS
1. Interfacing ADC and DAC
2. Interfacing with 8279,8259,8253.
3. Interfacing with stepper Motor and DC motor
COMMUNICATION BETWEEN TWO MP KIT
1. Serial Communication Between Two MP kit using 8251.
2. Parallel Communication Between Two Mp kit using Mode 1 and mode 2 of 8255.
8051 PROGRAMMING
1. Programming using Arithmetic,Logical,bit Manipulation
2. Programing in Timer,Interrupt,UART
3. Communication b/w 8051 and PC.

Branch: Electronics and Communication Engineering

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

CONTENTS
Sl.No

Date

Experiment

Page
No

Signature

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

EX NO :
DATE

STUDY OF 8086 KIT


:

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

AIM
To study about the 8086 microprocessor kit.
HARDWARE SPECIFICATIONS
1. CPU PROCESSOR AND CLOCK FREQUENCY
Intel 8086/8088 CPU at 5/4.77 MHz clock rate [Optionally 8 MHz]
2. MEMORY
MONITOR EPROM: F000:0000 - 3FFF for 16 K
EPROM EXPANSION: F000:0000 - 1FFF for 64 K
SYSTEM RAM: 0000:1000 - 3FFF for 16 K
SYSTEM RAM EXPANSION: 0000:1000 - FFFF for 64 K
INTERRUPT VECTORS: 0000:0000 - 03FF
3. PERIPHERALS
PARALLEL I/O: 48 I/O lines using two numbers of 8255.
SERIAL: One number of RS232C - Serial Interface using8251A USART.
TIMER: 3 Channel 16-bit Programmable Timer 8253. Channel0 used as baud rate generator
for the Serial Port.
4. DISPLAY
162 LCD DISPLAY [with Back light provision]
5. KEYBOARD
IBM PC-AT KEYBOARD
6. ON-BOARD BATTERY BACKUP: (Optional)
Onboard battery backup facility is optionally provided for RAM (U2 & U4).

7. POWER CONSUMPTION
+ 5 V: 1.5 Amps

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

8. POWER SUPPLY SPECIFICATIONS


Model: SMPS-01
Mains: 230 Volts AC at 50 Hz
Input: 230V AC at 50H
Output: 1) + 5 Volts, 3 amps regulated
2) + 12 Volts, 250 mA regulated
3) - 12 Volts, 250 mA regulated
4) +30 Volts, 250 mA unregulated
9. PHYSICAL CHARACTERISTICS
M - 86/88 LCD trainer PCB: 830 mm x 680 mm
10. BUS EXPANSION
A new concept of VXT_Bus has been incorporated in M - 86/88 LCD trainer which
facilitates addition of extra hardware on to M - 86/88 LCD trainer. Anunlimited number of
Add-OnBoards can be add to this Expansion Bus. All buffered address, data and control
signals are brought out to this bus. The trainer provision for one VXT_Bus connectors

SOFWARE SPECIFICATIONS

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

COMMAND LINE EDITOR FEATURES


i) Single line editor can process upto 40 characters.
ii) Valid key functions are:

1. ASSEMBLER COMMAND
FUNCTION
This command is used to enter the mnemonics of 8086 and it gives the opcode for the
Mnemonics.
SYNTAX
#A <CR>
A - Line Assembler Command.

PROCEDURE
1. After entering the 'A' command, the kit is displayed as follows

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

2. Then, it asks the starting address

Now, you entered the user RAM address and programs, for every mnemonics for 8086
entered,
it gives the opcode.
2. DIS-ASSEMBLER COMMAND
FUNCTION
This command gives the mnemonics and corresponding opcode in the given address.
SYNTAX
#U <CR>
U - Dis Assembler Command.
PROCEDURE
1. After entering the 'U' command, the kit is displayed as follows.

2. Then, if you enter the starting address

3. SUBSTITUTE MEMORY COMMAND


FUNCTION
This command is used to examine the contains of selected memory location and modify the
RAM contents if desired.
SYNTAX
i) #SB <ADDR> <CR>
SB - Substitute byte command word
<ADDR> - User can enter the address either in segment:
offset form or only offset form
<CR> - keyboard Return
ii) #SW <ADDR> <CR>

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

SW - Substitute word command word.


<ADDR> - Address either segment:
Offset or only.
<CR> - Keyboard return.
PROCEDURE
1) After entering a substitute command, the contents of that address are displayed as
Follows.

2) Use enter to examine the next location or to increment the memory location and the '--'
key to view previous locations. ie. to decrement the memory location.
3) To modify the contents, enter the new data and press enter key.
4) To terminate this command press a dot (.)

4. REGISTER COMMAND
FUNCTION
To examine and modify the register contents of the CPU.
SYNTAX
#R <R>
R - Register view / modify command word.
PROCEDURE
i) Enter register command when prompted for entry.
ii) Initially "AX" register is displayed

iii) Press enter or "-" key to view the subsequent or the previous register in the order as given
in the table below.

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

iv) Change data to any register if desired and press carriage return
v) The sequence is circular and there fore apressing enter key after the last register order,
Will again display the first one.
vi) To terminater this command press dot (.)
5. GO & EXEC COMMAND
FUNCTION
The GO command us used to Run a program. This command transfers control of the 8086A
CPU from the monitor program to user programs.
SYNTAX
# GO <ADDR> <CR>
GO - GO Command.
<ADDR> - 16 bit address. either segment : offset or offset only)
<CR> - Carriage return.
PROCEDURE
i) Type GO command with address from where execution should start.
ii) Now, the control is transferred to the address entered by you and the display will be as
shown below.

iii) To exit from the execution and to return control to the monitor, press reset key or
Interrupt key in the kit.
iv) By using INT-2 instruction with opcodes CD01, you can transfer control to monitor
without saving any registers. CD, 02 should be placed at the end of the program
6. TRACE COMMAND
FUNCTION
This command helps the user to execute programs in steps i.e instruction. This command will
be very helpful while debugging programs.
DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

SYNTAX
#TR <Addr> <CR>
TR - Trace command word.
<Addr> - Program starting Address. (segment : offset of offset only)
<CR> - Carriage Return.
PROCEDURE
i) Enter the Trace command with the above syntax.
ii) Now the first instruction is executed an the registers are updated.
iii) The next instruction to be executed and the memory location are displayed.
iv) Since, registers are updated after each individual instruction, you can view the register
contents after any execution of individual instruction.
v) Press dot (.) to return to monitor and view registers or memory locations are desired.
vi) Continue single stepping after viewing register contents by again executing trace
command

7.BLOCK MOVE COMMAND


FUNCTION
This command moves the contents of a specified block of memory to another block whose
starting address is specified [to RAM].
SYNTAX
i) #MB <Start Addr> <End Addr> <Dest Addr> <CR>
MB - Block move byte command word.
<Start Addr> - Block starting address.(segment : offset or offset only)
<End Addr> - Block Ending Address.(offset only)
<Dest Addr> - Destination Address.(segment : offset or offset only)
<CR> - Carriage return.
ii) #MB <Start Addr> <End Addr> <Dest Addr> <CR>
MB - Block move word command .
<Start Addr> - Block starting address.(segment : offset or offset only)
<End Addr> - Block Ending Address.(offset only)
<Dest Addr> - Destination Address.(segment : offset or offset only)
<CR> - Carriage return.
PROCEDURE
i) Enter th Block Move Command with the above syntax.
ii) Now, the data is moved from source block to destination block and the control is
transferred to monitor program.
iii) Address can be monitored in the display throughout the move block function

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

8.INPUT COMMAND
FUNCTION
This command inputs data from the desired port.
SYNTAX
i) #IB <Port Address> <CR>
IB - Input Byte command word.
<Port Addr> - Valid Input Address. (i.e 0000 to FFFFH).
<CR> - Carriage return.
ii) #ISW <Port Addr> <CR>
IW - Input word command
PROCEDURE
i) Enter IB command in the above stated syntax.
ii) Now, the data would be read and displayed as shown below.

9.SERIAL MONITOR COMMAND


FUNCTION
Using these serial monitor command you can operate your trainer through computer. before
that
you will connect RS232C cable (proper configuration) to the computer to any one of the
serial
port.

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

10.SERIAL INPUT COMMAND


FUNCTION
This command inputs data from the 8251 port of M - 86/88 LCD trainer asynchronously.
SYNTAX
#SI <Start Addr> <CR>
SI - Serial input command word.
<Start Addr> - Address to store the serial input data.
<CR> - Carriage return.
PROCEDURE
i) Enter the serial input command in the above said format.
ii) Now, transmit data from the host system.(Pls refer to 'Note -2' for further discussion
contact DATA TRANSMISSION FROM HOST SYSTEMS)
iii) The M - 86/88 LCD trainer received data and stores it from the given starting address and
returns to the command prompt on receiving the EOF MARK.(Ref Note-2)
iv) Using substitute memory command check for the data from the starting address specified.
11.SERIAL OUTPUT COMMAND
FUNCTION
This command outputs data serially through the 8251 of the M - 86/88 LCD trainer
asynchronously.
SYNTAX
#SO <Start Addr> <End Addr> <CR>
SO - Serial output command word.
<Start Addr> - Start address of the transmit data block.(Segment : offset or offset
only).
<End Addr> - End Address of the transmit data block (offset only)
<CR> - Carriage return.
PROCEDURE
i) Enter the serial output command in the above said format.
ii) Ensure that the const system is set in the receive mode.
iii) Now, data will be transmitted serially. M - 86/88 LCD trainer returns to command
prompt after data transmission is over.

RESULT

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

16 BIT ARITHMETIC OPERATION


EX NO: 2
DATE:
AIM
To perform 16 bit Arithmetic operation such as addition, subtraction, Multiplication,
division using 8086 Microprocessor Kit.
APPARATUS REQUIRED
S.no

Required Components

specification

Qty

1.

MICROPROCESSOR

MICRO 86/88 KIT

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

THEORY
The "add" instruction requires either the addend or the augend to be in a register,
unless the source operand is immediate since the addressing modes permitted for the source
and destination are register-register, memory-register, register -memory, register-immediate,
and finally memoryimmediate. Our objective is to obtain the sum of two numbers in
memory.Hence one of the operands is initially moved to AX. Then using the add instruction,
16 bitaddition is performed.
The next arithmetic primitive is SUB. As discussed in ADD it permits the same modes of
addressing. Hence moving the minuend to a register pair is necessary. Then the result is
movedto a location in memory.
Unlike most of the 8 bit processors which do not have an arithmetic multiply
instruction, 16 bit processors from 8086 upward provide both signed and unsigned multiply
in their instruction sets to overcome the loss of efficiency in performing repeated addition.
The MUL instruction can have both 16 and 8 bit operands and the multiplicand is AX or AL,
accordingly the result for a byte multiply is a 16 bit number in AX while that for a word
multiply is a 32 bit number, the lower word of which is in AX and the higher word in DX.
Using the DIV instruction of 8086, both division of a double word by a word and a
word by a
byte can be performed. For the first case, the lower order word of the dividend is in AX and
the higher order word is in DX. The quotient is in AX and remainder in DX. For the second
case, the dividend is in AL, the quotient is in AL and the remainder in AH.

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

FLOW CHART

ALGORITHM
(i) 16-bit addition
Get the first number.
Add the second number to the first number.
Store LSBs of sum.
Store MSBs of sum
PROGRAM FOR ADDITION
Memory address

Opcodes

Mnemonics
MOV AX, [1100]

Comments
Load the data into 16 bit
register AX from the memory
1100

ADD AX,[1102]

Add accumulator content with


the data in the memory
1102.The result will be stored
in the accumulator AX
Store the data byte from Axin
to the memory address 1200
Terminate the program

MOV [1200], AX
HLT

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

EXAMPLE

OBSERVATION

Let us add two numbers in locations 1100


and 1102 and store the result at 1200.
Input: [1100] = 1234
[1102] = 5678
Result: [1200] = 68AC
FLOW CHART FOR SUBTRACTION

ALGORITHM
(ii) 16-bit subtraction
Get the first number
Subtract the second number from the first number.
Store LSBs of difference
Store MSBs of difference.

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

PROGRAM FOR SUBTRACTION


Memory address

Opcodes

Mnemonics
MOV AX, [1100]

Comments
Load the data into 16 bit
register AX from the memory
1100

SUB AX,[1102]

subtract accumulator content


with the data in the memory
1102.The result will be stored
in the accumulator AX
Store the data byte from Axin
to the memory address 1200

MOV [1200], AX
HLT

Terminate the program

EXAMPLE

OBSERVATION

Input: Minuend : [1100] = 9999


Subtratend :[1102] = 369C
Result:

[1200] = 63FD

PROGRAM FOR MUTIPLICATION


Memory address

Opcodes

Mnemonics
MOV AX, [1100]
MOV BX,[1102]
MUL BX.

MOV [1200],DX
MOV [1202], AX
HLT

Comments
Load the data into 16 bit
register AX from the memory
1100.
Load the data in to BX register
from the memory 1102.
Multiply the Accumulator
content
with
the
BX
register.The higher order byte
will be stored in DX register
and the Lower order byte will
be stored in the AX register.
Move the DX content to 1200
Move the AX content to 1202.
Terminate the progream

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

EXAMPLE

OBSERVATION

Multiply the 16 bit numbers:


FEDC and BA98 at 1100 and 1102
Input: [1100] = FEDC
[1102] = BA98
Result: [1200] = B9C3
[1202] = 2AA0
PROGRAM FOR DIVISION
Memory address

Opcodes

Mnemonics
MOV DX, [1100]
MOV AX, [1102]
MOV CX,[1104]
DIV CX

Comments
Load the data into 16 bit
register DX from the memory
1100.
Load the data in to AX register
from the memory 1102.
Load the data in to CX register
from the memory 1104.
Divide the DX and
AX content by CX and the
result will be stored in DX and
AX
Move the AX content to 1200

MOV [1200], AX

Move the DX content to 1202

MOV [1202], DX
.
Terminate the progream
HLT

EXAMPLE
Data: Dividend : [1100] = 0000
[1102] = FFFF
Divisor : [1104] = FFFF
Result:Quotient: [1200] = 0001

OBSERVATION

Remainder: [1202] = 0000

PROCEDURE

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

Enter the Mnemonics starting from the RAM address1000 by using (A command).
Enter the two input data in the location 1100 and 1102 using (SB command)
Execute the program with the command (GO starting address).
Check the corresponding result in the location 1200 and 1201
Change the data in the location 1100and 1102 and verify the result

RESULT

EX NO :
DATE :

STRING MANIPULATION

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

AIM:
i.
To move a byte string of length FF from a source to a destination using MOVSB
instruction
ii.
To fill the locations 1100 to 11FF in memory with the byte 34 using STOSB
APPARATUS REQUIRED
S.no

Required Components

specification

Qty

1.

MICROPROCESSOR

MICRO 86/88 KIT

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

THEORY
Since the 8086 includes the string primitives, which require initialisation of the index
registers,the SI and DI registers are initialised to start of the source and start of the
destination array respectively. The direction flag is cleared to facilitate auto incrementing of
the index registers. The CX register is used to perform the operation repeatedly. The string
START
primitive used in MOVS. In the case of MOVE operation,
the status of the direction flag is
however immaterial. The function STOS will store the byte in AL or the word in AX
depending upon the operand size, from the location pointed to by the destination index DI. So
if we want to fill a block with a particular data then we should set destination index to the
beginning of the block and then use the STOSW instruction or theSTOSB instruction and use
DS,ES,SI,DI
CX to get the required length. S_ARRAY isInitialize
the location
1100 in this program.
ALGORITHM
a.
b.
c.
d.
e.
f.

Initialize the data segment .(DS)


Initialize the extra data segment .(ES)
Initialize the start of string in the DS.CX=length
(SI) of string,
Initialize the start of string in the ES.DF=0.
(DI)
Move the length of the string(FF) in CX register.
Move the byte from DS TO ES, till CX=0.
Move a byte from source string (DS)
to destination string (ES)

Decrement CX

FLOWCHART

Check
for ZF=1

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)


STOP

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

`
NO

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

PROGRAM USING MOVS B


MEMORY
ADDRESS

OPCODES

MNEMONICS

COMMENTS

MOV SI,2000

Move the data from the memory 2000


to the source index register
Move the data from the memory 2100
to the destination index.

MOV DI,2100
MOV CX, FF

Move the data FF to CX register.


CLD
Auto increment of index register.
MOVE: MOVSB
Move the content of SI to DI
LOOP MOVE
Move till CX is set to zero.
HLT
Terminate the Program
EXAMPLE
The data for the source array has to be initially entered. Hence let us fill the source locations
starting from S-ARRAY using the FILL command in the kit. Fill locations from 2000 to
20FFwith 41.
S-ARRAY = 2000
D-ARRAY = 20FF
Result: [2000] TO [20FF]= 41
RESULT VERIFICATION

PROCEDURE
i.
ii.
iii.

Enter the program from location 1000.


Fill FF locations as stated above with a particular data, 41
Execute the program. Check if the contents are duplicated to another 255 locations
using the compare command in the kit.

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

PROGRAM USING STOSB


MEMORY
ADDRESS

OPCODES

MNEMONICS

COMMENTS

MOV CX,,FFH

Move the data from the memory 2000


to the source index register
Move the data from the memory 2100
to the destination index.

MOV DI,2100
MOV AX, 34H

Move the data FF to CX register.


CLD
Auto increment of index register.
MOVE: STOSB
Move the content of SI to DI
LOOP MOVE
Move till CX is set to zero.
HLT
Terminate the Program

EXAMPLE
Input: [AX] = 0034
Result: [1100] to [11FF] = 34

OBSERVATION

PROCEDURE
i.
ii.

Enter the program from location 1000.


Check if locations 1100 to 11FF contain 34.

RESULT

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

EX NO :
DATE :

SORTING AND SEARCHING

AIM
Write an Assembly Language Program to arrange a given series of hexadecimal bytes in
ascending order
Write an ALP to find out the number of even and odd numbers from a given series of 16 bit
hexadecimal number.
THEORY
The simplest logic to decide wheather a binary number is even or odd is to check the least significant bit
of a number.if it is 0 ,the number is even else it is odd.Check LSB by rotaying the number through carry
flag and Increment even and odd number.
APPARATUS REQUIRED
S.no

Required Components

specification

Qty

1.

MICROPROCESSOR

MICRO 86/88 KIT

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

ALGORITHM:
(i) Searching Even and odd numbers in an array
a.
b.
c.
d.

Load the array count


Apply ROR( right with carry)
If carry occur means ,it is odd else it is even
Store odd and even numbers

PROCEDURE
1.
2.
3.
4.

Enter the mnemonics in the kit .


Enter the look up table value in the location 1200.
Execute the Program
The odd values are stored in the location 1300 and even number in 1400.

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

PROGRAM FOR EVEN AND ODD NO IN AN ARRAY

Memory
address

opcode

label

AGAIN:

ODD:
NEXT:

mnemonics

comments

MOV CL,COUNT
MOV SI,1200H
MOV AX,[SI]
ROR AX,01
JC ODD
INC BX
JMP NEXT
INC DX
ADD SI,02
DEC CL
JNZ AGAIN

Initialize count
Move the content
from the memory
location 1200 to SI
Move the content of
SI to AX
Rotate right without
carry
Carry occur means
go to ODD

MOV [1300],BX
MOV [1400],DX
HLT

LOOK UP TABLE

Increment BX(even)
Increment DX(odd)
Increment SI
Decrement count
Store Odd and even
value.

OBSERVATION
NO OF EVEN:
NO OF ODD :

MEMORY ADDRESS VALUE

FLOWCHART

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

ASCENDING ORDER

DESCENDING ORDER
START

START

INITIALIZE POINTER

INITIALIZE POINTER

COUNT = COUNT 1

COUNT = COUNT 1

FLAG = 0

FLAG = 0
YES

IS
POINTER

POINTER
NO
+1

YES

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

POINTER = POINTER +1
COUNT = COUNT + 1

NO

IS
POINTER

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

POINTER = POINTER +1
COUNT = COUNT + 1

NO
IS

IS

COUNT

COUNT
=0

YES

NO

=0

IS

IS

FLAG

FLAG

= 0

YES

STOP

YES

YES

= 0
STOP

ASCENDING ORDER OF AN ARRAY

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

ALGORITHM:
(ii) Sorting in ascending order:
e. Load the array count
f. Compare the numbers and exchange if necessary so that the two numbers are in
ascending order.
g. Decrement count.
h. Get the third number from the array and repeat the process until count is 0.
PROGRAM

Memory
address

opcode

label

mnemonics

comments

AGAIN0

MOV CX,COUNT

Initialize count

MOV SI,1200H
AGAIN1: MOV AX,[SI]
CMP AX,[SI+2]
JL PR1
XCHG [SI+2],AX
XCHG [SI],AX
PR1:
ADDSI,02
LOOP AGAIN1
DEC DX
JNZ AGAIN0
HLT

Move the content


from the memory
location 1200 to SI
Move the content of
SI to AX
Compare AX with
SI
If less means go to
PR1
Exchange
the
content
Decrement DX
Terminate
the
program

EXAMPLE
1200-11 1201-22 1202-44 1203-08
OUTPUT
1200-08 1201-11 1202-22 1203-44

OBSERVATION

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

INPUT
MEMORY ADDRESS VALUE

OUTPUT
MEMORY ADDRESS VALUE

PROCEDURE
1.Enter the mnemonics in the kit .
2.Enter the input value in the location 1200.
3.Execute the Program
4.check the values are arranged in ascending order in the location 1200.
RESULT

EX NO :

DIGITAL CLOCK AND STOP WATCH

DATE :
AIM
DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

To write a program to implement Real time Clock in 8086 kit using Timer.
APPARATUS REQUIRED
S.no

Required Components

specification

Qty

1.

MICROPROCESSOR

MICRO 86/88 KIT

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

4.

9-9 CABLE

PC

1
RS232

1
1

SOFTWARE SPECIFICATION
MASM SOFTWARE
PROGRAM
code segment
assume cs:code
org

1000h

; store time value (HEX VALUE) in memory location 1500;1501


;1502
start:
call

convert

call

display

mov

al,0b0h

out

16h,al

mov

cl,07h

mov

al,88h

out

14h,al

mov

al,80h

delay:

s2:

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

out

14h,al

s1:
nop
nop
nop
nop
in

al,14h

mov

dl,al

in

al,14h

or

al,dl

jnz

s1

dec

cl

jnz

s2

mov

si,1500h

mov

al,[si]

inc

al

mov

[si],al

cmp

al,3ch

jnz

start

mov

al,00h

mov

[si],al

inc

si

mov

al,[si]

inc

al

mov

[si],al

cmp

al,3ch

jnz

start

mov

al,0

mov

[si],al

inc

si

mov

al,[si]

inc

al

mov

[si],al

cmp

al,18h

jnz

start

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

mov

al,0

mov

[si],al

jmp

start

display:
mov

ah,06h

mov

dx,1600h

mov

ch,01h

mov

cl,0h

int

ret
convert:
mov

si,1500h

mov

bx,1608h

mov

al,24h

mov

[bx],al

mov

al,[si] ;seconds

mov

ah,0

mov

dh,0ah

div

dh

add

ah,30h

dec

bx

mov

[bx],ah

dec

bx

add

al,30h

mov

[bx],al

dec

bx

mov

al,3ah

mov

[bx],al

dec

bx

inc

si

mov

al,[si]

mov

ah,0

mov

dh,0ah

;minutes

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

div

dh

add

ah,30h

mov

[bx],ah

dec

bx

add

al,30h

mov

[bx],al

dec

bx

mov

al,3ah

mov

[bx],al

dec

bx

inc

si

mov

al,[si]

mov

ah,0

mov

dh,0ah

div

dh

add

ah,30h

mov

[bx],ah

dec

bx

add

al,30h

mov

[bx],al

;hours

ret
getc:
in

al,02h

and

al,0FFH

cmp

al,0f0h

jne

getc

code ends
end
PROCEDURE
1.Open command window (click:

start->run->type cmd )

2.Paste the 8086 or MASM software in any drive


DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

3.In that window change the directry [Where you paste the masm
4.In the command window type the directory name after that change the directory to
8086(masm) after that type edit
5.After changing directory type edit then you get one window in that window you can write a
program
6.After writing a program click: file->save->exit [again we enter the commond window]
7.Type : masm filename,,;
Type: link filename,,;
masm(8086)software]

[This will create a list file you can see this

8.Type :

debug filename.exe

[to create exe file]

9.Type :

n filename.bin

[to create a bin file

10.Type :

wcs:1000

11.Type :

DC (data com will open then set the com port ,Baud rate ,parity)

inside the

[writing code segment]

12.connect the RS232 cable between PC and the Kit.In the kit type SI 1000
13.Type filename.bin [Only if the file specified is found in the default drive and directory
setting, will the option for displaying the count be displayed. Else the user response whether
to try again]
14. The real time clock will be displayed in the microprocessor kit.

RESULT

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

EX NO :

INTERFACING 8279 WITH 8086

DATE :
AIM:
To write a program to roll your name in the 7 segment display
DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

APPARATUS REQUIRED
S.no

Required Components

specification

Qty

1.

MICROPROCESSOR

MICRO 86/88 KIT

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

8279 INTERFACING

1
VBMB 001

THEORY
The Intel 8279 is responsible for debouncing of the keys, coding of the keypad matrix and
refreshing of the display elements in a Microprocessor based development system. Its main
features are:
1) Simultaneous Keyboard and Display operation.
2 )3 Input modes such as Scanned Keyboard Mode, Scanned Sensor Mode and Strobed Input
Entry Mode.
3) 2 Output modes such as 8 or 16 character multiplexed displays, right entry or left entry
display formats.
4) Clock Prescaler.
5) Programmable Scan Timing.
6) 2 Key lockout or N-key Roll-over with contact debounce.7) Auto Increment facility for
easy programming.
1. Display Mode Setup: Control word-10 H
0
0

0
0

0
0

1
D

0
D

0
K

0
K

0
K

1
CD

1
CD

0
CF

0
CA

DD
00- 8Bit character display left entry
01- 16Bit character display left entry
10- 8Bit character display right entry
11- 16Bit character display right entry
KKK- Key Board Mode
000-2Key lockout.
2.Clear Display: Control word-DC H
1
1

1
1

0
0

1
CD

1-Enables Clear display


0-Contents of RAM will be displayed
1-FIFO Status is cleared
DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

1-Clear all bits


(Combined effect of CD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

11

A0-3; B0-3 =FF

3. Write Display: Control word-90H


1

0
1

0
0

1
0

AI

Selects one of the 16 rows of display.


Auto increment = 1, the row address selected will be incremented after each of read and
write operation of the display RAM.

HARDWARE ADDRESS
Command =c2H
Data= c0H
ALGORITHM :

Initialize the counter


Set 8279 for 8 digit character display, right entry
Set 8279 for clearing the display
Write the command to display
Load the character into accumulator and display it
Introduce the delay
Repeat from step 1.

FLOWCHART:
START

SET UP
POINTER
INITIALIZE THE COUNTER
DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

SET 8279 FOR 8-DIGIT CHARACTER


DISPLAY
SET 8279 FOR CLEARING THE
DISPLAY
WRITE THE COMMAND TO DISPLAY
LOAD THE CHARACTER INTO
ACCUMULATOR AND DISPLAY
DELAY

PROGRAM
MEMORY
ADDRESS

OPCODES

MNEMONICS

COMMENTS

START:MOV
SI,1200
MOV CX,count
MOV AL,10
OUTC2,AL
MOV AL,CC
OUT C2,AL
MOV AL,90
OUT C2,AL
NEXT:MOV AL.[SI]
OUT C0,AL
CALL DELAY
INC SI
LOOP NEXT
JMP START

Initialize SI to 1200.
Initialize count.
Right entry.
Clear display.
RAM write display.

Delay routine.
DELAY:MOV
DX,A0FF
LOP:DEC DX
JNZ LOP
RET

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

LOOK UP TABLE
ADDRESS

DATA

SEGMENT DEFINITION

DATA BUS

D7

SEGMENTS d

D6

D5

D4

D3

D2

D1

D0

dp

PROCEDURE:
i.

Enter the program from location 1000.

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

ii.
iii.
iv.

Connect the 8279 interface kit to 8086 Processor.


Execute the Program
The name will be displayed in the 7 segment

RESULT
EX NO :

INTERFACING ADC WITH 8086

DATE :
AIM
To write a program to convert the anolog into digital voltage
PROBLEM STATEMENT

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

The program is executed for various values of analog voltage which are set with the
help of a potentiometer. The LED display is verified with the digital value that is stored in a
memory location.
APPARATUS REQUIRED
S.no

Required Components

specification

Qty

1.

MICROPROCESSOR

MICRO 86/88 KIT

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

ANOLOG
CONVERTER

1
TO

DIGITAL VBMB 003

THEORY
Microprocessors are Digital logic devices that can process only digital signals that are in
binary form logic levels (either 0 or 1 or 0 volts or 5 volts), But most industrial applications
involve physical variables such as temperature, pressure etc, which are continuously (varying
voltage) when converted to analog signal by transducers & signal condition, unlike digital
signals having either a low or high state. In most cases we want to control these signals
electronically. This automatic control can be achieved using a microprocessor. But
microprocessor can understand only digital language. Then how can it control these
parameters? So there should be some translater who can translate these analog signals to a
digital form which the Microprocessor considers formal. This is the place where an Analog to
Digital Converter (ADC) comes into the picture. Thus an Analog to Digital Converter is an
electronic circuit that converts the analog or continuous signal to digital or discrete.
HARDWARE ADDRESS

ALGORITHM:
(i)
Select the channel and latch the address.
(ii)
Send the start conversion pulse.
(iii)
Read EOC signal.
(iv)
If EOC = 1 continue else go to step (iii)
(v)
Read the digital output.
(vi)
Store it in a memory location
FLOW CHART FOR ADC
START

SELECT THE CHANNEL AND LATCH


ADDRESS
DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

SEND THE START CONVERSION PULSE


NO
IS EOC =
1?

YES

READ THE DIGITALOUTPUT


STORE THE DIGITAL VALUE IN THE
MEMORY LOCATION SPECIFIED

STOP

PROGRAM
MEMORY
ADDRESS

OPCODES

MNEMONICS

COMMENTS

MOV AL,10
OUT C8,AL
MOV AL,18
OUT C8,AL
HLT

Channel selection and ALE low


ALE high
Terminate the Program

PROCEDURE:
i.
ii.
iii.
iv.

Enter the program from location 1000.


Connect the ADC interface kit to 8086 Processor
Vary the analog input using trimpot and give SOC by pressing the switch
See the corresponding digital value in the led display

OBSERVATION:
ANALOG

DIGITAL DATA ON LED

HEX CODE IN MEMORY

VOLTAGE

DISPLAY

LOCATION

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

RESULT

EX NO :

INTERFACING DAC WITH 8086

DATE :
AIM:
To write a program to
i.

generate square waveform in dac2 output

ii.

generate 0Vin th DAC 1 output.

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

APPARATUS REQUIRED
S.no

Required Components

specification

Qty

1.

MICROPROCESSOR

MICRO 86/88 KIT

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

DIGITAL
TO
CONVERTER

1
ANALOG VBMB 003

PROBLEM STATEMENT
The program is executed for various digital values and equivalent analog voltages are
measured and also the waveforms are measured at the output ports using CRO.
ALGORITHM
Square Waveform:
(i) Send low value (00) to the DAC.
(ii) Introduce suitable delay.
(iii) Send high value to DAC.
(iv) Introduce delay.
(v) Repeat the above procedure.

HARDWARE ADDRESS

FLOWCHART:
MEASUREMENT OF ANALOG VOLTAGE
START

SEND THE
DIGITALVALUE TO
ACCUMULATOR

SQUARE WAVE FORM


START
INTIALISE THE ACCUMULATOR
SEND ACC CONTENT TO DAC

DELAY

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

TRANSFER THE
ACCUMULATOR CONTENTS
TO DAC

LOAD THE ACC WITH MAX


VALUE SEND ACC CONTENT
TO DAC
DELAY

READ THE CORRESPONDING


ANALOG VALUE

STOP

PROGRAM TO GENERATE 0 V IN THE DAC1 OUTPUT


MEMORY
ADDRESS

OPCODES

MNEMONICS

COMMENTS

MOV AL,7FH
OUT C0,AL
HLT

7F(hex)=0v
Out the data in DAC1
Terminate the Program

PROCEDURE
i.
Enter the program from location 1000.
ii.
Connect the DAC interface kit to 8086 Processor
iii.
View the 0v output in the CRO
OBSERVATION
DIGITAL DATA

ANALOG VOLTAGE

PROGRAM TO GENERATE SQUARE WAVE IN DAC2 OUTPUT


MEMORY
ADDRESS

OPCODES

MNEMONICS

COMMENTS

START:MOV AL,00
OUT C8,AL
CALL DELAY
MOV AL,FF

Low data in DAC 2


Delay

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

OUT C8,AL
CALL DELAY
JMP START

DELAY:MOV
DX,A0FF
LOP:DEC DX
JNZ LOP
RET

High data in DAC 2 out put


Process repeat

Delay routine

OBSERVATION

PROCEDURE:
i.
ii.
iii.

Enter the program from location 1000.


Connect the DAC interface kit to 8086 Processor
View the square wave output in the CRO

RESULT
EX NO :

INTERFACING STEPPER MOTOR WITH 8086

DATE :
AIM:
To write a program to run the stepper motor at different speed.
APPARATUS REQUIRED
S.no

Required Components

specification

Qty

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

1.

MICROPROCESSOR

MICRO 86/88 KIT

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

STEPPER MOTOR

1
1 Kg

PROBLEM STATEMENT
Write a code for achieving a specific angle of rotation in a given time and particular
number of rotations in a specific time.
THEORY
Stepper motor control is a very popular application of microprocessor in control area. They
are widely used in (simple position control systems in the open and closed loop mode) a
variety ofapplications such as computer peripherals (printers, disk driver etc.) and in the areas
of processcontrol machine tools, medicine, numerically controlled machines and Robotics.
ALGORITHM:
For running stepper motor clockwise and anticlockwise directions
(i)
Get the first data from the lookup table.
(ii)
Initialize the counter and move data into accumulator.
(iii)
Drive the stepper motor circuitry and introduce delay
(iv)
Decrement the counter is not zero repeat from step(iii)
(v)
Repeat the above procedure both for backward and forward directions
HARDWARE ADDRESS

FLOWCHART:

START
INTIALIZE COUNTER FOR LOOK UP TABLE

GET THE FIRST DATA FROM THE ACCUMULATOR


MOVE DATA INTO THE ACCUMULATOR
DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

DRIVE THE MOTOR


CIRCUITARY
DELAY
DECREMENT COUNTER
YES
IS B = 0 ?
NO
GET THE DATA FROM LOOK UP
TABLE

PROGRAM
MEMORY
ADDRESS

OPCODES

MNEMONICS

COMMENTS

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

START:MOV AL,09
OUT C0,AL
CALL DELAY
MOV AL,05
OUT C0,AL
CALL DELAY
MOV AL,06
OUT C0,AL
CALL DELAY
MOV AL,0A
OUT C0,AL
CALL DELAY
JMP START
DELAY:MOV
DX,A0FF
LOP:DEC DX
JNZ LOP
RET

Out the 09 to the port address C0


Delay
Out the 05 to the port address
Delay
Out the value 06 to the port address
Delay
Out the value 0A to the Port address
Delay
Repeat the process
Delay routine

PROCEDURE:
i.
ii.
iii.

Enter the program from location 1000.


Connect the stepper motor to 8086 Processor
Stepper motor will rotate in clockwise direction.you can vary the speed by loading the
value in DX register

RESULT

EX NO :
DATE :

DC MOTOR CONTROL

AIM

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

Write an Assembly Language Program to control the speed of the motor


Write an ALP to read the count value from the timer
THEORY
This board uses a simple method for measurement and control of the DC motor speed. This
board uses the principle that the speed of any motor decreases as the input power to the motor
decreases. Hence, by varying the input voltage to the motor, the speed can be varied. The
speed measurement is based on the principle that the motor rotation is converted in to pulses
using optical pickup and these pulses are used to decremented a counter for a known time.
This count value can be calibrated to RPM (rotation per minute), which is the standard
unit for speed measurement.
APPARATUS REQUIRED
S.no

Required Components

specification

Qty

1.

MICROPROCESSOR

MICRO 86/88 KIT

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

4.

DC MOTOR

1
VBMB 17

SOFWARE SPECIFICATION
MASM SOFTWARE

HARDWARE ADDRESS

PROGRAM
To control the speed of DC motor

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

Memory
address

opcode

mnemonics

comments

MOV AL,FF
OUT C0,AL
HLT

Max data to DAC


port

PROCEDURE
1.Enter the mnemonics in the kit .
2.Load maximum value FF to Accumulator
3.Execute the Program
4.varry the input value and check the speed.
OBSERVATION

TO READ THE COUNT VALUE FROM TIMER


ALGORITHM
* Set DC motor speed
* Set control word and initialize the counter
* Enable the counter gate
* Apply delay for 1 sec.(RPS)
* Disable the counter gate
* Read the counter value
PROGRAM
MOV AL,0FFH
MOV AL,00H
OUT 0D8H,AL
CALL DELAY
MOV AL,30H
OUT 0CEH,AL
MOV AL,0FFH
OUT 0C8H,AL
OUT 0C8H,AL

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

MOV AL,00H
OUT 0D0H,AL
CALL DELAY
MOV AL,00H
OUT 0D8H,AL
IN AL,0C8H
MOV SI,1500h
MOV [SI],AL
MOV AL,00H
INC SI
MOV [SI],AL
HLT
PROCEDURE
1.Enter the mnemonics in the kit by down loading using MASM tool.
2.Load maximum value FF to Accumulator
3.Execute the Program
4.The count value will be stored in the location 1500.
OBSERVATION

RESULT

EX NO :
DATE :

8259 INTERFACING

OBJECTIVE
DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

To initialize the 8259 with the following specification


* ICW 4 needed.
* Single 8259.
* Interval of 4.
* Edge triggered mode.
* A7 A6 A5 = 000.
* Initialize to type 8 interrupt.
* 8086 mode.
* Normal EOI.
* Non-buffered mode (Since we are not using buffers).
* Not special fully-nested mode.
* Mask all interrupts except IRQ 0.
APPARATUS REQUIRED
S.no

Required Components

specification

Qty

1.

MICROPROCESSOR

MICRO 86/88 KIT

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

4.

8259 INTERFACING

1
VBMB 07

THEORY
The program initializesthe 8259 to type 8. So the interrupt vector for interrupt IRO is
0000: 0020 So at 0000:0020, enter the address0000: 1200H If the ISR is at 0:1200
In the ISR, non specific EOI command is given. In fully nested mode, the interrupt requests
are ordered in priority from 0 through 7 (0 highest). But in some applications there are a
number of interrupting devices of equal priority. In this mode, a device after being serviced
receives the lowest priority, This is known as Rotating priority
PROGRAM
Memory
address

opcode

mnemonics
MOV AL,17
OUT C0,AL
MOV AL,08
OUT C2,AL
MOV AL,01
OUT C2,AL
MOV AL,FE
OUT C2,AL
STI
HERE:SJMP HERE
INTEREPT SERVICE

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

MOV AL,20
OUT C0,AL
INT 2

INTERRUPT VECTOR:
0000: 0020 00
0000: 0021 12
0000: 0022 00
0000: 0023 00
OBSERVATION

RESULT

EX NO :
DATE :

8253 INTERFACING

OBJECTIVE

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

To study the various modes in 8253.


APPARATUS REQUIRED
S.no

Required Components

specification

Qty

1.

MICROPROCESSOR

MICRO 86/88 KIT

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

4.

8253 INTERFACING

1
VBMB 04

THEORY
MODE 0 - INTERRUPT ON TERMINAL COUNT:
The output will be initially low after mode set operation. After loading the counter, the
output will remain low while counting and on terminal count, the output will become high,
MODE 1 - PROGRAMMABLE ONE-SHOT:
After loading the counter, the output will remain low following the rising edge of the gate
input. The output will go high on the terminal count. It is re-triggerable, hence the output will
remain low for the full count after any rising edge of the gate input.
MODE 2 - RATE GENERATOR:
It is a simple divide by N counter. The output will be low for one period of the input clock.
The period from one output pulse to the next equals the number of input counts in the count
register. If the count register is reloaded between output pulses the present period will not be
affected, but the subsequent period will reflect the new value.
MODE 3 - SQUARE WAVE GENERATOR:
It is similar to Mode 2 except that the output will remain high until one half of count and go
low for the other half for even number count. If the count is odd, the output will be high for
(count+1)/2 counts and low for (count-1)/2 counts. This mode is used for generating baud
rate for 8251
MODE 4 - SOFTWARE TRIGGERED STROBE:
The output is high after mode is set and also during counting. On terminal count, the output
will go low for one clock period and becomes high again. This mode can be used for
interrupt generation.
MODE 5 - HARDWARE TRIGGERED STROBE:
Counter starts counting after rising edge of trigger input and output goes low for one clock
period when terminal count is reached. The counter is re-triggerable.

PROGRAM
MODE 0 - INTERRUPT ON TERMINAL COUNT

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

Memory
address

opcode

mnemonics

ORG 1000H
MOV AL,30
OUT CE,AL
MOV AL,05
OUT C8,AL
MOV AL,00
OUT C8,AL
HLT

NOTE: Please make sure that CLK 0 is connected to the debounce circuit.
PROCEDURE
1. Enter the program
2. Observe, using an CRO that the output of Channel 0 is initially low. After giving
six clock pulses, you may notice that the output goes high
MODE 1 - PROGRAMMABLE ONE-SHOT
Memory
opcode
mnemonics
address

ORG 1000H
MOV AL,32
OUT CE,AL
MOV AL,05
OUT C8,AL
MOV AL,00
OUT C8,AL
OUT D0,AL
HLT

NOTE: Connect CLK 0 to debounce circuit.


PROCEDURE

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

1. The following program, initializes Channel 0 of 8253 in mode 1 and also initiates
triggeringof GATE 0. OUT 0 goes low, an clock pulse after triggering the gate and
goes back to highlevel after five clock pulses.
2. Execute the program, give clock pulses through the debounce logic and verify using
a CRO.
MODE 2 - RATE GENERATOR:
Memory
address

opcode

mnemonics

ORG 1000H
MOV AL,74
OUT CE,AL
MOV AL,0A
OUT CA,AL
MOV AL,00
OUT CA,AL
HLT
NOTE: Please make sure that CLK 1 is connected to PCLK. In a CRO observe the
input clock to channel 1 and the output OUT 1.
MODE 3 - SQUARE WAVE GENERATOR:
Memory
address

opcode

mnemonics

ORG 1000H
MOV AL,36
OUT CE,AL
MOV AL,10
OUT C8,AL
MOV AL,00
OUT C8,AL
HLT
NOTE: Set the jumper such that CLK 0 of 8253 is connected to PCLK. The above
program divides the PCLK by 10 and thus the channel 0 output is 150 KHz.
MODE 4 - SOFTWARE TRIGGERED STROBE

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

Memory
address

opcode

mnemonics

ORG 1000H
MOV AL,36
OUT CE,AL
MOV AL,0A
OUT C8,AL
MOV AL,00
OUT C8,AL
MOV AL,B8
OUT CE,AL
MOV AL,98
OUT CC,AL
MOV AL,3A
OUT CC,AL
HLT

NOTE: Please make sure that OUT 0 is connected to CLK 2.


.
PROCEDURE
1. Connect OUT 0 to CLK 2 (Jumper J1).
2. Execute the program and observe the output OUT 2.Counter 2 will generate a pulse
after 1 sec.
3.
MODE 5 - HARDWARE TRIGGERED STROBE
Memory
address

opcode

mnemonics

ORG 1000H
MOV AL,1A
OUT CE,AL
MOV AL,05
OUT C8,AL
OUT D0,AL
HLT
HLT

NOTE: Connect CLK 0 to debounce circuit.

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

PROCEDURE
1. Execute the program.
2. After giving six clock pulses, you can see using CRO, the initially high
output goes low. The output (OUT 0 pin) goes high on the next clock pulse.

OBSERVATION

RESULT

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

EX NO :
DATE :

SERIAL COMMUNICATION

OBJECTIVE
To implement serial communication between two kit

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

APPARATUS REQUIRED
S.no Required Components

specification

Qty

1.

MICROPROCESSOR

MICRO 86/88 KIT

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

4.

9-9 cable

1
RS232

SOFWARE SPECIFICATION
MASM SOFTWARE
THEORY:
The 8251 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 CPU can read
the status of the USART at any time. These include data transmission errors and control
signals. The control signals define the complete functional definition of the 8251. Control
words should be written into the control register of 8251.These control words are split into
two formats: 1) Mode instruction word & 2) Command instruction word. Status word format
is used to examine the error during functional operation.

1...transmit enable
1...data terminal ready
1... receive enable
1... send break character
1.... reset error flags (pe,oe,fe)
1..... request to send (rts)
1...... internal reset
1....... enter hunt mode (enable search for sync characters)

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

1 ransmitter ready
1. receiver ready
1.. transmitter empty
1... parity error (pe)
1.... overrun error (oe)
1..... framing error (fe), async only
1...... sync detect, sync only
1....... data set ready (dsr)

ALGORITHM:
1. Initialize 8253 and 8251 to check the transmission and reception of a character
2. Initialize8253 to give an output of 150Khz at channel 0 which will give a 9600 baud rate
of 8251.
3. The command word and mode word is written to the 8251 to set up for subsequent
operations
4. The status word is read from the 8251 on completion of a serial I/O operation, or when
the host CPU is checking the status of the device before starting the next I/O operation

FLOW CHART:
START

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

Check TX/RX Ready


No

Is it High
Yes

Write Data into data register

STOP
PROGRAM FOR TRANSMITTER
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,1500H
MOV AL,36H
OUT 16H,AL
MOV AL,40H
OUT 10H,AL
MOV AL,01H
OUT 10H,AL
RELOAD: MOV CL,05H
CHECK: IN AL,0AH
AND AL,04H
JZ CHECK
MOV AL,[SI]
OUT 08H,AL
INC SI
CMP AL,3FH
JNZ RELOAD
DEC CL
JNZ CHECK
INT 02
CODE ENDS
END

PROGRAM FOR RECEIVER


CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 1000H
MOV SI,1500H

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

MOV AL,36H
OUT 16H,AL
MOV AL,40H
OUT 10H,AL
MOV AL,01H
OUT 10H,AL
RELOAD: MOV CL,05H
CHECK: IN AL,0AH
AND AL,02H
JZ CHECK
IN AL,08H
MOV [SI],AL
INC SI
CMP AL,3FH
JNZ RELOAD
DEC CL
JNZ CHECK
INT 02
INT 02
CODE ENDS
END
PROCEDURE
1. Enter the transmitter program in one kit and receiver program in another kit
2. Connect RS232 cable b/w two kit
3. Now the data will be received serially to the receiver kit in the location 1500.

RESULT

EX NO :
DATE :

PARALLEL COMMUNICATION

OBJECTIVE
To implement parallel communication between two kit

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

APPARATUS REQUIRED
S.no Required Components

specification

Qty

1.

MICROPROCESSOR

MICRO 86/88 KIT

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

4.

26 core cable

SOFWARE SPECIFICATION
MASM SOFTWARE
PROGRAM FOR TRANSMITER SIDE
code segment
assume cs:code,ds: code
org 1000h
mov al,82h
OUT 26h,al
mov al,3fh
OUT 20h,aL
loop: in al,22h
sub al,3fh
jnz loop
mov al,24h
out 20h,al
call delay
int 02
delay: mov bl,05h
lion: mov dl,0ffh
l2: dec dl
jnz l2
dec bl
jnz lion
ret
code ends
end
RECEIVER SIDE
code segment
assume cs:code,ds:code
org 1000h
mov al,90h
out 26h,al

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

check: in al,20h
sub al,3fh
jnz check
mov al,3fh
out 22h,al
mov cl,08h
call delay
mov si,1200h
l1: in al,20h
mov [si],al
call delay
inc si
dec cl
jnz l1
int 02
delay: mov bl,05h
lion: mov dl,0ffh
l2: dec dl
jnz l2
dec bl
jnz lion
ret
ret
code ends
end
PROCEDURE
1. Enter the transmitter program in one kit and receiver program in another kit
2. Connect 26 core cable b/w two kit
3. Now the data will be received parallel on the receiver kit in the location 1200.

RESULT

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

EX NO:
DATE :

ARITHMETIC LOGICAL AND BIT MANIPULATION

OBJECTIVE

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

To perform Arithmetic operation,logical operation and bit manipulation using 8051 controller
APPARATUS REQUIRED
S.no

Required Components

specification

Qty

1.

MICROCONTROLLER

MICRO 51LC LCD

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

THEORY
As there is only one 16-bit Register in 89C51, 16-bit addition is performed by using ADDC
instruction twice, i.e. adding LSD first and MSD next. The one's complement of a number is
obtained by inverting all the bits in that number , that isreplacing all 1's by 0's and all 0's by
1's. The two's complement is the negative of that number.Setting bits can be done by ORing
that particular bit by 1.
EXAMPLE
The program is to add the 16-bit data 1234 with the data 5678 and store the result at the
locations
4150 and 4151 using immediate addressing.
RESULT: [4150] = AC (LSB);
[4151] = 68 (MSB).
DATAL1 - 34; DATAL2 = 78.
DATAM1 - 12; DATAM2 = 56.
DATAM1 - MSD OF DATA1,
DATAM2 - MSD OF DATA2,
DATAL1 - LSD OF DATA1,
DATAL2 - LSD OF DATA2
ALGORITHM:
1. Clear Program Status Word
2. Load accumulator A with any desired 8-bit data.
3. Load the register R 0 with the second 8- bit data.
4. Add these two 8-bit numbers.
5. Store the result.
FLOW CHART

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

PROGRAM FOR ADDITION

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

Memory
address

opcode

mnemonics
CLR C
MOV A,#DATAL1
ADDC A,#DATAL2
MOV DPTR,#4150
MOVX @DPTR,A
INC DPTR
MOV A,#DATAM1
ADDC A,#DATAM2
MOVX @DPTR,A
HLT: SJMP HLT

RESULT:
OUTPUT
MEMORY LOCATION

DATA

4500

PROCEDURE
i) Enter the above opcodes from 4100 in the trainer.
ii) Execute the program.
iii) Check for the result at 4150 AND 4151
iv) Change data and see if the result at 4150 changes accordingly.
PROGRAM FOR ONES COMPLEMENT
Memory
address

opcode

mnemonics

MOV A,#DATA
CPL A
MOV DPTR,#4200
MOVX @DPTR,A
INC A
INC DPTR
MOVX @DPTR,A
HERE: SJMP HERE

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

PROCEDURE
i. Enter the opcodes and the data in the trainer.
ii. Execute the program and check for results.
iii Change data and check for the corresponding results.
PROGRAM FOR SETTING BIT
Memory
opcode
address

mnemonics

MOV A,#DATA1
ORL A,#DATA2
MOV DPTR,#4500
MOVX @DPTR,A
HERE: SJMP HERE

PROCEDURE:
i. Enter the opcodes and execute the program.
ii. Check whether the corresponding bits are set accordingly.
OBSERVATION

RESULT

EX NO:
DATE :

COMMUNICATION B/W 8051 AND PC

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

OBJECTIVE
To implement communication b/w 8051 with PC.
APPARATUS REQUIRED
S.no

Required Components

specification

Qty

1.

MICROCONTROLLER

MICRO 8051 LC KIT 1

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

4.

9 TO 9 CABLE

1
1

RS232

PROCEDURE
1. Type sm in the controller kit.
2. Now open the communication port.
3. Then it is ready to communicate with kit to PC
4. For Example if you type H in the communication window the help command will be
displayed in the PC

RESULT

EX NO :
DATE :

TIMER IN 8051

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

OBJECTIVE
Write a program to generate square wave using timer in P1.0
APPARATUS REQUIRED
S.no

Required Components

specification

1.

MICROCONTROLLER

MICRO 8051 LC KIT 1

2.

POWER CHORD

+5V SUPLLY

4. CRO
4.

KEY BOARD

Qty

1
1
1

THEORY
TMOD REGISTER

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

CALCULATION.
FFFF-7634=89CB+1=89CC=35276
35276X1.085s=38.274ms and frequency=26.127hz
OBSERVATION

PROGRAM
Memory
address

opcode

mnemonics

comments

MOV TMOD,#10
AA:MOV TL1,#34
MOV TH1,#76
SETB TR1
BACK:JNB TF1,BACK
CLR TR1
CPL P1.0
CLR TF1
SJMP AA

PROCEDURE:
i. Enter the opcodes and execute the program.
ii. square wave will be generated in the P1.0 pin

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

RESULT

EX NO :
DATE :

EXTERNAL INTERRUPT USING 8051

OBJECTIVE
Assume that the INT1 pin is connected to a switch that is normally high.whenever it goes low,it should
turn on a led.

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

APPARATUS REQUIRED
S.no Required Components

specification

Qty

1.

MICROCONTROLLER

MICRO 8051 LC KIT 1

2.

POWER CHORD

+5V SUPLLY

3.

KEY BOARD

1
1

THEORY

PROGRAM
Memory
address

opcode

mnemonics

comments

ORG 0013
SETB P1.3
MOV R3,#255
BACK:DJNZ R3,BACK
CLR P1.3
RETI
MAIN PROGRAM

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

ORG 30H
MAIN:MOV
IE,#10000100
HH:SJMP HH

PROCEDURE
i. Enter the opcodes and execute the program.
ii. when interrupt occurs P1.3 will goes to high.
OBSERVATION

RESULT

EX NO :
DATE :

UART IN 8051

OBJECTIVE
Write a program to transfer A in the communication port.
APPARATUS REQUIRED
S.no

Required Components

specification

Qty

1.

MICROCONTROLLER

MICRO 8051 LC KIT 1

2.

POWER CHORD

+5V SUPLLY

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

3.

KEY BOARD

9-9 CABLE

1
RS232 CABLE

THEORY

PROGRAM
Memory
address

opcode

mnemonics

comments

MOV TMOD,#20
MOV TH1,#-6
MOV SCON,#50
SETB TR1
GG:MOV SBUF,#A
HH:JNB TI,HH
CLR TI
SJMMP GG

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

EC2257- MICROPROCESSOR AND MICROCONTROLLER LAB

RESULT

DEPT OF ECE, Vi INSTITUTE OF TECHNOLOGY (A UNIT OF Vi MICROSYSTEMS PVT. LTD)

You might also like