Microcontroller and Embedded Systems

Microcontroller and Embedded Systems:
Branches:
Semester:
1.
2.
Electronics & Telecommunication Engineering
Electrical & Electronics Engineering
6th Semester / 7th Semester
1. Explain the differences between Microprocessor based system and Microcontroller based
system.
2. What is OTP, explain OTP in details.
3. Explain the applications of microcontroller.
4. What is embedded microcontroller?
5. List different 8051 family microcontroller with their features indicating serial port, timers,
interrupt sources and memories.
6. List the differences between 8051, 8052, 8031, 8032, 8751, 8752, AT89C2051, AT89C51, and
AT89C52.
7. Explain the features of Intel’s 8051 Microcontroller.
8. Draw and explain the architecture of Microcontroller 8051.
9. What is the Program status word explains in details with suitable example.
10. Explain register structure of the 8051 Microcontroller.
11. Explain following registers of the 8051 Microcontroller DPTR, PC and SP.
12. Explain the memory organization of the 8051 Microcontroller.
13. What is the special function register, what are their significances in the 8051
Microcontroller?
14. What are the addressing modes? Explain addressing modes of the Microcontroller 8051 in
details.
15. Write an ALP to add RAM location contents from 40 – 44h. Store the result of low byte in
register A and higher byte in register R7.
16. Write a program to add two 16 bit numbers 2345h and 567Ch. Place the sum in register R7
and R6. R6 should have the lower byte of the result.
17. Write an ALP to add 5 BCD numbers present in RAM memory location starting at 40h. Store
the result of lower byte in register A and higher byte in register R7.
18. Write an ALP to transfer value 41h serially via pin P2.1 .Put two high at the start and two
high at the end of the data. Send the byte LSB first.
19. Write a program to copy data byte serially one bit at a time from port pin P1.7 and save it in
register R2. The byte comes in with LSB first.
20. Write an ALP to count even and odd numbers from the 10 bytes present in the memory
location from 30h. Put the even and odd count in register R7 and R6 respectively.
21. Write an ALP to count positive and negative numbers from the 10 bytes present in the
memory location from 30h. Put the +ve and –ve count in register R7 and R6 respectively.
22. Write an ALP to find smallest byte from 10 bytes present in the memory location from 30h.
Put the smallest byte in register R7.
23. Write an ALP to find largest byte from 10 bytes present in the memory location from 30h.
Put the largest byte in memory location 7Fh.
24. Write an ALP to find cubes of a number 0 - 6 and put the result in the memory location from
30h.
Created By: N. B. Bahadure, Associate Professor, E & TC Deptt. B. I. T. Durg
1
25. Write an ALP to count byte 00h from 20 bytes present in the memory location from 30H. Put
the result in the external memory at 0200h.
26. Write an ALP to count byte 55h from 20 bytes present in the memory location from 30H.
Put the result in the external memory at 0200h.
27. Assume that register A has packed BCD number write a program to convert packed BCD
number to two ASCII numbers and place them in register R2 and R6.
28. Explain the following instruction JMP @A + DPTR, CALL, RET, INC DPTR, SWAP.
29. Explain absolute and long call with suitable examples.
30. State the contents of RAM location after the following program
SETB PSW.3
MOV R1, #67H
MOV R5, #34H
MOV R7, #0ACH
MOV R2, #55H
31. Write a program to add 3 to the accumulator 10 times. Save the result in register R7.
32. Write a program to load accumulator with AAh and complement the accumulator 700 times.
33. Find the size of the delay in the following program. Assume that the crystal frequency for
the 8051 Microcontroller is 11.0592 MHz.
Delay:
MOV R3, #200
Here:
DJNZ R3, Here
RET
34. Find the size of the delay in the following program. Assume that the crystal frequency for
the 8051 Microcontroller is 11.0592 MHz
MOV R3, #250
Here:
NOP
NOP
NOP
NOP
DJNZ R3, Here
RET
35. Find the size of the delay in the following program. Assume that the crystal frequency for
the 8051 Microcontroller is 11.0592 MHz
MOV R2, #200
Rep:
MOV R3, #250
Here:
NOP
NOP
DJNZ R3, Here
DJNZ R2, Rep
RET
36. Write a program to clear 16 RAM locations starting at RAM address 60h.
37. Write an ALP to find number of 1’s in a given byte.
38. Write an ALP to find number of one’s in a given byte and stored the result in external
memory location at 4000h.
39. Write a program to
a.
Write a value 55h to the RAM locations 40h – 4Fh
Created By: N. B. Bahadure, Associate Professor, E & TC Deptt. B. I. T. Durg
2
b.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
Add all these RAM location contents together and save the result in RAM
location 60h and 61h.
An external ROM uses the 8051 data space to store the look up table starting at address
1000h. Write a program to read 30 bytes of these data and send them to port P1.
External data ROM has a look up table for the squares of numbers 0 – 9. Write a program to
copy the table elements into the internal ram starting at address 30h. The look up table
starts at address 0000h.
Write a program to read 200 bytes of data from port P1 and save the data in external RAM
starting at address 5000h.
Write an ALP to calculate squares of 0 – 9 and put the result in the memory location from
30h.
Write an ALP to calculate squares of BCD numbers 0 – 9 and put the result in the memory
location from 30h.
Write a program to toggle all the bits of port P1 by sending to its value 55h and AAh
continuously. Put a time delay in between each issuing of data to port 1.
Explain the following pins of the 8051 Microcontroller EA, PSEN, ALE, and RXD.
Draw and explain power on reset circuit.
What are the reset values for the register of 8051 Microcontroller? Also explain the
importance of Port P0 and Port P2.
Write an ALP to toggle all the bits of P0, P1 and P2 every ¼ second. Assume a crystal
frequency of 11.0592 MHz
Write an ALP
a.
To create a square wave of 50% duty cycle on bit 0 of port 1.
b.
To create a square wave of 66% duty cycle on bit 3 of port 1.
c.
To create a square wave of 33% duty cycle on bit 4 of port 1.
Timers of 8051 Microcontroller:
51. Explain the registers of timers. Also explain TMOD and TCON registers.
52. Explain the following:
a.
13 – bit timer mode
b.
16 – bit timer mode
c.
8 – bit timer mode or auto reload mode
d.
Split timer mode
53. Draw and explain timer/counter 0 and timer/counter 1 for the mode 1
54. Draw and explain timer/counter 0 and timer/counter 1 for the mode 2
55. Explain how to initialize the timer with suitable example.
56. Explain 13 – bit timer mode and split timer mode of timers 8051 Microcontroller.
57. Assume that XTAL = 11.0592 MHz Write an ALP to generate pulse width of 5ms on port pin
P2.3 using timer 0.
58. Assume that XTAL = 11.0592 MHz, write a program to generate a square wave of 2 KHz
frequency on pin P1.5 using timer 1.
59. Write an assembly language program to generate square wave of 200 µs frequency using
timer 1 in mode 2. Assume that XTAL = 11.0592 MHz
Created By: N. B. Bahadure, Associate Professor, E & TC Deptt. B. I. T. Durg
3
60. Write an ALP to generate square wave of 50 Hz frequency on pin P2.3 using timer 1. Assume
that XTAL = 11.0592 MHz
61. Write an ALP to generate square wave of 7.2 Hz frequency on the port pin P1.2 using Timer
1 in auto reload mode. Assume that XTAL = 11.0592 MHz
62. Write an ALP to generate square wave of 100 µs frequency using Timer 0 in auto reload
mode with 66% duty cycle. Assume that XTAL = 11.0592 MHz
63. Find the frequency of a square wave generated on Pin P1.0
MOV TMOD,#2H
MOV TH0,#0
AGAIN:
MOV R5,#250
ACALL DELAY
CPL P1.0
SJMP AGAIN
DELAY:
SETB TR0
BACK:
JNB TF0,BACK
CLR TR0
CLR TF0
DJNZ R5,DELAY
RET
64. Assume that XTAL = 11.0592 MHz, find
a.
The frequency of square wave generated on P1.0 in the following program and
b.
The smallest frequency achievable in this program and TH value to do that.
MOV TMOD, #20H
MOV TH1, #5
SETB TR1
L1:
JNB TF1, L1
CPL P1.0
CLR TF1
SJMP L1
65. Assume that clock pulses are fed into pin T1, write a program for counter 1 in mode 2 to
count the pulses and display the state of TL1 register count on port P2.
Serial Communication of 8051 Microcontroller:
66. What is serial communication? Explain integrated means of serial communication.
67. Explain the type of transmission used in serial communication.
68. Explain the following: Simplex communication, Duplex Communication and Asynchronous
serial communication in details with examples.
69. Explain asynchronous serial communication using suitable example.
70. What are the means of data transfer rate in serial communication explain in details.
71. Explain in details how to write to the serial port.
72. Explain SBUF and SCON register of 8051 serial communication.
73. Explain the importance of transmit interrupt flag and receive interrupt flag bit of serial
communication.
Created By: N. B. Bahadure, Associate Professor, E & TC Deptt. B. I. T. Durg
4
74. Write an ALP for the 8051 to transfer character ‘A’ serially at 4800 baud rate, continuously.
75. Write a program to transfer the message “YES” serially at 9600 baud rate, 8 bit data, and 1
stop bit continuously.
76. Write an ALP to receive bytes of data serially and put them in port P1. Set the baud rate at
4800, 8 – bit data and 1 stop bit.
77. Explain PCON register. Also explain how baud rate will be doubled without increasing the
crystal frequency.
78. Assume that XTAL = 11.0592 MHz Write an ALP to transfer letter “B” in register A and then
serially continuously. Use baud rate at 19200.
79. Write a program to transfer the message “CSVTU” serially at 9600 baud rate, 8 bit data, and
1 stop bit continuously.
80. Assume that the 8051 serial port is connected to the COM port of the IBM PC, and on the PC
we are using the HyperTerminal program to send and receive data serially. P1 and P2 of the
8051 are connected to the LED's and switches respectively. write an ALP
(a) Send to the PC the message "we are ready"
(b) Receive any data sent by the PC and put it on LED's connected to the port P1 and
(c) Get data on switches connected to the port P2 and send it to the PC serially.
The program should perform part (a) once but part (b) and (c) continuously. Use 4800 baud
rate.
81. Explain how the baud rate of serial communication in the 8051 Microcontroller is doubled
without increasing the crystal frequency. Explain with suitable example.
82. Assuming that XTAL = 11.0592 MHz for the following program state
(a) What this program does.
(b) Compute the frequency used by timer 1 to set the baud rate and
(c) Find baud rate of the data transfer.
83. Assume a switch is connected to pin P1.7. Write a program to monitor its status and send
two messages to the serial port continuously as follows.
SW = 0 send "NO"
SW = 1 send "YES"
Assume XTAL = 11.0592 MHz, 9600 baud rate, 8 bit data.
84. Write an ALP to transfer the message "NBBAHADURE" serially at 38400 baud rate with 8 bit
data, 1 start bit and 1 stop bit continuously.
85. Write an ALP to transfer the ASCII character "A" serially at 19200 baud rate with 9 bits
continuously. Set 9th bit as high bit.
Interrupts of 8051 Microcontroller:
86. Explain the differences between Interrupts and Polling.
87. Explain the Interrupts of 8051 Microcontroller in details.
88. Draw and explain interrupt structure of 8051 Microcontroller also explain enabling and
disabling the interrupts.
89. Explain Interrupt enable and Interrupt priority register.
90. Show the instruction to
a.
Enable serial interrupt, timer 0 interrupt and external hardware interrupt 1.
b.
Disable timer 0 interrupt.
Created By: N. B. Bahadure, Associate Professor, E & TC Deptt. B. I. T. Durg
5
91.
92.
93.
94.
95.
96.
97.
98.
99.
c.
Show how to disable all the interrupt with a single instruction.
Program the IP register to assign the highest priority to external interrupt 1 then discuss
what happen if INT0, INT1 and TF0 are activated at the same time.
Assume that after reset the IP register is set by the instruction MOV IP, #0Ch. Discuss the
sequence in which the interrupts are serviced.
Write a program to generate square wave of 50Hz frequency on P1.2 using interrupt for
timer 0. Assume XTAL = 11.0592 MHz
Write an ALP to gets data from P1 and send to P2 continuously, while giving a copy of it to
the serial communication port to be transferred serially. Assume XTAL = 11.0592 MHz set
the baud rate at 9600.
Write a program that continuously gets 8 bit data from Port P0 and send it to port P1 while
simultaneously creating a square wave of 200 μsec period on port pin P2.1. Use timer 0 to
create the square wave. Assume that XTAL = 11.0592 MHz
Write a program to gets data from P1 and sends to P2 continuously while incoming data
from serial port is sent to P0. Assume XTAL = 11.0592 MHz set the baud rate at 9600.
Assume that INT1 pin is connected to a switch that is normally high, whenever it goes low, it
should turn ON LED. The LED is connected to the port pin P1.4 and is normally OFF. When it
is turned ON it should stay on for a fraction of second. as long as switch is pressed low, the
LED should stay ON.
Assume that pin P3.3 is connected to a pulse generator, write a program in which the falling
edge of the pulse will send a high to P1.4, which is connected to the LED. In other words, the
LED is turned ON and OFF at the same rate as the pulses is applied to the INT1 pin.
Write a program using interrupts to do the following:
(a) Receive data serially and send it to Port P0.
(b) Gets data from port P1 and transferred serially and give a copy to port P2.
(c) Make timer 0 to generate a square wave of 5 KHz frequency on P0.4
Assume XTAL = 12 MHz set baud rate 4800
Memory Interfacing with 8051 Microcontroller:
100.
Show that the design of an 8031 based system with 8K bytes of program ROM
and 8K bytes of data ROM.
101.
Design the interfacing system of 16 K × 8 data RAM with 8051 Microcontroller.
Use starting addresses 8000h.
102.
Design the interfacing of 8031 based system with 16 KB program space,
16 KB of data ROM starting at 0000h and 16 KB of NV – RAM starting at 8000h.
Show the design using 74LS138 for the address decoder.
103.
Design the interfacing system of 8051 Microcontroller with 256K × 8 data
NV – RAM. Also write an assembly language program to read the contents of
memory location from 20000h and store the contents in internal memory location
form 30h.
104.
Find the address range of the memory design for Y0, Y3 and Y6 of the
74LS 138 for the given diagrammed design shown in figure (1)
Created By: N. B. Bahadure, Associate Professor, E & TC Deptt. B. I. T. Durg
6
Fig (1)
Applications of 8051/AT89C51
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
Design an application to interface LED with the port pin P1.2 and write an
assembly language program to blink the LED.
Design an application to interface 7-segment LED with 8051 and write an
ALP to display number 8 on it.
Design an application to interface 2 Seven – segment LED with 8051 and
write an ALP to display 3 and 5 on it.
Design an application to interface 7-segment LED with 8051
Microcontroller and write an ALP to display 0 – 9 on it
Design an application to interface 2*16 LCD with 8051 and write an ALP
to display "BIT DURG" on it.
Design an application to interface stepper motor with 8051 and write an
ALP to rotate stepper motor clockwise continuously.
Design an application to interface stepper motor with 8051 and write an
ALP to rotate stepper motor anticlockwise continuously.
A switch is connected to pin P2.7. write a program to monitor the status
of switch and perform the following.
(a) If SW = 0
; the stepper motor moves clockwise
; the stepper motor moves anticlockwise
(b) If SW = 1
Design an application to interface ADC 0804 with 8051.
Interface ADC 0804 with 8051 Microcontroller. write an ALP to brings an
analog input into register A and then stored then in the internal memory location
from 30h onwards.
Interface ADC 0808/0809 with 8051 Microcontroller and write an ALP to
select channel 1 and stored the converted data by channel 1 into internal memory
location from 30h onwards.
Design an application to interface DAC 0808 with 8051 Microcontroller.
Write an ALP to generate a sine wave continuously on DAC. Use port P1 of 8051.
Interface DAC 0808 with 8051 µC. Write an ALP to generate a stair- step
ramp on port P1.
Interface DAC 0808 with 8051 µC. Write an ALP to generate reverse
sawtooth waveform using port P1.
Interface DAC 0808 with 8051 µC. Write an ALP to generate triangular
waveform at the DAC output. Generate 200 cycles. Use port P1.
Created By: N. B. Bahadure, Associate Professor, E & TC Deptt. B. I. T. Durg
7
120.
121.
122.
123.
124.
125.
Design an application to interface 8 * 8 matrix keyboards with 8051
Microcontroller.
Interface 4 * 4 matrix keyboards with 8051 Microcontroller. Write an ALP
to read the keypad and send the ASCII code of pressed key to the port P0.
P1.0 – P1.3 Connected to rows (output)
P2.0 – P2.3 Connected to columns (Input)
Design an application to interface 4 * 4 matrix keyboards with 8051
Microcontroller.
Design an application for digital voltmeter with 8051 Microcontroller.
Display digital voltage value on the LCD.
Design an application for frequency counter with 8051 Microcontroller
and display counter value on LCD.
Design an application to interface two 8051 Microcontroller, write a program to
transmit character byte serially from one microcontroller and receive serially by
other microcontroller. Also display received character byte on display device
connected with the port P1.
Dear students any queries on the above questions and also on the others related topics to the
Microcontroller are welcome. Please put up your queries on any of the topics of Microcontroller on
my email ID ([email protected] -- pls mention sub: BE (ET)/EE) or discuss with me directly as per
convenience.
Please remember the following for examination (if possible try this):
1. All Ur solution Theory or Programs must be in well manner and up to the point. Also
highlight important points.
2. If problem solved then please make a habit to outline Ur answers by drawing square or
underline it (Don’t use other ink pen other than blue or black).
3. If u attempt que -1 Part (a) and u wish to attempt then Part (b) or (c) of que -1 later but not
at the moment leave the space for it. But don’t solve other questions part and then again
remaining parts of que -1 its make lot of confusion for the checker so it must be ignore.
4. Finally all blank spaces are simply cross.
5. If possible avoids mistakes don’t rub it again and again make better visibility of your
attempt.
Created By: N. B. Bahadure, Associate Professor, E & TC Deptt. B. I. T. Durg
8