Radha Govind Engineering College, Meerut
Radha Govind Engineering College, Meerut
OPEN SLOT
6
II 8051 Microcontrollers Architectture of 8051 microcontroller 7
Pin description of 8051 microcontroller 8
8051 addressing mode and instructions 9
General idea of assembly language and 10
programming tools
Arithmetic instructions, logic instructions and 11
programs R1,R2
I/O port programming 12,13
Timer /Counter programming in 8051 14,15
8051 Serial Communication 16,17
8051 interrupts & programming timer interrupts 18,19
and External hardware interupt
OPEN SLOT 20
III Advanced Architecture of 8096/95 microcontroller and Pin 21
Microcontrollers description 22
Architecture of 98CXX, 89C20XX 23
Microcontroller and Pin description 24
Architecture of PIC Microcontroller and Pin 25 R3
description 26
Architecture of AVR Microcontroller and Pin 27
description 28
OPEN SLOT 29
OPEN SLOT 36
V Applications of Waves generation and Frequency Counter 37
Microcontroller Measurement applications 38 R1,R2
8255 interfacing and a stepper motor 39
Automation and controller applications 40
REFERENCES:
R1: - Ajay V.Deshmukh, Microcontrollers;Theory and applications,TMH
edition 2005
R2: - Muhammad Ali Mazidi, The 8051 Microcontroller and Embedded
Systems published by Pearson Education
R3: - Advanced Microprocessors & microcontrollers by B.P.Singh and
Renu Singh
Radha Govind Engineering College, Meerut
Department Of Electronics & Communication
Faculty: Anshul Gaur Subject:Microcontroller & Embedded
System
Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601
------------------------------------------------------------------------------------------------------------
Assignment-1
Q2. In a battery based embedded product, what is the most important factor in choosing
Microcontroller?
Q.1 A given 8051 chip has a speed of 16 MHz. What is the range of frequency that can
be applied to the Xtal1and Xtal2 pins?
Q2. In 8051 how many pins are designated as I/O pins? And what is the need of pull up
resistor.
Q4. Explain the Timer mode register and Serial mode register.
Q5. What is the advantage of Microcontroller in real world application? Explain the
frequency counter and automation applications.
Radha Govind Engineering College, Meerut
Department Of Electronics & Communication
Faculty: Anshul Gaur Subject:Microcontroller & Embedded
System
Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601
------------------------------------------------------------------------------------------------------------
Tutorial-1
1. Give the highest single digit for each of the number systems: decimal, binary, and hex.
(a) In binary:
(b) In hex:
(a) In binary:
(b) In hex:
(a) Decimal:
(b) Hex:
(a) Binary:
(b) Decimal:
Radha Govind Engineering College, Meerut
Department Of Electronics & Communication
Faculty: Anshul Gaur Subject:Microcontroller & Embedded
System
Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601
------------------------------------------------------------------------------------------------------------
Tutorial-2
PC = A= B=
R0= R1= R2= R7=
2. For Question 1, indicate the largest value (in decimal) that each register can contain.
PC = A= B=
R0= R1= R2= R7=
3. For Question 1, indicate the largest value (in hex) that each register can contain.
PC = A= B=
R0= R1= R2= R7=
4. Who generates each of the following files and what is the use of each.
.asm
.lst
.obj
.abs
.hex
5. Write and assemble a program to move value 99H to register A. Then from register A
move it to all registers R0 - R7. Use the simulator to single-step the program and examine
the registers.
6. Write and assemble a program to add all the single digits of your ID number and save
the result in R2. Pick 7 random numbers (all single digit) if you do not want to use your
ID number. Then use the simulator to single-step the program and examine the registers
7. Write and assemble a program to add the following data and then use the simulator to
examine the CY flag.
1. In the 8051, when dividing a byte by a byte what is the largest value for the
numerator?
What about the denominator? Give the value in both hex and decimal.
2. In the 8051, when dividing a byte by a byte what is the largest value for the quotient?
What about the remainder? Give the value in both hex and decimal.
3. In the 8051, when multiplying two number what is the largest value for each number?
5. In generating a square of numbers between 0 and 9 there are two methods: (a) using
the MUL instruction, or (b) using a look-up table. Which one is faster in the 8051?
6. Write a program to get a byte of hex data from P1, convert it to decimal, and then to
ASCII. For example, if P1 has FBH, which is equal to 251 in decimal, after conversion
we will have 32H, 35H, and 31H. Place the ASCII result in RAM locations starting at
40H. Using a simulator, single-step the program and examine the data.
7. Write a program to convert 4 bytes of hex data to ASCII and place the result in RAM
locations starting at 50H. The hex data is stored in ROM starting at 150H. The data is
stored as follows:
ORG 150H
MYDATA: DB 7FH, 3CH, 54H, 2AH; pick your own data
8. Write a program to find the average age of a group of children in a class. There are 12
children, ranging in age from 5 to 10 years old. Pick your own data. Notice that you must
first bring the data from ROM space into the CPU's RAM and then add them together.
Using a simulator, single-step the program and examine the data.
Radha Govind Engineering College, Meerut
Department Of Electronics & Communication
Faculty: Anshul Gaur Subject:Microcontroller & Embedded
System
Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601
------------------------------------------------------------------------------------------------------------
Tutorial-4
3 True or False. "DAA" must be used for adding BCD data only.
4. Can we use the "DAA" instruction to convert data such as 9CH into BCD without
first performing an ADD instruction? Explain your answer.
6. Write a program to add 10 bytes of data and store the result in registers R2 and R3.
The bytes are stored in the ROM space starting at 200H. The data would look as follows:
Notice that you must first bring the data from ROM space into the CPU's RAM, then add
them together. Use a simulator to single-step the program and examine the data.
7. Write a program to add 10 bytes of BCD data and store the result in R2 and R3. The
bytes are stored in ROM space starting at 300H. The data would look as follows:
Notice that you must first bring the data from ROM space into the CPU's RAM, then add
them together. Use a simulator to single-step the program and examine the data.
8. Write a program to add two multi-byte BCD numbers together and store the result in
RAM locations 40H - 44H. The two multi-byte items are stored in the ROM space
starting at 120H and 150H. See the following example data.
ORG 120H
DATA_1: DB 54H,76H,65H,98H ;number 98657654H
DATA_2 DB 93H,56H,77H,38H ;number 38775693H
Pick your own data for your program. Notice that you must first bring the data from
ROM space into the CPU's RAM and then add them together. Use a simulator to single-
step the program and examine the data.
Radha Govind Engineering College, Meerut
Department Of Electronics & Communication
Faculty: Anshul Gaur Subject:Microcontroller & Embedded
System
Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601
------------------------------------------------------------------------------------------------------------
Tutorial-5
1. Find the value of the CY flag after the execution of the following code.
3. Upon pushing data onto the stack, the SP register is _____________ (decremented,
incremented).
4. Upon popping data from the stack, the SP register is ___________ (decremented,
incremented).
5. Can you change the value of the SP register? If yes, explain why you would want
to do that.
7. Write and assemble a program to load values into each of registers R0 - R4 and then
push each of these registers onto the stack. Single-step the program, and examine the
stack and the SP register after the execution of each instruction.
1. What is the maximum frequency that can be generated using Mode 1 if the crystal
frequency is 11.0592 MHz? Show your calculation.
2. What is the maximum frequency that can be generated using Mode 2 if the crystal
frequency is 11.0592 MHz? Show your calculation.
3. What is the lowest frequency that can be generated using Mode 1 if the crystal
frequency is 11.0592 MHz? Show your calculation.
4. What is the lowest frequency that can be generated using Mode 1 if the crystal
frequency is 11.0592 MHz? Show your calculation.
1. The 8051 TxD and RxD signals ________ (are, are not) TTL-compatible.
3. With XTAL=11.0592 MHz, what is the maximum baud rate for the 8051?
7. For full duplex, what are the absolute minimum signals needed between the 8051 and
the
PC? Give their names.
Radha Govind Engineering College, Meerut
Department Of Electronics & Communication
Faculty: Anshul Gaur Subject:Microcontroller & Embedded
System
Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601
------------------------------------------------------------------------------------------------------------
Tutorial-8
2. If a given stepper motor has a step angle of 5 degrees, find the number of steps per
revolution.
3. Give the four sequences for counter clockwise if it starts with 10011001 (binary).
4. Using the "RL A" instruction, show the four-step sequences if the initial step is 0011
(binary).
5. Give the number of times the four-step sequence must be applied to a stepper motor to
make a 100-degree move if the motor has a 5-degree step angle. Also fill in the
characteristics for your motor below.
6. What is the purpose of generating the truth table for a given keyboard?
1. Name all of the interrupts in the 8051 and their vector table addresses.
6. True or False. There is only a single interrupt for the serial data transfer.
7. Write an 8051 program to get data from one port and send it to another port
continuously while an interrupt will do the following: One of the timers will toggle the
PX.Y bit every 100 microseconds.
8. Write an 8051 program to get data from a single bit of P1.2 and send it to P1.7
continuously while an interrupt will do the following: A serial interrupt service routine
will receive data from a PC and display it on one of the ports. (Either connect LEDs to
this port to examine the data coming in or display the received data on an LCD).
9 a/ Write an 8051 program to get data from one port and send it to another port
continuously while an interrupt can do the following: Connect the INT0 (or INT1) pin to
a normally high debounce SW and any time the switch is pressed, a single LED is turned
on.
b/ Write an 8051 program to get data from one port and send it to another port
continuously while an interrupt will do the following: A square wave is connected to the
INT0 (pin 3.2) and any time a H-to-L pulse comes in a single LED is turned on. The rate
of "On" and "Off" is the rate of the square wave. In this activity you can also use INT1.
Radha Govind Engineering College, Meerut
Department Of Electronics & Communication
Faculty: Anshul Gaur Subject:Microcontroller & Embedded
System
Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601
------------------------------------------------------------------------------------------------------------
Tutorial-10
1. Explain the difference between the following two instructions:
MOVC A,@A+DPTR
MOV A,@R0
6. Write a program to transfer a string of data from code space starting at address 200H to
RAM locations inside the CPU starting at 40H. The data representing your last name and
first name is as shown below:
MYDATA: DB "Alex Young",0
Using the simulator, single-step through the program and examine the data transfer and
registers.
7. Add the following subroutine to the program in Activity 1, single-step through the
subroutine and examine the RAM locations.
After data has been transferred from ROM space into RAM, the subroutine should copy
the data from RAM locations starting at 40H to RAM locations starting at 60H.
1. Upon reset, all the ports of the 8051 are configured as ______ (input, output).
2. To make all the bits of a port an input port we must write ____ hex to it.
5. Write a program to monitor P2.4 continuously. When it becomes low, it sends 55H to
P1.
6. Write and assemble a program to toggle all the bits of P0, P1, and P2 continuously by
sending 55H and AAH to these ports. Put a time delay between the "on" and "off" states.
Then using the simulator, single-step through the program and examine the ports. Do not
single-step through the time delay call.
MOV A,#45H
RR A
RR A
RR A
A= in hex
MOV A,#45H
RL A
RL A
RL A
A= in hex
3. In the absence of the "SWAP A" instruction, how would you perform the operation?
CLR A
XRL A,#0FFH
A= in hex
CLR A
CPL A
XRL A,#0FFH
A= in hex
7. Write a program to convert the following ASCII data to packed BCD.
ORG 120H
MYDATA: DB '1998'
Place the packed BCD result in RAM locations starting at 40H. Using a simulator,
single-step the program and examine the data.
8. Write a program to convert the following BCD data to ASCII. Place the result in RAM
locations starting at 50H. The BCD data is stored in ROM starting at 150H. The data is
stored as follows:
ORG 150H
MYDATA: DB 42H,58H,64H,29H ;pick your own data.
9. Write a program to find the average of the following numbers. Notice that they are
ASCII and must be converted to BCD before the average is calculated.
ORG 120H
MYDATA: DB '8','9','4','7','6','2','5' ;pick your own data
Notice that you must first bring the data from ROM space into the CPU's RAM, then add
them together. Using a simulator, single-step the program and examine the data.