Professional Documents
Culture Documents
MC Lab Manual 2022 Scheme
MC Lab Manual 2022 Scheme
Microcontrollers Lab
(BECL456A)
B.E –IV Semester
Name :
USN :
Batch : Section :
VISION OF THE INSTITUTE
M1 To impart quality educational experience and technical skills to students that enables them
to become leaders in their chosen professions.
M3 To inculcate students with an ethical and human values so as to have big picture of societal
development in their future career.
To be a premier department known for quality education and research in the field of Electronics and
Communication Engineering for the benefit of mankind.
Program Outcomes as defined by NBA (PO) Engineering Graduates will be able to:
2. Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and engineering sciences.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities
with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to
the professional engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage
in independent and life-long learning in the broadest context of technological change
PEO Statements
Apply fundamentals and skills needed for a successful professional Electronics
PEO1
& Communication Engineer and to pursue higher studies
PSOs Statements
PSO 1 To analyze, design and develop various types of integrated electronics systems.
Laboratory Experiments:
To create a new 8051 project using Keil IDE, Click on the ' Project ' item on the IDE
Menu bar and select ' New uVision Project... ' as shown in the above image.
Now give file name(e.g. P1) and your file should be in the Folder which you have
created in step1
Step 4:Selecting an 8051 Device in Keil
Select Atmel---AT89C51ED2
After selecting your 8051 derivative,You will get another dialog as shown
Above.Asking to copy STARTUP.A51
Type program in text window and save it with same name with extension .asm as
given name to project in step 3
Step 6: Adding file to source group
Step 7: After adding file to source group, click on project → select build target
Step 8: After checking errors, click on debug → select start/stop debug, you will
get following window
Step 9: After that click on ok,then go on clicking step into { } to check step by step
execution.
I)Assembly Language Programming
Program:
Result:
Before Execution After Execution
20H=01H 40H=01H
21H=03H 41H=03H
22H=04H 42H=04H
23H=06H 43H=06H
24H=0BH 44H=0BH
2. Write an ALP to move a block of n bytes of data from source
(2000h) to destination (2050h) using External RAM.
Program:
MOV DPTR,#2000H
MOV R0,#50H
MOV R1,#20H
MOV R2,#05H
UP:MOVX A,@DPTR
PUSH DPL
PUSH DPH
MOV A,R1
MOV DPH,A
MOV A,R0
MOV DPL,A
MOV A,R3
MOVX @DPTR,A
INC DPTR
MOV A,DPH
MOV R1,A
MOV A,DPL
MOV R0,A
POP DPL
POP DPH
INC DPTR
DJNZ R2,UP
END
Result:
Before Execution After Execution
2000H=01H 2050H=01H
2001H=02H 2051H=02H
2002H=03H 2052H=03H
2003H=04H 2053H=04H
2004H=05H 2054H=05H
3. Write an ALP To exchange the source block starting with
address 20h, (Internal RAM) containing N (05) bytes of data
with destination block starting with address 40h (Internal
RAM).
Program:
Program:
Result:
Program:
MOV R0,#34H
MOV R1,#35H
MOV R6,#00H
MOV A,@R0
ADD A,@R1
MOV R5,A
JNC DOWN
INC R6
DOWN:END
Result:
34H=05H R5=0AH
35H=05H R6=00H
6. Write an ALP to subtract the bytes in Internal RAM 34h &35h
store the result in register R5 (LSB) & R6 (MSB).
Program:
MOV R0,#34H
MOV R1,#35H
MOV R6,#00H
MOV A,@R0
SUBB A,@R1
MOV R5,A
END
Result:
34H=06H R5=01H
35H=05H
7. Write an ALP to multiply two 8-bit numbers stored at 30h and
31h and store16- bit result in 32h and 33h of Internal RAM.
Program:
MOV A,30H
MOV B,31H
MUL AB
MOV 32H,A
MOV 33H,B
END
Result:
30H=06H 32H=0CH
31H=02H 33H=00H
8. Write an ALP to perform division operation on 8-bit number
by 8- bit number.
Program:
MOV A,30H
MOV B,31H
DIV AB
MOV 32H,A
MOV 33H,B
END
Result:
30H=06H 32H=03H
31H=02H 33H=00H
9. Write an ALP to separate positive and negative in a given
array.
Program:
MOV 0D0H, #00H ; clear the PSW
MOV DPTR, #5000H
MOV R0, #30H
MOV R1, #20H
MOV R3, #05H
UP: MOVX A,@DPTR
RLC A
JNC NEXT
MOVX A,@DPTR
MOV @R1, A
INC R1
SJMP SKIP
NEXT: MOVX A,@DPTR
MOV @R0, A
INC R0
SKIP: INC DPTR
DJNZ R3, UP
END
Result:
Positive: 80 <= 1 0 0 0 0 0 0 0
20H<= 08H 05 <= 0 0 0 0 0 1 0 1
21H<= 05H
Negative: FF & 80 16 <= 0 0 0 1 0 1 1 0
22H<= 16H
Positive: 08, 05 & 16
Negative: Positive:
30H<= FFH 20H<=08H
31H<= 80H 21H<= 05H
22H<= 16H
10.Write an ALP to separate even or odd elements in a given
array.
Program:
Result:
Before Execution After Execution
Even: Odd:
30H<= 06H 20H<=05H
31H<= 08H 21H<= 07H
22H<= 09H
I) Ascending order
Program:
Result:
Before Execution After Execution
5000H<=08H 5000H<=01H
5001H<=01H 5001H<=02H
5002H<=02H 5002H<=05H
5003H<=09H 5003H<=08H
5004H<=05H 5004H<=09H
II) Descending order.
Program:
MOV R3, #05H
UP: MOV DPTR, #5000H
MOV R2, #04H
AGAIN: MOV R1, 82H
MOVX A,@DPTR
MOV 30H, A
INC DPTR
MOVX A,@DPTR
CJNE A, 30H, DOWN
SJMP SKIP
DOWN: JC SKIP
MOV 82H, R1
MOVX @DPTR, A
INC DPTR
MOV A, 30H
MOVX @DPTR, A
SKIP: DJNZ R2, AGAIN
DJNZ R3, UP
END
Result:
Before Execution After Execution
5000H<=08H 5000H<=09H
5001H<=01H 5001H<=08H
5002H<=02H 5002H<=05H
5003H<=09H 5003H<=02H
5004H<=05H 5004H<=01H
12. Write an ALP to find Largest & Smallest number from a given
array starting from 20h & store it in Internal Memory location
40h.
I)SMALLEST
Program:
30H<=09H 40H=01H
31H<=08H
32H<=05H
33H<=02H
34H<=01H
II) LARGEST
Program:
MOV R1, #30H
MOV R2, #05H
MOV R0, #00H
AGAIN: MOV A,@R1
MOV 30H, R0
CJNE A, 30H, DOWN
SJMP SKIP
DOWN: JC SKIP
MOV R0, A
SKIP: INC R1
DJNZ R2, AGAIN
END
Result:
30H<=09H 40H=09H
31H<=08H
32H<=05H
33H<=02H
34H<=01H
3.Counter Operation Programs:
MOV A, #00H
UP: LCALL 061DH
MOV R3, A
MOV R4, #00H
MOV R5, #02H
LCALL 059EH
ADD A, #01H
DA A
CJNE A, #00H, UP
END
Result:
After Execution
00
01
02
03
.
.
96
97
98
99
MOV A, #99H
UP: LCALL 061DH
MOV R3, A
MOV R4, #00H
MOV R5, #02H
LCALL 059EH
ADD A, #99H
DA A
CJNE A, #99H, UP
END
Result:
After Execution
99
98
97
96
.
.
03
02
01
00
Result:
After Execution
00
01
02
03
.
.
FC
FD
FE
FF
Result:
After Execution
FF
FE
FD
FC
.
.
03
02
01
00
II. C Programming
Program:
#include<reg51.h>//include the 8051 microcontroller header file
void main()
{
//give the number to which you need the factorial of the given number & initialize
with 1
unsigned int num=5, fact=1;
while(num>0)
{
fact = fact*num;
num--;
}
P1=fact; // display the result on the output port
while(1);
}
Program:
#include<reg51.h>
//look-up table of squares
const unsigned char squares[]={1,4,9,16,25,36,49,64,81,100};
void main()
{
unsigned char number=9; //Number for which we want to find the square
while(number<=10)
{
unsigned char square=squares [number-1];
Program:
#include<at89c5led2.h>
#include<stdio.h>
#define PHASED 0x09
#define PHASEC 0x0c
#define PHASEB 0x06
#define PHASEA 0x03
void delay_ms(unsigned int n)
{
int i;
for(i=0; i<n; i++)
{
}
}
void main()
{
while (1)
{
P0=PHASEA;
delay_ms(10000);
P0=PHASEB;
delay_ms(10000);
P0=PHASEC;
delay_ms(10000);
P0=PHASED;
delay_ms(10000);
}
}
unsigned char i;
while(1) {
for(i = 0; i < 10; i++) {
DAC_DATA = sineWave[i]; // Output sine waveform to DAC
delay(100); // Adjust delay for desired frequency
}
}
}
unsigned char i;
while(1) {
for(i = 0; i < 2; i++) {
DAC_DATA = squareWave[i]; // Output square waveform to DAC
delay(100); // Adjust delay for desired frequency
}
}
}
void main() {
// Initialize DAC interface
DAC_DATA = 0; // Initialize DAC data bus
while(1) {
generateSine(); // Generate sine waveform
//generateSquare(); // Uncomment this line to generate square
waveform
}
}
Viva Questions
1. What do you mean by Embedded System? Give examples.
2. Why are embedded Systems useful?
3. What is Embedded Controller?
4. What is Microcontroller?
5. List out the differences between Microcontroller and Microprocessor.
6. How are Microcontrollers more suitable than Microprocessor for Real Time Applications?
7. What are the General Features of Microcontroller?
8. Explain briefly the classification of Microcontroller.
9. Explain the general features of 8051 Microcontroller.
10. How many pin the 8051 has?
11. Differentiate between Program Memory and Data Memory.
12. What is the size of the Program and Data memory?
13. Write a note on internal RAM. What is the necessity of register banks?
14. What is the function of accumulator?
15. What are SFR’s?
16. What is the program counter? What is its use?
17. What is the size of the PC?
18. What is a stack pointer (SP)?
19. What is the size of SP?
20. What is the PSW? And briefly describe the function of its fields.
21. What is the difference between PC and DPTR?
22. What is the difference between PC and SP?
23. What is ALE? Explain the functions of the ALE in 8051.
24. What are the disadvantages of the ceramic resonator?
25. Explain briefly the difference between the Von Neumann and the Harvard Architecture.
26. Describe in detail how the register banks are organized.
27. What are the bit addressable registers and what is the need?
28. What is the need for the general purpose RAM area?
29. What is Stack and the Stack Pointer.
30. Explain briefly how internal and external ROM gets accessed.
31. What are the different addressing modes supported by 8051 Microcontroller ?
32. Explain the Immediate Addressing Mode.
33. Explain the Register Addressing Mode.
34. Explain the Direct Addressing Mode.
35. Explain the Indirect Addressing Mode.
36. Explain the Code Addressing Mode.
37. Explain in detail the Functional Classification of 8051 Instruction set
38. What are the instructions used to operate stack?
39. What are Accumulator specific transfer instructions?
40. What is the difference between INC and ADD instructions?
41. What is the difference between DEC and SUBB instructions?
42. What is the use of OV flag in MUL and DIV instructions?
43. What are single and two operand instructions?
44. Explain Unconditional and Conditional JMP and CALL instructions.
45. Explain the different types of RETURN instructions.
46. What is a software delay?
47. What are the factors to be considered while deciding a software delay?
48. What is a Machine cycle?
49. Give a brief introduction on Timers/Counter.
50. What is the difference between Timer and Counter operation?
51. How do you differentiate between Timers and Counters?
52. What is the significance of DA instruction?
53. What is packed and unpacked BCD?
54. What is the difference between CY and OV flag?
55. When will the OV flag be set?
56. What is an ASCII code?