22
Jaypee Institute of Information Technology University, NOIDA Course Code: 10B11CI401 Course Name: Microprocessors and Controllers Following instruction has to be followed in the tutorial class: 1. Maintain separate tutorial note book of at least 200 pages. 2. All students are required to get their own scientific calculators. 3. Tutorials has to be submitted on every Thursday ,if any holiday on the day very next day students should submit their tutorials. 4. If tutorials are not submitted on the above mentioned day the tutorial marks will be made to Zero automatically. 5. Any absentee’s will also get zero for that tutorials. 6. 3 Surprise quiz will be conducted in tutorial class each before T1, T2 and T3.

MPC Tutorial Odd Sem 2012

Embed Size (px)

Citation preview

Page 1: MPC Tutorial Odd Sem 2012

Jaypee Institute of Information Technology University, NOIDA

Course Code: 10B11CI401Course Name: Microprocessors and Controllers

Following instruction has to be followed in the tutorial class:

1. Maintain separate tutorial note book of at least 200 pages.

2. All students are required to get their own scientific calculators.

3. Tutorials has to be submitted on every Thursday ,if any holiday on

the day very next day students should submit their tutorials.

4. If tutorials are not submitted on the above mentioned day the tutorial

marks will be made to Zero automatically.

5. Any absentee’s will also get zero for that tutorials.

6. 3 Surprise quiz will be conducted in tutorial class each before T1,

T2 and T3.

Tutorial-1

Number System and Computer Data Format

1) Convert the following decimal numbers in to octal, binary and hexadecimal?

a. 57

b. 29.3

c. 2000.45

d. 547.72

e. 121.628

2) Convert the Hexadecimal that you have got in previous solution into its BCD

3) Convert the following BCD into hexadecimal, 1’s complement and 2’s complement?

a. 0101 1011

b. 1110 1010 0110

c. 1111 1001 0010 1011

d. 0111 0101 1111

e. 0101 1001 1000

4) Convert the following word into ASCII-coded character strings:

a. JAYPEE b. Institute

Page 2: MPC Tutorial Odd Sem 2012

c. Technology d. University

5) Convert the following into 8-bit signed binary numbers:

a. -53

b. +37

c. -99

d. +23

6) What are the ranges of 8-bit signed binary numbers and signed binary words?

Tutorial-2

8051 Assembly Programming

1) Using assemble language instruction format , show all the possible Source and Destination

for the following instruction with appropriate comment

a. MOV

b. ADD

c. DJNZ

d. JZ

e. ACALL

f. DA

2) Describe the following assembler directive with an examples

a. ORG

b. DB

c. EQU

d. END

3) For the instruction ADD A, B chooses appropriate values of A and B such that after

execution of this instruction will set the following flag bits of PSW independently.

a. CY

b. P

c. OV

d. AC

4) Write down the instruction to add two number R0 and R5 such that R0 belongs to Bank-0

and R5 belongs to Bank-3.

5) What is the initialized value of the stack pointer after 8051 is powered up? Above what

value the stack pointer has to be initialized to avoid the Bank memory usage.

6) Write program which complements the value of P1 continuously.

7) Explain the addressing modes required to access the RAM and ROM locations

8) Explains the cause of the errors in the following instructions

a. MOV R0,R4

b. CPL P1

c. PUSH A

d. MOV @R2,#4

e. MOV 2,3

Page 3: MPC Tutorial Odd Sem 2012

9) In Visitor Counter system, Infrared sensors are used, which has transmitter and receiver

across an entrance which is typically linked to a small LCD display unit at the side of the

doorway or can also be linked to a PC or send data via wireless links and GPRS. Such a

beam counts a 'tick' when the beam is broken, when ever visitor enters the hall. Suppose

port P1.2 of 8051 is interface to sensor and each ‘tick’ value is ‘0’, write an assembly

language program to count the number of visitor in the hall and output the count on the

Port-0.

Tutorial-3

8051 Assembly Programming

1) Write an 8051 assemble to read the two 16-bit numbers from the Port P0 and P1 to read

first 16-bit number and Port P2 and P3 to read second 16-bit number. Perform addition on

this and store the result at RAM location 30H and 40H.

2) Write an 8051 assemble to read the input from the Port P1 and check weather the input is

00H, FFH or some thing else and then send appropriate message at RAM location 30H as “

ALL ZERO’S ” if input is 00H, message “ ALL ONE’S ” if input is FFH or message “

WRONG INPUT” if the input is other then 00 or FFH.

3) Write an 8051 program to read 2 digit number 0-FH using Port-1 and the check the number

are in sequence or not for example 1-2, 3-4, 7-8, EFH soon and set the bit memory location

21.H to 1 if the number is in sequence else 0.

4) Write an 8051 program to read the string length of 10 from ROM location 200H and

convert the text lower to upper and upper to lower and store the converted string into RAM

location 30H.

5) In Home Security system, IR sensors are used, which has transmitter and receiver at the

secured locations of the home. When there is an interruption in the IR Rays then it should

generate an alarm. Suppose port P2.3 of 8051 is interface to sensor at the locker, write an

Input: Number 1: P0 P1Number 2: P2 P3Output 30H 40H

Page 4: MPC Tutorial Odd Sem 2012

assembly language program to enable the alarm, that’s connected to port P3.3, when the bit

P2.3 is cleared (indicating that there is interruption).

6) Design a Temperature control system in which the port 1 gets the temperature as input and

controls the Air Conditioner through Port 2.3. If the temperature value at port 0 exceeds 30

degree Celsius, it should reset the Port 2.3 or else should enable it.

7) Design an Automatic traffic signal at a T-Point, such that each sensor is kept at each road

to count the number of vehicles on those roads and in turn these sensors are connected to

port 1, port 2, and port 3 respectively. The Port 0.2 is used for signaling the road 1 (having

sensor connected to port 1), Port 0.3 is used for signaling the road 2 and port 0.4 is used for

signaling the road 3. Write an assembly language program to read the ports 1-3 and then

enable the corresponding road’s signal at Port 0 only if its vehicle count has maximum

vehicles.

Tutorial – 4Design Based Problems

1. (a) In a bank there are 16 counters. Under each counter ,near the right lag a switch is placed. If

there is attempted robbery at the counter then the employee must press the switch. Pressing the

switch will initiate the following actions:

a. Outside door of the bank is closed automatically.

b. In Central Security Room , alarm is displayed identifying the counter

c. An automatic call is placed to 100 for informing the police,

The above security system is controlled by 8051 microcontroller. Port P0 and P1 lines are

connected to switches under the counters. Writing 0FFH to P2 will close the outside door

automatically. Making bit locations 20H to 27H as 1 places automatic call to 100 with message “

Robbery – Bank Name – Branch Name”.

Port 3 lines are connected to security control room. Bit 0 to Bit 4 identify the counter code 1 to 16.

Bit 7 and Bit 6 if 1 annunciate the alarm.

Page 5: MPC Tutorial Odd Sem 2012

Develop a 8051 program for the above system. Program should have comments to illustrate the

logic.

(b) To avoid spurious action and wrong alarms. Switch closure must be checked 5 times after a gap

of 1 second each. Consider that 8051 has 12 oscillator clock machine cycle with clock frequency

as 20 MHz. Rewrite the above program to incorporate the above modification.

2. Simulate the traffic light operation on a road cross section using ports of 8051 (clock frequency

= 20 MHz., 12 clock machine cycle).Develop 8051 program for traffic operation. Consider that

making port bit =1 will glow the light connected to port line. Traffic in any direction is allowed

only for 1 minute. Lights available for each direction are RED, GREEN FORWARD and GREEN

RIGHT.

(a) Incorporate AMBER light as well as lights for pedestrian traffic in the above design and

program. AMBER light must blink 3 times before RED light.

Tutorial-5

8051 Architecture

1. Explain the 128 bytes RAM organization of 8051 with its use.

2. Explain I/O port pins and their function of 8051.

3. List all the Special Function register with their Physical Address and its use.

4. What is advantage of Harvard Architecture in 8051 which used the same address in

different memory location for Data and Code?

5. For the give crystal frequency for three different 8051-based systems, find the period of the

machine cycle in each case.

• 11.0592 MHz

• 16 MHz

• 20 MHz

Page 6: MPC Tutorial Odd Sem 2012

6. For an 8051 system of 11.0592Mhz, find how long it takes to execute each of the following

instructions

7. Mention dual functionality of Input output port pins of 8051. What are the advantages of

dual functionality?

8. What is the need of the Bit addressable memory in 8051? What are the instructions used to

manipulate it.

Tutorial-6

8086 Architecture

1. What is the difference between the physical and the logical address?

2. What are the advantages of segmented memory?

3. What are the registers associated with each of the Bus Interface Unit and Execution Unit

and Explain why their association with it.

4. Show the ending addresses of each segment located by the following segment register

values.

a) 1234H

b) 2300H

c) AB00H

5. What would be the offset required to map to physical address location 002C316 if the

contents of the corresponding segment register are 002A16?

6. Determine the offset register content for the following

Instruction Machine Cycles Time to Execute

MOV R3,#55 1

DEC R3 1

DJNZ R2,TARGET 2

LJMP 2

SJMP 2

NOP 1

MUL AB 4

Page 7: MPC Tutorial Odd Sem 2012

Segment Register Memory location Offset Register

DS = 1000h 12000h DI =

DS = 2000h 21002h SI =

DS = A000h A1000h BX =

CS = 3456h 3F12Dh IP =

SS = 2300h 26200h BP =

SS = 2900h 2CA00h SP =

7. Architecture based exercises

a. If Physical branch address is 5A230 when (CS) =5230, what will it be if the (CS)

are changed to 78FD?

b. Given that the EA of datum is 2359 and the (DS) = 490B, what is the physical

address of the datum?

c. Given the sum and the flag setting for AF,SF,ZF,CF,OF and PF after hexadecimally

adding 62A0 to each of the following :

i. 1234

ii. 4321

iii. CFA0

iv. 9D60

8. What is the purpose of the segment register in protected mode memory addressing?

9. For an 80286 descriptor that contains a base address of A00000H and a limit of 1000H,

what starting and ending locations are addressed by this descriptor?

10. For a Pentium descriptor that contains a base address of 00280000H, a limit of 00010H,

and G = 1, what starting and ending locations are addressed by this descriptor?

11. If the DS register contains 0020H, in a protected mode system, which global descriptor

table entry is accessed?

Page 8: MPC Tutorial Odd Sem 2012

Tutorial-7

8086 Addressing Mode

1. What are the common addressing modes used by 8051 and 8086?

2. What are main types of 8086 addressing mode? Why 8086 has more addressing when

compared to 8051.

3. What will the content of Destination after execution of each instruction? Assume DS =

1000H , BX =0300H, SI = 0200H, ARRAY =1000H

MOV AX,BX

MOV CH,3AH

MOV [1234],AX

MOV [BX],CL

MOV [BX+SI],BP

MOV CL,[BX+4]

MOV ARRAY[BX+SI],DX

MOV ARRAY[BX+SI+100],DX

4. In the above question mention the addressing mode for each instruction.

5. What is the difference between Intrasegment and Intersegment JMP?

6. What is displacement range for the Short, Near and Far Jump? And where do you see the

applications of these jump types.

7. With an example explain double indirect Jump addressing mode?

8. What is the purpose of the .MODEL TINY/SMALL/COMPACT/MEDIUM/LARGE

statement?

9. Explain, what is wrong in the following 8086 instructions when execute with MASM

assembler.

a. MOV BL,CX

b. MOV DS,SS

c. MOV [BX],[DI]

d. MOV AX,FFH

e. MOV AX,[2000H]

f. MOV DS,2000H

Page 9: MPC Tutorial Odd Sem 2012

10. Choose an instruction that requires BYTE PTR, WORD PTR and DWORD PTR.

11. How many bytes are stored on the stack by the PUSH instruction?

12. Explain how the PUSH [DI] instruction functions.

13. What registers are placed on the stack by the PUSHA instruction? In what order are they

placed?

14. Explain, why 8086 has downward growing stack? Mention use of BP, SP and SS register to

access stack memory.

15. Write an 8086 assembly program to simulate all the addressing mode of 8086.

16. What are the segment memories a programmer can access and modify its address?

17. Write an 8086 assembly program to store data 11H at location 2000H:100H

18. Modify the above program to store 1122H

Tutorial-8

Timer and Counter of 8051

1. What are the various registers shared by timer and counter. If you want to use timer register

as a counter, what are the changes to be done for TMOD register.

2. Write an 8051 assembly program to generate a square wave of frequency 33.33 KHz.

3. Assumes that XTAL=11.0592MHz. What values do we need to load into the timer’s

register if we want to have a time delay of 5ms? Show the program for Timer -0 to create a

pulse width of 5ms on P2.3

4. Generate a square wave with 66% duty cycle. Assuming XTAL frequency =11.0592MHz.

5. Assumes that XTAL=11.0592MHz, and we are generating a square wave on pin P1.2, find

the highest square wave frequency that we can generate using mode 1.

6. Program timer1 to be an event counter. Use mode2 and display the decimal count on P2, P1

and P0 continuously. Set the initial count to 99.

7. Write an 8051 assembly program to count the number of vehicles (Only cars) passing

through a road using two IR sensors. The distance between the front and rear wheel is used

to categorize it as car, which is assumed to 2 meters in distance approximately. Assume

that the speed of the car on this road is 10 kmph, the IR sensor-1 is connected to P1.1 and

IR sensor-2 is connected to P1.2. Monitor these pins P1.1 and P1.2 to identify a car and

count it. Also, Store the count of cars in that road at memory location 300H.

Page 10: MPC Tutorial Odd Sem 2012

8. Write an assembly program for a microwave oven in which the temperature has to be

maintained for specific time period based on the dish being prepared. The heating device in

the oven is controlled through P2.2. When P2.2 is enabled, the heating device is switched

on or else, it’ll be switched off. Once the dish is ready, print a message “ENJOY THE

MEAL” in memory location 300H. Assume the time period for various dishes of your own.

(Note: Specify all the assumptions you are going to make).

Tutorial-9

Serial communication of 8051

1. In a given situation we can not accept reception of any serial data. How do you block such

a reception with single instruction?

2. How do you calculate the baud rate for given crystal frequency and how do you double it.

3. “SERIAL OUTPUT WITH TIME DELAY” string has been defined at ROM location

300H. Now write 8051 program to serial output the above string with baud rate of 9600

and time delay of 200ms between each character output.

.

4. Write an 8051 serial communication program to read two strings and display their

concatenation. Use 9600 baud rate and 8 bit data and 1 stop bit mode.

5. Write a 8051 program that transmits serially “hello word” after every 10 seconds using

baud rate 2400 and frequency 11.0592 MHz..

6. Write a program for a vehicle speed monitoring system in which a message “OVER

SPEED” has to be sent when the speed of the vehicle is more than 60 kmph through the

UART. Assume the speed is inputted through port – 1.

7. Write a 8051 serial communication program to read the message “Jaypee Institute of

Information Technology” and output the message in reverse as “ygolonhceT noitamrofnI fo

etutitsnI eepyaJ”. Use 4800 baud rate and 8 bit data, 1 stop bit.

Page 11: MPC Tutorial Odd Sem 2012

Tutorial – 10

Design Based Problem (8051 Timer & Serial I/O)

Tutorial-11

8086 Programming

1. Give the difference between MUL and IMUL.

2. Write 8086 Assemble Language Program to add two numbers 1234H and 0F567H and

store the 32- bit result at data segment location 0000:0000.

3. Write 8086 Assemble Language Program to count the number of 1’s in the content of AX

Reg.

4. Write 8086 Assemble Language Program to read two digit numbers from key board and

store the result at the Data segment location 0000:100.

5. Write 8086 Assemble Language Program to display the message “8086 Programming”.

6. List down all the string transfer instruction with two examples.

7. Write 8086 Assemble Language Program to print the following pattern at mid of the

screen,

Tutorial-12

8086 Programming

1. Write 8086 Assemble Language Program to display system time.

************* * ** **************

Page 12: MPC Tutorial Odd Sem 2012

2. Write 8086 Assemble Language Program to display system date.

3. Execute the sample program of modular programming from Lecture slides

4. Write 8086 Modular Program to read 2 digit numbers between 00 to FFh using module-1, then

check the number is odd or even using module-2, and main program module-3 to read the

number using module-1, check odd or even using module-2 and print appropriate message

accordingly.

5. Convert the above program to .LIB

6. What is the difference between the Procedure and Macro?

7. Execute the sample program of MACRO from Lecture slides.

8. How do you define LABEL in the Macro?

Tutorial-13

8086 Hardware Specification

1. What is the difference between the maximum and minimum modes?

2. What is the purpose of status bits S3 and S4?

3. When DT/R is a logic 1, what condition does it indicate about the operation of the 80861

8088?

4. By what factor does the 8284A clock generator divide the crystal oscillator's output

frequency?

5. The PCLK output of the 8284A is ----------------MHz if the crystal oscillator is operating at

14 MHz.

6. What is the purpose of the demultiplexed BHE signal on the 8086 microprocessor?

7. Briefly describe the purpose of each T state listed:

a. T1

b. T2

c. T3

d. T4

8. How much time is allowed for memory access when the 8086/8088 microprocessors are

operated with 5 MHz clock?

Page 13: MPC Tutorial Odd Sem 2012

9. What main function is provided by the 8288 bus controller when used with 8086/8088

maximum mode operation?

10. Why are buffers often required in an 8086/8088-based system?

11. Give the detailed timing diagram of 8086 memory READ and WRITE operation. Show the

access time required to perform read or write operation.

12. What happens when READY is set to 1?

13. Draw and explain the basic block diagram of 8086 including support chips in minimum

mode configuration.

14. Interface 2KB, and 4KB and 8KB memory chips at Low and High bank thus creating

memory space of 32 KB. Draw detailed interfacing diagram and explain decoding

strategy.

Tutorial-14

Memory Interface of 8- bit /16-bit microprocessor and PPI Devices

1. What are the differences between SRAM and DRAM?

2. Design circuit that uses eight 27256 EPROMs for 32Kx8 section of memory in an 8088

microprocessor based system.

3. In the above design show the address range generated.

4. Design circuit that uses eight 2764 EPROMs for 8Kx8 section of memory in an 8086

microprocessor based system using separate decoders.

5. What is the need of handshaking in input/output operation?

6. Define 82C55 signals required for Mode 1 strobed input and strobed output.

7. Design 16 bit memory interface of 8086 with 64Kx8 memory device. Show the address

range generated.

Tutorial-15

Page 14: MPC Tutorial Odd Sem 2012

8254 Timer/Counter , 16550 UART Programming

1. 8254 Programmable Interval Timer (PIT) has three outputs OUT 0, OUT 1 and OUT 2.

Explain how this output is used by Microprocessor.

2. Set the content of control word of 8254 to program 100 KHz square wave in OUT 0 and 200

KHz continuously pulse in OUT1 given input clock is 8MHz; G input is pulled high and

control register at 706H.

3. Give the differences and similarities between 8051 and 8086 UART serial communication.

4. Explain with the neat diagram, the control signals which are exchanged between Data Terminal

Equipment (DTE) and Data Carrier Equipment (DTE).

5. Program the 16550 for operation using six data bits, even parity, one stop bit, and a baud rate

of 19200 using 18.432MHz clock.

6. Which are the types of error that a 16550 can detect while serially communicating between two

microcomputers?

Tutorial-16

8051 Interrupts and 8259A Interrupt Controller

1. Write a program that continuously get 8-bit data from P0 and sends it to P1 while

simultaneously creating a square wave of 200 μs period on pin P2.1. Use timer 0 to create the

square wave. Assume that XTAL = 11.0592 MHz.

2. Rewrite above program to create a square wave that has a high portion of 1085 us and a low

portion of 15 us. Assume XTAL=11.0592MHz. Use timer 1.

3. How do you change the priority of 8051 interrupts?

4. Explain with example the difference between software and hardware interrupts?

5. Explain how short comes of Daisy chain interrupts are overcome by 8259A?

6. Design Circuit where a master 8259A is connected with two 8259A salves?

7. Explain how the interrupts of 16550 communication controller are handled by 8259A?

Page 15: MPC Tutorial Odd Sem 2012

Tutorial-17

DMA controller

1. Microprocessor has a job where it has to read 1Mb of data from I/O devices and transfer it

to memory. Assuming this operation may take 1 hour in worst case, what changes need to

be made to increase the transfer rate and to improve the processor performance.