0% found this document useful (0 votes)
19 views99 pages

MP&MC Lab Obse Student

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views99 pages

MP&MC Lab Obse Student

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 99

VIVEKANANDHA

COLLEGE OF ENGINEERING FOR WOMEN


[AUTONOMOUS]

Department of ECE

Lab observation

SUBJECT CODE & :U19EC522- Microprocessor &


SUBJECT NAME Microcontroller Laboratory

1
2
3
4
5
6
Contents
Page Internal Faculty
S.No. Date Name of the Experiments
No. Marks Sign.

7
FLOWCHART

ADDITION SUBTRACTION

START START

SET UP COUNTER (CY) SET UP COUNTER (CARRY)

GET FIRST
GET FIRST OPERAND
OPERAND TO A

GET SECOND OPERAND SUBTRACT


TO A SECOND OPERAND
FROM MEMORY

YES
A=A+B
IS THERE
ANY CY

YES NO COUNTER =
IS THERE COUNTER + 1
ANY
CARRY

COUNTER = STORE THE


NO COUNTER + 1 DIFFERENCE

STORE THE CARRY

STORE THE SUM


STOP

STORE THE CARRY

STOP

8
EXPT NO:1(a) 8086 PROGRAMMING DATE:

ADDITION & SUBTRACTION

AIM:
To write an Assembly Language Program (ALP) for performing the addition and
subtraction operation of two byte numbers.

APPARATUS REQUIRED:
8086 kit, Power Chord

ALGORITHM:
(i) 16-bit addition
a. Initialize the MSBs of sum to 0
b. Get the first number.
c. Add the second number to the first number.
d. If there is any carry, increment MSBs of sum by 1.
e. Store LSBs of sum.
f. Store MSBs of sum.
g.
(ii) 16-bit subtraction
a. Initialize the MSBs of difference to 0
b. Get the first number
c. Subtract the second number from the first number.
d. If there is any borrow, increment MSBs of difference by 1.
e. Store LSBs of difference
f. Store MSBs of difference.

PROGRAM:

16-BIT ADDITION:

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 C7C10000 MOV CX, 0000H Initialize counter CX
1004 8B060012 MOV AX,[1200] Get the first data in AX reg
1008 8B1E0212 MOV BX, [1202] Get the second data in BX reg
01D8 ADD AX,BX Add the contents of both the
100C
regs AX & BX
100E 7301 JNC L1 Check for carry
41 INC CX If carry exists, increment the
1010
CX
1011 890E0612 L1 MOV [1206],CX Store the carry
1015 89060412 MOV [1204], AX Store the sum

9
1019 F4 HLT Stop the program

ADDITION

ADDRESS DATA
1200
1201
INPUT
1202
1203
OUTPUT 1204
(SUM) 1205
OUTPUT 1206
(CARRY) 1207

SUBTRACTION

ADDRESS DATA
1200
1201
INPUT
1202
1203
OUTPUT 1204
(Difference) 1205
OUTPUT 1206
(Borrow) 1207

10
16-BIT SUBTRACTION:

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 C7C10000 MOV CX, 0000H Initialize counter CX
1004 8B060012 MOV AX,[1200] Get the first data in AX
reg
1008 8B1C0212 MOV BX, [1202] Get the second data in BX
reg
100C 29D8 SUB AX,BX Subtract the contents of
BX from AX
100E 73F1 JNC L1 Check for borrow
1010 41 INC CX If borrow exists,
increment the CX
1011 890E0612 L1 MOV [1206],CX Store the borrow
1015 89060412 MOV [1204], AX Store the difference
1019 F4 HLT Stop the program

RESULT:

Thus addition & subtraction of two byte numbers are performed and the result is stored.

11
FLOWCHART

MULTIPLICATION DIVISION

Start
Start

Load Divisor &


Get Multiplier & Multiplicand Dividend
MULTIPLICAND

QUOTIENT = 0
REGISTER=00

DIVIDEND =
DIVIDEND-DIVISOR
REGISTER =
REGISTER +
MULTIPLICAND

QUOTIENT = QUOTIENT+1

Multiplier=MU
LTIPLIER – 1

IS
NO DIVIDEN
D<
DIVISOR
NO IS
?
MULTIPLIER
=0?
YES

YES STORE QUOTIENT


STORE REMAINDER
STORE THE RESULT = DIVIDEND NOW

STOP STOP
12
EXPT NO:1(b) 8086 PROGRAMMING DATE:

MULTIPLICATION & DIVISION

AIM:
To write an Assembly Language Program (ALP) for performing the multiplication and
division operation of 16-bit numbers.

APPARATUS REQUIRED:

8086 kit, Power Chord

ALGORITHM:

(i) Multiplication of 16-bit numbers:


a) Get the multiplier.
b) Get the multiplicand
c) Initialize the product to 0.
d) Product = product + multiplicand
e) Decrement the multiplier by 1
f) If multiplicand is not equal to 0,repeat from step (d) otherwise store the product.

(ii) Division of 16-bit numbers.


a) Get the dividend
b) Get the divisor
c) Initialize the quotient to 0.
d) Dividend = dividend – divisor
e) If the divisor is greater, store the quotient. Go to step g.
f) If dividend is greater, quotient = quotient + 1. Repeat from step (d)
g) Store the dividend value as remainder.

PROGRAM:

MULTIPLICATION:

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 8B060012 MOV AX,[1200] Get the first data
1004 8B1E0212 MOV BX, [1202] Get the second data
1008 F7F3 MUL BX Multiply both
100A 89060612 MOV [1206],AXd Store the lower order product
100E 89D0 Copy the higher order product
MOV AX,DX
to AX
1010 89060812 MOV [1208],AX Store the higher order product
1014 F4 HLT Stop the program

13
MULTIPLICATION:

ADDRESS DATA
1200
1201
INPUT
1202
1203
OUTPUT 1206
(SUM) 1207
OUTPUT 1208
(CARRY) 1209

DIVISON:

ADDRESS DATA
1200
1201
INPUT
1202
1203
OUTPUT 1206
(Quotient) 1207
OUTPUT 1208
(Remainder) 1209

14
DIVISION:

ADDRESS OPCODE LABEL MNEMONICS COMMENTS

1000 8B060012 MOV AX,[1200] Get the first data


1004 8B1E0212 MOV BX, [1202] Get the second data
1008 F7F3 Store the lower order
DIV BX
product
100A 89060612 Copy the higher order
MOV [1204],AX
product to AX
100E 89D0 Store the higher order
MOV AX,DX
product
1010 89060812 MOV [1206],AX Stop the program
1014 F4 HLT Get the first data

RESULT:.

Thus multiplication & division of two byte numbers are performed and the result is stored.

15
Flowchart of Ascending (8086):

16
EXPT NO:2(a) 8086 PROGRAMMING DATE:
SORTING

AIM:

To write an assembly language program for the sorting in ascending and descending order, using
8086

APPARATUS REQUIRED:

8086 kit, Power Chord

THEORY:

The Bubble-Sort technique is used to sort the numbers in either ascending order or
descending order. The numbers to be sorted is stored in the memory as a array with the first
location containing the count of the data in the array. The sorted numbers are stored back again
in the same source location of the array.

ALGORITHM: ASCENDING ORDER:

1. Start the program


2. Move data to CX register and move CX data to DI register
3. Move 1200 to the BX register and move the content of 1200 to memory of AX
4. Compare the content of AX with 1202
5. Jump on borrow to rep
6. Move the data in memory to AX and move Data from AX to AI
7. Add Data to BX register and go to loop2
8. Perform no operation and move data & DI to CX
9. Go to the loop
10. Stop the program

ALGORITHM : DESCENDING ORDER

1. Start the program.


2. Move the data to CX register and move CX content to D1 register.
3. Move the address to BX register and move the count of 1200 to AX
4. Compare the content of AX with 1202.5. Jump on no borrow to REP
5. Exchange AX and A1 register and move AX register to BX.
6. Add BX register to 2 and continue the loop up to CX is zero
7. Perform no operation and move D1 register to CX register and continue the loop up to CX is zero
8. Stop the program

17
Flowchart of Descending (8086):

18
PROGRAM FOR ASCENDING ORDER:

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 C7C10700 MOV CX,07 Move data to CX reg
1004 89C2 LOOP1: MOV DI,CX Move CX data to DI
1006 C7C30011 MOV BX,1100 Move 1200 to the BX reg
100A 8B07 Move the content of 1200 to
LOOP2: MOV AX,[BX]
memory of AX
100C 3B4702 Compare the content of AX
CMP AX,[BX+2]
with 1202H
100F 7205 JB 1016 Jump on borrow to rep
1011 874702 Move the data in memory
XCHG AX,[BX+2]
toAX
1014 8907 MOV [BX],AX Move data from AX to AI
1016 81C30200 REP: ADD BX,02 Add data to BX register
101A E2EE LOOP 100A Go to loop2
101C 90 NOP No operation
101D 89F9 MOV CX,DI Move data of DI to C
101F E2E3 LOOP 1004 Go to loop1
1021 F4 HLT Stop the process

PROGRAM FOR DESCENDING ORDER:


ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7C10700 MOV CX,07 Move data to CX reg
1004 89C2 LOOP1: MOV DI,CX Move CX data to DI
1006 C7C30011 MOV BX,1100 Move 1200 to the BX reg
100A 8B07 LOOP2: MOV AX,[BX] Move the content of 1200
to memory of AX
100C 3B4702 CMP AX,[BX+2] Compare the content of
AX with 1202H
100F 7205 JNB 1016 Jump on borrow to rep
1011 874702 XCHGAX,[BX+2] Move the data in memory
toAX
1014 8907 MOV [BX],AX Move data from AX to AI
1016 81C30200 REP: ADD BX,02 Add data to BX register
101A E2EE LOOP 100A Go to loop2
101C 90 NOP No operation
101D 89F9 MOV CX,DI Move data of DI to C
101F E2E3 LOOP 1004 Go to loop1
1021 F4 HLT Stop the process
ASCENDING ORDER:
19
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
1100 1100
1102 1102
1104 1104
1106 1106
1108 1108
110A 110A
110C 110C
110E 110E

DESCENDING ORDER:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
1100 1100
1102 1102
1104 1104
1106 1106
1108 1108
110A 110A
110C 110C
110E 110E

20
RESULT:
Thus the assembly language programs for sorting in ascending & descending order was
executed and verified

FLOWCHART FOR SEARCHING A STRING

21
START

Initialize DS,ES ,SI,DI

CX=length of the string,


DF=0.

Scan for a particular character


specified in AL Register.

NO
YES
Check for
ZF=1

Move DI to BX

STOP

INPUT:
0500 =
0501 =
0502 =
0503 = 0504 = 0800 =
RESULT:
0750=

EXPT NO:2(b) 8086 PROGRAMMING DATE:

22
SEARCHING A STRING
AIM:
To scan for a given byte in the string and find the relative address of the byte from the
starting location of the string.

APPARATUS REQUIRED:

8086 kit, Power Chord

ALGORITHM:
a. Initialize the extra segment .(ES)
b. Initialize the start of string in the ES. (DI)
c. Move the number of elements in the string in CX register.
d. Move the byte to be searched in the AL register.
e. Scan for the byte in ES. If the byte is found ZF=0, move the address pointed by ES:DI to
BL.

SEARCHING FOR A CHARACTER IN THE STRING:

MEMORY LABEL MNEMONICS


ADDRESS
1000 START MOV SI,0500H
1004 MOV DI,0750H
1008 MOV CH, 05H
100B MOV CL,00H
100E MOV BX,0800H
1012 FORWARD MOV AL,[SI]
1014 CMP AL,[BX]
1016 JZ DOWN
1018 UP INC SI
1019 DEC CH
101B JNZ FORWARD
101D JMP STOP
1020 DOWN MOV [DI],AL
1022 INC CL
1024 JMP UP
1027 STOP INT,3H
1028 HLT

RESULT:
Thus a given byte or word in a string of a particular length in the extra segment
(destination) is found .

FLOWCHART

23
START

SELECT THE CHANNEL AND LATCH


ADDRESS
SEND THE START CONVERSION PULSE

NO
IS EOC =
1?
YES

READ THE DIGITALOUTPUT

STORE THE DIGITAL VALUE IN THE


MEMORY LOCATION SPECIFIED

STOP

ANALOG DIGITAL DATA ON LED HEX CODE IN MEMORY


VOLTAGE DISPLAY LOCATION

24
EXPT NO: 3(a) 8086 INTERFACING DATE:
INTERFACING ANALOG TO DIGITAL CONVERTER

AIM:
To write an assembly language program to convert an analog signal into a digital signal
using an ADC interfacing.

APPARATUS REQUIRED:

8086 kit, Power Chord, ADC Interface board

THEORY:
An ADC usually has two additional control lines: the SOC input to tell the ADC when to
start the conversion and the EOC output to announce when the conversion is complete. The
following program initiates the conversion process, checks the EOC pin of ADC 0809 as to
whether the conversion is over and then inputs the data to the processor. It also instructs the
processor to store the converted digital data at RAM location.

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.

25
26
PROGRAM TABLE

ADDRESS OPCODE LABEL PROGRAM COMMENTS


2000 C6C000 Load accumulator with value
MOV AL,00
for ALE high
2003 E6C8 OUT 0C8H,AL Send through output port
2005 C6C008 Load accumulator with value
MOV AL,08
for ALE low
2008 E6C8 OUT 0C8H,AL Send through output port
200A C6C001 Store the value to make SOC
MOV AL,01
high in the accumulator
200D E6D0 OUT 0D0H,AL Send through output port
200F C6C000 MOV AL,00
2012 C6C000 MOV AL,00
Introduce delay
2015 C6C000 MOV AL,00
2018 C6C000 Store the value to make SOC
MOV AL,00
low the accumulator
201B E6D0 OUT 0D0H,AL Send through output port
201D E4DB L1
IN AL, 0D8H Read the EOC signal from port
& check for end of conversion
201F 80E001 AND AL,01
2022 80F801 CMP AL,01
2025 75F6 If the conversion is not yet
JNZ L1 completed, read EOC signal
from port again
2027 E4C0 IN AL,0C0H Read data from port
2029 C7C30011 Initialize the memory location
MOV BX,1100
to store data
202D 8807 MOV [BX],AL Store the data
202F F4 HLT Stop

RESULT:
Thus the ADC was interfaced with 8086 and the given analog inputs were converted into its
digital equivalent.

27
FLOWCHART:
MEASUREMENT OF ANALOG VOLTAGE SQUARE WAVE FORM

START START

INTIALISE THE ACCUMULATOR SEND


SEND THE ACC CONTENT TO DAC
DIGITALVALUE TO
ACCUMULATOR
DELAY

TRANSFER THE LOAD THE ACC WITH MAX


ACCUMULATOR CONTENTS VALUE SEND ACC CONTENT
TO DAC TO DAC

READ THE CORRESPONDING DELAY


ANALOG VALUE

TRIANGULAR WAVEFORM
STOP
START
SAWTOOTH WAVEFORM
INITIALIZE
START
ACCUMULATOR

INITIALIZE SEND ACCUMULATOR


ACCUMULATOR CONTENT TO DAC

INCREMENT
SEND ACCUMULATOR ACCUMULATOR
CONTENT
INCREMENT
CONTENT TO DAC
ACCUMULATOR YES
CONTENT IS ACC 
NO YES FF
NO
IS
ACC DECREMENT
 FF ACCUMULATOR CONTENT

SEND ACCUMULATOR
CONTENT TO DAC

IS ACC 
28 00
YES NO
EXPT NO: 3(b) 8086 INTERFACING DATE:
INTERFACING DIGITAL – TO – ANALOG CONVERTER
AIM :
1. To write an assembly language program for digital to analog conversion
2. To convert digital inputs into analog outputs & To generate different waveforms

APPARATUS REQUIRED:

8086 kit, Power Chord, DAC Interface board

THEORY:

Since DAC 0800 is an 8 bit DAC and the output voltage variation is between –5v and
+5v. The output voltage varies in steps of 10/256 = 0.04 (approximately). The digital data input
and the corresponding output voltages are presented in the table. The basic idea behind the
generation of waveforms is the continuous generation of analog output of DAC. With 00 (Hex)
as input to DAC2 the analog output is –5v. Similarly with FF H as input, the output is +5v.
Outputting digital data 00 and FF at regular intervals, to DAC2, results in a square wave of
amplitude 5v.Output digital data from 00 to FF in constant steps of 01 to DAC2. Repeat this
sequence again and again. As a result a saw-tooth wave will be generated at DAC2 output.
Output digital data from 00 to FF in constant steps of 01 to DAC2. Output digital data from FF to
00 in constant steps of 01 to DAC2. Repeat this sequence again and again. As a result a
triangular wave will be generated at DAC2 output.

ALGORITHM:

Waveform generation:

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.

Saw-tooth waveform:

(i) Load low value (00) to accumulator.


(ii) Send this value to DAC.
(iii) Increment the accumulator.
(iv) Repeat step (ii) and (iii) until accumulator value reaches FF.
(v) Repeat the above procedure from step 1.

29
WAVEFORM GENERATION:

WAVEFORMS AMPLITUDE TIME PERIOD


Square Waveform

Saw-tooth waveform

Triangular waveform

MODEL GRAPH:

Square Waveform Saw-tooth waveform

Triangular waveform

30
Triangular waveform:
(i) Load the low value (00) in accumulator.
(ii) Send this accumulator content to DAC.
(iii) Increment the accumulator.
(iv) Repeat step 2 and 3 until the accumulator reaches FF, decrement the
accumulator and send the accumulator contents to DAC.
(v) Decrementing and sending the accumulator contents to DAC.
(vi) The above procedure is repeated from step (i)

PROGRAM:

Square Wave:

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 C6C000 L2 : MOV AL,00H Load 00 in accumulator
1003 E6C0 Send through output
OUT C0,AL
port
1005 E80B00 CALL L1 Give a delay
1008 C6C0FF MOV AL,0FH Load FF in accumulator
100B E6C0 Send through output
OUT C0,AL
port
100D E80300 CALL L1 Give a delay
1010 E9EDFF JMP L2 Go to starting location
1013 C7C1FF05 Load count value in CX
L1 : MOV CX,05FFH
register
1017 E2FE Decrement until it
L3 : LOOP L3
reaches zero
1019 C3 RET Return to main program

Saw tooth Wave:


ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C6C000 L2 : MOV AL,00H Load 00 in accumulator
1003 E6C0 L1 : OUT C0,AL Send through output port
1005 FECO Increment contents of
INC AL
accumulator
1007 75FA Send through output port
JNZ L1
until it reaches FF
1009 E9F4FF JMP L2 Go to starting location

31
32
Triangular Wave:

ADDRESS OPCODE LABEL PROGRAM COMMENTS


1000 C6C000 L3 : MOV AL,00H Load 00 in accumulator
1003 E6C0 L1 : OUT C0,AL Send through output port
1005 FEC0 INC AL Increment contents of
accumulator
1007 75FA JNZ L1 Send through output port
until it reaches FF
1009 C6C0FF MOV AL,0FFH Load FF in accumulator
100C E6C0 L2 : OUT C0,AL Send through output port
100E FEC8 DEC AL Decrement contents of
accumulator
1010 75FA JNZ L2 Send through output port
until it reaches 00
1012 E9EBFF JMP L3 Go to starting location

RESULT:

Thus the DAC was interfaced with 8085 and different waveforms have been generated.

33
FLOWCHART

Mode 0 Mode 1 & 2


START
START
Store control word in control register

Store control word in


control register
Input to be read from port A

Input to be read from port A Disable all interrupts except RST


6.5

Store into accumulator Store output to port B

Output written on port B


STOP

STOP

34
EXP. NO: 4 INTERFACING PROGRAMMABLE PERIPHERAL
INTERFACE 8255 DATE:

AIM:
To write ALP by interfacing 8255 with 8086 in mode 0, mode 1 and mode 2

APPARATUS REQUIRED:

8086 kit, 8255 interface kit.

ALGORITHM:

1. Take two 8086 microprocessor kits.


2. Enter the transmitter program in transmitter kit.
3. Enter the receiver program in receiver kit.
4. Interface the two kits with 26-core cable on PPI-1.
5. Execute the receiver kit.
6. Execute the transmitter kit.
7. Go and see the memory location 1200 in receiver ur getting 8 same datas.
8. Data is available in transmitter kit the memory location is 100f.
9. We will change the data & execute the following procedure & get the result in receiver kit.
BSR mode

Bit set/reset, applicable to PC only. One bit is S/R at a time. Control word:

D7 D6 D5 D4 D3 D2 D1 D0
0 (0=BSR) X X X B2 B1 B0 S/R (1=S,0=R)

Bit select: (Taking Don't care's as 0)

B2 B1 B0 PC bit Control word (Set) Control word (reset)


0 0 0 0 0000 0001 = 01h 0000 0000 = 00h
0 0 1 1 0000 0011 = 03h 0000 0010 = 02h
0 1 0 2 0000 0101 = 05h 0000 0100 = 04h
0 1 1 3 0000 0111 = 07h 0000 0110 = 06h
1 0 0 4 0000 1001 = 09h 0000 1000 = 08h
1 0 1 5 0000 1011 = 0Bh 0000 1010 = 0Ah
1 1 0 6 0000 1101 = 0Dh 0000 1100 = 0Ch
1 1 1 7 0000 1111 = 0Fh 0000 1110 = 0Eh

35
I/O mode

36
D7 D6 D5 D4 D3 D2 D1 D0
1 (1=I/O) GA mode select PA PCU GB mode select PB PCL
 D6, D5: GA mode select:
o 00 = mode0
o 01 = mode1
o 1X = mode2
 D4(PA), D3(PCU): 1=input 0=output
 D2: GB mode select: 0=mode0, 1=mode1
 D1(PB), D0(PCL): 1=input 0=output

PROGRAM:

Transmitter

MEMORY OPCODES MNEMONICS


ADDRESS
1000 B082 MOVAL,82H
1003 E626 OUT26H,AL
1005 B03F MOVAL,3FH
1008 E620 OUT20H,AL
100A E422 LOOP:INAL,22H
100C 2C3F SUBAL,3FH
100F 75FA JNZLOOP
1011 B024 MOVAL,24H
1014 E620 OUT20H,AL
1016 E81017 R CALLDELAY
1019 CD02 INT 02
101B B305 DELAY:MOVBL,05H
101E B2FF LION:MOVDL,0FFH
1021 FECA L2:DECDL
1023 75FC JNZL2
1025 FECB DECBL
1027 75F6 JNZLION
1029 C3 RET

37
Receiver

38
MEMORYADDRESS OPCODES MNEMONICS

1000 B090 MOVAL,90H


1003 E626 OUT26H,AL
1005 E420 CHECK:INAL,20H
1007 2C3F SUBAL,3FH
100A 75FA JNZCHECK
100C B03F MOVAL,3FH
100F E622 OUT22H,AL
1011 B108 MOVCL,08H
1014 E81024 R CALLDELAY
1017 BE1200 MOVSI,1200H
101B E420 L1:INAL,20H
101D 8804 MOV[SI],AL
101E E81024 R CALLDELAY
1022 46 INCSI
1023 FEC9 DECCL
1025 75F4 JNZL1
1027 CD02 INT 02
1029 B305 DELAY:MOVBL,05H
102C B2FF LION:MOVDL,0FFH
102F FECA L2:DECDL
1031 75FC JNZL2
ANOTHER PROGRAM:

MEMORY ADDRESS OPCODES LABEL MNEMONICS


1000 C6 C0 90 MOV AL,90
1002 E6 C6 OUT C6,AL
1004 E4 C0 IN AL,C0
1006 E6 C2 OUT C2,AL
1008 C7 C6 00 11 MOV SI,1100
100A 88 04 MOV [SI],AL
100C F4 HLT

Result:
The programs for interfacing 8255 with 8086 are executed & the output is obtained for
modes 0, 1 & 2.

FLOWCHART:

39
SET UP
POINTER
INITIALIZE THE COUNTER

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

LOOK-UP TABLE:

1200 98 68 7C C8
1204 FF 1C 29 FF

MEMORY 7-SEGMENT LED FORMAT HEX


LOCATION d c b a d e g f DATA
1200H 1 0 0 1 1 0 0 0 98
1201H 0 1 1 0 1 0 0 0 68
1202H 0 1 1 1 1 1 0 0 7C
1203H 1 1 0 0 1 0 0 0 C8
1204H 1 1 1 1 1 1 1 1 FF
1205H 0 0 0 0 1 1 0 0 1C
1206H 0 0 1 0 1 0 0 1 29

EXP.NO: 5(a) INTERFACING PROGRAMMABLE KEYBOARD AND DISPLAY


CONTROLLER- 8279
40
DATE:

AIM :
To display the rolling message “HELP US “in the display.

APPARATUS REQUIRED:
8086 Microprocessor kit, Power supply, interfacing board.

ALGORITHM :
Display of rolling message “ HELP US “
1. Initialize the counter
2. Set 8279 for 8 digit character display, right entry
3. Set 8279 for clearing the display
4. Write the command to display
5. Load the character into accumulator and display it
6. Introduce the delay
7. Repeat from step 1.

1. Display Mode Setup: Control word-10 H

0 0 0 1 0 0 0 0
0 0 0 D D K K K

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 0 1 1 1 0 0
1 1 0 CD CD CD CF CA

11 A0-3; B0-3 =FF

1-Enables Clear display


0-Contents of RAM will be displayed
1-FIFO Status is cleared

1-Clear all bits


(Combined effect of CD)
41
3. Write Display: Control word-90H
1 0 0 1 0 0 0 0

42
1 0 0
AI A A A A

Selects one of the 16 rows


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

1207H 1 1 1 1 1 1 1 1 FF
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7C60012 START : MOV SI,1200H Initialize array
1004 C7C10F00 MOV CX,000FH Initialize array size
1008 C6C010 Store the control word for
MOV AL,10
display mode
100B E6C2 OUT C2,AL Send through output port
100D C6C00C Store the control word to
MOV AL,0CC
clear display
1010 E6C2 OUT C2,AL Send through output port
1012 C6C090 Store the control word to
MOV AL,90
write display
1015 E6C2 OUT C2,AL Send through output port
1017 8A04 L1 : MOV AL,[SI] Get the first data
1019 E6C0 OUT C0,AL Send through output port
101B E8C0F0 CALL DELAY Give delay
101E 46 INC SI Go & get next data
101F E2F6 Loop until all the data’s
LOOP L1
have been taken
1021 E9DCFF JMP START Go to starting location
1024 C7C2FFA0 DELAY : MOV DX,0A0FFH Store 16bit count value
1028 4A LOOP1 : DEC DX Decrement count value
1029 75FD Loop until count values
JNZ LOOP1
becomes zero
102B1 C3 RET Return to main program

43
44
START

INITIALIZE ACCUMULATOR
WITH MODE SET WORD

INITIALIZE LSB OF COUNT


RESULT:
Thus the rolling message “HELP US” is displayed using 8279 interface kit.

INITIALIZE MSB OF COUNT


FLOWCHART:

45
TRIGGER THE COUNT

STOP
CONTROL WORD FORMAT:
D7 D6 D5 D4 D3 D2 D1 D0
SC1 SC0 RL1 RL0 M2 M1 M0 BCD Mode 2 = 34 H

0 0 1 1 0 1 0 0

0 0 1 1 0 1 1 0 Mode 3 = 36 H

SC1 SC0 CHANNEL SELECT RL1 RL0 READ/LOAD

0 0 CHANNEL 0 0 0 LATCH
0 1 CHANNEL 1 0 1 LSB
1 0 CHANNEL 2 1 0 MSB
1 1 ----- 1 1 LSB FIRST, MSB NEXT
BCD --0 –BINARY COUNTER 1 --BCD COUNTER

M2 M1 M0 MODE

0 0 0 MODE 0
0 0 1 MODE 1
0 1 0 MODE 2
0 1 1 MODE 3
1 0 0 MODE 4
1 0 1 MODE 5

EXP. NO: 5 (b) INTERFACING PROGRAMMABLE TIMER-8253 DATE:

46
AIM :
To study different modes of operation of programmable timer 8253

APPARATUS REQUIRED:
8086 kit, Power Chord, 8253 interfacing kit, CRO
THEORY:
The main features of the timer are,
i. Three independent 16-bit counters
ii. Input clock from DC to 2 MHz
iii. Programmable counter modes
iv. Count binary or BCD
The control signals with which the 8253 interfaces with the CPU are CS, RD, WR, A1,
A2.The basic operations performed by 8253 are determined by these control signals. It has six
different modes of operation, viz, mode 0 to mode 5.

MODE 2 – RATE GENERATOR


It is a simple divide - by – N counter. The output will be low for one input clock period.
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 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

ALGORITHM:
Mode 2-
1. Initialize channel 0 in mode 2
2. Initialize the LSB of the count.
3. Initialize the MSB of the count.
4. Trigger the count
5. Read the corresponding output in CRO.
Mode 3-
1. Initialize channel 0 in mode 3
2. Initialize the LSB of the count.
3. Initialize the MSB of the count.
4. Trigger the count
5. Read the corresponding output in CRO.

MODEL GRAPH:

47
RATE GENERATOR:

SQUARE WAVE GENERATOR:

48
MODE 2 – RATE GENERATOR:

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 C6C074 Store the control word in
MOV AL, 74
accumulator
1003 E6CE OUT CE,AL Send through output port
1005 C6C00A Copy lower order count value
MOV AL, 0A
in accumulator
1008 E6CA OUT CA,AL Send through output port
100a C6C000 Copy higher order count value
MOV AL, 00
in accumulator
100D E6CA OUT CA,AL Send through output port
100F F4 HLT Stop

MODE 3 – SQUARE WAVE GENERATOR:

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 C6C036 Store the control word in
MOV AL, 36
accumulator
1003 E6CE OUT CE,AL Send through output port
1005 C6C010 Copy lower order count value in
MOV AL, 10
accumulator
1008 E6C8 OUT C8,AL Send through output port
100A C6C000 Copy higher order count value in
MOV AL, 00
accumulator
100D E6C8 OUT C8,AL Send through output port
100F F4 HLT Stop

49
50
RESULT:

Thus an ALP for rate generator and square wave generator are written and executed.

51
EX.NO. 5(c) INTERFACING PROGRAMMABLE INTERRUPT CONTROLLER - 8259

52
DATE:
AIM :
To interface programmable interrupt controller with 8086.

APPARATUS REQUIRED:
8086 kit, Power Chord, 8259 interfacing kit
ALGORITHM:
Initialize 8259 with the following specifications:
1. ICW4 needed,
2. single 8259,
3. Interval of 4,
4. Edge triggered mode,
5. A7, A6 , A5 = 0 0 0
6. Initialize to type 8 Interrupt
7. 8086 mode
8. Normal EOI
9. Non- buffered mode
10. Not special fully nested mode
11. Mask all Interrupts except IRQ 0
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
2000 C6C017 Store the control word in
MOV AL, 17
accumulator
2003 E6C0 OUT C0, AL Send through output port
2005 C6C008 Store the control word in
MOV AL, 08
accumulator
2008 E6C2 OUT C2,AL Send through output port
200A C6C001 Store the control word in
MOV AL, 01
accumulator
200D E6C2 OUT C2,AL Send through output port
200F C6C0FF Store the control word in
MOV AL,0FE
accumulator
2012 E6C2 OUT C2,AL Send through output port
2014 FB STI Set Interrupt
2015 E9FDFF HERE JMP HERE End of the program

53
INTERRUPT SERVICE ROUTINE:

54
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1200 C6C020 Store the control word in
MOV AL, 20
accumulator
1203 E6C0 OUT C0, AL Send through output port
1205 CD02 INT 2 Call interrupt 2

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

RESULT:

Thus the program for interfacing 8259 with 8086 are executed & the output is obtained

55
56
Ex.No:6 SERIAL COMMUNICATION BETWEEN TWO MP KITS USING 8251.

DATE:

AIM:
To write an assembly language program in 8086 to transmit & receive data between serial
ports of 8086 using RS232 cable.

APPARATUS REQUIRED:
8086 kit, Power Chord, RS-232 Cable.

PROGRAM:

Transmitter program:

ADDRESS LABEL MNEMONICS OPERAND OPCODE


1000 MOV SI,1500H C7C60015
1004 MOV AL,36H C6C036
1007 OUT 16H,AL E616
1009 MOV AL,40H C6C040
100C OUT 10H,AL E610
100E MOV AL,01H C6C001
1011 OUT 10H,AL E610
1013 RELOAD MOV CL,05H C6C105
1016 CHECK IN AL,0AH E40A
1018 AND AL,04H 80E004
101B JZ CHECK 74F9
101D MOV AL,[SI] 8A04
101F OUT 08H,AL E608
1021 INC SI 46
1022 CMP AL,3FH 80F83F
1025 JNZ RELOAD 75EC
1027 DEC CL FEC9
1029 JNZ CHECK 75EB
102B INT 02 CD02

FLOW CHART:
START

57
Check TX/RX Ready

No

Is it High
Yes

Write Data into data register

STOP

Receiver program:

58
ADDRESS LABEL MNEMONICS OPERAND OPCODE
1000 MOV SI,1500H C7C60015
1004 MOV AL,36H C6C036
1007 OUT 16H,AL E616
1009 MOV AL,40H C6C040
100C OUT 10H,AL E610
100E MOV AL,01H C6C001
1011 OUT 10H,AL E610
1013 RELOAD MOV CL,05H C6C105
1016 CHECK IN AL,0AH E40A
1018 AND AL,04H 80E002
101B JZ CHECK 74F9
101D IN AL,08 E408
101F MOV [SI],AL 8804
1021 INC SI 46
1022 CMP AL,3FH 80F83F
1025 JNZ RELOAD 75EC
1027 DEC CL FEC9
1029 JNZ CHECK 7BEB
102B INT 02 CD02
102D INT 02 CD02

RESULT:

Thus the assembly language program in 8086 to transmit & receive data between parallel
ports of 8086 was written & the output was obtained

59
60
EXP.NO: 7 STEPPER MOTOR INTERFACING DATE:

AIM:
To write an assembly language program in 8086 to rotate the motor at different speeds.

APPARATUS REQUIRED:
8086 kit, Stepper Motor, Stepper Motor Interface board

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 stepwise manner from one equilibrium position
to the next.Two-phase scheme: Any two adjacent stator windings are energized. There are two
magnetic fields active in quadrature and none of the rotor pole faces can be in direct alignment
with the stator poles. A partial but symmetric alignment of the rotor poles is of course possible.

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.

PROGRAM:

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


1000 C7C70012 START : MOV DI, Initialize memory location to store
1200H the array of number
1004 C7C10400 MOV CX, 0004H Initialize array size
1008 8A05 LOOP 1 : MOV AL,[DI] Copy the first data in AL
100A E6C0 OUT 0C0,AL Send it through port address
100C C7C21010 MOV DX, 1010H
1010 4A L1 : DEC DX
Introduce delay
1011 75FD JNZ L1
1013 47 INC DI Go to next memory location
1014 E2F2 Loop until all the data’s have been
LOOP LOOP1
sent
1016 E9E7FF Go to start location for continuous
JMP START
rotation
1200 : 09,05,06,0A Array of data’s

61
FLOWCHART:

START

INTIALIZE COUNTER FOR LOOK UP TABLE

GET THE FIRST DATA FROM THE ACCUMULATOR

MOVE DATA INTO THE ACCUMULATOR

DRIVE THE MOTOR


CIRCUITARY

DELAY

DECREMENT COUNTER

YES

NO IS B = 0 ?

GET THE DATA FROM LOOK UP


TABLE

SWITCHING SEQUENCE OF STEPPER MOTOR:

MEMORY A1 A2 B1 B2 HEX
LOCATION CODE
4500 1 0 0 0 09 H
4501 0 1 0 1 05 H
4502 0 1 1 0 06 H
4503 1 0 1 0 0A H

62
RESULT:
Thus the assembly language program for rotating stepper motor in both clockwise and
anticlockwise directions is written and verified.

63
FLOW CHART:

ADDITION

START

Clear PSW

Select Register
Bank

Load A and R 0
with 8- bit datas

Add A & R 0

Store the sum

STOP

SUBTRACTION

START

Clear PSW

Select Register
Bank

Load A and R 0
with 8- bit datas

Subtract A & R 0

Store the result

STOP

64
EXPT NO: 8(a) ARITHMETIC OPERATION USING 8051 DATE:

AIM:
To perform arithmetic operations using 8051 microcontroller.

APPARATUS REQUIRED:

8051 kit, Power Chord

ALGORITHM:
Addition:
1) Move the data 1(05) to accumulator.
2) Add the data 2(03) with accumulator.
3) Move the content 4500 to DPTR.
4) Move the accumulator value to DPTR
5) Short jump to HERE(4108).
Subtraction:
1) Move the data 1(06) to accumulator.
2) Add the data 2(04) with accumulator.
3) Move the content 4500 to DPTR.
4) Move the accumulator value to DPTR
5) Short jump to HERE(4108).
Multiplication:
1) Move the data 1(05) to accumulator.
2) Move the data 2(08) to B register.
3) Multiply the content of A & B.
4) Move the content 4500 to DPTR.
5) Move the accumulator value to DPTR.
6) Increment DPTR by 1.
7) Move the content of B to A.
8) Move the accumulator value to DPTR.
9) Short jump to HERE(410E).
Division:
1) Move the data 1(06) to accumulator.
2) Move the data 2(03) to B register.
3) Divide the content of A by B.
4) Move the content 4500 to DPTR.
5) Move the accumulator value to DPTR.
6) Increment DPTR by 1.
7) Move the content of B to A.
8) Move the accumulator value to DPTR.
9) Short jump to HERE(410E).

65
MULTIPLICATION

START

Clear PSW

Select Register
Bank

Load A and B
with 8- bit datas

Multiply A & B

Store the result

STOP

DIVISION

START

Clear PSW

Select Register
Bank

Load A and B
with 8- bit datas

Divide A & B

Store the result

STOP

66
PROGRAM:

8 bit Addition (Immediate Addressing)


ADDRESS OPCODE LABEL MNEMONICS COMMENTS
4200 C3 CLR C Clear CY Flag
4201 7403 Get the data1 in
MOV A,#data 1
Accumulator
4203 3401 ADDC A, # data 2 Add the data1 with data2
4205 90,45,00 MOV DPTR, # Initialize the memory
4500H location
4208 F0 Store the result in
MOVX @ DPTR, A
memory location
4209 80,FE L1 SJMP L1 Stop the program

8 bit subtraction:
ADDRESS LABEL MNEMONICS OPERAND OPCODE
4100 MOV A, # 06 74,06
4102 SUBB A, #04 94,04
4104 MOV DPTR, # 4500 90,45,00
4107 MOVX @ DPTR, A F0
4108 HERE SJMP HERE 80,08,41

8 bit multiplication:
ADDRESS LABEL MNEMONICS OPERAND OPCODE
4100 MOV A, # 05 74,05
4102 MOV B, # 08 75, 00,F0,03
4105 MUL AB A4
4106 MOV DPTR, # 4500 90,45,00
4109 MOVX @ DPTR, A F0
410A INC DPTR A3
410B MOV A,B E5,F0
410D MOVX @ DPTR,A F0
410E HERE SJMP HERE 80,0E,41

8 bit division:
ADDRESS LABEL MNEMONICS OPERAND OPCODE
4100 MOV A, # 06 74,06
4102 MOV B, #03 74,F0,03
4105 DIV AB 84
4106 MOV DPTR, # 4500 90,45,00
4109 MOVX @ DPTR, A F0
410A INC DPTR A3
410B MOV A,B E5,F0
410D MOVX @ DPTR, A F0
410E HERE SJMP HERE 80,0E,41

67
ADDTION:

OUTPUT
MEMORY LOCATION DATA

4500

DATA 1

DATA 2

SUBRACTION:

OUTPUT
MEMORY LOCATION DATA

4500

DATA 1

DATA 2

MULTIPLICATION:

INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA

4200 4500
4201

DIVISION:
INPUT OUTPUT
MEMORY LOCATION DATA MEMORY LOCATION DATA
4200 (dividend) 4502 (remainder)

4201 (divisor) 4500 (quotient)

68
RESULT:
Thus the arithmetic operations using 8051 microcontroller has been performed and output
was obtained.

69
FLOWCHART:
AND

START

Move First Data to A

AND Second data with A

Store the result in DPTR

STOP

XOR

START

Move First Data to A

XOR Second data with A

Store the result in DPTR

STOP

NOT

START

Move First Data to A

NOT the data in A

Store the result in DPTR

STOP
70
EXP. NO: 8(b) LOGICAL OPERATIONS USING 8051 DATE:

AIM:
To perform logical operations using 8051 microcontroller.

APPARATUS REQUIRED:
8051 microcontroller kit, Power Chord

ALGORITHM:

AND:
1) Move data 1 to accumulator.
2) AND data 2 with accumulator.
3) Move the data 4500 to DPTR.
4) Move the accumulator value to DPTR.
5) Short jump to HERE (4108).
XOR:
1) Move data 1 to accumulator.
2) XOR data 2 with accumulator.
3) Move the data 4500 to DPTR.
4) Move the accumulator value to DPTR.
5) Short jump to HERE (4108).
NOT:
1) Move data 1 to accumulator.
2) Not the content of accumulator.
3) Move the data 4500 to DPTR.
4) Move the accumulator value to DPTR.
5) Short jump to HERE (4107).

71
AND:

OUTPUT
MEMORY LOCATION DATA

4500

DATA 1

DATA 2

XOR:

OUTPUT
MEMORY LOCATION DATA

4500

DATA 1

DATA 2

NOT:

OUTPUT
MEMORY LOCATION DATA

4500

DATA

72
PROGRAM:

AND:

ADDRESS LABEL MNEMONICS OPERAND OPCODE


4100 MOV A, # data 1 74,#data1
4102 ANL A,# data 2 54,#data2
4104 MOV DPTR # 4500 90,00,45
4107 MOVX @ DPTR, A F0
4108 HERE SJMP HERE 80,08,41

XOR:

ADDRESS LABEL MNEMONICS OPERAND OPCODE


4100 MOV A, # data 1 74,#data1
4102 XRL A,# data 2 64,#data2
4104 MOV DPTR, #4500 90,45,00
4107 MOVX @ DPTR, A F0
4108 HERE SJMP HERE 80,08,41

NOT:

ADDRESS LABEL MNEMONICS OPERAND OPCODE


4100 MOV A, # data 74,#data
4102 CPL A F4
4103 MOV DPTR, #4500 90,45,00
4106 MOVX @ DPTR, A F0
4107 HERE SJMP HERE 80,07,41

RESULT:

73
Thus logical operations have been performed using 8051 microcontroller and output was
obtained.

FLOWCHART:

1’S COMPLEMENT & 2’S COMPLEMENT:

START

Move First Data to A

Complement the data in A

Move the result to DPTR

Increment A by 1

Move the result to DPTR

STOP

1’S COMPLEMENT & 2’S COMPLEMENT:

OUTPUT
MEMORY LOCATION DATA

4200

DATA

74
Ex.No: 8(c) BIT MANIPULATION INSTRUCTIONS USING 8051

DATE:

AIM:
To write an assembly language program for performing 1’s & 2’s complement operations
using 8051.

APPARATUS REQUIRED:
8051 microcontroller kit, Power Chord

PROGRAM:

ADDRESS LABEL MNEMONICS OPERAND OPCODE


4100 MOV A,#data 74,#data
4102 CPL A F4
4103 MOV DPTR,#4200 90,42,00
4106 MOVX @DPTR,A F0
4107 INC A 04
4108 INC DPTR A3
4109 MOVX @DPTR,A F0
410A HERE SJMP HERE 80,0A,41

ALGORITHM:

1) Move the data to accumulator.


2) Complement the content of accumulator.
3) Move the content 4200 to DPTR.
4) Move the accumulator value (1’s complement output) to DPTR.
5) Increment the content of accumulator by 1.
6) Increment DPTR by 1.
7) Move the accumulator value (2’s complement output) to DPTR.
8) Short jump to HERE (410A).

RESULT:

75
Thus the assembly language program for 1’s & 2’s complement operations using 8051
was written & the output was obtained.

INPUT:

1500 = 12
1501 = 10
1502 = 06

OUTPUT :

06:10:12
INPUT :

1500 00
1501 00
1502 00

OUTPUT:
00:00:00

76
EX.NO. 9 COMMUNICATION BETWEEN 8051 MICROCONTROLLER
KIT & PC
DATE :
AIM:
To write an ALP to communicate between 8051 microcontroller kit & PC
APPARATUS REQUIRED:
8051 microcontroller kit, PC

1. DIGITAL CLOCK: (MICRO-86 LCD KIT)


A. CONNECT 9-9 CABLE (PC TO KIT) WITH SERIAL PORT OF PC AND KIT.
B. IN PC OPEN THE EXECUTABLE FILE AND SELECT “TRANSMIT DATA”
FROM THE OPTION SPECIFIED AND PRESS ENTER KEY.
C. TYPE THE FILE NAME WITH .BIN AS EXTENSION.
D. TYPE N IN OPTION DISPLAYED .
E. IN KIT TYPE BU 5ENTER KEY (TO SET BAUD RATE=9600).
F. TYPE SI 1000 ENTER KEY (TO PROVIDE SERIAL INPUT).
G. IN PC PRESS ENTER KEY AND WAIT TILL TRANSMISSION OVER
MESSAGE IS DISPLAYED.
H. PROVIDE THE INPUT IN 1500 AND EXECUTE THE PROGRAM TO
DISPLAY DIGITAL CLOCK IN HH:MM:SS FORMAT.

2. STOP WATCH : (MICRO-51 LCD KIT)


A. CONNECT 9-9 CABLE (PC TO KIT) WITH SERIAL PORT OF PC AND KIT.
B. IN PC OPEN THE EXECUTABLE FILE AND SELECT “TRANSMIT DATA”
FROM THE OPTION SPECIFIED AND PRESS ENTER KEY.
C. TYPE THE FILE NAME WITH .BIN AS EXTENSION.
D. TYPE N IN OPTION DISPLAYED .
E. IN KIT TYPE BU 5ENTER KEY (TO SET BAUD RATE=9600).
F. TYPE SI 1000 ENTER KEY (TO PROVIDE SERIAL INPUT).
G. IN PC PRESS ENTER KEY AND WAIT TILL TRANSMISSION OVER
MESSAGE IS DISPLAYED.
H. PROVIDE THE INPUT IN 1500 AND EXECUTE THE PROGRAM TO
DISPLAY STOP WATCH
I. PRESS ANY KEY TO INITIATE THE WATCH.

RESULT:
77
Thus the communication between 8051 microcontroller kit and PC is done.

78
EX.NO. 10 INTERFACING SWITCH AND LED WITH ARDUINO DATE :

AIM:
To Connect and operating LED connected to the digital outputs of an Arduino.

APPARATUS REQUIRED:

A computer (Windows, Mac, or Linux), An Arduino-compatible microcontroller & A USB A-to-


B cable.

PROGRAM:

Part 1: Connecting Arduino to the computer

1. Open the Arduino IDE by clicking on the Arduino Icon.

2. Connect your Arduino to the computer using the USB cable.

3. Make sure you select the right board (see below screen-shot)

4. Then select the correct serial port. (see below screen-shot)

79
80
Part 2: Compiling and Uploading file to the Arduino

Pinout of Arduino UNO

1. Once you see your Arduino board is connected to your computer. Go to the
File menu -> Examples -> 01.Basics -> Blink.

81
82
2. This should open up a new window that has a tab labeled Blink. See below screen-shot
for description.

3. Then click on the Sketch menu and check for any typos / errors using verify button and
Compile to the machine language if the verification is successful.

83
84
4. If the above process is successful, you should see the message in the status
bar showing that the compilation is successful.

5. Now upload your program to the Arduino by clicking upload button in the
Sketch menu.

6. You might face some issues from step 3-5 if you have not selected a correct
board/serial port. So please make sure you went through the part 1
carefully.

Part 3: Blinking LED

1. In the above Blink code you see bunch of lines performing certain operations. In
our case, turning on and off an LED connected to the Digital pin 13.
2. Most Arduinos have an on-board LED that is attached to digital pin 13. So, you
must see the LED on your board starting to blink. (In some cases, the boards are
pre-installed with the program. So the LED starts to blink once you have powered
the Arduino )

In the code you can see that the OUTPUT is being taken from the digital pin 13. We can
change the output of the board by just changing the output pin numbers, i.e., see what
happens if you replace 13 with 12. (You have to upload every time to see the changes)

85
86
3. Before uploading your new code to the Arduino we have to make sure that LED is
connected to the Digital pin 12, if there is nothing connected we don’t have a way
to see our result. Please follow the below schematic for connecting the LED to the
digital pins on the Arduino board. A series resistor is mandatory for the circuit, it
prevents the LED from burning out.
4. Now, you have a blinking LED controlled using an Arduino. Now, we can change
the LED turn on and off times by editing the time in the software.

RESULT:
Thus the assembly program interfacing switch and LED with Arduino was executed.
The output was verified in the Arduino kit.

87
88
EX.NO. 11 INTERRUPT PROGRAMMING USING PIC

DATE :
AIM:

To write an assembly program for interrupt and verify the output in the PIC16F877.

APPARATUS REQUIRED:

PIC16F877 Kit , MPLAB IDE & Personal Computer

PROCEDURE:

1. Start the program

2. Initialize the IO port lines

3. Set the PORTB as input port

4. Set the switch to perform the interrupt operation

5. execute the program and verify the results

6. Stop the program

THEORY:
Interrupt is the one of the most powerful feature in embedded applications. Almost all
the real time applications are implemented using Interrupts. So what is an Interrupt…?? As
the name suggests Interrupts are a special event that requires immediate attention, it stops a
microcontroller/microprocessor from the running task and to serve a special task known as
Interrupt Service Routine (ISR) or Interrupt Handler. Suppose you are at home, taking coffee.
Suddenly your mobile phone rings. You stop taking coffee and answer the call. When you
have finished the conversation, you will go back to take coffee. This process is similar to ISR
execution. You can think the main service routine as taking coffee and the ringing of mobile
phone is causes interrupt in taking coffee. This initiates your mobile phone conversation
which is similar to executing ISR. When the mobile conversation is ended you will go back
to the main service routine of taking coffee. Consider a MP3 player which builds around
microcontroller. It contains push button switches to select song, control volume etc. The
microcontroller should be programmed to convert the data stored in MP3 files to electrical
signal and to change controls according to the status of push button switches. Consider this
application without using interrupt; the programmer wants to continuously do the following
tasks.
 Read the status of push button switches and change controls accordingly

 Read data from MP3 file

 Convert it to electrical signal

89
90
This process of continuous monitoring is known as POLLING. This is not an efficient
way of programming as it consumes all its processing time for monitoring. Consider if this
problem is addressed using Interrupts. The microcontroller wants to respond only when
an interrupt occurs. Here is an analogy to understand the difference better. The method of
polling is similar to a salesperson, which goes door-to-door to requesting to buy his product
or service. This is similar to a microcontroller continuously monitoring the status of all
devices attached to it.

Hardware and Software Interrupts: PIC Microcontroller consists of both Hardware and
Software Interrupts. If the interrupts are generated by external hardware at certain pins of
microcontroller, or by inbuilt devices like timer, they are called Hardware Interrupts. While
Software interrupts are generated by a piece of code in the program. Also known as External
and Internal Interrupts.

PROGRAM:

LIST P=P16F877
INCLUDE "P16F877.INC"
;CBLOCK 0X20
;SCALER
;TEMP1
;TEMP
;ENDC
ORG 0X00
BCF STATUS,RP1
BSF STATUS,RP0 ;SELECT BANK1
MOVLW B'00010000'
MOVWF TRISB ;RB4 INPUT PORT
MOVLW 0X7F
MOVWF OPTION_REG
CLRF TRISA
CLRF TRISE
BCF STATUS,RP0
CLRF PORTA
CLRF PORTE

BACK BTFSC PORTB,4 ;CHECH FOR SWITCH1


;(LOW WHEN PRESS)
GOTO BACK
REPEAT MOVLW 0X20
MOVWF PORTA
MOVLW 0X00
MOVWF PORTE
GOTO REPEAT
;DELAY
; MOVLW 0X07 ;GENERATES DELAY OF 1 SECOND
; MOVWF SCALER
; MOVLW 0X7
; MOVWF TEMP
; MOVLW 0XFF
; MOVWF TEMP1
; DECFSZ TEMP1,1
; GOTO $-1
91
92
; DECFSZ TEMP,1
; GOTO $-5
; DECFSZ SCALER,1
; GOTO $-9
; RETURN

END

RESULT:

Thus the assembly program for interrupt was written and executed. The output was
verified in the PIC16F877 kit.
93
94
EX.NO. 12 USART PROGRAMMING USING PIC DATE :

AIM:

To write an assembly program for USART Communication in asynchronous mode


and verify the output in the PIC16F877.

APPARATUS REQUIRED:

PIC16F877 Kit , MPLAB IDE & Personal Computer

PROCEDURE:

1. Start the program


2. Initialize the IO port lines
3. Set RC6 & RC7 as input ports
4. Set the USART MODE SELECT as asynchronous mode
5. Enable the serial port and disable the USART transmit interrupt
6. Enable the transmission value which is pressed in computer keyboard
7. Execute the program and verify the results through HyperTerminal
8. Stop the program

THEORY:

A USART (Universal Synchronous/Asynchronous Receiver/Transmitter) is a


microchip that facilitates communication through a computer's serial port using the RS-232C
protocol. Like a UART (Universal Asynchronous Receiver/Transmitter), a USART provides
the computer with the interface necessary for communication with modems and other serial
devices. However, unlike a UART, a USART offers the option of synchronous mode. In
program-to-program communication, the synchronous mode requires that each end of an
exchange respond in turn without initiating a new communication. Asynchronous operation
means that a process operates independently of other processes.
Practical differences between synchronous mode (which is possible only with a
USART) and asynchronous mode (which is possible with either a UART or a USART) can
be outlined as follows:
 Synchronous mode requires both data and a clock. Asynchronous mode requires only
data.
 In synchronous mode, the data is transmitted at a fixed rate. In asynchronous mode,
the data does not have to be transmitted at a fixed rate.
 Synchronous data is normally transmitted in the form of blocks, while asynchronous
data is normally transmitted one byte at a time.
 Synchronous mode allows for a higher DTR (data transfer rate) than asynchronous
mode does, if all other factors are held constant.

95
96
PROGRAM:

; USART IN ASYNCHRONOUS MODE

LIST P=P16F877
INCLUDE "P16F877.INC"
ERRORLEVEL -302
CBLOCK H'20'
DATA1
ENDC

ORG H'00'
GOTO START
ORG 0X04
RETFIE

START
CALL INITIALIZE ; INITIALIZATION OF PORTS & OTHER
REGISERS

LOOP CALL USART_RECEIVE

STOP GOTO STOP

INITIALIZE
BCF STATUS,RP1
BSF STATUS,RP0 ;CHANGE TO BANK1
MOVLW B'11000000' ;RC6 & RC7 AS INPUT PORTS
MOVWF TRISC

MOVLW .25 ; SET SPBRG FOR 6 WHICH IS THE BAUD RATE


GENERATOR
MOVWF SPBRG ; FOR 9600 BAUD RATE

BSF TXSTA,BRGH ;HIGH SPEED IN ASYNCHRONOUS MODE


BCF TXSTA,SYNC ;USART MODE SELECT AS ASYNCHRONOUS
MODE

BCF STATUS,RP0
BSF RCSTA,SPEN ;SERIAL PORT ENABLE

BSF STATUS,RP0
BCF PIE1,TXIE ;DISABLES THE USART TRANSMIT INTRUPT
BCF TXSTA,TX9 ;SELECT 8-BIT TRANSMISSION

RETURN

TRANSMIT

BSF STATUS,RP0
BSF TXSTA,TXEN ;TRANSMIT ENABLED
97
98
BTFSS TXSTA,TRMT ;WAIT UNTILL TSR REGISTER IS EMPTY
GOTO $-1

BCF STATUS,RP0
MOVF DATA1,F ;MOVE DATA TO WORKIN REGISTER
MOVWF TXREG ;MOVE DATA TO TRANSMIT REGISTER

BTFSS PIR1,TXIF ;WAIT UNTILL TXREG IS EMPTY


GOTO $-1

BSF STATUS,RP0
BTFSS TXSTA,TRMT ;WAIT UNTILL TSR REGISTER IS EMPTY
GOTO $-1

RETURN

USART_RECEIVE

BCF STATUS,RP0
BSF RCSTA,CREN
BTFSS PIR1,RCIF
GOTO $-1

MOVF RCREG,W

MOVWF DATA1
CALL TRANSMIT

NOP
GOTO LOOP
END

RESULT:

Thus the assembly program for USART Communication in asynchronous mode was
written and executed. The output was verified in the PIC16F877 kit.

99

You might also like