Post on 22-Apr-2015
transcript
LABORATORY MANUAL
ECE 306
UNIFIED ELECTRONICS LAB IV
1 | P a g e
TABLE OF CONTENTS
S. No. Title of the Experiment Page No.
1 Perform the basic programs using 8085 Microprocessor kit in assembly language.
3
2 Interfacing of Seven segment displays with 8085 microprocessor. 9
3 Interfacing and control of stepper motor using 8085 microprocessor.
11
4 Interfacing of D/A converter with 8085 microprocessor. 12
5 Design a 8085 Microprocessor based Traffic light control 13
6 8051 Assembly language programming using Keil compiler. (At least 5 programs.).
15
7 Interfacing of LCD with8051 Microcontroller 21
8 Interfacing of ADC with 8051 Microcontroller 24
9 Interfacing of DAC with 8051 Microcontroller 29
10 Interfacing of keyboard with 8051 Microcontroller 30
11 Implementing of Serial Communication using 8051 Microcontroller
34
12 Perform the basic programs using 8086 Microprocessor kit in assembly language.
36
2 | P a g e
Experiment 1
Aim: Perform the following using 8085 Microprocessor kit in assembly language.
i. Write a program to add two 8-bit numbers. (Or) Write a program to add two 16-
bit numbers.
ii. Write a program to subtract two 8-bit numbers. (Or) Write a program to subtract
two 16-bit numbers.
iii. Write a program to multiply two 8 bit numbers by repetitive addition method.
(Or) Write a program to multiply two 8 bit numbers by rotation method.
iv. Write a program to generate Fibonacci series.
Requirements: 8085 Microprocessor kit
Program ( i.a ):
Address Machine
Code / Data
Label Mnemonics Operands Comments
2000 21 LXI H,3000h
2001 00
2002 30
2003 7E MOV A,M
2004 23 INX H
2005 86 ADD M
2006 23 INX H
2007 77 MOV M,A
2008 EF RST5
Program ( i.b ):
Address Machine
Code / Data
Label Mnemonics Operands Comments
3 | P a g e
2007 2A LHLD 2000h
2008 00
2009 20
200A EB XCHG
200B 2A LHLD 2002h
200C 02
200D 20
200E 0E MVI C,00h
200F 00
2010 19 DAD D
2011 D2 JNC KK
2012 15
2013 20
2014 0C INR C
2015 22 KK SHLD 2004h
2016 04
2017 20
2018 79 MOV A,C
2019 32 STA 2006h
201A 06
201B 20
201C EF RST5
Program ( ii.a ):
Address Machine
Code / Data
Label Mnemonics Operands Comments
2000 21 LXI H,3000h
2001 00
2002 30
2003 7E MOV A,M
2004 23 INX H
4 | P a g e
2005 96 SUB M
2006 23 INX H
2007 77 MOV M,A
2008 EF RST5
Program ( ii.b ):
Address Machine
Code / Data
Label Mnemonics Operands Comments
2007 21 LXI H, 2000h
2008 00
2009 20
200A 7E MOV A,M
200B 23 INX H
200C 96 SUB M
200D 32 STA 2004h
200E 04
200F 20
2010 23 INX H
2011 7E MOV A,M
2012 23 INX H
2013 9E SBB M
2014 32 STA 2005h
2015 05
2016 20
2017 3E MVI A, 00h
2018 00
2019 17 RAL
201A 32 STA 2006h
201B 06
201C 20
201D EF RST5
5 | P a g e
Program ( iii.a ):
Address Machine
Code / Data
Label Mnemonics Operands Comments
2000 3A LDA 3000h
2001 00
2002 30
2003 5F MOV E, A
2004 16 MVI D, 00h
2005 00
2006 3A LDA 3001h
2007 01
2008 30
2009 4F MOV C,A
200A 21 LXI H, 0000h
200B 00
200C 00
200D 19 KK DAD D
200E 0D DCR C
200F C2 JNZ KK
2010 0D
2011 20
2012 22 SHLD 3002h
2013 02
2014 30
2015 EF RST5
Program ( iii.b ):
Address Machine
Code / Data
Label Mnemonics Operands Comments
6 | P a g e
2000 21 LXI H, 2501h
2001 01
2002 25
2003 5E MOV E, M
2004 16 MVI D, 00h
2005 00
2006 23 INX H
2007 7E MOV A, M
2008 21 LXI H, 0000h
2009 00
200A 00
200B 06 MVI B, 08h
200C 08
200D 29 YY DAD H
200E 13 RAL
200F D2 JNC KK
2010 13
2011 20
2012 19 DAD D
2013 05 KK DCR B
2014 C2 JNZ YY
2015 0D
2016 20
2017 22 SHLD 2503h
2018 03
2019 25
201A EF RST5
Program ( iv ):
Address Machine
Code / Data
Label Mnemonics Operands Comments
7 | P a g e
2000 21 LXI H, 2501h
2001 00
2002 25
2003 3E MVI A, 00h
2004 00
2005 0E MVI C, 0Ah
2006 0A
2007 77 MOV M, A
2008 06 MVI B,01h
2009 01
200A 0D DCR C
200B 23 KK INX H
200C 80 ADD B
200D 70 MOV M, B
200E 57 MOV D, A
200F 78 MOV A, B
2010 42 MOV B, D
2011 0D DCR C
2012 C2 JNZ KK
2013 0B
2014 20
2015 EF RST5
8 | P a g e
Experiment 2
Aim: Interfacing of Seven segment display with 8085 microprocessor.
Requirements: 8085 Microprocessor kit, Seven Segment LED & wires.
Circuit Diagram:
Program:
MVI A, 80H
OUT 03h
K: LXI H, 2000H
MVI B, 10H
KK: MOV A, M
OUT 00h
CALL DELAY
INX H
JNZ KK
JMP K
HLT
Delay: LXI D, Count
Back: DCX D
MOV A, D
ORA E
JNZ Back
RET
9 | P a g e
Inputs:
2000: 40H, 79H, 24H, 30H, 19H, 12H, 02H, 78H, 00H, 18H, 08H, 03H, 46H, 21H, 06H,
0EH
Result:
On the Seven segment LED we can see all the Hexadecimal no’s displayed with some
delay as mentioned.
10 | P a g e
Experiment 3
Aim: Interfacing and control of stepper motor using 8085 microprocessor.
Requirements: 8085 Microprocessor kit, Stepper Motor, Motor driver circuit
(ULN2003) & wires.
Program:
i) To rotate in Clock Wise direction
MVI A, 80H
OUT CR
MVI A, 44H
KK: OUT PA
CALL DELAY
RRLC
JMP KK
RST 5
ii) To rotate in Anti-Clock Wise direction
MVI A, 80H
OUT CR
MVI A, 44H
KK: OUT PA
CALL DELAY
RLC
JMP KK
RST 5
Delay: LXI D, Count
Back: DCX D
MOV A, D
ORA E
JNZ Back
RET
Result: Stepper motor rotates in Clock wise & Anti-clock wise direction.
11 | P a g e
Experiment 4:
Aim: Interfacing of D/A converter with 8085 microprocessor to generate RAMP wave.
Requirements: 8085 Microprocessor Kit, DAC0808, 100nF(2), 1k, Op-Amp 741.
Circuit Diagram:
Program:
MOV A, 80H
OUT CW
MVI A, 00H
KK: OUT PA
CALL DELAY
INC A
JMP KK
RST 5
Delay: LXI D, Count
Back: DCX D
MOV A, D
ORA E
JNZ Back
RET
Result: On the CRO we can see a RAMP wave generated.
12 | P a g e
Experiment 5
Aim: Design a 8085 Microprocessor based Traffic light control for
figure shown below with the following conditions:
Allow traffic to flow from N to S & S to N for 1sec
Glow all Yellow lights for 0.2sec
Allow traffic to flow from W to E & E to W for 1sec
Glow all Yellow lights for 0.2sec
Make this process continues.
Requirements: 8085 Microprocessor Kit, 9 LED’s, 5K resistors (9)
Circuit Diagram:
Program:
MVI A, 80H : Initialize 8255, port A and port B
OUT CR ;(CR) : in output mode
START: MVI A, 09H
OUT PA; (PA) : Send data on PA to glow R1 and R2
MVI A, 24H
OUT PB; (PB) : Send data on PB to glow G3 and G4
MVI C, 28H : Load multiplier count (40ıο) for delay
CALL DELAY : Call delay subroutine
MVI A, 12H
13 | P a g e
OUT PA; PA : Send data on Port A to glow Y1 and Y2
OUT 81H ;PB : Send data on port B to glow Y3 and Y4
MVI C, 0AH : Load multiplier count (10ıο) for delay
CALL: DELAY : Call delay subroutine
MVI A, 24H
OUT 80H ;PA : Send data on port A to glow G1 and G2
MVI A, 09H
OUT 81H; PB : Send data on port B to glow R3 and R4
MVI C, 28H : Load multiplier count (40ıο) for delay
CALL DELAY : Call delay subroutine
MVI A, 12H
OUT 80H : Send data on port A to glow Y1 and Y2
OUT 81H : Send data on port B to glow Y3 and Y4
MVI C, 0AH : Load multiplier count (10ıο) for delay
CALL DELAY : Call delay subroutine
JMP START
Delay Subroutine:
DELAY: LXI D, Count : Load count to give 0.5 sec delay
BACK: DCX D : Decrement counter
MOV A, D
ORA E : Check whether count is 0
JNZ BACK : If not zero, repeat
DCR C : Check if multiplier zero, otherwise repeat
JNZ DELAY
RET : Return to main program
14 | P a g e
Experiment 6
Aim: 8051 Assembly language programming using Keil compiler. (At least 5 programs.).
a. Find the sum of the values 79H, F5H, E2H. Put the sum in register R0 (low
byte) and R5 (high byte).
b. Write a program to copy the values 55H into RAM memory locations 40H to
45H using
i) Direct addressing mode
ii) Register indirect addressing mode without using loop
iii) With a loop
c. Write a program to toggle all the bits of P1 after some delay
d. Write a program to generate square wave of 50% duty cycle on bit 0 of port 1
e. Write a program to
i) Make P1 as input port.
ii) To get hex data from P1 and convert it into decimal and save the digits in
R7, R6, R5.
f. Write a program to add two 16 – bit numbers 3CE7H and 3B8DH. Place the
sum in R7 and R6 (Lower Byte).
g. A switch is connected to P1.7. Write a program to check the status of SW and
perform the following:
i) If SW=0, send letter „N. to P2.
ii) If SW=1, send letter „Y. to P2.
h. Write a program for Hex to ASCII conversion
i. Write a program to generate square wave using timer
Requirements: Keil software
Program (a):
Org 0000h
mov a,#79h
mov r5,#00h
add a,#0f5h
jnc here
inc r5
15 | P a g e
here: add a,#0e2h
jnc go
inc r5
go: mov r0,a
end
Program (b):
i) Direct addressing mode
MOV A,#55
MOV 40H,A
MOV 41H,A
MOV 42H,A
MOV 43H,A
MOV 44H,A
MOV 45H,A
ii) Register indirect addressing mode without using loop
MOV R0,#40H
MOV A,#55H
MOV @R0,A //copy a to ram location r0 points to
INC R0
MOV @R0,A
INC R0
MOV @R0,A
INC R0
MOV @R0,A
INC R0
MOV @R0,A
INC R0
END
iii) With a loop.
MOV R0,#40H
MOV A,#55H
GO:MOV @R0,A
INC R0 16 | P a g e
CJNE R0,#46H, GO
END
Program (c):
org 0000h
again:
mov p1,#55h
acall delay
mov p1,#0aah
acall delay
sjmp again
delay:mov r0,#04h
go3:mov r1,#0ffh
go2:mov r2,#0ffh
go1:djnz r2,go1
djnz r1,go2
djnz r0,go3
ret
end
Program (d):
org 0000h
again:cpl p1.0
sjmp again
end
Program (e):
Org 0000h
mov a,#0ffh
mov p1,a
mov a,p1
mov b,#10
div ab
mov r7,b
mov b,#10
div ab 17 | P a g e
mov r6,b
mov r5,a
end
Program (f):
org 0000h
mov r5,#00h
mov a,#0e7h
add a,#8dh
mov r6,a
mov a,#3ch
addc a,#3bh
jnc go
inc r5
go: mov r7,a
end
Program (g):
org 0000h
setb p1.7
again:mov c,p1.7
jnc go
mov p2,#'Y'
go:mov p2,#'N'
sjmp again
end
Program (h):
org 0000h
mov a,#2dh
mov r1,a
anl a,#0fh
acall char
mov r2,a
mov a,r1
swap a 18 | P a g e
anl a,#0fh //mov the lower nibble to r2
acall char
mov r3,a
here:sjmp here
char:
cjne a,#0ah,out1
mov a,#41h //to get 41
sjmp go
out1:cjne a,#0bh,out2
mov a,#42h //to get 42
sjmp go
out2:cjne a,#0ch,out3
mov a,#43h //to get 43
sjmp go
sjmp code1
code1:
out3:cjne a,#0dh,out4
mov a,#44h //to get 44
sjmp go
out4:cjne a,#0eh,out5
mov a,#45h //to get 45
sjmp go
out5:cjne a,#0fh,out
mov a,#46h //to get 46
sjmp go
out:
orl a,#30h
go:
ret
end
19 | P a g e
Program (i):
org 0000h
again:mov tmod,#01h
mov th0,#01h
mov tl0,#00h
cpl p1.1
setb tr0
here: jnb tf0,here
clr tr0
clr tf0
sjmp again
end
20 | P a g e
Experiment 7
Aim: Interfacing of LCD with8051 Microcontroller
Requirements: 8051, 11.0592MHz Crystal, 33pF (2), 10uF, 10K, push button, 1K (10),
LCD (Liquid Crystal Display), Bread Board, Connecting wires, 5V power supply.
Circuit Diagram:
Program:
ORG 0000H
MOV A,#38H
ACALL COM
MOV A,#0EH
ACALL COM
MOV A,#01H
ACALL COM
MOV A,#10H
ACALL COM
MOV A,#80H
ACALL COM21 | P a g e
AGAIN: ACALL DISPLAY
MOV A,#01H
ACALL COM
SJMP AGAIN
COM: ACALL DELAY
CLR P2.0
CLR P2.1
SETB P2.2
MOV P1,A
ACALL DELAY
CLR P2.2
ACALL DELAY
RET
DATA1: ACALL DELAY
SETB P2.0
CLR P2.1
SETB P2.2
MOV P1,A
ACALL DELAY
CLR P2.2
ACALL DELAY
RET
DELAY: MOV R0,#15H
GO: MOV TMOD,#01H
MOV TL0,#0FFH
MOV TH0,#0DBH
SETB TR0
BACK: JNB TF0,BACK
CLR TR0
CLR TF0
DJNZ R0,GO
RET
DISPLAY: MOV R1,#14D22 | P a g e
MOV A,#00H
MOV DPTR,#MYDATA
NEXT: CLR A
MOVC A,@A+DPTR
JZ OUT
ACALL DATA1
INC DPTR
CLR A
DJNZ R1,NEXT
OUT: RET
MYDATA:DB "*I LOVE INDIA*"
END
23 | P a g e
Experiment 8
Aim: Interfacing of ADC with 8051 Microcontroller
Requirements: 8051, 11.0592MHz Crystal, 33pF (2), 10uF, 10K, push button, 1K (10),
Analog to Digital Convertor (ADC0808), Bread Board, Connecting wires, 5V power
supply
Circuit Diagram:
Program :
ORG 0000H
LJMP MAIN ;jump to main progam
ORG 000B ;address of Timer 0 interrupt
CPL P2.3 ;generation of less than 100MHz frequency
RETI
MAIN:
ORG 0300H
LCALL LCD ;Initialisaiton of LCD
ACALL DISPLAY
MOV TMOD,#02H ;initialisation of timer 0
24 | P a g e
MOV TH0,0D8H ;delay for more than 100MHz frequency
MOV IE,#82H ;Enable Timer interrut 0
SETB TR0 ;Start timer
MOV P0,#0FFH ;Make P0 as input port
SETB P2.7 ;make EOC an input port
CLR P2.4 ;clear ALE
CLR P2.6 ;clear WR i.e. start of conversion
CLR P2.5 ;clear RD i.e. out enable
CLR P3.7 ;For the selection of data bus for 3.
SETB P3.6
SETB P3.5
BACK:ACALL DELAY
SETB P2.4 ;ALE
ACALL DELAY
SETB P2.6 ;SC
ACALL DELAY
CLR P2.4 ;ALE
CLR P2.6 ;SC
HERE:JB P2.7,HERE ;wait untill done
SETB P2.5
ACALL DELAY_1
MOV A,P0
CLR P2.5
ACALL CONVERSION
ACALL DISPLAY
SJMP BACK
CONVERSION: ;conversion from HEX to BCD
MOV B,#0AH
DIV AB
MOV R0,B
MOV B,#10
DIV AB
MOV R1,B 25 | P a g e
MOV R2,A
MOV A,R0
ADD A,#30H
MOV R0,A
MOV A,R1
ADD A,#30H
MOV R1,A
MOV A,R2
ADD A,#30H
MOV R2,A
RET
LCD: ;Initialization of LCD
MOV A,#38H
ACALL COMM
ACALL DELAY_1
MOV A,#0EH
ACALL COMM
ACALL DELAY_1
MOV A,#01H
ACALL COMM
ACALL DELAY_1
MOV A,#06H
ACALL COMM
ACALL DELAY_1
MOV A,#80H
ACALL COMM
ACALL DELAY_1
RET
DISPLAY:
MOV A,#'T'
ACALL WRITE
MOV A,#'E'
ACALL WRITE 26 | P a g e
MOV A,#'M'
ACALL WRITE
MOV A,#'P'
ACALL WRITE
MOV A,#'.'
ACALL WRITE
MOV A,#' '
ACALL WRITE
MOV A,R2
ACALL WRITE
MOV A,R1
ACALL WRITE
MOV A,R0
ACALL WRITE
MOV A,#'`'
ACALL WRITE
MOV A,#'C'
ACALL WRITE
ACALL DELAY_1
MOV A,#80H
ACALL COMM
RET
COMM:
MOV P1,A
CLR P2.0
CLR P2.1
SETB P2.2
ACALL DELAY_1
CLR P2.2
RET
WRITE:
MOV P1,A
SETB P2.0 27 | P a g e
CLR P2.1
SETB P2.2
ACALL DELAY_1
CLR P2.2
RET
DELAY_1:
MOV R4,#01H
HERE11:MOV R5,#0FFH
HEREE:DJNZ R5,HEREE
DJNZ R4,HERE11
RET
DELAY:
MOV R6,#50
HERE55:DJNZ R6,HERE55
RET
END
28 | P a g e
Experiment 9
Aim: Interfacing of DAC with 8051 Microcontroller
Requirements: 8051, 11.0592MHz Crystal, 33pF (2),100nF(2), 10uF, 10K, push button,
10K resistor(1),1k resistor(1), DAC0808, Op-Amp 741, Bread Board, Connecting wires,
5V & 12V split power supply,
Circuit Diagram:
Program:
;Generation of Triangle wave
org 0000h
again:mov a,#00h ;minimum magnitude
back:mov p2,a ;mag. copy to p2
cjne a,#0ffh,next ;max. mag.
sjmp triangle
next:
inc a
sjmp back
triangle: ;for slope down
mov r0,a
djnz r0,again
mov p2,r0
sjmp triangle
end
29 | P a g e
Experiment 10
Aim: Interfacing of keyboard with 8051 Microcontroller
Requirements: 8051, 11.0592MHz Crystal, 33pF (2), 10uF, 10K, push button
(5 piece for Key-Board),4k7 resistor,10k resistor, 1K (10), LCD, Bread Board,
Connecting wires, 5V power supply
Circuit Diagram:
Program:
//Interfacing of keyboard with lcd
org 0000h
acall lcd
acall keyboard
lcd:
mov a,#38h //2*16 matrix lcd
acall command
mov a,#0eh //dispaly on cursor on
acall command
30 | P a g e
mov a,#01h
acall command
mov a,#06h
acall command
mov a,#80h
acall command
ljmp code2
code2:
ret
command:
acall delay
mov p1,a
clr p3.0
clr p3.1
setb p3.2
acall delay
clr p3.2
ret
data1:
acall delay
mov p1,a
setb p3.0
clr p3.1
setb p3.2
acall delay
clr p3.2
acall delay
ret
delay:
mov r0,#15h
go:mov tmod,#01h
mov tl0,#0ffh
mov th0,#0dbh 31 | P a g e
setb tr0
back:jnb tf0,back
clr tr0
clr tf0
djnz r0,go
ret
keyboard:
mov p2,#0ffh
k1:mov p0,#00h //checking of keyboard's
mov a,p2
anl a,#03h
cjne a,#03h,k1
k2:
acall delay
mov a,p2
anl a,#03h
cjne a,#03h,over
sjmp k2
over:acall delay //checking for row
mov a,p2
anl a,#03h
cjne a,#03h,over1
sjmp k2
over1:
mov p0,#0feh
mov a,p2
anl a,#03h
cjne a,#03h,row0
mov p0,#0fdh
mov a,p2
anl a,#03h
cjne a,#03h,row1
ljmp k2 32 | P a g e
row0:
mov dptr,#code0
sjmp find
row1:
mov dptr,#code1
sjmp find
find:
rrc a
jnc match
inc dptr
sjmp find
match:
clr a
movc a,@a+dptr
acall data1
ljmp k1
code0:
db '1','2'
code1:
db '3','4'
end
33 | P a g e
Experiment 11
Aim: Implementing of Serial Communication using 8051 Microcontroller
i) To transfer letter „A‟ serially at 4800 baud, continuously
ii) To receive bytes of data serially and put them in P1
Requirements: 8051, 11.0592MHz Crystal, 33pF (2), 10uF, 10K, push button,
MAX232, RS232 DB-9 Connector.
Circuit Connections:
Program:
i)
ORG 00H
MOV TMOD,#20H ; Timer 1, mode 2(auto-reload)
MOV TH1,#-6 ; 4800 baud rate
MOV SCON,#50H ; 8 bit, 1 stop, REN enabled
SETB TR1
AGAIN: MOV SBUF,# „A‟ ; letter “A” to be transfered
HERE: JNB TI,HERE
CLR TI ; clear TI for next char
SJMP AGAIN ; keep sending A
34 | P a g e
ii)
ORG 0H
MOV TMOD, #20H ; timer 1, mode 2
MOV TH1,#-6 ; 4800 baud
MOV SCON, #50H ; 8 bit, 1 stop, REN enabled
SETB TR1
HERE: JNB RI, HERE ; wait for char to come in
MOV A, SBUF ; save incoming byte in A
MOV P1, A ; send to port 1
CLR RI ; get ready to receive next byte
SJMP HERE ; keep getting data
END
35 | P a g e
Experiment 12
Aim: Perform the basic programs using 8086 Microprocessor kit in assembly language.
a. Write a program to move block of no’s using repeat instruction using 8086
Microprocessor kit.
b. Write a program to find smallest of given n numbers using 8086 Microprocessor
kit.
Requirements: 8086 Microprocessor kit
Program (a) :
Address Machine
Code / Data
Label Mnemonics Operands Comments
3000 B1 MOVB CL, 07
3001 07
3002 BE MOVW SI, 4000H
3003 00
3004 40
3005 BF MOVW DI, 5000H
3006 00
3007 50
3008 FC CLD
3009 F3 REP
300A A4 MOVSB DI, SI
300B CC INT 03
Program (b):
Address Machine
Code / Data
Label Mnemonics Operands Comments
2012 BE MOVW SI, 2000H
2013 00
2014 20
2015 B1 MOVB CL, 05H
2016 05
2017 8A MOVB AL, [SI]
36 | P a g e
2018 04
2019 46 L1: INCW SI
201A 3A CMPB AL, [SI]
201B 04
201C 7C JL L2
201D 02
201E 86 XCHGB AL, [SI]
201F 04
2020 E2 L2: LOOP L1
2021 F7
2022 A2 MOVB @1000,AL
2023 00
2024 10
2025 CC INT 03
Aim: Write a program to find largest of given n numbers using 8086 Microprocessor kit.
Requirements: 8086 Microprocessor kit
Program:
Address Machine
Code / Data
Label Mnemonics Operands Comments
2012 BE MOVW SI, 2000H
2013 00
2014 20
2015 B1 MOVB CL, 05H
2016 05
2017 8A MOVB AL, [SI]
2018 04
2019 46 L1: INCW SI
201A 3A CMPB AL, [SI]
201B 04
201C 7C JG L2
201D 02
37 | P a g e
201E 86 XCHGB AL, [SI]
201F 04
2020 E2 L2: LOOP L1
2021 F7
2022 A2 MOVB @500,AL
2023 00
2024 05
2025 CC INT 03
38 | P a g e