0% found this document useful (0 votes)
51 views

MPMC Lab Manual 2023-24

Uploaded by

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

MPMC Lab Manual 2023-24

Uploaded by

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

Department of Electronics and Communication Engineering

V Semester
(Autonomous)

Microprocessors and Microcontrollers Lab manual


Course Code: 21EC502
(with effect from Academic year 2023-24)
(for B.Tech ECE)

GMR INSTITUTE OF TECHNOLOGY


(An Autonomous Institute Affiliated to JNTU-GV)
(Accredited by NBA, NAAC with grade ‘A’ & ISO 9001:2008 Certified Institution)
Approved by AICTE, New Delhi
GMR NAGAR, RAJAM-532 127, A.P.
MICROPROCESSORS AND MICROCONTROLLERS
LABORATORY MANUAL

Issued to: Dept of ECE


Copy No: _____ of ______

Prepared/verified by: Staff In charge Approved by : HOD

Signature Signature

Date: Date:

Department of Electronics and Communication Engineering

GMR INSTITUTE OF TECHNOLOGY


(An Autonomous Institute Affiliated to JNTU-GV)
(Accredited by NBA, NAAC with grade ‘A’ & ISO 9001:2008 Certified Institution)
Approved by AICTE, New Delhi
GMR NAGAR, RAJAM-532 127, A.P.
Microprocessors and Microcontrollers Lab
Course Code: 21EC502, Regulation: AR21

B. Tech ECE, 5th Semester, A.Y: 2023-24

List of experiments
Lab Content
Number
Experiments Based On 8086 Microprocessor using MASM IDE
1 Data transfer program using different addressing modes in assembly language
programming.
2 Perform arithmetic operations on 8 bit and 16 bit numbers in assembly language
programming.
3 Data transfer program using string instruction in assembly language programming.
4 Program for data conversion in assembly language programming.
5 Write assembly language program using procedure.
6 Write assembly language program using macro.
7 Program to reject negative numbers from a series of bytes.
Experiments Are Based On 8051 Microcontroller using MCU8051 IDE
8 Perform Arithmetic operations on 8-bit numbers in assembly language programming
using 8051 microcontroller.
9 Program to toggle the LED
10 Programming and interfacing of traffic light logic.
11 Program to generate square wave using interrupts.
12 Programming and interfacing of the key pad matrix.
13 Programming and interfacing of seven-segment display.
14 Programming and interfacing of the LCD.
15 Programming and interfacing of the relay.
16 Programming and interfacing of the dc/Stepper motor.
Introduction to MASM Assembler:

The main advantage of machine language programming is that the memory control is directly in the hands
of the programmer enabling him to manage the memory of the system more efficiently. However, there are
more disadvantages. The programming, coding and resource management techniques are tedious. As the
programmer has to consider all these functions, the chances of human errors are more. To understand the
programs one has to have a thorough technical knowledge o the processor architecture and instruction set.

The assembly language programming is simpler as compared to the machine language programming. The
instruction mnemonics are directly written in the assembly language programs. The advantage that
assembly language has over machine language is that now the address values and the constants can be
identified by labels. If the labels are clear then certainly the program will become more understandable,
and each time the programmer will not have to remember the different constants and the addresses at
which they are stored, throughout the programs.

An assembler is a program that converts an assembly language input file also called as source file to an
object file that can further be converted into machine codes or an executable file using a linker. It decides
the address of each label and substitutes the values for each of the constants and variables. Two types of
assemblers are available, one is MASM (Microsoft Macro Assembler) and TASM (Turbo Assembler).
MASM is the popular assemblers used along with a LINK program to structure the codes generated by
MASM in the form of an executable file.

Programming with an Assembler:

While writing a program for an assembler, the first step will be to use a text editor and type the program.
Before quit the editor program, do not forget to save it. A number of text editors are available in the
market, e.g. Norton's Editor [NE}, Turbo C [TC], EDLIN, etc. Thus for writing a program in assembly
language, one will need editor, MASM assembler, linker and DEBUG utility of DOS.

The main task of any assembler program is to accept the text_assembly language program file as an input
and prepare an object file. The MASM accepts the file names only with the extension .ASM. Even if a
filename without any extension is given as input, it provides an .ASM extension to it.

Example: C> MASM KMB

or

C> MASM KMB.ASM

If the program contains syntax errors, they are displayed using error code number and the corresponding
line number at which they appear. Once these syntax errors and warnings are taken care of by the
programmer, the assembly process is completed successfully.
The DOS linking program LINK.EXE links the different object modules of a source program and function
library routines to generate an integrated executable code of the source program. The main input to the
linker is the .OBJ file that contains the object modules of the source programs.

Example: C> LINK KMB.OBJ

The output of the LINK program is an executable file with the entered filename and .EXE extension. This
executable filename can further be enterd at the DOS prompt to execute the file.

DEBUG.COM is a DOS utility that facilitaes the debugging and trouble-shooting of assembly language
programs.

Example: C> DEBUG KMB.EXE

The DEBUG offers a good platform for trouble shooting, executing and observing the results of the
assembly language programs.

Table: DEBUG commands

COMMAND Format Functions


CHARACTER

-T SEG:OFFSET <ENTER> Trace the program execution by single


stepping starting from the address
SEG:OFFSET

-R <ENTER> Display all registers and flags

-R <ENTER> Display specified register contents and


modify with the entered new contents.

-D <ENTER> Display 128 memory locations of RAM


starting from the current display pointer.

-D SEG:OFFSET1 OFFSET2<ENTER> Display memory contents in SEG from


OFFSET1 to OFFSET2.

-E <ENTER> Enter Hex data at current display pointer


SEG:OFFSET
-E SEG:OFFSET1 <ENTER> Enter data at SEG:OFFSET1 byte by byte.
The memory pointer is to be increased by
space key, data entry is to be completed by
pressing the <ENTER> key.

-F SEG:OFFSET1 OFFSET2 BYTE Fill the memory area starting from


<ENTER> SEG:OFFSET1 to OFFSET2 by the byte
BYTE.

-F SEG:OFFSET1 OFFSET2 BYTE1, Fill the memory area as abpve with the
BYTE2, BYTE3<ENTER> sequence BYTE1, BYTE2, BYTE3, ETC.

-A <ENTER> Assemble from the current CS:IP

-A SEG:OFFSET <ENTER> Assemble the entered instruction from


SEG:OFFSET

-U <ENTER> Unassemble from the current CS:IP

-U SEG:OFFSET <ENTER> Unassemble from the address SEG:OFFSET

Step MICROPROCESSOR LAB EXECUTION PROCEDURE

1 Open “DOS BOX”

2 Z:\> mount c c: \8086


3 Z:\> c:

4 c:\> edit name_of_file.asm

“A asm file editor will open and write program in editor”

After writing the program:


In the editor window, Select File  Save
In the editor window, Select File  Exit

5 c:\masm name_of_file.asm

“An object file will created with extension .obj”


c:\link name_of_file.obj

“An executable file will created with extension .exe”

c:\debug name_of_file.exe
Type “t”
Single step execution of program will takes place
Experiment No-1

Demonstration of MASM Integrated Development Environment

AIM: Write an ALP of 8086 microprocessor using MASM IDE for accessing data using:
(i) Immediate Addressing Mode (ii) Direct Addressing Mode (iii) Register Addressing Mode (iv)
Register Indirect Addressing Mode

APPARATURS:

1. PC with windows
2. MASM software

1. Immediate Addressing Mode

PROGRAM:

ASSUME CS: CODE

CODE SEGMENT

START: MOV AX, 45F3H

MOV BX, 0F344H

MOV CL, 65H

MOV SI, 456AH

HLT

CODE ENDS

END START

END
RESULTS:

Before Execution of Program

Register DATA (HEX)

After Execution of Program

Register DATA (HEX)

CONCLUSION:
2. Direct Addressing Mode

PROGRAM:

ASSUME CS: CODE, DS: DATA

DATA SEGMENT

N1 DB 34H, 56H

DATA ENDS

CODE SEGMENT

START: MOV AX, DATA

MOV DS, AX

MOV AL, [0000]

MOV BL, [0001]

HLT

CODE ENDS

END START

END
RESULTS:

Before Execution of Program

Memory Location DATA (HEX)

After Execution of Program

Memory Location DATA (HEX)

CONCLUSION:
3. Register Addressing Mode

PROGRAM:

ASSUME CS: CODE

CODE SEGMENT

START: MOV AX, 45F3H

MOV BX, AX

MOV CX, AX

MOV DL, AH

MOV DH, AL

HLT

CODE ENDS

END START

END
RESULTS:

Before Execution of Program

Registers DATA (HEX)

After Execution of Program

Registers DATA (HEX)

CONCLUSION:
4. Register Indirect Addressing Mode

PROGRAM:

ASSUME CS: CODE, DS: DATA

DATA SEGMENT

N1 DB 38H

DATA ENDS

CODE SEGMENT

START: MOV AX, DATA

MOV DS, AX

MOV SI, OFFSET N1

MOV AL, [SI]

HLT

CODE ENDS

END START

END
RESULTS:

Before Execution of Program

Memory Location DATA (HEX)

After Execution of Program

Memory Location DATA (HEX)

CONCLUSION:
Experiment No-2

Perform arithmetic operations on 8-bit/16-bit numbers in assembly language programming

(a) Addition of two 16-bit numbers:

AIM: To write an Assembly language program for addition of two 16-bit numbers.

APPARATURS:

1. PC with windows (95/98/XP/NT/2000)

2. MASM software

THEORY:

ADD/ADC Instruction:

These instructions add a number from source to a number from destination and put the result in the destination.
The ADC, instruction also adds the status of carry flag into the result. The source may be an immediate number, a
register, or a memory location. The source and the destination in an instruction cannot both be memory locations.
The source and destination both must be a word or byte.

Flags affected: AF, CF, OF, PF, SF, ZF.

PROGRAM:

ASSUME CS: CODE, DS:DATA

DATA SEGMENT

NUM1 DW 3423H

NUM2 DW 6789H

RESULT DW 02H DUP(?)

DATA ENDS

CODE SEGMENT

START: MOV AX,DATA

MOV DS,AX

MOV AX,NUM1
MOV BX,NUM2

XOR CX,CX

ADD AX,BX

ADC CX,0000H

MOV [RESULT],AX

MOV [RESULT+2],CX

HLT

CODE ENDS

END START
RESULTS:

Input

Memory location Register Data (Hexa)

Output

Memory location Register Data (Hexa)

CONCLUSION:
(b) Division of 16/8 bit numbers

AIM: To write an Assembly language program for division of 16-bit/8-bit numbers.

APPARATURS:

1. PC with windows (95/98/XP/NT/2000)

2. MASM software

THEORY:

DIV Instruction:

This instruction is used to divide an unsigned word by a byte or to divide an unsigned double word by a word.

When dividing a word by a byte, the word must be in AX register. After the division AL will contain an 8-bit
quotient and AH will contain an 8-bit remainder. If an attempt is made to divide by 0 or the quotient is too large to
fit in AL, the 8086 will automatically execute a type 0 interrupt.

When a double word is divided by a word, the most significant word of the double word must be in DX and the
least-significant word must be in AX. After the division AX will contain a 16-bit quotient and DX will contain a 16-bit
quotient and DX will contain a 16-bit remainder.

PROGRAM:

ASSUME CS: CODE, DS:DATA

DATA SEGMENT

OPR1 DB 12H

OPR2 DW 0156H

RESULT DB 03H DUP (0)

DATA ENDS

CODE SEGMENT

START: MOV AX,DATA

MOV DS,AX

MOV BL,OPR1

MOV AX, OPR2


DIV BL

MOV [RESULT], AX

HLT

CODE ENDS

END START
RESULT:

Input

Memory location Register Data (Hexa)

Output

Memory location Register Data (Hexa)

CONCLUSION:
Experiment No-3

AIM: Write an ALP of 8086 microprocessor to transfer five bytes from one memory location to another using string
instruction. Use assembler directives to write the program.

APPARATURS:

1. PC with windows

2. MASM software

PROGRAM:

ASSUME CS: CODE, DS: DATA

DATA SEGMENT

NUMBERS DB 34H, 40H, 55H, 0A4H, 5FH

TRANSFER DB ?

DATA ENDS

CODE SEGMENT

START: MOV AX, DATA

MOV DS, AX

MOV ES, AX

MOV SI, OFFSET NUMBERS

MOV DI, OFFSET TRANSFER

MOV CX, 0005H

REP MOVSB

HLT

CODE ENDS

END START

END
RESULTS:

Before Execution of Program

In Destination Memory Location DATA (HEX)

After Execution of Program

In Destination Memory Location DATA (HEX)

CONCLUSION:
Experiment No-4

AIM: Write an ALP of 8086 microprocessor to convert a packed BCD to ASCII number

APPARATURS:

1. PC with windows

2. MASM software

PROGRAM:

ASSUME CS:CODE, DS:DATA

DATA SEGMENT

N1 DB 45H

RESULT DB ?

DATA ENDS

CODE SEGMENT

START: MOV AX,DATA

MOV DS,AX

MOV SI,OFFSET N1

MOV DI,OFFSET RESULT

MOV BL,[SI]

MOV BH,BL

AND BL,0FH

AND BH,0F0H

MOV CL,04H

ROL BH,CL

ADD BX,3030H

MOV [DI],BX

HLT
CODE ENDS

END START

END

RESULTS:

BCD Number ASCII Number

CONCLUSION:
Experiment No-5

AIM: Write an Assembly language program for implementation of near procedure.

APPARATURS:

1. PC with windows

2. MASM software

THEORY:

Whenever to use a group of instructions several times throughout a program, there are two ways that can
avoid having to write the group of instructions each time to use them. One way is to write the group of
instructions as a separate procedure. Then just CALL the procedure whenever to execute that group of
instructions. For calling the procedure, have to store the return address onto the stack. This process takes
some time. If group of instructions is big enough then this overhead time is negligible with respect to
execution time. But if the group of instructions is too short, the overhead time and execution time are
comparable. In such cases, it is not desirable to write procedures. For these cases, the macros can be used.

The type of procedure depends on where the procedure is stored in the memory. If it is in the same code
segment where the main program is stored then it is called near procedure otherwise it is referred to as
far procedure. For near procedure CALL instruction pushes only IP register contents on to the stack, since
CS register contents remain unchanged for main program and procedure. But far procedure CALL
instruction pushes both IP and CS on the stack.

PROGRAM:

ASSUME CS:CODE, DS:DATA

DATA SEGMENT

NUM1 DW 5678H

NUM2 DW 1234H

RESULT DW 08H DUP(0)

DATA ENDS

CODE SEGMENT

START: MOV AX,DATA

MOV DS,AX
CALL XYZ

ADD AX,BX

MOV RESULT,AX

CALL XYZ

SUB AX,BX

MOV RESULT+02H,AX

HLT

XYZ PROC

MOV AX,NUM1

MOV BX,NUM2

RET

XYZ ENDP

CODE ENDS

END START
RESULTS:

Input

Memory location Register Data (Hexa)

Output

Memory location Register Data (Hexa)

CONCLUSION:
Experiment No-6

AIM: Write an Assembly language program for implementation of MACRO.

APPARATURS:

1. PC with windows

2. MASM software

THEORY:

Macro is a group of instructions. The macro assembler generates the code in the program each time where
the macro is called. Macro can be defined by MACRO and ENDM assembler directives.

It is important to note that macro sequences execute faster than procedures because there are no CALL and
RET instructions to execute.

Comparison of Procedure and Macro:

Procedure Macro

Accessed by CALL and RET instruction during Accessed during assembly with name given to macro
program execution. when defined.

Machine code for instructions is put only Machine code is generated for instructions each time
once in the memory. when macro is called.

With procedures less memory is required. With macros more memory is required.

Parameters can be passed in registers, Parameters passed as part of statement which calls
memory locations or stack. macro.

PROGRAM:

ASSUME CS:CODE, DS:DATA

DATA SEGMENT

NUM1 DW 5678H

NUM2 DW 1234H

RES DW 08H DUP(0)


DATA ENDS

CODE SEGMENT

START: MOV AX,DATA

MOV DS,AX

XYZ MACRO

MOV AX,NUM1

MOV BX,NUM2

ENDM

XYZ

ADD AX,BX

MOV RES,AX

XYZ

SUB AX,BX

MOV RES+04H,AX

HLT

CODE ENDS

END START
RESULTS:

Input

Memory location Register Data (Hexa)

Output

Memory location Register Data (Hexa)

CONCLUSION:
Experiment No-7

AIM: Write an ALP of 8086 microprocessor to reject negative numbers from a series of five bytes and store the
positive numbers in memory

APPARATURS:

1. PC with windows

2. MASM software

PROGRAM:

ASSUME CS:CODE, DS:DATA

DATA SEGMENT

N1 DB 34H, 40H, 85H, 0A3h, 70H

RESULT DB ?

DATA ENDS

CODE SEGMENT

START: MOV AX, DATA

MOV DS, AX

MOV SI, OFFSET N1

MOV DI, OFFSET RESULT

MOV CX,0005H

REPEAT: MOV AL,[SI]

ROL AL,01H

JC REJECT

ROR AL,01H

MOV [DI],AL

INC DI

REJECT: INC SI
LOOP REPEAT

HLT

CODE ENDS

END START

END
RESULTS:

Before Execution of Program

Memory location

1st Number

2nd Number

3rd Number

4th Number

5th Number

After Execution of Program

Memory location

1st Number

2nd Number

3rd Number

4th Number

5th Number

CONCLUSION:
Experiment No-8

AIM: To write an ALP of 8051 microcontroller to perform:


(a) Multiplication (b) Subtraction

APPARATURS:

1. PC with windows

2. MCU8051

3. Development Board

(a) PROGRAM:

Multiplication of two 8-bit numbers stored in internal RAM memory location 30H and 31H and
store the result at 40H.

ORG 0000h

MOV R0,#30H

MOV R1,#40H

MOV A,@R0

INC R0

MOV B,@R0

MUL AB

MOV @R1,A

INC R1

MOV @R1,B

HERE: SJMP HERE

END
RESULT:

Data Set

Before Execution of Program

Source

RAM Location DATA (HEX)

30H

31H

Destination

40H

Data Set

After Execution of Program

Destination

RAM Location DATA (HEX)

40H

CONCLUSION:
(b) PROGRAM:

Subtract two 8-bit numbers stored in internal RAM memory location 30H and 31H.

ORG 0000h

MOV R0,#30H

MOV A,@R0

INC R0

SUBB A,@R0

HERE: SJMP HERE

END
RESULT:

Data Set-1

Before of Program

Source

RAM Location DATA (HEX)

30H

31H

Result After Execution of Program

Data Set-2

Before of Program

Source

RAM Location DATA (HEX)

30H

31H

Result After Execution of Program

CONCLUSION:
Experiment No-9

AIM: Write a program for 8051 microcontroller to toggle a LED connected at P1.0 pin.

APPARATURS:

1. PC with windows

2. MCU8051

3. Development Board

PROGRAM:

ORG 0000H

REPEAT:

SETB P1.0

LCALL DELAY

CLR P1.0

LCALL DELAY

SJMP REPEAT

ORG 0030H

DELAY: MOV R0,#03H

B2: MOV R1,#0F0H

B1: DJNZ R1, B1

DJNZ R0, B2

RET

END

CONCLUSION:
Experiment No-10

AIM: Write an ALP of 8051 microcontroller to interface traffic light logic

APPARATURS:

1. PC with windows

2. MCU8051

3. Development Board

Program

The traffic light logic can be observed at P0.0 pin, P0.1 pin and P0.2 pin. Let Red LED is connected at P0.0,
Yellow LED is connected at P0.1 and Green LED is connected at P0.2. Red and LED is ON for 15 seconds and
Yellow LED is ON for 5 seconds.

ORG 0000H

REPEAT:

SETB P0.0 ; RED LED = ON

CLR P0.1 ; YELLOW LED = OFF

CLR P0.2 ; GREEN LED = OFF

LCALL DELAY10SEC

SETB P0.1 ; YELLOW LED = ON

LCALL DELAY5SEC

CLR P0.0 ; RED LED = OFF

CLR P0.1 ; YELLOW LED = OFF

SETB P0.2 ; GREEN LED = ON

LCALL DELAY10SEC

SETB P0.1 ; YELLOW LED = ON

LCALL DELAY5SEC

SJMP REPEAT
ORG 0030H

DELAY10SEC: MOV TMOD,#10H

MOV R0,#200D

L1: MOV TH1,#4BH

MOV TL1,#0FDH

SETB TR1

B1: JNB TF1,B1

CLR TR1

CLR TF1

DJNZ R0,L1

RET

ORG 0090H

DELAY5SEC: MOV TMOD,#10H

MOV R0,#100D

L2: MOV TH1,#4BH

MOV TL1,#0FDH

SETB TR1

B2: JNB TF1,B2

CLR TR1

CLR TF1

DJNZ R0,L2

RET

END

CONCLUSION:
Experiment No-11

AIM: Write an ALP for 8051 microcontroller to generate square wave using interrupts.

APPARATURS:

1. PC with windows

2. MCU8051

Program

ORG 0000H

LJMP MAIN

ORG 001BH

LJMP ISR

ORG 0300

MAIN: MOV TMOD,#00010000B

MOV IE,#10001000B

MOV TH1,#0FFH

MOV TL1,#0F0H

MOV R0,#02H

SETB TR1

BACK1: SJMP BACK1

ORG 0400

ISR: CPL P1.0

CLR TR1

DJNZ R0,AHEAD

MOV R0,#02H

CPL P2.0
AHEAD: MOV TH1,#0FFH

MOV TL1,#0F0H

SETB TR1

RETI

END

CONCLUSION:
Experiment No-12

AIM: Interface 8051 microcontroller with a key pad matrix.

APPARATURS:

1. PC with windows

2. MCU8051

INTERFACING DIAGRAM:

Fig. 1: Interfacing of 3x3 key matrix with 8051 Fig. 2: Interfacing of CC 7-Segment Display with 8051
Instruction for Execution: Execute in single step execution mode by pressing F7 key every time.

PROGRAM:

ORG 0000H

REP: LCALL DELAY

MOV P2,#00H ; 7-segment display off

MOV P1,#00H

SCAN:

JNB P0.0,COL_1 ;if key in col.1 is pressed then go to label COL_1

JNB P0.1,COL_2 ;if key in col.2 is pressed then go to label COL_2

JNB P0.2,COL_3 ;if key in col.3 is pressed then go to label COL_3

SJMP SCAN ; if no key is pressed then go to label SCAN

COL_1:

MOV P1,#11111110B

JNB P0.0,ONE

MOV P1,#11111101B

JNB P0.0,FOUR

MOV P1,#11111011B

JNB P0.0,SEVEN

COL_2:

MOV P1,#11111110B

JNB P0.1,TWO

MOV P1,#11111101B

JNB P0.1,FIVE

MOV P1,#11111011B
JNB P0.1,EIGHT

COL_3:

MOV P1,#11111110B

JNB P0.2,THREE

MOV P1,#11111101B

JNB P0.2,SIX

MOV P1,#11111011B

JNB P0.2,NINE

ONE: MOV P2, #06H ;Control word to display 1

SJMP REP

TWO: MOV P2,#5BH ;Control word to display 2

SJMP REP

THREE: MOV P2,#4FH ;Control word to display 3

SJMP REP

FOUR: MOV P2,#66H ;Control word to display 4

SJMP REP

FIVE: MOV P2,#6DH ;Control word to display 5

SJMP REP

SIX: MOV P2,#7DH ;Control word to display 6

SJMP REP

SEVEN: MOV P2,#07H ;Control word to display 7

SJMP REP

EIGHT: MOV P2,#7FH ;Control word to display 8

SJMP REP
NINE: MOV P2,#67H ;Control word to display 9

SJMP REP

ORG 0100h

DELAY: MOV TMOD,#20H

MOV TH1,#00H

MOV TL1,#00H

SETB TR1

B1: JNB TF1,B1

CLR TF1

RET

END

CONCLUSION:
Experiment No-13

AIM: Interface 8051 microcontroller with a common cathode Seven segment display and develop an ALP to display
numbers from 0 to 9

APPARATURS:

1. PC with windows

2. MCU8051

3. Development Board

Develop the control words to display numbers from 0 to 9 in a common cathode Seven segment display

Fig. Common Cathode 7 Segment Display


Common Cathode Connection and Control word:

INTERFACING DIAGRAM:

Fig. 1: CC 7 Segment Interfacing with Port 1


PROGRAM:

ORG 0000h

REPEAT: MOV P1,#3FH ; DISPLAY 0

LCALL DELAY

MOV P1,#06H ; DISPLAY 1

LCALL DELAY

MOV P1,#5BH ; DISPLAY 2

LCALL DELAY

MOV P1,#4FH ; DISPLAY 3

LCALL DELAY

MOV P1,#66H ; DISPLAY 4

LCALL DELAY

MOV P1,#6DH ; DISPLAY 5

LCALL DELAY

MOV P1,#7DH ; DISPLAY 6

LCALL DELAY

MOV P1,#07H ; DISPLAY 7

LCALL DELAY

MOV P1,#7FH ; DISPLAY 8

LCALL DELAY

MOV P1,#67H ; DISPLAY 9

LCALL DELAY

HERE: SJMP REPEAT

DELAY: MOV TMOD,#10H


MOV R0, #10H

LOOP1: MOV TH1, #3CH

MOV TL1, #0B0H

SETB TR1

BACK1: JNB TF1, BACK1

CLR TR1

CLR TF1

DJNZ R0, LOOP1

RET

END

CONCLUSION:
Experiment No-14

AIM: Interfacing of LCD with 8051 microcontroller and display the message.

APPARATURS:

1. PC with windows

2. MCU8051

3. Development Board

PROGRAM:

ORG 0000H

LCALL COMANDWR1

LCALL DATAWR1

LCALL COMANDWR2

LCALL DATAWR2

HERE: SJMP HERE

ORG 0020H

COMANDWR1: MOV DPTR,#COMMANDWORD1

REP1: CLR A

MOVC A,@A+DPTR

JZ LAST1

MOV P1,A

CLR P0.6; Register select pin (Command word register selected)

SETB P0.7; Enable pin

LCALL DELAY

CLR P0.7
INC DPTR

SJMP REP1

LAST1: RET

ORG 0050H

DATAWR1: MOV DPTR, #DATAWORD1

REP2: CLR A

MOVC A,@A+DPTR

JZ LAST2

MOV P1,A

SETB P0.6; Register select pin (Data word register selected)

SETB P0.7; Enable pin

LCALL DELAY

CLR P0.7

INC DPTR

SJMP REP2

LAST2: RET

ORG 0080H

COMANDWR2: MOV DPTR, #COMMANDWORD2

REP3: CLR A

MOVC A,@A+DPTR

JZ LAST3

MOV P1,A
CLR P0.6

SETB P0.7

LCALL DELAY

CLR P0.7

INC DPTR

SJMP REP3

LAST3: RET

ORG 00B0H

DATAWR2: MOV DPTR,#DATAWORD2

REP4: CLR A

MOVC A,@A+DPTR

JZ LAST4

MOV P1,A

SETB P0.6

SETB P0.7

LCALL DELAY

CLR P0.7

INC DPTR

SJMP REP4

LAST4: RET

ORG 00E0H

COMMANDWORD1: DB 38H,0FH,80H,00H
ORG 00F0H

DATAWORD1: DB ' ECE DEPARTMENT ',00H

ORG 0200H

COMMANDWORD2: DB 38H,0FH,0C0H,00H

ORG 0110H

DATAWORD2: DB ' WELCOMES YOU ',00H

ORG 0130H

DELAY: MOV R1,#255D

B1: DJNZ R1,B1

RET

END

CONCLUSION:
Experiment No-15

AIM: Interfacing of a dc motor with 8051 microcontroller and rotate it in clockwise and anti-clockwise direction.

APPARATURS:

1. PC with windows

2. MCU8051

3. Development Board

PROGRAM:

ORG 0000H

REPEAT:

SETB P1.2

CLR P1.3

LCALL DELAY1

CLR P1.2

LCALL DELAY2

CLR P1.2

SETB P1.3

LCALL DELAY1

CLR P1.3

LCALL DELAY2

SJMP REPEAT

ORG 0030H

DELAY1: MOV TMOD, #10H

MOV R0,#200D
L1: MOV TH1,#4BH

MOV TL1,#0FDH

SETB TR1

B1: JNB TF1,B1

CLR TR1

CLR TF1

DJNZ R0,L1

RET

ORG 0070H

DELAY2: MOV TMOD,#10H

MOV R0,#100D

L2: MOV TH1,#4BH

MOV TL1,#0FDH

SETB TR1

B2: JNB TF1,B2

CLR TR1

CLR TF1

DJNZ R0,L2

RET

END

CONCLUSION:
Experiment No-16

AIM: Write a program for 8051 microcontroller to work with a relay.

APPARATURS:

1. PC with windows

2. MCU8051

3. Development Board

PROGRAM:

ORG 0000H

REPEAT:

SETB P3.4

LCALL DELAY

CLR P3.4

LCALL DELAY

SJMP REPEAT

ORG 0030H

DELAY: MOV R0,#03H

B2: MOV R1,#0F0H

B1: DJNZ R1, B1

DJNZ R0, B2

RET

END

CONCLUSION:

You might also like