You are on page 1of 50

MICROPROCESSORS & MICROCONTROLLERS

LABORATORY MANUAL (R20)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Department of ECE, VLITS Page 1


JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY: KAKINADA
KAKINADA - 533 003, Andhra Pradesh, India

L T P C
III Year - II Semester
0 0 3 1.5
MICROPROCESSORS AND MICROCONTROLLERS LAB (R20)

LIST OF EXPERIMENTS

PART- A: (Minimum of 5 Experiments has to be performed)


8086 Assembly Language Programming and Interfacing

1. Programs for 16 -bit arithmetic operations (using Various Addressing Modes).


a. Addition of n-BCD numbers.
b. Multiplication and Division operations.
2. Program for sorting an array.
3. Program for Factorial of given n-numbers.
4. Interfacing ADC to 8086.
5. Interfacing DAC to 8086.
6. Interfacing stepper motor to8086.

PART- B: (Minimum of 5 Experiments has to be performed)


8051 Assembly Language Programming and Interfacing
1. Finding number of 1’s and number of 0’s in a given 8-bit number
2. Average of n-numbers.
3. Program and verify Timer/ Counter in8051.
4. Interfacing Traffic Light Controller to8051.
5. UART operation in8051
6. Interfacing LCD to8051.

PART- C: (Minimum of 2 Experiments has to be performed) Conduct the


following experiments using ARM CORTEX M3 PROCESSOR USING KEIL
MDK ARM
1. Write an assembly program to multiply of 2 16-bit binary numbers.
2. Write an assembly program to find the sum of first 10 integers numbers.
3. Write a program to toggle LED every second using timer interrupt.

Equipment Required:

Department of ECE, VLITS Page 2


1. Regulated Power supplies
2. Analog/Digital Storage Oscilloscopes
3. 8086 Microprocessor kits
4. 8051 microcontroller kits
5. ADC module, DAC module
6. Stepper motor module
7. Key board module
8. LED, 7-SegemtUnits
9. Digital Multi-meters
10. ROM/RAM Interface module
11. Bread Board etc.
12. ARM CORTEX M3
13. KEIL MDKARM, Digital Multi-meters

Department of ECE, VLITS Page 3


INTRODUCTION TO TASM
The assembler is a program that converts an assembly input file also called source
file to an object file that can further be converted in to machine codes or an executable
file using a linker. There are a number of assemblers available like MASM, TASM and
DOS assembler. TASM is one of the popular assemblers used along with a link program
to structure the codes generated By TASM in the form of executable files. TASM reads
the source program as its input and provides an object file. The link accepts the object file
produced by TASM as input and produces an EXE file.
Before staring the process ensure that all the files namely, TASM, .EXE,
LINK .EXE, DEBUG. EXE
Are available in the same directory which is working .Start the procedure with the
following command after boot the terminal and enter the directory containing all the files
mentioned.
D: Valid directory
Cod: Change the directory with all files
Edit: Edit the assembler to enter the program
Save the files with. .ASM
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
OPR1 DW 1234H
OPR DW 0002H
RESULT DW 01H DUP ?
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, OPR1
MOV BX, OPR2
CLC
ADD AX, BX
MOV DI, OFFSET RESULT
MOV DI, AX
MOV AH, 4CH
INT 03H
CODE ENDS.

Department of ECE, VLITS Page 4


END START.

The main task of any assembler program is to accept the text _assembly language
program file as input and prepare an object file .the TASM accepts the file names only
with the extension .ASM.
The TASM 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 program.
Debug .Exe facilitates the debugging and trouble shooting of assembly language program.
The debug utility enables to have the control these resources unto some extent.
TASM file name. ASM
TLINK file name
Debug file name.exe
G - Execute current CS: IP.
- Execute from offset in the current series
U - Un assemble from the current CS: IP
- Un assemble from the address SEG: OFFSET
D - Display 128 memory locations of RAM starting from the current display
pointer
- Display memory contents SEG from offset1 to offset2
ASSEMBLER DIRECTIVES:
An Assembler is a program used to convert an assembly language program in
to equivalent machine code modules which may further be converted in to executable
codes. The assembler decides the address of each label and substitutes the values for each
of the constants and variables. It then forms the machine code for the mnemonics and data
in assembly language program. While doing all these all these things, the assembler may
find out Syntax errors. The logical errors or other programming errors are not find out by
the assembler. For completing all these tasks, an assembler needs some hints from the
programmer, i.e. the required storage for a particular constant or variable, logical
names of the segments, types of the different routines and modules, end of file etc.
These types of hints are given to assembler using some predefined alphabetical strings
called “ASSEMBLER DIRECTIVES”.
DB:
This is used to reserve byte or bytes of memory locations in the available memory.
While preparing the EXE file, this directive directs the assembler to allocate the specified
number of memory bytes to the said data type that may be constant, variable or stringent.
DW:

Department of ECE, VLITS Page 5


This directive serves the same purposes as the DB directive, but it now makes the
assembler. Reserve the number of memory words instead of bytes.
DQ:
This directive is used to direct the assembler to reserve words of memory for the
specified variable and may initialize it with the specified values.
ASSUME:
The ASSUME directive is used to inform the assemble, the names of the logical
segments to be assumed for different segments used in the program.
END:
The END directive marks the end of an assembly language program. When the
assembler comes across this directive, it ignores the source lines available later on.

ENDP:
In assembly language programming, the subroutines are called procedures.
Thus, procedures may be Independent program modules which return particular results
or values to the calling programs. The ENDP Directive is used to indicate an end of
procedures. A procedure is usually assigned a name, i.e. label. To mark the end of a
particular procedure, the name of the procedure, i.e label appear as a prefix with the
directive ENDP.
ENDS:
This directive marks the end of a logical segment. The logical segments are
assigned with names, using the ASSUME directive. The names appear with the ENDS
directive as prefixes to mark the end of those particular segments.
LABEL:
This is used to assign a name to the current content of the location counter. At the
start
of the assembly process, the assembler initializes a location counter to keep track of
memory
Locations assigned to the program. As the program assembly proceeds, the contents of
the
Location counter are updated.
LENGTH:
This is used to refer the length of a data array or string.
OFFSET:
When the assembler comes across the offset operator along with a label, it first
computes the 16-bit displacement of the particular label, and replaces the string ‘offset
label’ by the computed displacement.
SEGMENT:

Department of ECE, VLITS Page 6


This marks the staring of a logical segment .The started segment is also assigned a
name i.e., label by this statement. The SEGMENT and ENDS directive must bracket
each logical Segment of a program.

Department of ECE, VLITS Page 7


PART – A

8086 Assembly Language Programming and


Interfacing

LIST OF EXPERIMENTS (Minimum of 5 Experiments has to be performed)

S.No. Name of the Experiment

Programs for 16 -bit arithmetic operations


(using Various Addressing Modes).
1 a. Addition of n-BCD numbers.
b. Multiplication and Division
operations.

2 Program for sorting an array.

3 Program for Factorial of given n-numbers.

4 Interfacing ADC to 8086.

5 Interfacing DAC to 8086.

6 Interfacing stepper motor to 8086.

Department of ECE, VLITS Page 8


Experiment No: 01

PROGRAMS FOR 16 -BIT ARITHMETIC


OPERATIONS

1(A). ADDITION OF N-BCD NUMBERS

Aim: To write an 8086 ALP for Addition of n-BCD numbers.

Apparatus:

1. Hard ware-computer
2. Software- TASM

Procedure:

1. Go to ‘start’ menu and press ‘run’ option.


2. In run option type cmd and press enter than command will be opened.
3. Type cd\ then press enter.
4. Type E:
5. Type CD TASM to enter into the TASM directory.
6. Types edit file name.asm to enter the program.
7. Enter the whole program and save the program and then click exit option.
8. Type TASM filename.asm for assembling the program.
9. Type tlink file name for linking the file.
10. Type td file name to load the program. Press F7 for step by step execution or run
to run at a time.
11. For O/P go to dump from view menu note down the values of dump table,
registers & flags.

Department of ECE, VLITS Page 9


Assembly Language Program:

ASSUME DS:DATA, CS:CODE


START:
DATA SEGMENT
A DB 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
SUM DB ?
DATA ENDS
CODE SEGMENT
START:
MOV AX, DATA
MOV DS, AX
LEA BX, A
MOV CL, 10
MOV AX, 0000
L1:ADDC AL, [BX]
DAA
INC BX
DEC CL
CMP CL, 00
JNZ L1
MOV SUM, AL
INT 03H
CODE ENDS
END START

Input: A : 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Output: 55H

Result: Thus, the Addition of n-BCD numbers is performed using TASM software.

Department of ECE, VLITS Page 10


1(B). MULTIPLICATION AND DIVISION OPERATIONS

Aim: To write an 8086 ALP for Multiplication and Division operations.

Apparatus:

1. Hard ware-computer
2. Software- TASM

Procedure:

1. Go to ‘start’ menu and press ‘run’ option.


2. In run option type cmd and press enter than command will be opened.
3. Type cd\ then press enter.
4. Type E:
5. Type CD TASM to enter into the TASM directory.
6. Types edit file name.asm to enter the program.
7. Enter the whole program and save the program and then click exit option.
8. Type TASM filename.asm for assembling the program.
9. Type tlink file name for linking the file.
10. Type td file name to load the program. Press F7 for step by step execution or run
to run at a time.
11. For O/P go to dump from view menu note down the values of dump table,
registers & flags.

Department of ECE, VLITS Page 11


Assembly Language Program for Multiplication:

ASSUME CS:CODE , DS;DATA


DATA SEGMENT
X DW 9000H
Y DW 1000H
R DW ?
DATA ENDS
CODE SEGMENT
START:
MOV AX, DATA
MOV DS, AX
MOV AX, X
MOV BX, Y
MUL BX
MOV R, AX
MOV R+2, DX
INT 03H
CODE ENDS
END START

Input: X = 9000H, Y =1000H


Output: R = 0000H
R+2=0900H

Department of ECE, VLITS Page 12


Assembly Language Program for Division:

ASSUME CS:CODE , DS;DATA


DATA SEGMENT
X DW 9000H
Y DW 4000H
R DW ?
Q DW ?
DATA ENDS
CODE SEGMENT
START:
MOV AX, DATA
MOV DS, AX
MOV AX, X
MOV BX, Y
DIV BX
MOV R, AX
MOV Q, DX
INT 03H
CODE ENDS
END START

Input: X = 9000H, Y =4000H


Output: Q=0002H, R = 1000H

Result: Thus multiplication and division performed on two 16 bit numbers using 8086
ALP.

Department of ECE, VLITS Page 13


Experiment No: 02
PROGRAM FOR SORTING AN ARRAY
(ASCENDING & DESCENDING ORDER)

Aim: To write an 8086 ALP for Ascending order and Descending order

Apparatus:

1. Hard ware-computer
2. Software- TASM

Procedure:

1. Go to ‘start’ menu and press ‘run’ option.


2. In run option type cmd and press enter than command will be opened.
3. Type cd\ then press enter.
4. Type E:
5. Type CD TASM to enter into the TASM directory.
6. Types edit file name.asm to enter the program.
7. Enter the whole program and save the program and then click exit option.
8. Type TASM filename.asm for assembling the program.
9. Type tlink file name for linking the file.
10. Type td file name to load the program. Press F7 for step by step execution or run
to run at a time.
11. For O/P go to dump from view menu note down the values of dump table,
registers & flags.

Department of ECE, VLITS Page 14


Assembly Language Program For Ascending Order:

DATA SEGMENT
STRING1 DB 99H, 12H, 56H, 45H, 36H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: MOV AX, DATA
MOV DS, AX
MOV CH, 04H
UP2: MOV CL, 04H
LEA SI, STRING1
UP1: MOV AL, [SI]
MOV BL, [SI+1]
CMP AL, BL
JC DOWN
MOV DL, [SI+1]
XCHG [SI], DL
MOV [SI+1], DL
DOWN: INC SI
DEC CL
JNZ UP1
DEC CH
JNZ UP2
INT 3
CODE ENDS
END START

Input: STRING1: 99H, 12H, 56H, 45H, 36H


Output: STRING1: 12H, 36H, 45H, 56H, 99H

Department of ECE, VLITS Page 15


Assembly Language Program For Descending Order:

DATA SEGMENT
STRING1 DB 99H, 12H, 56H, 45H, 36H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: MOV AX, DATA
MOV DS, AX
MOV CH, 04H
UP2: MOV CL, 04H
LEA SI, STRING1
UP1: MOV AL, [SI]
MOV BL, [SI+1]
CMP AL, BL
JNC DOWN
MOV DL, [SI+1]
XCHG [SI], DL
MOV [SI+1], DL
DOWN: INC SI
DEC CL
JNZ UP1
DEC CH
JNZ UP2
INT 3
CODE ENDS
END START

Input: STRING1: 99H, 12H, 56H, 45H, 36H


Output: STRING1: 99H, 56H, 45H, 36H.12H

Result:

Thus, the Ascending order and Descending order performed using 8086 ALP.

Department of ECE, VLITS Page 16


Experiment No: 03
FACTORIAL OF GIVEN NUMBER

Aim: To write an 8086 ALP for Factorial of given number.

Apparatus:

1. Hard ware-computer
2. Software- TASM

Procedure:

1. Go to ‘start’ menu and press ‘run’ option.


2. In run option type cmd and press enter than command will be opened.
3. Type cd\ then press enter.
4. Type E:
5. Type CD TASM to enter into the TASM directory.
6. Types edit file name.asm to enter the program.
7. Enter the whole program and save the program and then click exit option.
8. Type TASM filename.asm for assembling the program.
9. Type tlink file name for linking the file.
10. Type td file name to load the program. Press F7 for step by step execution or run
to run at a time.
11. For O/P go to dump from view menu note down the values of dump table,
registers & flags.

Department of ECE, VLITS Page 17


Assembly Language Program:

ASSUME DS:DATA, CS:CODE


DATA SEGMENT
A DW 0007H
B DW ?
C DW ?
DATA ENDS
CODE SEGMENT
START:
MOV AX, DATA
MOV DS, AX
MOV CX, 0AH
MOV AX, 0001H
MOV DX, 0000H
CMP AX,CX
JNC DOWN
L1: MUL CX
LOOP L1
DOWN: MOV B, AX
MOV C, DX
INT 03H
CODE ENDS
END START

Input: A : 07H

Output: 13B0H

Result: Thus, the Addition Factorial of given number is performed using TASM
software.

Department of ECE, VLITS Page 18


Experiment No: 04
INTERFACING ADC TO 8086

Aim: To write a program for conversion of analog data to digital output.

Apparatus:

1. 8086 Trainer.

2. Power supply for trainer and interface module.

3. A/D, D/A interface module.

4. Power mate connector.

5. FRC connector.

Procedure:

1. Connect the 26 core FRC connector to the 8086 trainer at connector no CN4 and the
interface module.

2. Connect the power mate connector to the interface module and the other side of the
connector to the power supply. The connections to the power supply are given below.
Connections: (power supply)

3. 5- Way power mate is wired to the motor. This power mate is to be inserted into the
male socket provided on the interface. Care should be taken such that, below given
code for the particular colored wire coincides with the code on the interface.
4. After the completion of the program and connections enter the program as given in
the listing below.

Department of ECE, VLITS Page 19


Assembly Language Program:

LABEL MNEMONIC
MOV AL, 90
MOV DX, 0FFC6
OUT DX
MOV AL, 07

MOV DX, FFC4


OUT DX
MOV AL, 0F
MOV DX, 0FFC6
OUT DX
MOV CX, 3FFF
D1
LOOP D1
MOV AL, 0E
MOV DX, 0FFC6
OUT DX
MOV AL, 0C
MOV DX, 0FFC6
OUT DX
D2
MOV DX, 0FFC0
IN DX
AND AL, 80
CMP AL, 80
JNZ D2
MOV AL, 0D
MOV DX, 0FFC6
OUT DX
MOV DX, 0FFC0
IN DX
MOV DX, 0FFC2
OUT DX
JMP D3

RESULT: Program for interfacing ADC to 8086 performed.

Department of ECE, VLITS Page 20


Experiment No: 05
INTERFACING DAC TO 8086.
Aim:

To write an assembly language program to generate sine wave by using 8255 interfacing
with 8086 microprocessor.

Apparatus:

1. ESA 86/88-2 Microprocessor kit.


2. C.R.O.
3. F R C Cable.
4. Power supply.
5. Dual DAC kit.

Theory:

The parallel input-output port chip 8255 is also called as Programmable peripheral input-
output Port. The Intel’s 8255 are designed for use with Intel’s 8 -bit, 16-bit and higher
capability microprocessors. It has 24 input/output lines which may be individually
programmed in 2-groups of 12 lines each, or 3 groups of 8 lines .The two groups of I/O
pins are named as GROUP A and GROUP B. Each of these two groups contain a sub
group of 8 I/O lines called as 8-bit Port and other sub group of 4 I/O lines are a 4-bit port.
Thus GROUP A Contains an 8-bit port A along with a 4-bit port, C upper. Port lines are
identified by symbols PAO-PA7, While the port C lines are identified as PC4-
PC7 .Similarly group B contains an 8-bit port B, containing lines PB0-PB7 and a 4-bit
port C with lower bits PC0-PC3 .The port C upper and port C lower can be used in
recombination as an 8-bit port-C .Both the port Cs are assigned the same address. Thus
one may have either Three 8-bit I/O ports are two 8-bit and two 4-bit I/O ports from
8255.All of these ports can function independently either as input or as output ports. This
can be achieved by programming the bits of an internal register of 8255 called as Control
word register (CWR).

PORT ADDRESSES OF 8255

Control word register = FFE6


Port A = FFE0
Port B = FFE2

Department of ECE, VLITS Page 21


Generation of a Sine Waveform:

8086 8255 8-BIT CRO


MICRO
PROCESSOR
PPI DAC

Assembly Language Program:

Memory Op codes labels Mnemonics Operands Comments


address

2000 B0, 80 MOV AL, 80H ;Initialize 8255


2002 BA, E6, FF MOV DX, FFE6H all ports o/p

2005 EE OUT DX, AL


2006 BA, E0, FF MOV DX, FFE0H
2009 B9, 24, 00 BACK: MOV CX, 24H ;Keep on
writing the
200C 8B, 36, 00, 30 MOV SI, 3000 sine wave co
2010 8A, 04 L1: MOV AL, [SI] ordinate data
2012 EE OUT DX, AL values to port
A
2013 46 INC SI
2014 49 DEC CX
2015 75, F9 JNZ L1
2017 EB, F0 JMP BACK

*After Execution: Output Sine wave Amplitude 29.4V, frequency 50Hz.

Result: Thus, the generation of sine wave by using 8255 interfacing with 8086
microprocessor is performed.

Department of ECE, VLITS Page 22


Experiment No: 06
INTERFACING STEPPER MOTOR TO 8086
AIM :
To rotate the stepper motor both in clockwise and anticlockwise direction.

ROTATE THE STEPPER MOTOR IN ANTICLOCKWISE DIRECTION


;Connect 8255 Ports A to CNLED
;**** INCLUDE DEFINATION FILES NOW
#INCLUDE "TKUP86.DEF"
;****START CODING HERE
ORG 0FFFF0H
JMPF 0F000H,0F000H ; the basic reset jump
ORG 0FF000H
START MOV SP,STKPTR ; load stack pointer
CALL INIT8255 ; initialize 8255 LP1
MOV AL,01H ; use num1 for led count value
MOV DX,PA8255
OUT DX,AL
CALL DELAY ; call delay
MOV AL,02H ; use num1 for led count value
MOV DX,PA8255
OUT DX,AL
CALL DELAY ; call delay
MOV AL,04H ; use num1 for led count value
MOV DX,PA8255
OUT DX,AL
CALL DELAY ; call delay
MOV AL,08H ; use num1 for led count value
MOV DX,PA8255
OUT DX,AL
CALL DELAY ; call delay
JMP START ; restart again
Department of ECE, VLITS Page 23
;******* Delay module
DELAY NOP
MOV CX,03500H ; load Delay count = 0x3500 NOP
DLY1 NOP ; LOOP DLY1
RET ; end of delay

;******* initialize 8255


INIT8255
MOV AL,080H ; make all ports output
MOV DX, CMD8255
OUT DX,AL ; write to command register
MOV AL,00H ; clear all ports
MOV DX,PA8255
OUT DX,AL
MOV DX,PB8255
OUT DX,AL
MOV DX,PC8255
OUT DX,AL

RET
(B)ROTATE THE STEPPER MOTOR IN CLOCKWISE DIRECTION
***** START CODING HERE
ORG 0FFFF0H
JMPF 0F000H,0F000H ; the basic reset jump
ORG 0FF000H
START MOV SP,STKPTR ; load stack pointer
CALL INIT8255 ; initialize 8255
LP1 MOV AL,08H ; use num1 for led count value
MOV DX,PA8255
OUT DX,AL
CALL DELAY ; call delay
MOV AL,04H ; use num1 for led count value
MOV DX,PA8255
OUT DX,AL
Department of ECE, VLITS Page 24
CALL DELAY ; call delay
MOV AL,02H ; use num1 for led count value
MOV DX,PA8255
OUT DX,AL
CALL DELAY ; call delay
MOV AL,01H ; use num1 for led count value
MOV DX,PA8255
OUT DX,AL
CALL DELAY ; call delay
JMP START ; restart again

******* Delay module


DELAY NOP
MOV CX,03500H ; load Delay count = 0x3500
NOP
DLY1 NOP
LOOP DLY1
RET ; end of delay

******* initialize 8255


INIT8255
MOV AL,080H ; make all ports output
MOV DX, CMD8255
OUT DX,AL ; write to command register
MOV AL,00H ; clear all ports
MOV DX,PA8255
OUT DX,AL
MOV DX,PB8255
OUT DX,AL
MOV DX,PC8255
OUT DX,AL
RET
RESULT:
INPUT:
OUTPUT

Department of ECE, VLITS Page 25


PART – B

8051 Assembly Language Programming and


Interfacing

LIST OF EXPERIMENTS (Minimum of 5 Experiments has to be performed)

S.No. Name of the Experiment

Finding number of 1’s and number of 0’s in


1
a given 8-bit number

2 Average of n-numbers.

3 Program and verify Timer/ Counter in 8051.

4 Interfacing Traffic Light Controller to 8051.

5 UART operation in 8051

6 Interfacing LCD to 8051.

Department of ECE, VLITS Page 26


INTRODUCTION TO 8051 MICROCONTROLLER:

Feature of 8051 Microcontroller:

1. ESA 51e operates on single +5v power supply either in standalone mode using PC keyboard
and LCD or with host PC through its RS-232C interface in serial mode implemented using the
On-chip serial port of Microcontroller.

2. Stand alone and serial monitor programs support the entry of user programs editing and
debugging facilities like single stepping and full speed execution of user programs.

3. Total On-board memory is 128bytes of which 80 bytes RAM has back-up provision.

4. I/O lines and four programmable interval timers.

5. INTERRUPTS:

EXTERNAL: INT is used for implementing single stepping and user’s break switching is
available to user.
INTERNAL: Internal timer and serial interrupts are used by the system monitor.

COMMANDS:

A Assembler:
ESA 5E provides the powerful, PROM resident one-line assembler to enhance
development work. This assembler supports the entire standard mnemonics and addressing modes of
Intel /5 microcontrollers.
FUNCTION: The assembler generates the actual machine and stores them in the memory
locations defined by the program. Also, the system will display the codes generated as well as the
source statements. Any error detected is also displayed on the screen.
C Compare a block of memory with destination block
Function: Compare command can be used to compare the contents of one memory block with
the content of another memory block.
F Fill memory
Fill a block of memory with a constant or search a string of data in program memory, external data
memory and internal data memory.

Department of ECE, VLITS Page 27


Function: This command is used to fill a block of memory with specified constant.
G Go command
Transfer the processor control from the monitor to user program.
Function: The GO command is used to transfer the control of the system from monitor to the
users Program.
H Help command
List all the commands supported by serial monitor.
Function: The help command is used to list all the commands supported by the monitor.
J Jump to address:
Function: The J command is used to change the program counter value to the desired address
Before executing a program by either GO command or SINGLE STEP command.
M Modify/Display/Move memory
Modify/Display/Move memory contents in program memory, external data memory and internal data
memory with all combinations
Function: The M Modify memory command is used to examine the contents of specified
memory locations. Further if location are in RAM their contents can be altered if desired and block
move contents of memory from program, data or internal memory to program or data or internal
memory for all combinations.
The M Display memory command is used to display the contents of the program memory, external or
internal data memory. The M Move memory command is used to move a block of data from one area
of the memory to another area.
P Programmer:
S Single step command:
The command is used to execute a program one instruction at a time. With each instruction
Executed, control is returned to the monitor. Thus this command is an extremely useful debugging
tool. Provision has been made for single stepping with disassembly.
S Single step command with disassembly:
Function: This command is used to single step a program with disassembly. The register
content will not be displayed.
Z Disassemble: Disassembly is an extremely useful feature, often employed during debugging
Function: A disassemble converts machine language codes in to assembly language
mnemonics, making it easy for user to understand the/verify the program.

Department of ECE, VLITS Page 28


Experiment No: 01
FINDING NUMBER OF 1’S AND NUMBER OF 0’S IN A
GIVEN 8-BIT NUMBER

Aim: To write a program to Finding number of 1’s and number of 0’s in a given 8-bit number
using Keil software.

Apparatus:

1. Keil software

2. Personal computer

Procedure:

1. Click the Keil micro version-3 software on desktop

2. Press project on toolbar and then click the New micro version project give the project
name and save.

3. Select the device for target and then press Intel data base of 80C51SL then press ok.

4. Click new text document and enter the program and then save the program.

5. Click target1 and add files to source group

6. To check the errors rebuild all target files.

7. Press debug on tool bar then click start/stop debug session.

8. Press step by step execution (or) run

9. Note down the sys and disassembly.

Department of ECE, VLITS Page 29


Assembly Language Program:
ORH 0000H
MOV R0, #50H
MOV R1, #00H
MOV R2, #00H
MOV R3, #08H
MOV A, @R0
LOOP3: RRC A
JNC LOOP1
INC R2
SJMP LOOP2
LOOP1: INC R1
LOOP2: DJNZ R3, LOOP3
MOV P0, R1
MOV P1, R2
END

INPUT 22H = 00100010B

OUTPUT No of zeroes = R1= 06

No of ones = R2 = 02
Result:
The program for Finding number of 1’s and number of 0’s is done in 8051 microcontroller by
using Keil s/w.

Department of ECE, VLITS Page 30


Experiment No: 02

AVERAGE OF N-NUMBERS

Aim: To write a program to Average of n-numbers using Keil software.

Apparatus:

1. Keil software
2. Personal computer

Procedure:

1. Click the Keil micro vision-5 software on desktop


2. Press project on toolbar and then click the New micro version project give the project
name and save.
3. Select the device for target and then press Intel data base of 80C51SL then press ok.
4. Click new text document and enter the program and then save the program.
5. Click target1 and add files to source group
6. To check the errors rebuild all target files.
7. Press debug on tool bar then click start/stop debug session.
8. Press step by step execution (or) run
9. Note down the sys and disassembly.

Department of ECE, VLITS Page 31


Program:
ORG 0000h
MOV R0, #05H
MOV R1, #50H
MOV A, #00H
MOV B, #05H
L1: ADD A, @R1
INC R1
DJNZ R0, L1
DIV AB
MOV @R0, A
END

INPUT OUTPUT

01, 02, 03, 04, 05 03H

Result:
The program for Average of n-numbers is done in 8051 microcontroller by using Keil s/w.

Department of ECE, VLITS Page 32


EXPERIMENT NO: 03

PROGRAM AND VERIFY TIMER/COUNTER IN 8051


AIM: To write an ALP for verifying the timer / counter in 8051.

APPARATUS REQUIRED:

1. Personal Computer,
2. Keil μVision 5.

Procedure:

1. Click the Keil micro vision-5 software on desktop

2. Press project on toolbar and then click the New micro version project give the project
name and save.

3. Select the device for target and then press Intel data base of 80C51SL then press ok.

4. Click new text document and enter the program and then save the program.

5. Click target1 and add files to source group

6. To check the errors rebuild all target files.

7. Press debug on tool bar then click start/stop debug session.

8. Press step by step execution (or) run

9. Note down the sys and disassembly.

Department of ECE, VLITS Page 33


PROGRAM :

ORG 0000H
MOV TMOD, #00H
MOV TH0, #0FFH
MOV TL0, #01H
HERE: SETB TR0
AGAIN: JNB TF0, AGAIN
CLR TR0
CLR TF0
SJMP HERE
END

Result:
Thus programming for timer /counter in 8051 using Keil has been verified successfully

Department of ECE, VLITS Page 34


Experiment No: 04
TRAFFIC LIGHT CONTROLLER

Aim: To write a program to interface Traffic Light Controller to 8051.

Apparatus:

1.8051 Kit

2. Traffic Light Controller kit

3. Connecting wires

Theory:

The interface simulates the control and operation of traffic lights at a junction of four roads.
The interface provides a set of 6 LED indicators at each of the four corners. Each of these
LEDs can be controlled by a port line.

Thus the interface allows the user to simulate a variety of traffic situations using appropriate
software routines. The sample programs provided in section 4 of this manual simulate some
interesting traffic movement sequences.

Kit diagram:

Department of ECE, VLITS Page 35


Assembly Language Program:

PORT_A EQU E800H


PORT_B EQU E801H
PORT_C EQU E802H
CW
R EQU E803H

ADDRESS OPCODE LABEL MNEMONIC COMMENTS

8000 ORG 8000H


8000 90 E8 03 MOV DPTR, #CWR ;Initialise 8255
8003 74 80 MOV A, #80H ;for MODE 0.
8005 F0 MOVX @DPTR, A ;All Ports as
;O/P Ports.
8006 90 00 00 AGAIN: MOV DPTR, #0000H ;Table of Port
8009 E0 NEXTST:MOVX A, @DPTR ;values.
800A C0 82 PUSH DPL
800C C0 83 PUSH DPH
800E 90 E8 00 MOV DPTR, #PORT_A ;Port A value.
8011 F0 MOVX @DPTR, A
8012 D0 83 POP DPH
8014 D0 82 POP DPL
8016 A3 INC DPTR
8017 E0 MOVX A, @DPTR
8018 C0 82 PUSH DPL
801A C0 83 PUSH DPH
801C 90 E8 01 MOV DPTR, #PORT_B ;Port B value.
801F F0 MOVX @DPTR, A
8020 D0 83 POP DPH
8022 D0 82 POP DPL
8024 A3 INC DPTR
8025 E0 MOVX A, @DPTR
8026 C0 82 PUSH DPL
8028 C0 83 PUSH DPH
802A 90 E8 02 MOV DPTR, #PORT_C ;Port C value.
802D F0 MOVX @DPTR, A
802E D0 83 POP DPH
8030 D0 82 POP DPL
8032 A3 INC DPTR
Department of ECE, VLITS Page 36
8033 12 80 3D CALL DELAY ;Provide delay.
8036 E5 82 MOV A, DPL
8038 B4 01 CE CJNE A, #1EH, NEXTST
803B 80 C9 SJMP AGAIN
803D 7A 07 DELAY: MOV R2, #07H ;Delay routine.
803F 7C FF LOOP3: MOV R4, #0FFH
8041 7B FF LOOP2: MOV R3, #0FFH
8043 1B LOOP1: DEC R3
8044 BB 00 FC CJNE R3, #00, LOOP1

8047 1C DEC R4
8048 BC 00 F6 CJNE R4, #00, LOOP2
804B 1A DEC R2
804C BA 00 F0 CJNE R2, #00, LOOP3
804F 22 RET

Result:
The interfacing of Traffic Light Controller is done in 8051 microcontroller.

Department of ECE, VLITS Page 37


EXPERIMENT NO: 05

UART OPERATION IN 8051

AIM:
To write an ALP to perform the operation of UART in 8051

APPARATUS REQUIRED:

3. Personal Computer,
4. Keil μVision 5.

Procedure:

1. Click the Keil micro vision-5 software on desktop

2. Press project on toolbar and then click the New micro version project give the project
name and save.

3. Select the device for target and then press Intel data base of 80C51SL then press ok.

4. Click new text document and enter the program and then save the program.

5. Click target1 and add files to source group

6. To check the errors rebuild all target files.

7. Press debug on tool bar then click start/stop debug session.

8. Press step by step execution (or) run

9. Note down the sys and disassembly.

Department of ECE, VLITS Page 38


PROGRAM :

ORG 0000H
START: MOV TMOD, #20H
MOV TH1, #0FDH
MOV TL1, #OFDH
MOV SCON, #50H
SETB TR1
MOV SBUF, #’A’
LOOP: JNB TI, LOOP
CLR TI
MOV SBUF, #’B’
LOOP1: JNB TI, LOOP1
CLR TI
MOV SBUF, #’C’
LOOP2: JNB TI, LOOP2
CLR TI
END

INPUT : ABC
OUTPUT : Received ABC serially

Result:
Thus the program for UART in 8051 has been verified successfully.

Department of ECE, VLITS Page 39


EXPERIMENT NO: 06

INTERFACING LCD TO 8051.

AIM:
To write an ALP to interface LCD display with 8051.

APPARATUS REQUIRED:

1. Personal Computer,
2. Keil μVision 5.

Procedure:

1. Click the Keil micro version-5 software on desktop

2. Press project on toolbar and then click the New micro version project give the project
name and save.

3. Select the device for target and then press Intel data base of 80C51SL then press ok.

4. Click new text document and enter the program and then save the program.

5. Click target1 and add files to source group

6. To check the errors rebuild all target files.

7. Press debug on tool bar then click start/stop debug session.

8. Press step by step execution (or) run

9. Note down the sys and disassembly.

Department of ECE, VLITS Page 40


PROGRAM :

#include<reg51.h>
sbit rs = p1^0;
sbit rw = p1^1;
sbit en = p1^2;
void lcdcmd(unsigned char);
void lcddat(unsigned char);
void delay();
void main()
{
P2=0x00; // output declaration
While(1)
{
lcdcmd(0x38); //5x7 matrix crystal
delay();
lcdcmd(0x01); //clear screen
delay();
lcdcmd(0x10); // cursor blinking
delay();
lcdcmd(0x0C); // display on
delay();
lcdcmd(0x81); // force cursor first line first position
delay();
lcddat(‘E’);
delay();
lcddat(‘M’);
delay();
lcddat(‘B’);
delay();
}
}

Department of ECE, VLITS Page 41


Void lcdcmd(unsigned char val)
{
p2 = val;
rs = 0;
rw = 0;
en = 1;
delay();
en = 0;
}
Void lcddat(unsigned char val)
{
p2 = val;
rs = 1;
rw = 0;
en = 1;
delay();
en=0;
}
void delay
{
unsigned int I;
for(i = 0;i<12000;i++)
}

INPUT : Display ‘E’;’M’;’B’


OUTPUT : Output displayed in first line first position

Result:
Thus the LCD display was interfaced with 8051 and verified successfully.

Department of ECE, VLITS Page 42


PART – C

ARM CORTEX M3 PROCESSOR USING KEIL


MDK ARM

LIST OF EXPERIMENTS (Minimum of 2 Experiments has to be performed)

S.No. Name of the Experiment

Write an assembly program to multiply of 2


1
16-bit binary numbers.

Write an assembly program to find the sum


2
of first 10 integers numbers.

Write a program to toggle LED every


3
second using timer interrupt.

Department of ECE, VLITS Page 43


EXPERIMENT NO: 01

MULTIPLICATION OF 2 16-BIT NUMBERS

AIM:
To write an assembly program to multiply 2 16- bit numbers using ARM Instructions.

APPARATUS REQUIRED:

1. Personal Computer,
2. Keil μVision 5.

Procedure:

1. Click the Keil micro vision-5 software on desktop

2. Press project on toolbar and then click the New micro version project give the project
name and save.

3. Select the device for target and then press Intel data base of 80C51SL then press ok.

4. Click new text document and enter the program and then save the program.

5. Click target1 and add files to source group

6. To check the errors rebuild all target files.

7. Press debug on tool bar then click start/stop debug session.

8. Press step by step execution (or) run

9. Note down the sys and disassembly.

Department of ECE, VLITS Page 44


PROGRAM :

AREA RESET, CODE, READONLY


ENTRY
EXPORT_main
_main
LDR R1, =0XFFFF
LDR R2, =0XFFFF
MUL R3, R1, R2
NOP
Stop
END

INPUT : FFFF, FFFF


OUTPUT : FFFE 0001

Result:
Thus the 16-bit multiplication using ARM CORTEX- M3 has been successfully
verified

Department of ECE, VLITS Page 45


EXPERIMENT NO: 02

SUM OF FIRST 10 INTEGER NUMBERS

AIM:
To write an assembly language program to toggle a LED using timer interrupt.

APPARATUS REQUIRED:

1. Personal Computer,
2. Keil μVision 5.

Procedure:

1. Click the Keil micro vision-5 software on desktop

2. Press project on toolbar and then click the New micro version project give the project
name and save.

3. Select the device for target and then press Intel data base of 80C51SL then press ok.

4. Click new text document and enter the program and then save the program.

5. Click target1 and add files to source group

6. To check the errors rebuild all target files.

7. Press debug on tool bar then click start/stop debug session.

8. Press step by step execution (or) run

9. Note down the sys and disassembly.

Department of ECE, VLITS Page 46


PROGRAM :

AREA RESET, CODE, READONLY


ENTRY
EXPORT_main
_main
MOV R0, #10
MOV R1, #0
LOOP ADD R1, R0
SUBS R0, #1
BNE LOOP
LDR R0, =0X10000000
STR R1, [R0]
NOP
stop
END

INPUT : 1, 2, 3, 4, 5, 6, 7, 8, 9, A
OUTPUT : 37H

Result:
Thus the program of sum of first 10 integer numbers using ARM CORTEX-M3 has
been executed successfully

Department of ECE, VLITS Page 47


EXPERIMENT NO: 03

TOGGLE LED USING TIMER INTERRUPT

AIM:
To write an assembly language program for sum of first 10 integer numbers using ARM

CORTEX-M3 instructions.

APPARATUS REQUIRED:

1. Personal Computer,
2. Keil μVision 5.

Procedure:

1. Click the Keil micro vision-5 software on desktop

2. Press project on toolbar and then click the New micro version project give the project
name and save.

3. Select the device for target and then press Intel data base of 80C51SL then press ok.

4. Click new text document and enter the program and then save the program.

5. Click target1 and add files to source group

6. To check the errors rebuild all target files.

7. Press debug on tool bar then click start/stop debug session.

8. Press step by step execution (or) run

9. Note down the sys and disassembly.

PROGRAM :

#include “config.h”
#include “lpc13xx_gpio.h”
Department of ECE, VLITS Page 48
int main(void)
{
u32_t Count=0,time=0;
boolean led_state=TRUE;
InitializeSystem();
SYSCON_AHBPeriphClockCmd(SYSCON_AHBPeriph_GPIO,ENABLE);
GPIO_SetDir(PORT1,GreenLED,1);
GPIO_SetDir(PORT1,BlueLED,1);
time=millis();
while(1)
{
If (millis() – time>1000)
{
time= millis();
if(led_state==TRUE)
{
led_state=FALSE;
GPIO_SetBits(PORT1,GreenLED);
GPIO_SetBits(PORT1,BlueLED);
}
Else
{
led_state=TRUE;
GPIO_ResetBits(PORT1,GreenLED);
GPIO_ResetBits(PORT1,BlueLED);
}
}
#ifdef SEMIHOSTING
Printf(“Count value is %d\n”,Count);
#endif
Count++;
}

Department of ECE, VLITS Page 49


}

Result:
Thus the LED blinking using timer has been verified with ARM CORTEX M3
program successfully.

Department of ECE, VLITS Page 50

You might also like