Date post: | 23-Nov-2015 |
Category: |
Documents |
Upload: | parul-soni |
View: | 59 times |
Download: | 10 times |
EC0321 PROCESSOR LAB
EC0321 PROCESSOR LAB
LABORATORY MANUALSEMESTER V
DEAPRTMENT OF
ELECTRONICS AND COMMUNICATION ENGINEERING
SRM UNIVERISTY
(Under SECTION 3 of the UGC Act, 1956)
S.R.M. NAGAR, KATTANKULATHUR 603203.
Department of Electronics and Communication EngineeringDepartment of Electronics and Communication EngineeringEC0321Processor Lab
Laboratory ManualJune 2014Mrs. A Ruhan Bevi. and course committee
LTPC
EC0321PROCESSOR LAB0032
Prerequisite : nil
PURPOSE :
To make the students understand the basic programming of Microprocessor, Micro controller and Nuvoton processor. Also, to introduce them to Microcontrollers and few interfacing circuits.
INSTRUCTIONAL OBJECTIVES
To understand and gain knowledge about
1. Microprocessor (8086)
2. Microcontroller (8051)
3. Interfacing circuits
4. Nuvoton ProcessorLIST OF EXPERIMENTSPart NoExperiment No.Experiment Name
I
8086 Programming0116 bit Addition , Subtraction, Multiplication and Division
02Largest and Smallest number
03Ascending and Descending numbers
04Sum of Series
II
8086 Interfacing05 Programmable peripheral Interface
06Stepper Motor Interface
07Programmable Timer Interface
08A/D and D/A Converters
III
8051 Programming9Addition , Subtraction, Multiplication and Division
10Ones and twos complement
11Word Disassembly
12Decimal to Hexa decimal Conversion
IV
8051 interfacing138279 interface
148253 timer interface
15Stepper motor interface
16DAC interface
V
Nuvoton programming17Seven segment display from 0000 to 9999
18Seven segment display from ADC input
EC0321 Processor Lab
Course designed byDepartment of Electronics & Communication Engineering
1ProgramoutcomeabcdefghiJk
xxxxx
2CategoryGeneral(G)Basic Sciences(B)Engineering Sciences andTechnical Arts(E)Professional Subjects(P)
X
3Broad area (for Pcategory)CommunicationSignal ProcessingElectronicsVLSIEmbedded
X
4Staff responsible for preparing the syllabusMr. A.V.M Manikandan
Mr. Selvakumar
5Date of preparationMay 2014
S.R.M University
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
Sub Code: EC0321
Semester : V
Sub Title: Processor Lab
Course Time: JulDec14Pre-requisite : NIL
Co-requisite : EC0309 Microprocessors & MicrocontrollersProgram Outcome
b. Graduates will demonstrate the ability to identify, formulate and solve engineering problems
Experiment 1 to Experiment no. 18 (Please refer Expt. list)c. Graduate will demonstrate the ability to design and conduct experiments, analyze and interpret data
Experiment 1 to Experiment no. 18 (Please refer Expt. list)d. Graduate will demonstrate the ability to design a system, component or process as per needs and specification
Experiment 5: To interface 8255 Programmable Peripheral Interface with 8086 microprocessor and to test mode 0 operation
Experiment 6: To interface a stepper motor with a 8086 kit and to make it run a) clockwise b) anti clockwise
Experiment 7: To interface a programmable timer with 8086
Experiment 8: To interface a A/D Converter with 8086 and to measure the analog voltage and display digital equivalent of it
To interface a D/A Converters with 8086 and to generate square and triangular waveforms
Experiment 13: To interface Keyboard /Display to 8051 micro controller and to read key and display data in leds.Experiment 14: To interface 8253 programmable timer with 8051 controller and to test the mode 0 operation.
Experiment 15: To interface a stepper motor with a 8051 kit and to make it run a) clockwise b) anti clockwise
Experiment 16: To interface a D/A Converters with 8051 and to generate square and triangular waveformsf. Graduate will demonstrate the skills to use modern engineering tools, softwares and equipment to analyze problemsExperiment 1: Using 8086 emulator add, subtract, multiply and divide two 16 bit numbers stored in the memory and save the results of the operation in the memory.
Experiment 2: To find the largest and the smallest of the given array of numbers stored in memory using 8086.
Experiment 3: To sort the given array of numbers stored in memory location into ascending and descending order using 8086.
Experiment 4: To find the sum of a series of numbers using 8086.
Experiment 17: Perform seven segment display from 0000 to 9999 in Keil IDEExperiment 18: Perform seven segment display fetching data from the potentiometer using Keil IDEk. Graduate will show the ability to participate and try to succeed in competitive examinationsExperiment 1 to Experiment no. 18 (Please refer Experiment list)S.R.M University
Faculty of Engineering and Technology
Department of Electronics and Communication EngineeringSub Code : EC0321
Semester : V
Sub Title : Processor Lab
Course Time : JulDec14Pre_requisite : NIL
Co_requisite : EC0309 Microprocessors & Microcontrollers Program Educational Objectives Vs Program OutcomeProgram OutcomesProgram Instructional Objectives
1. To prepare students to compete for a successful career in their chosen profession through global education standards.2. To enable the students to aptly to apply their acquired knowledge in basic sciences and mathematics in solving engineering problems.3. To produce skill full graduates to analyze, design and develop a system/component/process for the required needs under the realistic constraints.4.To train the students to approach ethically any multidisciplinary engineering challenges with economic, environmental and social contexts
5. To create an awareness among students about the need for life long learning to succeed in their professional career.
b. Graduates will demonstrate the ability to identify
,formulate and solve engineering problems dataxxx
c. Graduate will demonstrate the ability to design and conduct experiments, analyze and interpret dataxxx
d. Graduate will demonstrate the ability to design a system, component or process as per needs and specificationsxxxx
f. Graduates will demonstrate the skills to use modern engineering tools, software, equipment to analyse problemsxxx
k. Graduate will show the ability to participate and try to succeed in competitive examinationxxx
S.R.M University
Faculty of Engineering and Technology
Department of Electronics and Communication EngineeringSub Code : EC0321
Semester : V
Sub Title : Processor Lab
Course Time : JulDec11Pre_requisite : NIL
Co_requisite : EC0309 Microprocessors & MicrocontrollersInstructional Objective and Program OutcomeS.NoInstructional ObjectiveProgram Outcome Experiment Details
1To understand and gain knowledge about Microprocessor (8086)
b. Graduates will demonstrate the ability to identify
,formulate and solve engineering problems dataEx.No.1: Using 8086 trainer kit, add, subtract, multiply and divide two 16 bit numbers stored in the memory and save the results of the operation in the memory.
c. Graduate will demonstrate the ability to design and conduct experiments, analyze and interpret data
d. Graduate will demonstrate the ability to design a system, component or process as per needs and specificationEx.No. 2 : To find the largest and the smallest of the given array of numbers stored in memory using 8086.
f. Graduate will demonstrate the skills to use modern engineering tools, softwares and equipment to analyze problemsEx.No.3 : To sort the given array of numbers stored in memory location into ascending and descending order using 8086
k. Graduate will show the ability to participate and try to succeed in competitive examinationsEx.No.4: To find the sum of a series of numbers using 8086.
2To understand and gain knowledge about Microcontroller (8051)b.Graduates will demonstrate the ability to identify
,formulate and solve engineering problems dataEx.No.9: To perform Addition , Subtraction, Multiplication and Division of two 8 bit,16 bit numbers using 8051 trainer kit
c. Graduate will demonstrate the ability to design and conduct experiments, analyze and interpret dataEx.No.10: To perform ones and twos complement of a given number using 8051
d. Graduate will demonstrate the ability to design a system, component or process as per needs and specificationEx.No.11: To perform word disassembly using 8051
k. Graduate will show the ability to participate and try to succeed in competitive examinationsEx.No.12: Convert the given decimal number to Hexadecimal using 8051
3To understand and gain knowledge about interfacing circuitsb.Graduates will demonstrate the ability to identify
,formulate and solve engineering problems dataEx.No.6& 15:To interface a stepper motor with a 8086/8051 kit and to make it run a) clockwise b) anti clockwise
c. Graduate will demonstrate the ability to design and conduct experiments, analyze and interpret dataEx.No.7 &14 :To interface a programmable timer with 8086/8051
d. Graduate will demonstrate the ability to design a system, component or process as per needs and specificationEx.No.8 & 16:To interface a A/D Converter with 8086 /8051and to measure the analog voltage and display digital equivalent of it. To interface a D/A Converters with 8086 and to generate square and triangular waveforms
k. Graduate will show the ability to participate and try to succeed in competitive examinationsExNo. 5 : Interfacing PPI with 8086Ex.No.13: Interfacing 8279 with 8051
4To understand and gain knowledge about Nuvoton Processorc. Graduate will demonstrate the ability to design and conduct experiments, analyze and interpret dataEx.No. 17: Perform seven segment display from 0000 to 9999 in Keil IDE
d. Graduate will demonstrate the ability to design a system, component or process as per needs and specification
f. Graduate will demonstrate the skills to use modern engineering tools, softwares and equipment to analyze problemsEx.No. 18: Perform seven segment display fetching data from the potentiometer using Keil IDE
S.R.M University
Faculty of Engineering and Technology
Department of Electronics and Communication EngineeringSub Code : EC0321
Semester : V
Sub Title: Processor Lab
Course Time : JulDec14Pre_requisite : NIL
Co_requisite : EC0309 Microprocessors & MicrocontrollersEXPERIMENTS DETAILSS.No.Experiments DetailEquipments RequiredComponents Required
I. Programming in 8086
1Using 8086 trainer kit, add, subtract, multiply and divide two 16 bit numbers stored in the memory and save the results of the operation in the memory.8086
Trainer Kit Power Cables
2To find the largest and the smallest of the given array of numbers stored in memory using 8086.8086 Trainer KitPower Cables
3To sort the given array of numbers stored in memory location into ascending and descending order using 80868086 Trainer KitPower Cables
4To find the sum of a series of numbers using 8086.
8086 Trainer KitPower Cables
II. 8086 Interfacing
5To interface 8255 Programmable Peripheral Interface with 8086 microprocessor and to test mode 0 operation
8086 Trainer KitPower Cables
6To interface a stepper motor with a 8086 kit and to make it run a) clockwise b) anti clockwise8086 Trainer Kit stepper motor interface add on card Power Cables
Add on card connector bus.
7To interface a programmable timer with 8086.8086 Trainer Kit programmable timer- add on cardPower Cables
Add on card connector bus.
8To interface a A/D Converter with 8086 and to measure the analog voltage and display digital equivalent of it.
To interface a D/A Converters with 8086 and to generate square and triangular waveforms.8086 Trainer Kit A/D, D/A interface boards, CROPower Cables
Add on card connector bus.
III.Programming in 8051
9To perform Addition, Subtraction, Multiplication and Division of two 8 bit, 16 bit numbers using 8051 trainer kit.8051 Trainer kitPower Cables
10To perform ones and twos complement of a given
number using 8051.8051 Trainer kitPower Cables
11To perform word disassembly using 80518051 Trainer kitPower Cables
12Convert the given decimal number to Hexa decimal using8051.8051 Trainer kitPower Cables
IV.8051 Interfacing
13To interface 8279 with 80518279 module,
8051 kitPower Cables
14To interface a 8253 programmable timer with 80518253 module,
8051 kitPower Cables
15To interface a stepper motor with 8051Stepper motor ,
8051 kitPower Cables
16To interface an ADC with 8051ADC module,
8051 kitPower Cables
V. Programming in Nuvoton Board
17Seven segment display using Nuvoton boardNuvoton kitPower Cables
18Seven segment display for ADC input using Nuvoton boardNuvoton kit, PotentiometerPower Cables
EC0321- Laboratory Policies and Report Format
Reports are due at the beginning of the lab period. The reports are intended to be a complete documentation of the work done in preparation for and during the lab. The report should be complete so that someone else familiar with microprocessor and controllers could use it to verify your work. The prelab and postlab report format is as follows:
1. A neat thorough prelab must be presented to your Staff Incharge at the beginning of your scheduled lab period. Lab reports should be submitted on A4 paper. Your report is a professional presentation of your work in the lab. Neatness, organization, and completeness will be rewarded. Points will be deducted for any part that is not clear.
2.In this laboratory students will work in teams of three. However, the lab reports will be written individually. Please use the following format for your lab reports.
a. Cover Page: Include your name, Subject Code, Section No., Experiment No. and Date.
b.Objectives: Enumerate 3 or 4 of the topics that you think the lab will teach you. DO NOT REPEAT the wording in the lab manual procedures. There should be one or two sentences per objective. Remember, you should write about what you will learn, not what you will do.
c.Program: This part contains all the steps required to produce the required operation. The program written should be verified with the staff member to correct the flow of the code written.. This section should also include a description of the experiment by writing suitable codes. e. Questions: Specific questions (Prelab and Postlab) asked in the lab should be answered here. Retype the questions presented in the lab and then formally answer them.
3. Your work must be original and prepared independently. However, if you need any guidance or have any questions or problems, please do not hesitate to approach your staff incharge during office hours. Copying any prelab/postlab will result in a low grade. The incident will be formally reported to the University and the students should follow the dress code in the Lab session.
4. Each laboratory exercise must be completed and demonstrated to your Staff Incharge in order to receive working program credit. This is the procedure to follow:
a. Program works: If the program works during the lab period (3 hours), call your staff incharge and he/she will sign and date it. This is the end of this lab, and you will get a complete grade for this portion of the lab.
b. Program does not work: If the program does not work, you must make use of the open times for the lab room to complete your lab exercise. When your program instructions are ready, contact your staff incharge to set up a time when the two of you can meet to check your program.
5. Attendance at your regularly scheduled lab period is required. An unexpected absence will result in loss of credit for your lab. If for valid reason a student misses a lab, or makes a reasonable request in advance of the class meeting, it is permissible for the student to do the lab in a different section later in the week if approved by the staff incharge of both the sections. Habitually late students (i.e., students late more than 15 minutes more than once) will receive 10 point reductions in their grades for each occurrence following the first.
6. Final grade in this course will be based on laboratory assignments. All labs have an equal weight in the final grade. Grading will be based on pre-lab work, laboratory reports, post-lab and in-lab performance (i.e., completing lab, answering laboratory related questions, etc.,).The Staff Incharge will ask pertinent questions to individual members of a team at random. Labs will be graded as per the following grading policy:
Pre-Lab Work
20.00%
In-Lab Performance 30.00%
Post Lab Work
20.00%
Laboratory Report
30.00%
8. Reports Due Dates: Reports are due one week after completion of the corresponding lab. A late lab report will have 20% of the points deducted for being one day late. If a report is 2 days late, a grade of 0 will be assigned.
9. Systems of Tests: Regular laboratory class work over the full semester will carry a weight of 75%. The remaining 25% weight will be given by conducting an end semester practical examination for every individual student if possible or by conducting a 1 to 1 hours duration common written test for all students, based on all the experiment carried out in the semester.
10. General Procedure:
a. Properly use the microprocessor and microcontroller trainer kit and identify the starting address of the RAM locations and trainer instructions in advance.
b. Know the instruction set of the processor and the controllers to be used in the lab classes.
c. Verify the function of all the programs scheduled for the lab session.
d. Properly use the interfacing cable to connect the peripherals to the processor.
e. After the completion of the experiments switch off the power supply and return the components.
SRM UNIVERSITY
Department of Electronics and Communication Engineering
EC0321 Processor Lab
Laboratory Report Cover Sheet
ODD SEM 2011 Name: ______________________________________
Section: Tick One M ( ) TU ( )
W ( )
Th ( )
Fr ( )
Venue: _______________________________________
Title of Lab: ________________________________________
Preparation Verification
Staff Name & Signature: ______________________
______________________Experiment Completion Verification
Staff Name & Signature: ______________________
______________________
Date, Time: ______________________
ParticularsMax MarksMarks Obtained
Prelab5 marks
Lab Performance 20marks
Post lab 5marks
Record 20marks
Total 50 marks
Report Verification
Staff Name & Signature: ______________________
______________________
Date, Time: ______________________CONTENTSExperiments
Page NoLab 1
1.1 (a) Introduction
11.2 (a) Hardware requirement
11.3 (a) Program logic
11.4 (a) Procedure
11.5 (a) Pre lab Questions
11.6 (a) Lab Assignment
11.7 (a) Post lab Questions
21.1 (b) Introduction
21.2 (b) Hardware requirement
21.3 (b) Program logic
21.4 (b) Procedure
21.5 (b) Pre lab Questions
21.6 (b) Lab Assignment
31.7 (b) Post lab Questions
3Lab 22.1 Introduction
42.2 Hardware requirement
42.3 Program logic
42.4 Procedure
42.5 Pre lab Questions
42.6 Lab Assignment
52.7 Post lab Questions
5Lab 3 3.1 Introduction
63.2 Hardware requirement
63.3 Program logic
63.4 Procedure
63.5 Pre lab Questions
63.6 Post lab Questions
7Lab 44.1 Introduction
84.2 Hardware requirement
84.3 Program logic
84.4 Pre lab Questions
84.5 Post lab Questions
9Lab 5
5.1 Introduction
105.2 Hardware requirement
105.3 Program logic
105.4 Pre lab Questions
115.5 Post lab Questions
12Lab 6 6.1 Introduction136.2 Hardware requirement
136.3 Program logic
136.3.1 wave scheme
136.3.2 2 phase scheme
136.3.3 half stepping scheme
146.4 Pre lab Questions
146.5 Lab Assignment
146.6 Post lab Questions
14Lab 77.1 Introduction
157.2 Hardware requirement
157.3 Program logic
157.3.1 Mode 0 Interrupt on terminal count
157.3.2 Mode 1 Programmable one shot
157.3.3. Mode 2 Rate Generator
157.3.4 Mode 3 Square Wave Generator
157.3.5 Mode 4 Software triggered strobe
157.4 Pre lab Questions
177.5 Post lab Questions
17Lab 8 8.1 (a) Introduction
188.2 (a) Hardware requirement
188.3 (a) Program logic
188.3.1 (a) Mode 0 square wave generation
188.3.2 (a) Mode 1 saw tooth wave generation
188.4 (a) Pre lab Questions
198.5. (a) Lab Assignments
198.6 (a) Post lab Questions
198.1. (b) Introduction
208.2. (b) Hardware Requirement
208.3. (b) Program Logic
20
8.3.1. (b) Channel Selection
20
8.3.2. (b) A to D Conversion
20
8.3.3. (b) To measure voltage in channel
208.4. (b) Pre lab questions
218.5 (b)Post lab Questions
21Lab 9
9.1 Introduction
22
9.2 Hardware requirement
22
9.3 Program
22
9.4 Prelab
22
9.5 Post lab
Lab 1010.1 Introduction
2210.2 Hardware requirement
2210.3 Program
2210.4 Prelab
2210.5 Post lab
22Lab 1111.1 Introduction
24
11.2 Hardware requirement
24
11.3 Program
24
11.4 Prelab
24
11.5 Post lab
24
Lab 1212.1 Introduction
2512.2 Hardware requirement
2512.3 Program
2512.4 Prelab
2512.5 Post lab
25Lab 1313.1 Introduction
2613.2 Hardware requirement
2613.3 Program
2613.4 Prelab
2613.5 Post lab
26Lab 14 14.1 Introduction
26
14.2 Hardware requirement
26
14.3 Program
26
14.4 Prelab
26
14.5 Post lab
29Lab 1515.1 Introduction
3015.2 Hardware requirement
3015.3 Program
3015.4 Prelab
3215.5 Postlab
32Lab 16 16.1 Introduction
3316.2 Hardware requirement
3316.3 Program
3316.4 Prelab
3316.5 Post lab
33Lab 1717.1 Introduction
3517.2 Hardware requirement
3517.3 Program
3517.4 Prelab
3517.5 Post lab
35Lab 18
18.1 Introduction
35
18.2 Hardware requirement
35
18.3 Program
35
18.4 Prelab
35
18.5 Post lab
Lab 1Ex.No.1: 16-Bit Addition & Subtraction1.1(a) Introduction:
The purpose of this experiment is to add and to subtract the given two 16 bit numbers and store them in a memory location. The student should also be able to design the addition and subtraction with carry and borrow.1.2(a) Hardware Requirement:
The 8086 Microprocessor kit, Power Supply.
1.3 (a) Program Logic:The add instruction requires either the addend or the augend to be in a register, unless the source operand is immediate since the addressing modes permitted for the source and destination are register-register, memory to register, register to memory, register to immediate, and finally memory to immediate.
Hence one of the operands is initially moved to AX. Then using the add instruction, 16-bit addition is performed.
The next arithmetic primitive is SUB. As discussed in ADD it permits the same modes of addressing. Hence moving the minuend to a register pair is necessary. Then the result is moved to a location in memory.1.4 (a) Procedure1. Enter the opcodes in ram memory from location 1000 using SUB command
2. Using STEP command, execute the program instruction by instruction
3. After each instruction verified register contents and see that they are initialised to the required values.1.5(a) Pre Lab Questions1. Difference between Microprocessor & Microcontroller?
2. Define BUS and give the classification of Buses
3. What is an addressing mode?
4. How the Microprocessors can be categorized?
5. What is stack and Subroutine?
6. Mention the features of 8086?
7. Define Opcode and Operand8. Explain how physical address is formed in 8086.
1.6(a) Lab Assignment1. Write an assembly language program to move the content in memory location 1100h into register BX and also move to register CX, and also store the content in CX in memory location 1300H.
2. Write an assembly language program to add and subtract the two 16-bit numbers using the program logic given in 1.3. (Use immediate and direct addressing modes)
3. Write an algorithm for the questions 1 & 2, and also draw the flowchart?1.7(a) Post Lab Questions (Refer the program to answer these questions)
1. Calculate the physical address for the given data. DS=1000h, BP=1234h 2. What is the purpose of HLT instruction?
3. What happens if the result is greater than 16bit?
4. Give the steps to calculate physical address?5. If carry is set to 1 before subtraction what is the instruction to be used?
6. What is the difference between MOV AX, [1100] and MOV [1200], AX?Ex.No:1-B (Multiplication And Division)1.1.(b)Introduction
The purpose of this experiment is to multiply and to divide the given two 16 bit numbers and store them in a memory location. 1.2 (b) Hardware Requirement
The 8086 Microprocessor kit, Power Supply.
1.3(b) Program Logic
The 8086 Processor provides both signed and unsigned multiply in their instruction set to overcome the loss of efficiency in performing the repeated addition.
The MUL instruction can have both 16 and 8 bit operands and the multiplicand is AX or AL, accordingly the result for a byte multiply is a 16 bit number in AX while that for a word multiply is a 32 bit number, the lower word of which is in AX and the higher word in DX.
1.4(b) Procedure
1. Enter the opcodes in ram memory from location 1000 using SUB command
2. Using STEP command, execute the program instruction by instruction
a. After each instruction verified register contents and see that they are initialised to the required values.1.5(b) Pre-Lab Questions
1. A single instruction may use more than one addressing modes or some instructions may not require any addressing modes. Why?
2. How is the addressing mode of an instruction communicated to the CPU?
3. How does the CPU identify between 8-bit and 16-bit operation?
4. What do you mean by pipelined architecture?
5. What is a Flag register?
6. What is a machine cycle?
7. What is a status signal?
8. What is minimum mode operation of 8086?
9. What is the maximum memory addressing and I/O addressing capabilities of 8086?
10. From which address the 8086 starts execution after reset?
1.6(b) Lab Assignment
1. Write an assembly language program to move the content in memory location 1100h into register BX and also move to register CX, and also store the content in CX in memory location 1300h.(Use based indexed addressing mode)
2. Write an assembly language program to multiply and divide the two 16-bit numbers using the program logic given in 1.9. (Use immediate and direct addressing modes)
3. Write an algorithm for the questions 1 & 2, and also draw the flowchart?1.7(b) Post-Lab Questions (Refer the program to answer these questions)1. List out the type of addressing modes used in your program.2. If result exceeds 32 bit where is it stored?
3. What is the name given to the register combination DX:AX?
4. What is the instruction used for signed division?
5. In the above program instead of DIV BX, is it possible to use DIV num2?
Lab 2
Ex.No.2: Largest and Smallest number in an array2.1 Introduction:
The purpose of this experiment is to find the larger and the smaller numbers from an array which is stored in a memory location.2.2 Hardware Requirement:
The 8086 Microprocessor kit, Power Supply.
2.3 Program Logic:
To find the largest number in any given array, the contents of the array must be compared with an arbitrary biggest number. The first number of the array is taken in a register AL. The second number of the array is compared with the first one. If the first one is greater than the second one, it is left unchanged. However if the second one is greater than the first, the second number replaces the first one in the AL register. The procedure is repeated for every number in the array and thus it requires n iterations. At the end of nth iteration the largest number will reside in the register AL.
For smallest number the above said logic is repeated but, If the first number is smaller than the second one it is left unchanged. Otherwise the second number replaces the first number in the AL register2.4 Procedure:1. Enter the opcodes in ram memory from location 1000 using SUB command2. Using STEP command, execute the program instruction by instruction
3. After each instruction verified register contents and see that they are initialized to the required values
4. Execute the program and check for results.
2.5 Pre-Lab Questions:1. Draw the flowchart to find the largest and smallest number of an array?
2. What is the similarity and difference between Subtract and Compare Instruction?
3. What are the addressing modes are used in our program?
4. Initialize register CX to value FFFF and register AX to value 0000, write a program to exchange the contents of both these register?
5. Illustrate the use of LEA, LDS, and LES instruction and to initialize registers using these instructions?
6. Logic calculations are done in which type of registers?
7. In an 8086 microprocessor program, data and stack memory occupies uniform memory space. State true or false?
8. Explain cross-compiler, linker, editor and debugger?
9. Suppose that DS=1000h, SS=2000h, BP=1000h and DI=0100h. Determine the memory address accessed by each of the following instructions.
MOV AL, [BP + DI]
MOV CX, [BP]
10. Form a jump instruction that jumps to the address pointed by the BX register?
2.6 Lab Assignment
1. Write an assembly language program to sort the numbers of an array in a memory location 1100h and store the largest number of the array in 1200h and smallest number in the location 1300h.2.7 Post-Lab Questions:1. What is the purpose of MOV DS, AX?
2. What will be the status of flags after executing the program?
3. What are the addressing modes are used in our program?
4. What is the difference between JUMP and LOOP instructions?
5. What instructions are needed to add AL, 3L and DL together, and place the result in CL? Do not destroy BL or DL.
6. Show the instruction needed to count the number of 1s found in AL. For example if AL contains 10110001, the number of 1s is 4.
Lab 3
Ex.No.3: Sorting of an array in ascending and descending series3.1 Introduction:
The purpose of this experiment is to sort the sequence of numbers from the array stored in a memory location into ascending and descending series.3.2 Hardware Requirement:
The 8086 Microprocessor kit, Power Supply.
3.3 Program Logic:
To arrange the given numbers in ascending and descending order, the bubble sorting method is used. Initially the first number of the series is compared with the second one. If the first number is greater than second, exchange their positions in the series otherwise leave the position unchanged. Then compare the second number in the recent form of the series with third and repeat the exchange part that you are carried out for the first and second number, and for all the remaining number of the series. Repeat this procedure for complete series (n-1) times. After n-1 iterations you will get the largest number at the end of the series. Again start from the first number of the series. Repeat the same procedure right from the first element to the last element. After n-2 iteration you will get the second highest number at the last but one place in the series. Repeat this till the complete series is arranged in ascending order.
3.4 Pre-Lab Questions:1. Draw the flow chart to arrange a given series of numbers in ascending and descending order.
2. In a given program how many times DEC and JNZ instructions are executed? What will be content in AX register after executing the program?
MOV AX, 00FF
MOV CL, 05
REPEAT:INC AX
DEC CL
JNZ REPEAT
3. Write a small program using DAA instruction?
4. Which type of jump instruction (short, near or far) assembles for the following:
If the distance is 0210H bytes
If the distance is 0020H bytes
If the distance is 100000H bytes
5. If DL = 0F3H and DH = 72H, List the difference after DH subtracts from DL,
and show the contents of the flag register bits.
6. How is register AL is used during execution of XLAT?
7. What conditional jump instruction should be used after CMP AL, 30H to jump when AL equals 30H?
3.5 Post-Lab Questions: 1. What is the purpose of XCHG instruction?
2. What is the use of PUSH and POP instruction?
3. Write an assembly language program in 8086 to sort the given array of 16-bit numbers in descending order.
4. What do square brackets means when they appear in an operand?
5. What is the difference between MOV AX, 0 and SUB AX, AX? There may be more than one difference to comment on.
6. Write a routine to swap nibbles in AL. For example if AL contains 3E, then it will contain E3 after execution.
Lab 4
Ex.No.4: Sum of series
4.1 Introduction:
The purpose of this experiment is to find the sum of sequence of numbers from the array stored in a memory location and store the result in a specified location.4.2 Hardware Requirement:
The 8086 Microprocessor kit, Power Supply.
4.3 Program Logic:
In this program we show the addition of 10 numbers and is used as count for number of additions. The initial sum is assumed as zero. Initially, the resulting sum of the first two numbers will be stored. To this sum, the third number will be added. This procedure will be repeated till all the numbers in the series are added. A conditional JUMP instruction will be used to implement the counter checking logic.
4.4 Pre-Lab Questions
1. Draw the flowchart to find the sum of series of 8-numbers in a given array of 10 numbers?
2. Write a program to find the sum of series with carry and verify the answer with 8086 processor kit?
3. Given an instruction, how do you identify the addressing mode of the instruction, explain with example?
4. Identify the type of addressing modes used in the following data transfer operations. When data is moved from AX register to EX and when the data is moved from Ex register to a memory location whose address is given by DX register.
5. A 20-bit address bus allows access to a memory of capacity
(a) 1 MB
(b) 2 MB
(c) 4 MB
(d) 8 MB
6. Programs are written in assembly language because they
(a) run faster than High-level language
(b) are portable
(c) easier to write than machine code programs
(d) they allow the programmer access to registers or instructions that are not usually provided by a High-level language
7. What is meant by Maskable interrupts?
(a) An interrupt that can be turned off by the programmer.
(b) An interrupt that cannot be turned off by the programmer.
(c) An interrupt that can be turned off by the system.
(d) An interrupt that cannot be turned off by the system
8. Is overlapping of segment possible in 8086?4.5 Post-Lab Questions
1. How many times the JNZ instruction executed in our program?
2. In our program, List out the instructions which are not affected by the flags.
3. Which are pointers present in this 8086?4. Which Flags can be set or reset by the programmer and also used to control the operation of the processor?
5. Find the error in this program?
MOV AL, 00H
MOV BL, 05H
MOV CL, 02H
AGAIN:ADD AL, BL
JNZ AGAIN
DEC CL
MOV DI, 1300H
MOV [DI], AL
HLT
6.List the instructions that can be used to clear the accumulator or any registers?
Part II-8086 Microprocessor Interfacing
EXPERIMENT: 5 8255- PROGRAMMABLE PERIPHERAL INTERFACE (PPI)
5.1 Objective
To interface 8255 Programmable Peripheral Interface with 8086 microprocessor and to test mode 0 operation
5.2 Hardware requirements
The 8086 Microprocessor kit, 8255 Programmable Peripheral Interface add on card, Interface cable and Power Supply.
5.3 Theory
The 8255 is a widely used, programmable, parallel I/O device.It can be programmed to transfer data under various conditions, from simple I/O to interrupt I/O.
Features
Three 8-bit IO ports PA, PB, PC
PA can be set for Modes 0, 1, 2. PB for 0,1 and PC for mode 0 and for BSR. Modes 1 and 2 are interrupt driven.
PC has two 4-bit ports: PC upper (PCU) and PC lower (PCL), each can be set independently for Input or Output. Each PC bit can be set/reset individually in BSR mode.
PA and PCU are Group A (GA) and PB and PCL are Group B (GB)
Address/data bus must be externally demultiplexed.
8255 can be operated in two modes
BSR (Bit Set Reset ) mode or
i. I/O mode
ii. BSR mode
Bit set/reset, applicable to PC only. One bit is S/R at a time. Command word
D7D6D5D4D3D2D1D0
0 (0=BSR)XXXB2B1B0S/R (1=S,0=R)
Bit select: (Taking Don't care's as 0)
B2B1B0PC bitControl word (Set)Control word (reset)
00000000 0001 = 01h0000 0000 = 00h
00110000 0011 = 03h0000 0010 = 02h
01020000 0101 = 05h0000 0100 = 04h
01130000 0111 = 07h0000 0110 = 06h
10040000 1001 = 09h0000 1000 = 08h
10150000 1011 = 0Bh0000 1010 = 0Ah
11060000 1101 = 0Dh0000 1100 = 0Ch
11170000 1111 = 0Fh0000 1110 = 0Eh
I/O mode
The I/O mode is further divided into three modes:
Mode 0 : all ports function as simple I/O ports
Mode 1 : Hand shake mode whereby Ports A and/or B use bits from port C as handshake signals
Mode 2. : Port A can be set up for bidirectional data transfer using handshaking signals from Port C, and Port B can be set up either in Mode 0 or Mode 1.
Command word
D7D6D5D4D3D2D1D0
1 (1=I/O)GA mode selectPAPCUGB mode selectPBPCL
D6, D5: GA mode select:
00 = mode0
01 = mode1
1X = mode2
D4(PA), D3(PCU): 1=input 0=output
D2: GB mode select: 0=mode0, 1=mode1
D1(PB), D0(PCL): 1=input 0=output
Port Address
RegisterAddress
Control word registerC6
Port AC0
Port BC2
Port CC4
5.4 Pre-lab Questions
1. What is control word register?
2. Name the two operating modes of 8255
3. What is BSR mode?
4. Give control word format of BSR mode.
5. What is Input output mode?
5.5 Program
1. Initialize port A as input port and port B as output port in mode 0 , to input the data at port A as set by the SPDT switches and to output the same data to port B to glow the LED accordingly.
2. Initialize port A as input port and port c as output port in mode 0 , to input the data at port A as set by the SPDT switches and to output the same data to port B to glow the LED accordingly.
3. Initialize port C as input port and port B as output port in mode 0 , to input the data at port A as set by the SPDT switches and to output the same data to port B to glow the LED accordingly.
5.6 Procedure
1. Enter the opcodes in RAM memory from location 1000 using the Assembler (A) command
2. Using GO command, execute the program instruction by instruction
3. After execution verify register contents and see that they are initialized to the required values and transfer the output to RAM memory .
5.7 Post-lab Questions
1. Initialize the control word register for port A as input and port B as output in mode1
2. Compare mode 0, mode 1 and mode 2 of 8255 I /O mode.
3. Initialize the control word register for port C as input and Port B as output in mode0
4. Initialize 8255 for bidirectional data transfer Port A as input and port B as output.
5. Which control word is required to transfer a data from Port B to Port C in mode 1Lab 6Ex.No.6: Stepper Motor Interface6.1 Introduction:
To interface a stepper motor with a 8086 trainer kit and to run the motor in clockwise and anticlockwise directions with a controlled speed.6.2 Hardware Requirement:
The 8086 Microprocessor kit, Stepper motor interface add on card, interface cable, Power Supply.
6.3 Program Logic:
A motor in which the rotor is able to assume only discrete stationary angular position is a stepper motor. The rotor motion occurs in a stepwise manner from one equilibrium position to the next. They are widely used in open and closed looped systems in a variety of applications. It is either of reluctance type or permanent magnet type. The four poles structure is continuous with the stator frame and the magnetic field passes through the cylindrical stator annular ring. The stator poles and three pairs of rotor poles, there exists 12 possible positions in which a south pole of the rotor can lock with the north pole of the stator. From this it can be noted that the step size is 360( in degrees)/ Ns x Nr
where Ns = number of stator poles
Nr = number of pair of rotor poles.
There are three different stepping schemes for a stepper motor.
1. Wave scheme
2. 2- phase scheme
3. half stepping and mixed scheme
6.3.1 Wave scheme
The stepper motor windings A1,A2,B1,B2 can be cyclically excited with a DC current to run the motor in the clockwise direction. Consider the four rotor positions of the motor along with the stator excitations. The switching scheme for the wave mode excitation is given as follows.
Anti clockwiseClockwise
Step A1 A2 B1 B2Step A1 A2 B1 B2
1 1 0 0 0
2 0 0 0 1
3 0 1 0 0
4 0 0 1 0
1 1 0 0 0
2 0 0 1 0
3 0 1 0 0
4 0 0 0 1
6.3.2 2- Phase scheme:
In this scheme the two adjacent stator windings are energized. There are two magnetic fields achieved in quadrature and none of the rotor pole faces can be in a direct alignment with the stator poles.
The switching scheme for the 2- phase mode excitation is given as follows.
Anti clockwiseClockwise
Step A1 A2 B1 B2Step A1 A2 B1 B2
1 1 0 0 1
2 0 1 0 1
3 0 1 1 0
4 1 0 1 0
1 1 0 1 0
2 0 1 1 0
3 0 1 0 1
4 1 0 0 1
6.3.3 Half stepping scheme
The previously discussed two schemes have a step size of 30 degrees for the stepper motor under consideration. However there is a offset of 15 degrees between these two schemes. By interleaving these two schemes , the step size can be reduced to 15 degrees there by improving the accuracy of the motor. This is called half stepping scheme.
The switching sequence is as follows.
1. A1 on
2. A1 and B1 on
3. B1 on
4. B1 and A2 on
5. A2 on
6. A2 and B2 on
7. B2 on
8. B2 and A1 on
9. A1 on etc.Pre-Lab Questions: 1. What is the specific property of the stepper motor which makes it compatible to interface with the processor?
2. Can a single phase motor or a DC motor be interfaced with a 8086 processor?
3. What is the operating voltage of a stepper motor?
4. What are the different types of stepper motor?
5. State any two applications of stepper motor interfaced with 8086.6.5 Lab assignments:1. Write a program to interface the stepper motor with 8086 and make it run in clockwise direction.2.Write a program to interface the stepper motor with 8086 and make it run in anti clockwise direction.
6.6 Post-Lab Questions:
1. Write a program to run the stepper motor for any number of steps and to stop it.
2. Justify the look up table listed in your program.
3. What do you mean by the instruction out C0 in the program?
4. What is the value of the delay element used in the program?Lab 7Ex.No.7: Programmable Interval timer Interface7.1 Introduction:
To interface a programmable timer interface with a 8086 trainer kit and to operate it in various modes.7.2 Hardware Requirement:
The 8086 Microprocessor kit, Programmale Timer interface add on card, interface cable, Power Supply.
7.3 Program Logic:
The main features of 8253 are as follows:
1. Three independent 16 bit counters
2. Input clock
3. Programmable counter modes
The clk0 can be connected either to the pclk or to the debounce circuit. Using the debounce circuit we can generate a pulse and clock the timer. Similarly clock1 can be connected to pclk and clock2 can be connected to either pclk or out0. In a microprocessor based application, interrupting the processor after a time delay is essential which is achieved using a timer.
7.3.1 Mode 0 Interrupt on terminal count
The output will be initially low after mode set operation. After loading the counter, the output will remain low while counting and on terminal count the output will become high, until reloaded again. Channel 0 is in mode 0 and the program is executed. Output is observed through a CRO.
Program:ORG 1000H
MOV AL,30
OUT CE,AL
MOV AL,05
OUT C8,AL
MOV AL,00
OUT C8,AL
HLT
7.3.2 Mode 1 Programmable one shot
After loading the counter, the output will remain low following the rising edge of the gate input. The output will go high on the terminal count. It is retriggerable, hence the output will remain low for the full count after the rising edge of the gate input.
Execute the program, give the clock pulses through the debounce logic and observe the output at the CRO.
Program:ORG 1000H
MOV AL,32
OUT CE,AL
MOV AL,05
OUT C8,AL
MOV AL,00
OUT C8,AL
OUT D0,AL
HLT
7.3.3 Mode 2 Rate generator
It is a divide by N counter. The output will be low for for one period of the clock input. The period from one output pulse to the next equals the number of input counts in the count register. In the CRO observe the input at channel 1 and the output at out1.
Program:ORG 1000H
MOV AL,74
OUT CE,AL
MOV AL,0A
OUT CA,AL
MOV AL,00
OUT CA,AL
HLT7.3.4 Mode 3 Square Wave GeneratorIt is similar to mode 2 except that the output will remain high for one half of the count and go low for the other half for even number count.
If the count is odd, the output will remain high for (count-1)/2 counts.
PROGRAM:
ORG 1000H
MOV AL,36
OUT CE,AL
MOV AL,10
OUT C8,AL
MOV AL,00
OUT C8,AL
HLT
7.3.5 Mode 4 Software triggered strobe
In this method , the output is high after mode is set and also during counting. On terminal count , the output will go low for one clock period and becomes high again. This mode is used for interrupt generation.
PROGRAM:
ORG 1000H
MOV AL,36
OUT CE,AL
MOV AL,0A
OUT C8,AL
MOV AL,00
OUT C8,AL
MOV AL,B8
OUT CE ,AL
MOV AL,98
OUT CC,AL
MOV AL,3A
OUT CC,AL
HLT7.4 Pre-Lab Questions:1. What are the main features of 8253 timers?
2. List out the basic operations that can be performed by the timers.
3. Draw the control word format of timer?
4. Define baud rate factor
5. What is SC0 and SC1?
6. Define the functions of READ and LOAD functions of the timer?
7. How many channels are available in the 8253 IC?
7.5 Post-Lab Questions:
1. Is it possible to transmit and receive serial data using 8086 processors?
2. If it possible, explain how?3. Write a program to generate a square wave of frequency 150 Khz at channel 0.
Lab 8Ex.No.8: A/D and D/A Interface8.1(a) Introduction:
To interface a digital to analog interface with 8086 and to perform the lab assignments.
8.2 (a) Hardware Requirement:
The 8086 Microprocessor kit, D/A add on card, interface cable, Power supply.
8.3(a) Program Logic: The physical quantities like temperature, pressure etc are required for the electronic circuit for data processing. The electrical equivalent of such parameters are obtained by the use of transducers. It is difficult to process or store the analog values so there is a conversion of analog signals to the digital domain for the ease of processing and again converting it into the analog domain for the real time output . This is of course achieved by the use of converters. The circuit which is used to convert a digital value into a analog value is a digital to analog converter.
8.3.1 (a) Square wave generationThe basic idea behind the generation of the waveform is the continuous generation of analog output at DAC. With 00(hex) as the input to the DAC2, the analog value is -5v. similarly , with FF (hex) as input, the output of the DAC is +5v. Outputting the digital data 00 and FF at regular intervals at DAC2, results in a square wave generation.
Program:
MOV AL,00
OUT C8,AL
CALL 1010
MOV AL,FF
OUT C8,AL
CALL 1010
JMP 1000
MOV CX, 05FF
LOOP 1013
RET
8.3.2 (a) Saw tooth wave generationOutput digital data from 00 to FF in constant steps of 01 to DAC1.Repeat this sequence again and again. As a result a saw tooth is generated at DAC1 output.
Program:
MOV AL,00
OUT CO,AL
INC AL
JNZ 1002
JMP 1000
MOV BL,00
MOV AL,BL
OUT C8,AL
INC BL
JNZ 1002
MOV BL,FF
MOV AL,BL
OUT C8,AL
DEC BL
JNZ 100C
JMP 1000
8.4(a) Pre-Lab Questions:
1. What is the basic principle of digital to analog converter?
2. Why DAC is interfaced with 8086?
3. State any two applications where DAC is used?
4. How many waveforms are generated in the program stated above?
5. Is it possible to generate a sine wave using a DAC?8.5(a) Lab Assignments
1. To generate the square wave at the DAC2 output.2. To generate a saw tooth wave at the DAC1 output.8.6 (a) Post-Lab Questions:
1.Write a program to generate a triangular wave
2. What do you mean by DAC1 and DAC2?
3. For a digital value of 7F ,the approximate analog voltage is ----------8.1(b) Introduction:
The purpose of this experiment is to convert the analog input given in the channel to a digital value and glow the LEDs accordingly using ADC interfaced with 8086 microprocessor.8.2 (b) Hardware Requirement:
The 8086 Microprocessor kit, A/D add on card, interface cable, Power supply.
8.3(b) Program Logic: ADC 0809 is a monolithic CMOS device with a 8 bit analog to digital converter, 8 channel multiplexer and microprocessor compatible interface logic.
The main features of ADC are
1. 8 bit resolution
2. 100 microsec conversion time
3. low power consumption
4. latched tristate outputs
8.3.1 (b)The following program selects channel 0 and start analog to digital conversion by using ALE signal.
Program:
MOV AL,10
OUT C8,AL
MOV AL,18
OUT C8,AL
MOV AL,10
OUT C8,AL
HLT
8.3.2 (b): Initiating the analog to digital conversion process by giving the analog input at channel 0 and observing the output at LEDs.
Program:MOV AL,10
OUT C8,AL
MOV AL,18
OUT C8,AL
MOV AL,01
OUT D0,AL
MOV AL,00
MOV AL,00
OUT D0,AL
HLT
8.3.3 (b) To measure the voltage at channel1 and store the equivalent in the memory location.
Program: MOV AL,03
OUT C8,AL
MOV AL,23
OUT C8,AL
MOV AL,03
OUT C8,AL
MOV AL,01
OUT D0,AL
MOV AL,00
OUT D0,AL
LOOP:IN AL,E0
AND AL,01
CMP AL,01
JNZ LOOP
IN AL,CO
MOV BX,1100
MOV[BX],AL
HLT8.4 (b) Pre-Lab Questions:
1. Define SOC and EOC.
2. What type of ADC have you used in the program?
3. What are the types of ADCs available in the electronic market?
4. What is conversion time?8.5 (b) Post-Lab Questions:
1. Write a program to convert a analog input to digital value and store the result in a RAM location
2. How many channels are available in the ADC used in the program?
Lab 9Part III- 8051Microcontroller Ex.No.9: Addition, Subtraction, Multiplication and Division using 80519.1 Introduction:
The purpose of this experiment is to add, subtract, multiply and divide the given two 8 bit numbers and store them in a memory location. The student should also be able to design the addition and subtraction with carry and borrow.9.2 Hardware Requirement:
The 8051 Microcontroller kit , Power supply.
9.3 Program Logic: To perform addition in 8051 one of the data should be in accumulator, another data can be in any of the general purpose register or in memory or immediate data. After addition the sum will be in accumulator. The sum of two 8-bit data can be either 8-bits(sum only) or 9-bits(sum and carry). The accumulator can accumulate only the sum and there is a carry the 8051 will indicate by setting carry flag. Hence one of the register is used to account for carry.
The 8051 has MUL instruction unlike many other 8-bit processors. MUL instruction multiplies the unsigned 8-bit integers in A and B. The lower order byte of the product is left in A and the higher order byte in B.
The 8051 has DIV instruction unlike many other 8-bit processors. DIV instruction divides the unsigned 8-bit integers in A and B. The accumulator receives the integer part of the quotient and the register B receives the remainder.
9.4 Procedure:
i) Enter the opcodes from memory location 4200
ii) Execute the program
iii) Check for the result at 4100 and 4101
Using the accumulator, subtraction is performed and the result is stored. Immediate addressing is employed. The SUBB instruction drives the result in the accumulator.
9.5 Pre-Lab Questions:
1. Show the status of carry flag, auxiliary carry and parity flags after the addition of 38H and 2FH in the following instructions
MOV A, #38H
ADD A, #2FH
2. A programmer puts the first opcode at address at 100H. What happens when the microcontroller is powered up?
3. what is the result of the following code and where is it kept
MOV A, #15
MOV R5, #15
ADD A, R5
4. Write a program if R5 contains the value 0. If so put 55h in it.
5. What do the mnemonics LCALL and ACALL stands for.
6. How does the CPU know where to return after executing the RET instruction.
7. Find the number of times the following loop is performed
MOV R6, #200
BACK:MOV R5, #100
HERE:
DJNZ R5, HERE
DJNZ R6, BACK
9.6 Post-Lab Questions:
1. Examine the following code then answer the following questions
A. Will it jump to NEXT?
B. What is in A after CJNE instruction is executed
MOV A, #55H
CJNE A, #99H, NEXT
.
NEXT:
2. Assume that P1 is an input port connected to a temperature sensor. Write a program to read the temperature and test it for the value 75. According to the test results place the temperature value in to the registers indicated by the following.
If T = 75 then A = 75
If T < 75 then R1 = T
If T > 75 then R2 = T
3. Write a program to monitor P1 continuously for the value 63H. it should be get out of monitoring only if P1 = 63H
4. Find the contents of register A after executing the following code
CLR A
ORL A, #99H
CPL A
5. In the absence of a SWAP instruction how would you exchange the nibbles?
Write a simple program to show the process.
Lab 10Ex.No.10: Ones and twos complement of a number 10.1 Introduction:
The purpose of this experiment is to add and subtract the given two 8 bit numbers and store them in a memory location using a DSP processor. The student should also be able to design the addition and subtraction with carry and borrow.10.2 Hardware Requirement:
The 8051 Microcontroller kit , Power supply.
10.3 Program Logic:
The ones complement of a number is obtained by inverting all the bits in that number, i.e. replacing all ones by zero and all zero by ones. The Twos complement is the negative of that number. The CPL instruction is employed to find the ones complement. Since the Twos complement of a number is its ones complement + 1, The INC instruction is employed.
10.4 Pre-Lab Questions:
1. What is the major difference between 8051 and 8086?
2. What is meant by the term immediate addressing?
3. There is no stop instruction in the 8051 instruction. Describe a method for implementing a program stop.
4. Explain what the CJNE instruction does? And show an example program using CJNE instruction?
5. The 8051 address bus is 16-bits wide and the data bus is 8-bits wide-what is the maximum size for the external CODE memory or DATA memory. Show your calculation.
6. List out the directives of 8051 microcontroller.
10.5 Post-Lab Questions:
1. Write an assembly language program to find ones and twos complement without using CPL instruction.
2. What are the two registers in 8051 which are used for indirect addressing?
3.Find the value of the CY flag after the execution of the following code
1. MOV A #85H
2. ADD A #72H
4.What is the function of program counter in 8051? 5.Explain the bit level logical instructions of 8051.Lab 11Ex.No.11: Word Disassembly
11.1 Introduction:
Split the contents of 4500 into two nibbles (4-bit numbers) and store the. higher nibble at 4501 and the lower nibble at 4502.
11.2 Hardware Requirement:
The 8051 Microcontroller kit, Power supply.
11.3 Program Logic:
The data is fetched from memory and SWAP instruction of 8051 is used which will interchange the low and high-order nibbles of the accumulator. The higher nibble of the result is masked off and is stored in memory. Then, the higher nibble in the original data is masked off and is stored in memory.
11.4 Pre-Lab Questions:
1. Upon reset, all ports of the 8051 are configured as _____________ (output, input).
2. Which ports of the 8051 have internal pull-up resistors?
3. Which ports of the 8051 require the connection of external pull-up resistors in order to be used for I/O? Show the drawing for the connection.
4. In the 8051, explain why we must write "1" to a port in order for it to be used for input.
5. Explain why we need to buffer the switches used as input in order to avoid damaging the 8051 port.
11.5 Post-Lab Questions:1. How the DPTR register is classified, explain its functions?
2. What is the function of EA pin in 8051?
3. List out the special function registers in 8051.Lab 12Ex.No.12: Hexadecimal To Decimal Conversion12.1 Introduction:
The purpose of this experiment is to obtain the decimal equivalent of an 8-bit hex number stored in memory using 8051 micro controller trainer kit.
12.2 Hardware Requirement:
The 8051 Microcontroller kit , Power supply.
12.3 Program Logic:
In this program, the hex number is converted to its equivalent decimal number. The algorithm followed is very simple. The hex number to be converted is brought to the accumulator and is divided by 100 D to find the number of hundreds in it. DIV instruction of 8051 is used in this program. The remainder is now divided by 10 D to count the number of tens in it. Finally, the remainder obtained from the above division gives the number of units in the given hex number. The result is stored in memory in the unpacked form.12.4 Pre-Lab Questions:
1. Write an Assembly language program to convert the given Decimal number in to
Hexadecimal number.
2. Why are program counter and stack pointer are 16-bit registers?
3. What are register banks?
4. Mention any 3 applications of microcontroller?
5. Howto program the microcontroller 89C51?12.5 Post-Lab Questions:
1. Write an assembly Language program to convert the given hexadecimal number
in to decimal number.
2. Mention the difference between AT89C51, AT89C52 and AT89C2051.
3. Explain power down mode of 8051.
4. Explain the function of RXD and TXD pins of 8051 microcontroller.
5. Explain the reset circuit in 8051.
6. What is the difference between power-on reset and manual reset?Part IV : Interfacing with 8051
EXPERIMENT: 13 8279 INTERFACE 13.1 Objective
To interface 8279 Keyboard Interface with 8051 microcontroller
13.2 Hardware requirements
The 8051 Microcontroller kit, 8279 Interface add on card, Interface cable and Power Supply.
13.3 Theory
The 8255 is a widely used for debouncing keys, coding of the keypad matrix and refreshing the display elements in the microprocessor development system.
Features
A0: Selects data (0) or control/status (1) for reads and writes between micro and 8279.BD: Output that blanks the displays
CLK: Used internally for timing. Max is 3 MHz.
CN/ST: Control/strobe, connected to the control key on the keyboardCS: Chip select that enables programming, reading the keyboard, etcDB7 DB0 : Consists of bidirectional pins that connect to data bus on microcontrollerIRQ: Interrupt request, becomes 1 when a key is pressed, data is available.
OUT A0- A3/B3-B0: Outputs that sends data to the most significant/least significant nibble of display.
RD(WR): Connects to micro's IORCor RDsignal, reads data/status registers.
RESET: Connects to system RESET.R: Return lines are inputs used to sense key depression in the keyboard matrix.
Shift: Shift connects to Shift key on keyboard.SL3 SL0: Scan line outputs scan both the keyboard and displays.Keyboard Interface of 8279The keyboard matrix can be any size from 2x2 to 8x8. Pins SL2- SL0 sequentially scan each column through a counting operation. The 74LS138 drives 0's on one line at a time. The 8279 scans RL pins synchronously with the scan.RL pins incorporate internal pull-ups, no need for external resistor pull-ups.
Display mode set up:
000DDKKK
DD- Display mode:00- 8 bit character display (left)
01- 16 -8 bit character display (left)
10- 8 bit character display (right)11-16 -8 bit character display (right)
KKK- Keyboard Interface
000 Encoded Scan Keyboard 2 key lock out
001- Decoded Scan Keyboard 2 key lock out
010- Encoded Scan Keyboard N key roll over
011- Decoded Scan Keyboard N key roll over
100- Encoded Scan sensor matrix
101- Decoded Scan sensor matrix
110- Strobed input, Encoded display Scan
111- Strobed input, Decoded display Scan
Sample program to display AMOV DPTR, # FFC2MOV A, #00
MOV@DPTR, A
MOV A,#CC
MOV@DPTR, A
MOV A,#90
MOV@DPTR, A
MOV DPTR, # FFC0
MOV A,#88
MOV@DPTR, A
MOV R0, #05
MOV A, FF
LOOP: MOVX @DPTR, A
DJNZ R0, LOOP
HERE: SJMP HERE13.4 PreLab:1. State the operating modes of 8279
2. What are the use of CS, A0, RD and WR lines?
3. What is N key lock out?
4. What is N key roll over?
13.5 Post Lab:
1. Define Clock pre scaling.2. What is BD?
EXPERIMENT: 14 8253- PROGRAMMABLE TIMER INTERFACE
14.1 Objective
To interface 8253 Keyboard Interface with 8051 microcontroller14.2 Hardware requirements
The 8051Microcontroller kit, 8253 Interface add on card, Interface cable and Power Supply.
14.3 Theory
The main features of 8253 are as follows:
1. Three independent 16 bit counters
2. Input clock
3. Programmable counter modes
The clk0 can be connected either to the pclk or to the debounce circuit. Using the debounce circuit we can generate a pulse and clock the timer. Similarly clock1 can be connected to pclk and clock2 can be connected to either pclk or out0. In a microprocessor based application, interrupting the processor after a time delay is essential which is achieved using a timer.
14.3. 1 MODES
Mode 0 Interrupt on terminal count
The output will be initially low after mode set operation. After loading the counter, the output will remain low while counting and on terminal count the output will become high, until reloaded again. Channel 0 is in mode 0 and the program is executed. Output is observed through a CRO.
Program:MOV DPTR, FFCE
MOV A, # 30
MOVX @DPTR, A
MOV DPTR, FFC8
MOV A, # 05
MOVX @DPTR, A
MOV A, # 00
MOVX @DPTR, A
HERE: SJMP HERE
Mode 1 Programmable one shot
After loading the counter, the output will remain low following the rising edge of the gate input. The output will go high on the terminal count. It is retriggerable, hence the output will remain low for the full count after the rising edge of the gate input.
Execute the program, give the clock pulses through the debounce logic and observe the output at the CRO.
Program:
MOV DPTR, FFCE
MOV A, # 32
MOVX @DPTR, A
MOV DPTR, FFC8
MOV A, # 05
MOVX @DPTR, A
MOV A, # 00
MOVX @DPTR, A
MOV DPTR, FFD0
MOVX @DPTR, A
HERE: SJMP HERE
Mode 2 Rate generator
It is a divide by N counter. The output will be low for for one period of the clock input. The period from one output pulse to the next equals the number of input counts in the count register. In the CRO observe the input at channel 1 and the output at out1.
Mode 3 Square Wave GeneratorIt is similar to mode 2 except that the output will remain high for one half of the count and go low for the other half for even number count.
If the count is odd, the output will remain high for (count-1)/2 counts.
PROGRAM:MOV DPTR, FFCE
MOV A, # 36MOVX @DPTR, A
MOV A, # 0AMOV DPTR, FFC8MOVX @DPTR, A
MOV A, # 00
MOVX @DPTR, A
HERE: SJMP HERE
Mode 4 Software triggered strobe
In this method , the output is high after mode is set and also during counting. On terminal count , the output will go low for one clock period and becomes high again. This mode is used for interrupt generation.
14.4 Pre Lab:1. What is RS 232 and state the use of RTS and CTS?2 What is the use of select counter SC in timer?3 Draw the control word format of timer.14.5 Post Lab:1 What is Debouncing of keys?Lab 15Ex.No.15: Stepper Motor Interface15.1 Introduction:
To interface a stepper motor with a 8051 trainer kit and to run the motor in clockwise and anticlockwise directions with a controlled speed.15.2 Hardware Requirement:
The 8051 Microcontroller kit, Stepper motor interface add on card, interface cable, Power Supply.
15.3 Program Logic:
A motor in which the rotor is able to assume only discrete stationary angular position is a stepper motor. The rotor motion occurs in a stepwise manner from one equilibrium position to the next. They are widely used in open and closed looped systems in a variety of applications. It is either of reluctance type or permanent magnet type. The four poles structure is continuous with the stator frame and the magnetic field passes through the cylindrical stator annular ring. The stator poles and three pairs of rotor poles, there exists 12 possible positions in which a south pole of the rotor can lock with the north pole of the stator. From this it can be noted that the step size is 360( in degrees)/ Ns x Nr
where Ns = number of stator poles
Nr = number of pair of rotor poles.
There are three different stepping schemes for a stepper motor.
4. Wave scheme
5. 2- phase scheme
6. half stepping and mixed scheme
15.3.1 Wave scheme
The stepper motor windings A1,A2,B1,B2 can be cyclically excited with a DC current to run the motor in the clockwise direction. Consider the four rotor positions of the motor along with the stator excitations. The switching scheme for the wave mode excitation is given as follows.
Anti clockwiseClockwise
Step A1 A2 B1 B2Step A1 A2 B1 B2
1 1 0 0 0
2 0 0 0 1
3 0 1 0 0
4 0 0 1 0
1 1 0 0 0
2 0 0 1 0
3 0 1 0 0
4 0 0 0 1
15.3.2 2- Phase scheme:
In this scheme the two adjacent stator windings are energized. There are two magnetic fields achieved in quadrature and none of the rotor pole faces can be in a direct alignment with the stator poles.
The switching scheme for the 2- phase mode excitation is given as follows.
Anti clockwiseClockwise
Step A1 A2 B1 B2Step A1 A2 B1 B2
1 1 0 0 1
2 0 1 0 1
3 0 1 1 0
4 1 0 1 0
1 1 0 1 0
2 0 1 1 0
3 0 1 0 1
4 1 0 0 1
15.3.3 Half stepping scheme
The previously discussed two schemes have a step size of 30 degrees for the stepper motor under consideration. However there is a offset of 15 degrees between these two schemes. By interleaving these two schemes , the step size can be reduced to 15 degrees there by improving the accuracy of the motor. This is called half stepping scheme.
The switching sequence is as follows.
10. A1 on
11. A1 and B1 on
12. B1 on
13. B1 and A2 on
14. A2 on
15. A2 and B2 on
16. B2 on
17. B2 and A1 on
18. A1 on etc.15.4 Pre-Lab Questions: 1 State applications of stepper motor in control systems2 Draw the 4 possible rotor positions and the corresponding stator excitations in a stepper motor
15.5 Post Lab:1. Write a program to interface the stepper motor with 8051 and make it run in clockwise and anti clock wise direction.Lab 16
Ex.No.16: A/D and D/A Interface16.1(a) Introduction:
To interface a digital to analog interface with 8051 and to perform the lab assignments.
16.2 (a) Hardware Requirement:
The 8051 Microcontroller kit, D/A add on card, interface cable, Power supply.
16.3(a) Program Logic: (Refer Lab 8)The physical quantities like temperature, pressure etc are required for the electronic circuit for data processing. The electrical equivalent of such parameters are obtained by the use of transducers. It is difficult to process or store the analog values so there is a conversion of analog signals to the digital domain for the ease of processing and again converting it into the analog domain for the real time output . This is of course achieved by the use of converters. The circuit which is used to convert a digital value into a analog value is a digital to analog converter.
16.3.1 (a) Square wave generationThe basic idea behind the generation of the waveform is the continuous generation of analog output at DAC. With 00(hex) as the input to the DAC2, the analog value is -5v. similarly , with FF (hex) as input, the output of the DAC is +5v. Outputting the digital data 00 and FF at regular intervals at DAC2, results in a square wave generation.
16.3.2 (a) Saw tooth wave generationOutput digital data from 00 to FF in constant steps of 01 to DAC1.Repeat this sequence again and again. As a result a saw tooth is generated at DAC1 output.
16.4(a) Pre-Lab Questions:1. What is the basic principle of analog to digital converter?
2. Why DAC is interfaced with 80513. Is it possible to generate any wave using DAC interface
8.6 (a) Post-Lab Questions:
1.Write a program to generate a triangular wave in 80512. For a digital value of 6F ,the approximate analog voltage is ----------Lab 17Part IV Nuvoton ProcessorEx.No.17: Seven segment display from 0000 to 999917.1 Introduction:
The purpose of this experiment is to display the number from 0000 to 9999 in the 4 LEDs in the Nuvoton Nu-LB-NUC140series Board17.2 Tool Requirement:
KEIL Uversion 4.0, Nuvoton CMSIS Library Files, DrvSYS Library Files, NUC140LB Series ARM Target Board.17.3 Program :Smpl_7seg : counting from 0 to 9999 and display on 7-segment LEDs
#include
#include "NUC1xx.h"
#include "DrvSYS.h"
#include "Seven_Segment.h"
// display an integer on four 7-segment LEDs
void seg_display(int16_t value)
{
int8_t digit;
digit = value / 1000;
close_seven_segment();
show_seven_segment(3,digit);
DrvSYS_Delay(5000);
value = value - digit * 1000;
digit = value / 100;
close_seven_segment();
show_seven_segment(2,digit);
DrvSYS_Delay(5000);
value = value - digit * 100;
digit = value / 10;
close_seven_segment();
show_seven_segment(1,digit);
DrvSYS_Delay(5000);
value = value - digit * 10;
digit = value;
close_seven_segment();
show_seven_segment(0,digit);
DrvSYS_Delay(5000);
int32_t main (void)
{
int32_t i =0;
UNLOCKREG();
DrvSYS_Open(48000000);
LOCKREG();
while(iOFFD|=0x00800000; //Disable digital input path
SYS->GPAMFP.ADC7_SS21_AD6=1; //Set ADC function
/* Step 2. Enable and Select ADC clock source, and then enable ADC module */
SYSCLK->CLKSEL1.ADC_S = 2; //Select 22Mhz for ADC
SYSCLK->CLKDIV.ADC_N = 1; //ADC clock source = 22Mhz/2 =11Mhz;
SYSCLK->APBCLK.ADC_EN = 1; //Enable clock source
ADC->ADCR.ADEN = 1; //Enable ADC module
/* Step 3. Select Operation mode */
ADC->ADCR.DIFFEN = 0; //single end input
ADC->ADCR.ADMD = 0; //single mode
/* Step 4. Select ADC channel */
ADC->ADCHER.CHEN = 0x80;
/* Step 5. Enable ADC interrupt */
ADC->ADSR.ADF =1; //clear the A/D interrupt flags for safe
ADC->ADCR.ADIE = 1;
// NVIC_EnableIRQ(ADC_IRQn);/* Step 6. Enable WDT module */
ADC->ADCR.ADST=1;
}
void Delay(int32_t count)
{
while(count--)
{
// __NOP;
}
}
void seg_display(int16_t value)
{
int8_t digit;
digit = value / 1000;
close_seven_segment();
show_seven_segment(3,digit);
Delay(5000);
value = value - digit * 1000;
digit = value / 100;
close_seven_segment();
show_seven_segment(2,digit);
Delay(5000);
value = value - digit * 100;
digit = value / 10;
close_seven_segment();
show_seven_segment(1,digit);
Delay(5000);
value = value - digit * 10;
digit = value;
close_seven_segment();
show_seven_segment(0,digit);
Delay(5000);
}
/*----------------------------------------------------------------------------
MAIN function
----------------------------------------------------------------------------*/
int32_t main (void)
{
int32_t adc_value;
UNLOCKREG();
SYSCLK->PWRCON.XTL12M_EN = 1; //Enable 12Mhz and set HCLK->12Mhz
SYSCLK->CLKSEL0.HCLK_S = 0;
LOCKREG();
InitADC();
while(1)
{
while (ADC->ADSR.ADF==0); // ADC Flag, wait till 1 (A/DC conversion done)
ADC->ADSR.ADF=1; // write 1 to ADF is to clear the flag
adc_value=ADC->ADDR[7].RSLT; // input 12-bit ADC value
seg_display(adc_value); // display value to 7-segment display
ADC->ADCR.ADST=1; // activate next ADC sample
// 1 : conversion start; // 0 : conversion stopped, ADC enter idle state
}
}
RESULT : The Simple Seven Segment display to display the value 0000 to FFFF was executed on KEILuVersion4 and successfully ported verified on NUC140 series board.
18.4 Pre Lab Questions:
1.What does ARM mean?
2. State the specifications of the Nuvoton processor?3. Differentiate Nuvoton and 8086 trainer boards18.5 Post Lab Questions1. What is IDE and why it is needed?
2. What is meant by in circuit programming?PAGE 1