You are on page 1of 6

MICROCONTROLLER LAB

LIST OF EXPERIMENT (B.Tech., VIIth Sem, EEE)


1. TO UNDERSTAND THE BASIC ARITHMETIC AND INTRODUCTION
TO 8051 MICROCONTROLLER.
1(a) Write an ALP to add, subtract & multiply , division of two 8 bit
numbers. Numbers are in Register in R1 & R2. Result of addition in
register in R0, subtraction in R3, borrow if any in R4, Result of
multiplication in Register R5 & R6, & Result of division , quotient in R7,
Remainder in R0 of RB1. Display all results on port 1 LED Bank with a 5
sec delay.
1(b) Write an ALP to AND, OR, NOT & XOR of two 8 bit numbers.
Numbers are in Register in R1 & R2. Result of ANDING in Register R0,
ORING in R3, Negation in Register R5 & R6, XORING in R7. Display all
results on Port 1 LED Bank with a 5 sec delay.
1(c) Write an ALP to add of two byte number. 1st two byte number are in
Register R1 & R2 and 2nd two byte number are in Register in R3, R4,
Result of addition in Register R5,R6,R7. Display all results on port 1 LED
Bank with a 5sec delay.
1 (d) Write an ALP to subtract of two byte number from another two byte
number. 1st two byte number are in Register R1 & R2 and 2nd two byte
number are in Register in R3, R4, Result of subtraction in Register R5,R6,
borrow if any in R7. Display all results on port 1 LED Bank with a 5sec
delay.
1 (e) Write an ALP to add n byte number stored in external RAM
(Starting addresss 9000 and no of bytes is 10 or 0Ah). 1st two byte number
are in Register R0 & R1 and 2nd two byte number are in Register in R2, R3.
Result of addition in Register R5,R6,R7. Display all results on port 1 LED
Bank with a 5sec delay.
2. COPY BLOCK AND SHIFT BLOCK

2 (a) Write an ALP to move block of data bytes present in internal memory
with starting address 10h and ending address 20h to the destination
memory with starting address 30h. (Without overlap).Numbers are in
Register R1,R2,. Result of without overlapping in Register R0. Display all
results on Port 1 LED Bank with a 5 sec delay.
2 (b) Write an ALP to move block of data bytes present in internal
memory with starting address 10h and ending address 20h to the
destination memory with starting address 15h. (With Overlap).
2 (c) Write an ALP to move block of data bytes present in external
memory with starting address 800h to the destination memory with
starting address 900h and size of array is 10h.
2 (d) Write an ALP to exchange block of data bytes present in external
memory. Starting address of first is 8000h and starting address of other
block 900h and size of array is 10h.
3.HEX TO BCD CONVERSION
3 (a) Write an ALP to illustrate hexadecimal up counter with a given
starting and ending value. Starting Range is 00H, Ending Range is 0FFH,
Register used R0,R1,R3,R6.
3 (b) Write an ALP to illustrate hexadecimal down counter with a given
starting and ending value. Starting Range is 0FFH, Ending Range is 00H.
3 (c) Write an ALP to illustrate decimal up counter with a given starting
and ending value. Starting Range is 00H, Ending Range is 099H, Register
used R0, R1, R3,R6.
3 (d) Write an ALP to illustrate decimal down counter with a given
starting and ending value. Starting Range is 99H, Ending Range is 00H,
Register used R0, R1, R3,R6.

3 (e) Write an ALP to convert decimal number to its equivalent


hexadecimal number. Input Register is R0, Output Register is R1.
3 (f) Write an ALP to convert hexadecimal number to its equivalent
decimal number. Input Register is R0, Output Register is R2.
3 (g) Write an ALP to convert decimal number to its equivalent ASCII
code. Input Register is R1
3 (h) Write an ALP to convert ASCII code to its equivalent decimal
number. Input Register is R1.
3 (i) Write an ALP to convert BCD to its equivalent ASCII code. Input
Register is R0.

4. PACK ARRAY OF UNPACKED BCD DIGITS FIND LARGEST AND


SMALLEST INTEGERS OF AN ARRAY
4 (a) Using only one pointer, R0, pack two arrays of BCD digits to create a
third array. The highest digits are available from 30H to 3FH. Lower digits
are available from 40H to 4FH. Packed BCD numbers are to be stored
from 50H to 5FH
4(b) Find the largest and smallest from N unsigned integers. Assume the
value of N to be available in the internal data memory location 30H. The
array starts from location 31H. Store the maximum integers in R4 and
minimum in R3.
5. Write an ALP to find largest elements in a given array present in
external memory with a starting address 900h and size of array is 10h.
6 Write an ALP to sort a given array present in external memory with a
starting address 9000h and size of an array is 10h using bubble sort
technique
7. Write an ALP to search a byte in array of bytes stored in external RAM

8. FIND THE SUM OF FACTORIALS


8(a) A few random unsigned integers are stored from the internal data
memory location 31H onwards. Number of term (N) is available in location
30H. Assuming that none of these numbers is greater than 5, find the
factorials of these integers and then find their sum. Assume that the sum
would not exceed 8-bit value.
8(b) Write an ALP to demonstrate call and return instruction using a
program to find factorial of a number.

9. WAP TO BLINK 8 LEDS CONNECTED TO PORT 1.


(i) All LEDS to blink together for 5 sec & then all LEDS off for 5 sec. This
should go on continuously.
(ii) Alternate LEDS (i.e. connected to odd & even pins of port 1) to glow for 5
sec.
(iii) Develop a program so that the LED interfaced with Port P1.0 blinks
continuously.
(iv) Two keys and one LED are interfaced with 8051 . Develop a software so
that K1 would turn the LED on and K2 would turn it off.

10. WAP for configuring timer to generate variable frequency square wave.

MOV R1,#20H
MOV R2,#10H
MOV A,R2
ADD A,R1
MOV R0,A
MOV P1,A
CALL DELAY
MOV A,#00H
MOV A,R2
SUBB A,R1
MOV R3,A
JNC NEXT
NEXT: INC R4
MOV P1,A
CALL DELAY
MOV A,#00H
MOV A,R1
MOV B,R2
MUL AB
MOV R5,A
MOV R6,B
MOV P1,A
CALL DELAY
MOV A,#00H

MOV A,R1
MOV B,R2
DIV AB
MOV R7,A
SETB P1.4
MOV R0,B
MOV P1,A
CALL DELAY

DELAY:
LOOP1: MOV R2,#20H
DJNZ R2,LOOP1
RET