radha govind engineering college, …read.pudn.com/downloads159/ebook/714049/microcontroller/... ·...

25
RADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION COURSE BLOW – UP Microcontroller & Embedded Systems (TIC – 601) Name of Faculty: Anshul Gaur Internal: 50 Course: B.Tech (VI Sem) External: 100 Branch: EI Total lectures: 40 Unit Topic Description Lecture No. Ref. I Introduction To Microcontroller Introduction to Microcontroller and microprocessor Embedded versus external memory devices 8bit and 16 bit Microcontroller CISC & RISC processor Harvard & Von-Neumann architecture of Microcontroller 1 2 3 4 5 R2,R3 OPEN SLOT 6 II 8051 Microcontrollers Architectture of 8051 microcontroller Pin description of 8051 microcontroller 8051 addressing mode and instructions General idea of assembly language and programming tools Arithmetic instructions, logic instructions and programs I/O port programming Timer /Counter programming in 8051 8051 Serial Communication 8051 interrupts & programming timer interrupts and External hardware interupt 7 8 9 10 11 12,13 14,15 16,17 18,19 R1,R2 OPEN SLOT 20 III Advanced Microcontrollers Architecture of 8096/95 microcontroller and Pin description Architecture of 98CXX, 89C20XX Microcontroller and Pin description Architecture of PIC Microcontroller and Pin description Architecture of AVR Microcontroller and Pin description 21 22 23 24 25 26 27 28 R3 OPEN SLOT 29 IV Interfacing 8051 interfacing to LEDs, PUSH Button,Relay and Latch 8051 interfacing to the keyboard Interfacing a 7-segment display and LCD to 8051 30 31 32 33 34 R2

Upload: hathuy

Post on 03-May-2018

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

RADHA GOVIND ENGINEERING COLLEGE, MEERUTDEPARTMENT OF ELECTRONICS & COMMUNICATION

COURSE BLOW – UPMicrocontroller & Embedded Systems (TIC – 601)

Name of Faculty: Anshul Gaur Internal: 50 Course: B.Tech (VI Sem) External: 100 Branch: EI Total lectures: 40

Unit Topic Description Lecture

No.Ref.

I Introduction To Microcontroller

Introduction to Microcontroller and microprocessorEmbedded versus external memory devices 8bit and 16 bit MicrocontrollerCISC & RISC processorHarvard & Von-Neumann architecture of Microcontroller

1

2345

R2,R3

OPEN SLOT6

II 8051 Microcontrollers Architectture of 8051 microcontrollerPin description of 8051 microcontroller8051 addressing mode and instructionsGeneral idea of assembly language and programming toolsArithmetic instructions, logic instructions and programs I/O port programmingTimer /Counter programming in 80518051 Serial Communication8051 interrupts & programming timer interrupts and External hardware interupt

789

10

11

12,1314,1516,1718,19

R1,R2

OPEN SLOT 20

III Advanced Microcontrollers

Architecture of 8096/95 microcontroller and Pin descriptionArchitecture of 98CXX, 89C20XX Microcontroller and Pin descriptionArchitecture of PIC Microcontroller and Pin descriptionArchitecture of AVR Microcontroller and Pin description

2122232425262728

R3

OPEN SLOT 29

IV Interfacing 8051 interfacing to LEDs, PUSH Button,Relay and Latch 8051 interfacing to the keyboard Interfacing a 7-segment display and LCD to 8051Interfacing a ADC and DAC to the 8051

303132333435

R2

OPEN SLOT 36

V Applications of Microcontroller

Waves generation and Frequency CounterMeasurement applications8255 interfacing and a stepper motor Automation and controller applications

37383940

R1,R2

REFERENCES: R1: - Ajay V.Deshmukh, Microcontrollers;Theory and applications,TMH

edition 2005R2: - Muhammad Ali Mazidi, The 8051 Microcontroller and Embedded Systems published by Pearson EducationR3: - Advanced Microprocessors & microcontrollers by B.P.Singh and Renu Singh

Page 2: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

Radha Govind Engineering College, MeerutDepartment Of Electronics & Communication

Faculty: Anshul Gaur Subject:Microcontroller & Embedded System Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Assignment-1

Q1. What is the difference between Microcontroller and Microprocessor?

Q2. In a battery based embedded product, what is the most important factor in choosing Microcontroller?

Q3. Why would someone want to use an X86 as an embedded processor?

Q4. Define CISC and RISC processors.

Q5. Explain the Harvard & Von-Neumann architecture.

Page 3: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

Radha Govind Engineering College, MeerutDepartment Of Electronics & Communication

Faculty: Anshul Gaur Subject:Microcontroller & Embedded System Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Assignment-2

Q.1 a Explain difference between 8051 and 8052 microcontroller. b.What does the term “ third party “ support mean?

Q.2 Explain the pin description of 8051 with all parts.

Q3. Define 8051 Data types and Directives.

Q4. Describe the 8051 register banks and stack.

Q5. What are the advantages of SJMP and LJMP?

Page 4: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

Radha Govind Engineering College, MeerutDepartment Of Electronics & Communication

Faculty: Anshul Gaur Subject:Microcontroller & Embedded System Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Assignment-3

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.

Q3. Describe I/O and single bit addressability.

Q4. Explain the Timer mode register and Serial mode register.

Q5 Explain the Asynchronous serial communication and data framing.

Page 5: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

Radha Govind Engineering College, MeerutDepartment Of Electronics & Communication

Faculty: Anshul Gaur Subject:Microcontroller & Embedded System Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Assignment-4

Q1. What is difference between interrupt & polling in 8051?

Q2. Explain interrupt service routine in 8051.

Q3. Explain about the Interrupt enable register.

Q4. What is level-triggered interrupt and edge-triggered interrupt?

Q5. What is interrupt priority and its parameters in 8051?

Page 6: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

Radha Govind Engineering College, MeerutDepartment Of Electronics & Communication

Faculty: Anshul Gaur Subject:Microcontroller & Embedded System Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Assignment-5

Q1. Explain the features of 8096/95,89c20xx and PIC Microcontroller.

Q2. Explain the AVR Microcontroller’s block diagram.

Q3. Explain the pin description of LCD.

Q4. Explain about ADC and DAC interfacing.

Q5. What is the advantage of Microcontroller in real world application? Explain the frequency counter and automation applications.

Page 7: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

Radha Govind Engineering College, MeerutDepartment 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.

2. Which of the following cannot be a number in base-2? Give the reason.

(a) 11001 (b) 113 (c) 10001

3. What is the highest 8-bit number?

(a) In binary:

(b) In hex:

4. What is the highest 16-bit number?

(a) In binary:

(b) In hex:

5. Convert binary 100000 to decimal and hex.

(a) Decimal:

(b) Hex:

6. Convert hex number BAAD to binary and decimal.

(a) Binary:

(b) Decimal:

Page 8: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

Radha Govind Engineering College, MeerutDepartment Of Electronics & Communication

Faculty: Anshul Gaur Subject:Microcontroller & Embedded System Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Tutorial-2

1. Indicate the size (8- or 16-bit) of each of the following registers.

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.

92H, 23H, 66H, 87H, F5H

Page 9: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

Radha Govind Engineering College, MeerutDepartment Of Electronics & Communication

Faculty: Anshul Gaur Subject:Microcontroller & Embedded System Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Tutorial-3

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?

4. Explain the role of the OV flag in division and multiplication instructions.

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 150HMYDATA: DB 7FH, 3CH, 54H, 2AH; pick your own data Using a simulator, single-step the program and examine the 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.

Page 10: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

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, MeerutDepartment Of Electronics & Communication

Faculty: Anshul Gaur Subject:Microcontroller & Embedded System Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Tutorial-4

1. Explain the difference between the ADD and ADDC instructions.

2. Show how to perform the subtraction: 29H - 21H.

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.

5. (a) Show a simple program to add 2345H and 56F8H. (b)Show a simple program to subtract 2345H from 56F8H.

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:

MYDATA: DB 92,34,84,129,... ;pick your own data.

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:

Page 11: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

MYDATA: DB 92H,34H,84H,29H,... ;pick your own data.

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 98657654HDATA_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, MeerutDepartment 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.

(a) MOV A,#85HADD A,#92H

(b) MOV A,#15HADD A,#72H

(c) MOV A,#0F5HADD A,#52H

(d) MOV A,#0FFINC A

2. Upon reset, what is the value in the SP register?

3. Upon pushing data onto the stack, the SP register is _____________ (decremented, incremented).

Page 12: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

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.

6. The stack uses the same area of RAM as bank ______.

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.

8. Write and assemble a program to:(a) Set SP = 0D, (b) Put a different value in each of RAM locations 0D, 0C, 0B, 0A, 09, and 08,(c) POP each stack location into registers R0 - R4.

Radha Govind Engineering College, MeerutDepartment Of Electronics & Communication

Faculty: Anshul Gaur Subject:Microcontroller & Embedded System Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Tutorial-6

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.

Page 13: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

5. In mode 1, when is TFx set to high?

6. In mode 2, when is TFx set to high?

7. Write a program-using timer 0 to generate a 500 Hz square wave frequency on one of the pins of P1. Then examine the frequency using the oscilloscope. Modify the count value to make sure that the frequency is exactly 500 Hz. 8. Write a program-using timer 1 to generate a 1 kHz square wave frequency on one of the pins of P1. Then examine the frequency using the oscilloscope. Modify the count value to make sure that the frequency is exactly 1 kHz.

Radha Govind Engineering College, MeerutDepartment Of Electronics & Communication

Faculty: Anshul Gaur Subject:Microcontroller & Embedded System Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Tutorial-7

1. The 8051 TxD and RxD signals ________ (are, are not) TTL-compatible.

2. In this lab, what is the role of the MAX233 (MAX232) chip?

3. With XTAL=11.0592 MHz, what is the maximum baud rate for the 8051?

Page 14: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

4. Show how to achieve the maximum baud rate in Question 3.

5. What is the role of TI and RI?

6. True or false. The 8051 can transfer data in full-duplex.

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 & CommunicationFaculty: Anshul Gaur Subject:Microcontroller & Embedded System Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Tutorial-8

1. What is a step angle? Define steps per revolution.

Page 15: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

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.

Step angle ______________ Degree of movement per 4-step sequence ________

Steps per revolution _____ Number of rotor teeth ______________ 6. What is the purpose of generating the truth table for a given keyboard?

7. What is the purpose of grounding each row in keyboard interfacing? 8. What is the input to the microcontroller from column if no key is pressed?

Radha Govind Engineering College, MeerutDepartment Of Electronics & Communication

Faculty: Anshul Gaur Subject:Microcontroller & Embedded System

Page 16: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Tutorial-9

1. Name all of the interrupts in the 8051 and their vector table addresses.

2. In timer mode 1, indicate when TF0 causes the interrupt.

3. In timer mode 2, indicate when TF0 causes the interrupt.

4. On reset, INT0 (and INT1) are _________ (edge, level) triggered.

5. On reset, which interrupt has the highest priority?

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.

Page 17: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

Radha Govind Engineering College, MeerutDepartment Of Electronics & Communication

Faculty: Anshul Gaur Subject:Microcontroller & Embedded System Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Tutorial-101. Explain the difference between the following two instructions: MOVC A,@A+DPTR MOV A,@R0

2. Circle the invalid instructions. MOV A,@R1 MOV A,@R2

MOVC A,@R0+DPTR MOV @R3,A

3. Explain the difference between the following two instructions: MOV A,40H MOV A,#40H

4. Explain the difference between the following two instructions: MOV 40H,A MOV 40H,#0A

5. Give the RAM address for the following registers. A= B= R0= R2=

PSW= SP= DPL= DPH=

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",0Using 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. 8. Write a program to calculate y where y = x2 + 2x + 9. x is between 0 and 9 and the look-up table for x2 is located at the address (code space) of 200H. Register R0 has the x, and at the end of the program R2 should have y. Use the simulator to change the x value and single-step through the program, examining the registers as you go.

Page 18: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

Radha Govind Engineering College, MeerutDepartment Of Electronics & Communication

Faculty: Anshul Gaur Subject:Microcontroller & Embedded System Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Tutorial-11

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.

3. Which ports of the 8051 are bits addressable?

4. What does it mean for port to be "read-modify-write"?

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.

7. Explain the role of the C/T bit in the TMOD register.

8. How is the 8051 used as an event counter to count an external event?

Page 19: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

Radha Govind Engineering College, MeerutDepartment Of Electronics & Communication

Faculty: Anshul Gaur Subject:Microcontroller & Embedded System Course: B.Tech. (EI-VI Sem) Subject Code: TIC-601------------------------------------------------------------------------------------------------------------

Tutorial-12

1. Find the value in A, the accumulator, after the following code.

MOV A,#45HRR ARR ARR A

A = in hex

2. Find the value in A, the accumulator, after the following code.

MOV A,#45HRL ARL ARL A

A = in hex

3. In the absence of the "SWAP A" instruction, how would you perform the operation?

4. Can the SWAP instruction work on any register?

5. Find the value in A after the following code.

CLR AXRL A,#0FFH

A = in hex

6. Find the value in A after the following code.

CLR ACPL A

Page 20: RADHA GOVIND ENGINEERING COLLEGE, …read.pudn.com/downloads159/ebook/714049/microcontroller/... · Web viewRADHA GOVIND ENGINEERING COLLEGE, MEERUT DEPARTMENT OF ELECTRONICS & COMMUNICATION

XRL A,#0FFH

A = in hex7. Write a program to convert the following ASCII data to packed BCD.

ORG 120HMYDATA: 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 150HMYDATA: DB 42H,58H,64H,29H ;pick your own data.

Using a simulator, single-step the program and examine the 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 120HMYDATA: 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.