8051 Microcontroller
Programming Lab Experiments
+++
Cycle 1 (2016-17) :
1. write a program to perform multiplication and division operation.
2. write a program to find product of two numbers using repeated addition.
3. Write a program to find the sum of first ten decimal numbers.
4. Write a program to swap the given 8-bit number using rotate instruction.
5. Write a program to copy a set of data from one location to another.
6. Write a program to exchange two set of data.
7. Write program to find the largest from a set of n numbers.
8. Write program to find the smallest from a set of n numbers.
9. Write a program to sort a set of numbers in ascending order.
10.Write a program to sort a set of numbers in descending order.
CYCLE II
11. Write a program to toggle the LEDs connected to P2.
12. Write a program to display a number (5) using a 7 segment display.
13. Write a program to display the hexadecimal numbers using 7 seg display continuously.
14. Write a program to read the input set using DIP switch and to display the same using 7 segment.
15. Write a program to display your name using LCD display.
16. Write a program to generate a square wave.
17. Write a program to generate a sawtooth wave.
18. Write a program to rotate the given motor in clock-wise direction.
19. Write a program to rotate the motor in anti-clock wise direction.
CYCLE III
20. Write a program using embedded C in Kiel to blink a LED connected to P1.2.
21. Write a program in embedded C using Kiel to toggle the pins in P0.
22. Write a program in embedded C using Kiel to display 0-9 on seven segment display.
23. Write a program in embedded C using Kiel to create a delay of 500msec and to blink a LED accordingly.
CYCLE II
11. Write a program to toggle the LEDs connected to P2.
12. Write a program to display a number (5) using a 7 segment display.
13. Write a program to display the hexadecimal numbers using 7 seg display continuously.
14. Write a program to read the input set using DIP switch and to display the same using 7 segment.
15. Write a program to display your name using LCD display.
16. Write a program to generate a square wave.
17. Write a program to generate a sawtooth wave.
18. Write a program to rotate the given motor in clock-wise direction.
19. Write a program to rotate the motor in anti-clock wise direction.
CYCLE III
20. Write a program using embedded C in Kiel to blink a LED connected to P1.2.
21. Write a program in embedded C using Kiel to toggle the pins in P0.
22. Write a program in embedded C using Kiel to display 0-9 on seven segment display.
23. Write a program in embedded C using Kiel to create a delay of 500msec and to blink a LED accordingly.
========================================================================
CYCLE 1: EXPERIMENTS ON ASSEMBLY PROGRAMMING
1.
Write a program to perform multiplication and division operations.
2.
Write a program to transfer a
block of data from internal memory to external memory.
3.
Write a program to exchange two
set of data.
4.
Write a program to find the sum
of two numbers in decimal?
5.
Write a program to convert
decimal number to hexadecimal.
6.
Write a program to add a number
n, m number of times.
7. Write program to find the largest from a
set of n numbers.
8.
Write program to count the number of occurrence of
a number in a block of numbers
9.
Write program to perform swap and exchange
operations.
10. Write a program to sort a set of numbers in ascending order?
11. Write a program to sort a set of numbers in
descending order?10. Write a program to sort a set of numbers in ascending order?
CYCLE
2: EXPERIMENTS ON 8051 INTERFACING
- Write an assembly language program for generating a triangular wave?
- Write program to toggle port bits.
- Write a program to find the largest from a set of ten numbers and display it using LEDs.
- Write a program to for displaying the decimal numbers in 7 Segment display?
- Write a program to read the DIP switches for displaying the reading using 7 Segment display.
- Write a program to rotate the given motor in clockwise direction?
- Write a program to rotate the given motor in anticlockwise direction?
- Write a program to generate a square wave?
- Write a program to display a message in LCD display.
- Write a program to Interface ADC with 8051 and to read voltage values.
- Write a program to generate a frequency of 10khz using interrupts on Px.i
CYCLE 3: EXPERIMENTS ON 8051 PROGRAMMING IN C USING KEIL
- Write program for toggling the LEDs connected to a Port Px
- Write program for generating a square/triangular wave?
- Write a program display a hexadecimal digit using LEDs.
- Write a program that sequentially displays the decimal numbers using 7 segment.
- Write a program to create a delay of 5ms using 8051 Timers.
- Write a program to read an input through DIP switch and display the reading using LED or 7-segment.
- Write a program to rotate the given motor in?
Note: A minimum of 22 experiments; 8 from cycle 1, 6 from
cycle 2 and 5 from cycle 3 is to be carried out compulsorily.
SOLVED QUESTIONS1. ADDITION
MOV A,#00H
MOV R0,#0AH
GO:ADD A,#05H
DJNZ R0,GO
MOV R1,A
END
2. BLOCK DATA TRANSFER
MOV RO,#20H
MOV R1,#010H
MOV R1,#040H
LOC:MOV A,@R0
MOV @R1,A
INC R0
INC R1
DJNZ R3,LOC
END
3. ADDITION OF FIRST TEN NATURAL
NUMBERS
MOV A,#0AH
MOV R0,0AH
CLR A
LOOP:ADD A,RO
DJNZ R0,LOOP
MOV 046H,A
END
4. MULTIPLICATION AND DIVISON
MOV R0,#020H
MOV A,@R0
INC R0
MOV 0F0H,@RO
MUL AB
MOV R1,A
CLR A
INC R0
MOV A,@R0
INC R0
MOV 0F0H,@R0
DIV AB
MOV R5,A
END
5. LARGEST OF BLOCK OF DATA
MOV R0,#020H
MOV R1,#0AH
MOV 0F0H,#00H
LOC3:MOV A,@R0
CJNE A,OFOH,LOC2
LOC2:JC LOC1
MOV 0F0H,A
LOC1:INC RO
DJNZ R1,LOC3
MOV A,0F0H
END
6. SMALLEST OF BLOCK OF DATA
MOV R0,#0AH
MOV R1,#30H
MOV 0F0H,@R1
L2:MOV A,@R1
CJNE A,0F0H,L1
L1:JC,L4
INC R1
DJNZ R0,L2
SJMP L3
L4:MOV 0F0H,A
INC R1
DJNZ R0,L2
L3:MOV 60H,0F0H
END
7. ASCENDING ORDER
MOV R1,#09H
START:MOV R2,#09H
MOV R0,#020H
MOV A,#00H
BACK: MOV A,@R0
INC R0
MOV 0F0H,@R0
CJNE A,0F0H,LOC1
SJMP LOC3
LOC1:JNC,LOC2
SJMP LOC3
LOC2:DEC R0
MOV @R0,OFOH
INC R0
MOV @R0,A
LOC3:DJNZ R2,BACK
DJNZ R1,START
END
8. DESCENDING ORDER
MOV R1,#09H
START:MOV R2,#09H
MOV R0,#020H
MOV A,#00H
BACK: MOV A,@R0
INC R0
MOV 0F0H,@R0
CJNE A,0F0H,LOC1
SJMP LOC3
LOC1:JC,LOC2
SJMP LOC3
LOC2:DCC R0
MOV @R0,OFOH
INC R0
MOV @R0,A
LOC3:DJNZ R2,BACK
DJNZ R1,START
END
9. MERGING TWO SET OF DATA
MOV R0,#020H
MOV R3,#0BH
MOV R1,#040H
LOC:MOV A,@R0
MOV @R1,A
INC R0
INC R1
DJNZ R3,LOC
CLR A
MOV RO,#030H
MOV R2,#0AH
MOV R1,#O4BH
L1:MOV A,@R0
MOV @R1,A
INC R0
INC R1
DJNZ R3,L1
END
10. BLOCK DATA EXTANGE
MOV R3,#005H
MOV R1,#040H
MOV R0,#050H
L1:MOV A,@R1
XCH A,@R0
MOV @R1,A
INC R1
INCR0
DJNZ R3,L1
END
11. TOGGLING PORT BITS
LOC:MOV A,#0AAH
MOV P2,A
ACALL DELAY
MOV A,#055H
MOV P2,A
ACALL DELAY
SJMP LOC
DELAY:MOV R3,#0FFH
BACK:MOV R4,#0FFH
AGAIN:DJNZ R4,AGAIN
DJNZ R3,BACK
RET
END
12. TRIANGULAR WAVE FORM
ORG OOH
AGAIN:MOV A,#00H
LOC:MOV P1,A
INC A
CJNE A,#0FFH,LOC
MOV P1,A
L1:DEC A
MOV P1,A
CJNE A,#00H,L1
SJMP AGAIN
END
13. SQUARE WAVE FORM GENERATION
ORG OOH
AGAIN:MOV P1,#0FFH
ACALL DELAY
MOV P1,#OOH
ACALL DELAY
SJMP AGAIN
DELAY:MOV R3,#0FFH
HERE2:MOV R4,#OFFH
HERE:DJNZ R4,HERE
DJNZ R3,HERE2
RET
END
14. STEPPER MOTOR CLOCK WISE ROTATION
ORG 00H
START: SETB P1.0
SETB P1.1
SETB P1.2
CLR P1.3
ACALL DELAY
SETB P1.0
SETB P1.1
CLR P1.2
SETB P1.3
A CALL DELAY
SETB P1.0
CLR P1.1
SETB P1.2
SETB P1.3
ACALL DELAY
CLR P1.0
SETB P1.1
SETB P1.2
SETB P1.3
SJMP START
DELAY: MOV R3,#0FFH
L1: MOV R4,#0FFH
L2: DJNZ R4,L2
DJNZ R3,L1
RET
END
15. STEPPER MOTOR ANTI-CLOCK WISE ROTATION
ORG 00H
START: SETB P1.3
SETB P1.2
SETB P1.1
CLR P1.0
ACALL DELAY
SETB P1.3
SETB P1.2
CLR P1.1
SETB P1.0
A CALL DELAY
SETB P1.3
CLR P1.2
SETB P1.1
SETB P1.0
ACALL DELAY
CLR P1.3
SETB P1.2
SETB P1.1
SETB P1.0
SJMP START
DELAY: MOV R3,#0FFH
L1: MOV R4,#0FFH
L2: DJNZ R4,L2
DJNZ R3,L1
RET
END
16. DIP SWITCH
ORG 00H
HERE:MOV A, P2
MOV P1,A
SJMP HERE
END
17. 7 SEGMENT FOR DISPLAYING (0-9)
ORG 00H
MOV 80H,#0FFH
SETB 90H
START:MOV R0,#00AH
MOV DPTR,#200H
LOC:MOV A,#00H
MOV C,A@A+DPTR
MOV 80H,A
L CALL DELAY
LCALL DELAY
LCALL DELAY
LCALL DELAY
INC DPTR
DJNZ R0, LOC
SJMP START
ORG 200H
DB
3FH,06H,5BH,4FH,66H,6DH,7DH,67H,7FH,67H
DELAY:MOV R1,#0FFFH
HERE2:MOV R4,#0FFH
HERE:DJNZ R4,HERE
DJNZ R1,HERE2
RET
END
18. DISPLAY THE MESSAGE "BPC"
ORG 00H
MOV A,#38H
ACALL COMNDWRT
ACALL DELAY
MOV A,#0EH
ACALL COMNDWRT
ACALL DELAY
MOV A,#01H
ACALL COMNDWRT
ACALL DELAY
MOV A,#06H
ACALL COMNDWRT
ACALL DELAY
MOV A,#82H
ACALL COMNDWRT
ACALL DELAY
MOV A,#’B’
ACALL DATAWRT
ACALL DELAY
MOV A,#’P’
ACALL DATAWRT
ACALL DELAY
MOV A,#’C’
ACALL DATAWRT
MOV A,#01H
ACALL COMNDWRT
AGAIN:SJMP AGAIN
DATAWRT:MOV P1,A
SETB P3.0
CLR P3.1
SETB P3.2
CLR P3.2
RET
COMNDWRT:MOV P1,A
SETB P3.0
CLR P3.1
SETB P3.2
CLR P3.2
RET
DELAY:MOV R3,#0FFH
HERE2:MOV R4,#0FFH
HERE:DJNZ R4,HERE
DJNZ R3,HERE2
RET
END
19. WAP IN C FOR LED BLINKING
#include<reg51.h>
soid delay(void);
sbit x=ox92;
void main(void)
{
for(;;)
{
x=0;
delay();
x=1;
delay();
}
}
void delay( )
{
unsigned int i,j,t=500;
for(i=0;i<500;i++)
{
for(j=0;j<t;j++)
{
}
}
}
No comments:
Post a Comment