Вы находитесь на странице: 1из 36

LABORATORY MANUAL ECE 322

MICRO CONTROLLER AND APPLICATIONS LABORATORY

1|Page

TABLE OF CONTENTS

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

Title of the Experiment 8085 Basic Program on simulator 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. 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 7 11 13 15 18 24 29 30 33

2|Page

Experiment 1
Aim: 8085 Basic Program on simulator. i. Write a program to add two 8-bit numbers. ii. Write a program to subtract two 8-bit numbers. iii. Write a program to multiply two 8 bit numbers by repetitive addition method. iv. Write a program to generate Fibonacci series.

Requirements: 8085 Simulator Learning Objectives: Use of 8085 simulator to perform basic assembly programs. Outline of the Procedure: 1. Open simulator on your laptop. 2. Write the given code. 3. Save the file. 4. Assemble the code and check error, if error remove it and again assemble it. 5. Execute the code and verify the results. Program (i):

Address

Machine Code / Data

Label

Mnemonics

Operands

Comments

2000 2001 2002 2003 2004 2005 2006 2007 2008 3|Page

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 (ii):

Address

Machine Code / Data

Label

Mnemonics

Operands

Comments

2000 2001 2002 2003 2004 2005 2006 2007 2008

21 00 30 7E 23 96 23 77 EF

LXI

H,3000h

MOV INX SUB INX MOV RST5

A,M H M H M,A

Program (iii):

Address

Machine Code / Data

Label

Mnemonics

Operands

Comments

2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 200A 200B 4|Page

3A 00 30 5F 16 00 3A 01 30 4F 21 00

LDA

3000h

MOV MVI

E, A D, 00h

LDA

3001h

MOV LXI

C,A H, 0000h

200C 200D 200E 200F 2010 2011 2012 2013 2014 2015

00 19 0D C2 0D 20 22 02 30 EF RST5 SHLD 3002h KK DAD DCR JNZ D C KK

Program (iv):

Address

Machine Code / Data

Label

Mnemonics

Operands

Comments

2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 200A 200B 200C 200D 200E 200F

21 00 25 3E 00 0E 0A 77 06 01 0D 23 80 70 57 78 KK

LXI

H, 2501h

MVI

A, 00h

MVI

C, 0Ah

MOV MVI

M, A B,01h

DCR INX ADD MOV MOV MOV

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

5|Page

2010 2011 2012 2013 2014 2015

42 0D C2 0B 20 EF

MOV DCR JNZ

B, D C KK

RST5

Learning outcomes: to be written by the students in 50-70 words.

6|Page

Experiment 2
Aim: Perform the following using 8085 Microprocessor kit in assembly language. i. ii. iii. Write a program to add two 16-bit numbers. Write a program to subtract two 16-bit numbers. Write a program to multiply two 8 bit numbers by rotation method.

Requirements: 8085 Microprocessor kit Learning Objectives: Use of 8085 Kit to perform basic assembly programs. Outline of the Procedure: 1. Turn of the kit 2. Enter the code in assembly language. 3. Execute the code and verify the results.

Program (i):

Address

Machine Code / Data

Label

Mnemonics

Operands

Comments

2007 2008 2009 200A 200B 200C 200D 200E 200F 2010 2011 7|Page

2A 00 20 EB 2A 02 20 0E 00 19 D2

LHLD

2000h

XCHG LHLD 2002h

MVI

C,00h

DAD JNC

D KK

2012 2013 2014 2015 2016 2017 2018 2019 201A 201B 201C

15 20 0C 22 04 20 79 32 06 20 EF RST5 MOV STA A,C 2006h KK INR SHLD C 2004h

Program (ii):

Address

Machine Code / Data

Label

Mnemonics

Operands

Comments

2007 2008 2009 200A 200B 200C 200D 200E 200F 2010 2011 2012 2013 2014 2015 8|Page

21 00 20 7E 23 96 32 04 20 23 7E 23 9E 32 05

LXI

H, 2000h

MOV INX SUB STA

A,M H M 2004h

INX MOV INX SBB STA

H A,M H M 2005h

2016 2017 2018 2019 201A 201B 201C 201D

20 3E 00 17 32 06 20 EF RST5 RAL STA 2006h MVI A, 00h

Program (iii):

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

21 01 25 5E 16 00 23 7E 21 00 00 06 08 29 13 D2 13 20 YY

LXI

H, 2501h

MOV MVI

E, M D, 00h

INX MOV LXI

H A, M H, 0000h

MVI

B, 08h

DAD RAL JNC

KK

9|Page

2012 2013 2014 2015 2016 2017 2018 2019 201A

19 05 C2 0D 20 22 03 25 EF KK

DAD DCR JNZ

D B YY

SHLD

2503h

RST5

Learning outcomes: to be written by the students in 50-70 words.

10 | P a g e

Experiment 3
Aim: Interfacing of Seven segment display with 8085 microprocessor. Requirements: 8085 Microprocessor kit, Seven Segment LED & wires. Learning Objectives: Interfacing of seen segment using 8255. Outline of the Procedure: 1. Connect the circuit as shown in the below diagram 2. Turn on the kit. 3. Write the given code. 4. Execute the code and verify the results on seven segment display.

Circuit Diagram:

Program: MVI A, 80H OUT CR K: LXI H, 2000H MVI B, 10H 11 | P a g e

KK: MOV A, M OUT PA JMP DELAY INX H JNZ KK JMP K HLT Delay: LXI D, Count Back: DCX D MOV A, D ORA E JNZ Back RET

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. Learning outcomes: to be written by the students in 50-70 words.

12 | P a g e

Experiment 4
Aim: Interfacing and control of stepper motor using 8085 microprocessor. Requirements: 8085 Microprocessor kit, Stepper Motor, Motor driver circuit (ULN2003) & wires. Learning Objectives: Interfacing of stepper motor using 8255. Outline of the Procedure: 1. Connect the interfacing circuit of stepper motor to 8085 kit. 2. Turn on the kit. 3. Write the given code. 4. Execute the code and verify the results.

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 13 | P a g e

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. Learning outcomes: to be written by the students in 50-70 words.

14 | 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)

Learning Objectives: Design of traffic light control using 8085 microprocessor Outline of the Procedure: 1. Connect the circuit as shown in the below diagram 2. Turn on the kit. 3. Write the given code. 4. Execute the code and verify the results on leds.

Circuit Diagram:

15 | P a g e

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 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 16 | P a g e

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 Learning outcomes: to be written by the students in 50-70 words.

17 | P a g e

Experiment 6
Aim: 8051 Assembly language programming using Keil compiler. 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 Learning Objectives: Use of Keil software to perform basic assembly programs Outline of the Procedure: 1. Open Keil software on your laptop. 2. Write the given code. 18 | P a g e

3. Save the file. 4. Assemble the code and check error, if error remove it and again assemble it. 5. Execute the code and verify the results.

Program (a): Org 0000h mov a,#79h mov r5,#00h add a,#0f5h jnc here inc r5 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 19 | P a g e

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 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 20 | P a g e

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 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 21 | P a g e

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 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 22 | P a g e

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

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 Learning outcomes: to be written by the students in 50-70 words.

23 | P a g e

Experiment 7
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 24 | P a g e

MOV TMOD,#02H ;initialisation of timer 0 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 25 | P a g e

MOV R1,B 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' 26 | P a g e

ACALL WRITE 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 27 | P a g e

SETB P2.0 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 Learning outcomes: to be written by the students in 50-70 words.

28 | P a g e

Experiment 8
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 9
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 30 | 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: 31 | 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 Learning outcomes: to be written by the students in 50-70 words.

32 | 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 33 | P a g e

mov a,#0eh //dispaly on cursor on acall command 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 34 | P a g e

mov tl0,#0ffh mov th0,#0dbh 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 35 | P a g e

cjne a,#03h,row1 ljmp k2 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

Learning outcomes: to be written by the students in 50-70 words.

36 | P a g e

Вам также может понравиться