You are on page 1of 38

LABORATORY MANUAL ECE 306

UNIFIED ELECTRONICS LAB IV

1|Page

TABLE OF CONTENTS

S. No. 1 2 3 4 5 6 7 8 9 10 11 12

Title of the Experiment Perform the basic programs using 8085 Microprocessor kit in assembly language. Interfacing of Seven segment displays with 8085 microprocessor. Interfacing and control of stepper motor using 8085 microprocessor. Interfacing of D/A converter with 8085 microprocessor. Design a 8085 Microprocessor based Traffic light control 8051 Assembly language programming using Keil compiler. (At least 5 programs.). Interfacing of LCD with8051 Microcontroller Interfacing of ADC with 8051 Microcontroller Interfacing of DAC with 8051 Microcontroller Interfacing of keyboard with 8051 Microcontroller

Page No. 3 9 11 12 13 15 21 24 29 30

Implementing of Serial Communication using 8051 34 Microcontroller Perform the basic programs using 8086 Microprocessor kit in 36 assembly language.

2|Page

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 16bit 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 2001 2002 2003 2004 2005 2006 2007 2008

21 00 30 7E 23 86 23 77 EF

LXI

H,3000h

MOV INX ADD INX MOV RST5

A,M H M H M,A

Program ( i.b ):

Address

Machine Code / Data

Label

Mnemonics

Operands

Comments

2007 2008 3|Page

2A 00

LHLD

2000h

2009 200A 200B 200C 200D 200E 200F 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 201A 201B 201C

20 EB 2A 02 20 0E 00 19 D2 15 20 0C 22 04 20 79 32 06 20 EF RST5 MOV STA A,C 2006h KK INR SHLD C 2004h DAD JNC D KK MVI C,00h XCHG LHLD 2002h

Program ( ii.a ):

Address

Machine Code / Data

Label

Mnemonics

Operands

Comments

2000 2001 2002 2003 2004 2005

21 00 30 7E 23 96

LXI

H,3000h

MOV INX SUB

A,M H M

4|Page

2006 2007 2008

23 77 EF

INX MOV RST5

H M,A

Program ( ii.b ):

Address

Machine Code / Data

Label

Mnemonics

Operands

Comments

2007 2008 2009 200A 200B 200C 200D 200E 200F 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 201A 201B 201C 201D

21 00 20 7E 23 96 32 04 20 23 7E 23 9E 32 05 20 3E 00 17 32 06 20 EF

LXI

H, 2000h

MOV INX SUB STA

A,M H M 2004h

INX MOV INX SBB STA

H A,M H M 2005h

MVI

A, 00h

RAL STA 2006h

RST5

5|Page

Program ( iii.a ):

Address

Machine Code / Data

Label

Mnemonics

Operands

Comments

2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 200A 200B 200C 200D 200E 200F 2010 2011 2012 2013 2014 2015

3A 00 30 5F 16 00 3A 01 30 4F 21 00 00 19 0D C2 0D 20 22 02 30 EF KK

LDA

3000h

MOV MVI

E, A D, 00h

LDA

3001h

MOV LXI

C,A H, 0000h

DAD DCR JNZ

D C KK

SHLD

3002h

RST5

Program ( iii.b ):

Address

Machine Code / Data

Label

Mnemonics

Operands

Comments

2000 6|Page

21

LXI

H, 2501h

2001 2002 2003 2004 2005 2006 2007 2008 2009 200A 200B 200C 200D 200E 200F 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 201A

01 25 5E 16 00 23 7E 21 00 00 06 08 29 13 D2 13 20 19 05 C2 0D 20 22 03 25 EF RST5 SHLD 2503h KK DAD DCR JNZ D B YY YY DAD RAL JNC KK H MVI B, 08h INX MOV LXI H A, M H, 0000h MOV MVI E, M D, 00h

Program ( iv ):

Address

Machine Code / Data

Label

Mnemonics

Operands

Comments

7|Page

2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 200A 200B 200C 200D 200E 200F 2010 2011 2012 2013 2014 2015

21 00 25 3E 00 0E 0A 77 06 01 0D 23 80 70 57 78 42 0D C2 0B 20 EF KK

LXI

H, 2501h

MVI

A, 00h

MVI

C, 0Ah

MOV MVI

M, A B,01h

DCR INX ADD MOV MOV MOV MOV DCR JNZ

C H B M, B D, A A, B B, D C KK

RST5

8|Page

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 CR K: LXI H, 2000H MVI B, 10H KK: MOV A, M OUT PA 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|Page

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 nos 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 RRC 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 LEDs, 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 COM 21 | 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: GO:

MOV R0,#15H MOV TMOD,#01H MOV TL0,#0FFH MOV TH0,#0DBH SETB TR0

BACK:

JNB TF0,BACK CLR TR0 CLR TF0 DJNZ R0,GO RET

DISPLAY: 22 | P a g e

MOV R1,#14D

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 nos 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 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 300A 300B B1 07 BE 00 40 BF 00 50 FC F3 A4 CC CLD REP MOVSB INT DI, SI 03 MOVW DI, 5000H MOVW SI, 4000H MOVB CL, 07 Label Mnemonics Operands Comments

Program (b): Address Machine Code / Data 2012 2013 2014 2015 2016 2017 36 | P a g e BE 00 20 B1 05 8A MOVB AL, [SI] MOVB CL, 05H MOVW SI, 2000H Label Mnemonics Operands Comments

2018 2019 201A 201B 201C 201D 201E 201F 2020 2021 2022 2023 2024 2025

04 46 3A 04 7C 02 86 04 E2 F7 A2 00 10 CC INT 03 MOVB @1000,AL L2: LOOP L1 XCHGB AL, [SI] JL L2 L1: INCW CMPB SI AL, [SI]

Aim: Write a program to find largest of given n numbers using 8086 Microprocessor kit. Requirements: 8086 Microprocessor kit Program: Address Machine Code / Data 2012 2013 2014 2015 2016 2017 2018 2019 201A 201B 201C 201D 37 | P a g e BE 00 20 B1 05 8A 04 46 3A 04 7C 02 JG L2 L1: INCW CMPB SI AL, [SI] MOVB AL, [SI] MOVB CL, 05H MOVW SI, 2000H Label Mnemonics Operands Comments

201E 201F 2020 2021 2022 2023 2024 2025

86 04 E2 F7 A2 00 05 CC L2:

XCHGB

AL, [SI]

LOOP

L1

MOVB

@500,AL

INT

03

38 | P a g e

You might also like