EE6612 – Microprocessors and Microcontrollers LaboratoryValliammai Engineering College SRM Nagar, Kattankulathur - 603203 Department of Electrical and Electronics Engineering EE6612 – Microprocessors and Microcontrollers Laboratory Manual LAB MANUAL III Year- VI Semester - Electrical and Electronics Engineering Academic Year 2015-2016 (2013 Regulation) Prepared by, Dr.G.Udhayakumar, Associate Professor Mr.S.Rajanbabu,AssistantProfessor(Sr.G) Mrs K.Durgadevi, AssistantProfessor Mrs A.Shanmugapriyaa, AssistantProfessor Department of Electrical and Electronics Engineering - VEC EE6612 – Microprocessors and Microcontrollers Laboratory SYLLABUS EE6612 - MICROPROCESSORS AND MICRO CONTROLLERS LABORATORY OBJECTIVES: To provide training on programming of microprocessors and microcontrollers and understand the interface requirements. LIST OF EXPERIMENTS: 1. Simple arithmetic operations: addition / subtraction / multiplication / division. 2. Programming with control instructions: (i) Ascending / Descending order, Maximum / Minimum of numbers (ii) Programs using Rotate instructions (iii)Hex / ASCII / BCD code conversions. 3. Interface Experiments: with 8085 (i) A/D Interfacing. & D/A Interfacing. 4. Traffic light controller. 5. I/O Port / Serial communication 6. Programming Practices with Simulators/Emulators/open source 7. Read a key,interface display 8. Demonstration of basic instructions with 8051 Micro controller execution, including: (i) Conditional jumps, looping (ii) Calling subroutines. 9. Programming I/O Port 8051 (i) study on interface with A/D & D/A (ii (ii) study on interface with DC & AC motor . 10. Mini project development with processors. TOTAL: 45 PERIODS OUTCOMES: • • Ability to understand and analyse, linear and digital electronic circuits. To understand and apply computing platform and software for engineering problems. Department of Electrical and Electronics Engineering - VEC EE6612 – Microprocessors and Microcontrollers Laboratory LIST OF EXPERIMENTS CYCLE I 8-bit Microprocessor 1. Simple arithmetic operations: (a) Addition (b) subtraction (c) multiplication (d) division. 2. Ascending / Descending order, Maximum / Minimum of numbers : (a) Ascending order (b) Descending order (c) Maximum of numbers (d) Minimum of numbers. 3. Rotate instructions: (a) Odd and Even Number (b) Positive and Negative Number 4. Code conversion. (a) ASCII to hexadecimal number (b) hexadecimal to ASCII (c) hexadecimal to decimal number (d) binary to hexadecimal number and (e) hexadecimal to binary number CYCLE II 8085 Interfacing Program 5. Interface Experiments: (a) A/D Interfacing. (b) D/A Interfacing 6. Traffic light controller: I/O port - 8255 7. Serial Communication: 8251 8. Read a key, interface display: 8279 CYCLE III 8-bit Microcontroller 9. Demonstration of basic instructions with 8051 Micro controller execution, including: (a) Addition (b) subtraction (c) multiplication (d) division. 10. (a) Conditional jumps, looping : Sum of elements in an array (b) Calling subroutines : Check whether given number is Odd or Even using call option 11. Programming I/O Port : (a) A/D Interfacing. (b) D/A Interfacing 12. Interface with DC & AC motor 13. Mini project development with processors ADDITIONAL EXPERIMENTS 14. Interfacing 8253 Timer With 8085 15. Stepper Motor Interfacing With 8051 Department of Electrical and Electronics Engineering - VEC VEC Signature .EE6612 – Microprocessors and Microcontrollers Laboratory S.no Date List Of Experiments Department of Electrical and Electronics Engineering . VEC .EE6612 – Microprocessors and Microcontrollers Laboratory Department of Electrical and Electronics Engineering . VEC .EE6612 – Microprocessors and Microcontrollers Laboratory 8085 MICROPROCESSOR Department of Electrical and Electronics Engineering . Department of Electrical and Electronics Engineering . 8 BIT DATA ADDITION: ALGORITHM: 1. 3. Get the second number and add it to the accumulator. No: 1 SIMPLE ARITHMETIC OPERATIONS AIM: To write an assembly language program to add. a. Store the answer at another memory location. subtract.EE6612 – Microprocessors and Microcontrollers Laboratory Ex. multiply and divide the given data stored at two consecutive locations using 8085 microprocessor. Get the first number from memory in accumulator. 4.VEC . 2. Initialize memory pointer to data location. VEC .EE6612 – Microprocessors and Microcontrollers Laboratory FLOW CHART: START [C] 00H [HL] 4500H [A] [M] [HL] [HL]+1 [A] [A]+[M] Is there a Carry ? NO YES [C] [C]+1 [HL] [HL]+1 [M] [A] [HL] [HL]+1 [M] [C] STOP Department of Electrical and Electronics Engineering . C L1 Department of Electrical and Electronics Engineering . Increment C reg. to point next memory Location. Transfer the result from acc. M 4106 INX H 4107 ADD M 4108 4109 410A JNC L1 410B 410C INR INX C H 410D MOV M. 00 LXI H. to 4500 Transfer first data to accumulator Increment HL reg.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRESS OPCODE LABEL 4100 START 4101 4102 4103 4104 4105 MNEMONICS OPERAND MVI C.VEC COMMENT Clear C reg. to point next memory Location. Add first number to acc. to memory. Increment HL reg. Initialize HL reg. to point next memory Location. A 410E INX H 410F 4110 MOV HLT M. Jump to location if result does not yield carry. Content. Move carry to memory Stop the program . Increment HL reg. 4500 MOV A. Get the first number from memory in accumulator. is complemented and 01H is added to it (2’s complement). is incremented in case there is a borrow. A register is cleared and the content of that reg. 8 BIT DATA SUBTRACTION ALGORITHM: 1. 2. If there is no borrow the content of the acc. 3. Get the second number and subtract from the accumulator. the content of the acc.VEC . 5. Initialize memory pointer to data location. If the result yields a borrow. 4. Department of Electrical and Electronics Engineering . is directly taken as the result.EE6612 – Microprocessors and Microcontrollers Laboratory b. Store the answer at next memory location. VEC .EE6612 – Microprocessors and Microcontrollers Laboratory START FLOW CHART: [C] [HL] 00H 4500H [A] [M] [HL] [HL]+1 [A] [A]-[M] Is there a Borrow? NO YES Complement [A] Add 01H to [A] [C] [C]+1 [HL] [HL]+1 [M] [A] [HL] [HL]+1 [M] [C] STOP Department of Electrical and Electronics Engineering . 4500 Initialize HL reg. to point next mem. Transfer the result from acc. Jump to location if result does not yield borrow. Increment HL reg. Stop the program . LXI H. Increment HL reg. C L1 Department of Electrical and Electronics Engineering . A 4111 INX H 4112 4113 MOV HLT M. Complement the Acc.VEC Increment C reg. Subtract first number from acc. Content. 00 COMMENT Clear C reg. Location. to point next mem.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRESS OPCODE LABEL 4100 START 4101 4102 4103 4104 4105 MNEMONICS OPERAND MVI C. M 4106 INX H 4107 SUB M 4108 4109 410A JNC L1 Transfer first data to accumulator Increment HL reg. 410B 410C INR CMA C 410D 410E 410F ADI 01H INX H 4110 MOV M. to memory. Location. Location. to 4500 MOV A. to point next mem. Move carry to mem. content Add 01H to content of acc. 6. The result. 8. Initialize memory pointer to data location. Department of Electrical and Electronics Engineering . 5. 8 BIT DATA MULTIPLICATION: ALGORITHM: LOGIC: Multiplication can be done by repeated addition. Move the multiplier to another register. 7.EE6612 – Microprocessors and Microcontrollers Laboratory c. which is in the accumulator. Add multiplicand to accumulator Decrement multiplier Repeat step 5 till multiplier comes to zero. 1. is stored in a memory location. 2. 3. 4. Clear the accumulator.VEC . Move multiplicand to a register. EE6612 – Microprocessors and Microcontrollers Laboratory FLOW CHART: START [HL] ←4500 B ←M [HL] ← [HL]+1 A ← 00 C ← 00 [A] ← [A] +[M] Is there any carry NO YES C ← C+1 B ← B-1 NO IS B=0 YES A Department of Electrical and Electronics Engineering - VEC EE6612 – Microprocessors and Microcontrollers Laboratory A [HL] [HL]+1 [M] [A] [HL] [HL]+1 [M] [C] STOP Department of Electrical and Electronics Engineering - VEC EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRESS OPCODE LABEL 4100 START 4101 4102 4103 MNEMONICS LXI OPERAND H, 4500 MOV B, M 4104 INX H 4105 4106 4107 4108 MVI A, 00H Transfer first data to reg. B Increment HL reg. to point next mem. Location. Clear the acc. MVI C, 00H Clear C reg for carry ADD M 410A JNC NEXT 410B 410C 410D 410E 410F 4110 4111 4112 INR DCR JNZ C B L1 Increment C reg Decrement B reg Jump to L1 if B is not zero. INX H 4113 MOV M, A 4114 INX H 4115 MOV M, C 4116 HLT Increment HL reg. to point next mem. Location. Transfer the result from acc. to memory. Increment HL reg. to point next mem. Location. Transfer the result from C reg. to memory. Stop the program 4109 L1 NEXT Department of Electrical and Electronics Engineering - VEC COMMENT Initialize HL reg. to 4500 Add multiplicand multiplier times. Jump to NEXT if there is no carry Load Divisor and Dividend 2. Subtract divisor from dividend 3.The dividend now becomes the remainder. Stop the program execution.VEC . 8 BIT DIVISION: ALGORITHM: LOGIC: Division is done using the method Repeated subtraction.EE6612 – Microprocessors and Microcontrollers Laboratory d. Department of Electrical and Electronics Engineering . Stop subtraction when the dividend is less than the divisor . Count the number of times of subtraction which equals the quotient 4. 1. 5. Otherwise go to step 2. VEC .EE6612 – Microprocessors and Microcontrollers Laboratory START FLOWCHART: B ← 00 [HL] ←4500 A ←M [HL] ← [HL]+1 M ← A-M [B] ← [B] +1 No IS A<0 Yes A ← A+ M YES B ← B-1 [HL] [HL]+1 [M] [A] [HL] [HL]+1 [M] [B] STOP Department of Electrical and Electronics Engineering . to point next mem. to memory.00 COMMENTS Clear B reg for quotient LXI H. Location. Decrement B reg Increment HL reg. Stop the program 4106 4107 LOOP Department of Electrical and Electronics Engineering .4500 Initialize HL reg. to point next mem. Increment HL reg. to 4500H MOV A. to point next mem.M INX H SUB M 4108 4109 410A 410B 410C 410D 410E INR JNC B LOOP ADD DCR INX M B H 410F MOV M. Location.VEC .A 4110 INX H 4111 MOV M.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRESS 4100 4101 4102 4103 4104 4105 OPCODE LABEL MNEMONICS MVI OPERAND B. Increment HL reg.B 4112 HLT Transfer dividend to acc. Location. Transfer the quotient from B reg. Subtract divisor from dividend Increment B reg Jump to LOOP if result does not yield borrow Add divisor to acc. to memory. Transfer the remainder from acc. NO 1 2 Department of Electrical and Electronics Engineering .NO 1 2 DIVISION: S.VEC .NO 1 2 MULTIPLICATION: S.EE6612 – Microprocessors and Microcontrollers Laboratory OBSERVATION: ADDITION: S.NO 1 2 INPUT ADDRESS DATA 4500 4501 4500 4501 OUTPUT ADDRESS DATA 4502 4503 4502 4503 INPUT ADDRESS DATA 4500 4501 4500 4501 OUTPUT ADDRESS DATA 4502 4503 4502 4503 INPUT ADDRESS DATA 4500 4501 4500 4501 OUTPUT ADDRESS DATA 4502 4503 4502 4503 INPUT ADDRESS DATA 4500 4501 4500 4501 OUTPUT ADDRESS DATA 4502 4503 4502 4503 SUBTRACTION: S. EE6612 – Microprocessors and Microcontrollers Laboratory Department of Electrical and Electronics Engineering .VEC . Department of Electrical and Electronics Engineering .EE6612 – Microprocessors and Microcontrollers Laboratory RESULT: Thus the addition. multiplication and division of two numbers was performed using the 8085 microprocessor. subtraction.VEC . Maximum / Minimum of numbers AIM: To write an assembly language program to arrange an array of data in ascending and descending order and to find the smallest and largest data among the array. Repeat steps 2 and 3 until the numbers are in required order Department of Electrical and Electronics Engineering . 3. Compare the first two numbers and if the first number is larger than second then I interchange the number.VEC . go to step 4 4. If the first number is smaller. ASCENDING ORDER ALGORITHM: 1. Get the numbers to be sorted from the memory locations. 2.EE6612 – Microprocessors and Microcontrollers Laboratory Ex. No: 2 Ascending / Descending order. a. EE6612 – Microprocessors and Microcontrollers Laboratory FLOWCHART: START [HL] Å 4200H [C] Å [HL] [C] Å [C] -1 [D] Å [C] [HL] Å4201H [A] Å [HL] [HL Å [HL] + 1 Yes Is [A] < [HL]? No [B]Å [HL] [HL] Å [A] [HL] Å [HL] .VEC .1 [HL] Å [B] [HL] Å [HL] + 1 [D] Å [D] – 01 H A Department of Electrical and Electronics Engineering . VEC .EE6612 – Microprocessors and Microcontrollers Laboratory A IS [D] = 0? No Yes [C] Å [C]-1 IS [C] = 0? No Yes STOP Department of Electrical and Electronics Engineering . B 4113 4114 4115 4116 4117 4118 4119 411A 411B 411C INX DCR JNZ H D LOOP2 DCR JNZ C LOOP3 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 410A OPC ODE LABEL LOOP 3 LOOP2 LOOP1 MNEMONICS HLT Department of Electrical and Electronics Engineering .VEC COMMENTS Set pointer for array Load the Count Decrement Count Transfer data from C to D Load data from 4201 Copy content of M to A Increment HL reg. to point next memory location Compare M & A If A is lesser than M then go to loop1 Transfer data from M to D reg Transfer data from acc to M Decrement HL pair Transfer data from B to M Increment HL pair Decrement D reg If D is not zero go to loop2 Decrement C reg If C is not Zero go to loop3 Stop the program .A 4111 4112 DCX MOV H M.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRESS LXI OPERA ND H.M C D.4200 MOV DCR MOV C.C LXI H.4201 MOV INX A.M H 410B 410C CMP JC M LOOP1 410D 410E 410F MOV B.M 4110 MOV M. go to step 4 4. If the first number is larger. Compare the first two numbers and if the first number is smaller than second then I interchange the number.VEC . 2. Get the numbers to be sorted from the memory locations.EE6612 – Microprocessors and Microcontrollers Laboratory b. DESCENDING ORDER ALGORITHM: 1. 3. Repeat steps 2 and 3 until the numbers are in required order Department of Electrical and Electronics Engineering . 1 [HL] Å [B] [HL] Å [HL] + 1 [D] Å [D] – 01 H A Department of Electrical and Electronics Engineering .VEC .EE6612 – Microprocessors and Microcontrollers Laboratory START FLOWCHART: [HL] Å 4200H [C] Å [HL] [C] Å [C] -1 [D] Å [C] [HL] Å4201H [A] Å [HL] [HL Å [HL] + 1 No Is [A] < [HL]? Yes [B]Å [HL] [HL] Å [A] [HL] Å [HL] . VEC .EE6612 – Microprocessors and Microcontrollers Laboratory A IS [D] = 0? No Yes [C] Å [C]-1 IS [C] = 0? No Yes STOP Department of Electrical and Electronics Engineering . EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRESS LXI OPERA ND H,4200 MOV DCR MOV C,M C D,C LXI H,4201 MOV INX A,M H 410B 410C CMP JNC M LOOP1 410D 410E 410F MOV B,M 4110 MOV M,A 4111 4112 DCX MOV H M,B 4113 4114 4115 4116 4117 4118 4119 411A 411B 411C INX DCR JNZ H D LOOP2 DCR JNZ C LOOP3 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 410A OPC ODE LABEL LOOP 3 LOOP2 LOOP1 MNEMONICS HLT Department of Electrical and Electronics Engineering - VEC COMMENTS Set pointer for array Load the Count Decrement Count Transfer data from C to D Load data from 4201 Copy content of M to A Increment HL reg. to point next memory location Compare M & A If A is lesser than M then go to loop1 Transfer data from M to D reg Transfer data from acc to M Decrement HL pair Transfer data from B to M Increment HL pair Decrement D reg If D is not zero go to loop2 Decrement C reg If C is not Zero go to loop3 Stop the program EE6612 – Microprocessors and Microcontrollers Laboratory c. LARGEST ELEMENT IN AN ARRAY ALGORITHM: 1. Place all the elements of an array in the consecutive memory locations. 2. Fetch the first element from the memory location and load it in the accumulator. 3. Initialize a counter (register) with the total number of elements in an array. 4. Decrement the counter by 1. 5. Increment the memory pointer to point to the next element. 6. Compare the accumulator content with the memory content (next element). 7. If the accumulator content is smaller, then move the memory content (largest element) to the accumulator. Else continue. 8. Decrement the counter by 1. 9. Repeat steps 5 to 8 until the counter reaches zero 10. Store the result (accumulator content) in the specified memory location. Department of Electrical and Electronics Engineering - VEC EE6612 – Microprocessors and Microcontrollers Laboratory FLOW CHART: START [HL] Å [4200H] [B] Å 04H [A] Å [HL] [HL Å [HL] + 1 NO IS [A] < [HL]? YES [A]Å [HL] [B] Å [B]-1 IS [B] = 0? NO YES [4205] Å [A] STOP Department of Electrical and Electronics Engineering - VEC to 4200H Initialize B reg with no.M H CMP JNC M LOOP MOV DCR JNZ A. Stop the program Department of Electrical and Electronics Engineering .VEC . to point next memory location Compare M & A If A is greater than M then go to loop Transfer data from M to A reg Decrement B reg If B is not Zero go to loop1 Store the result in a memory location.M B LOOP1 STA 4205 HLT COMMENTS Initialize HL reg.4200 MVI B.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRE SS 4101 4102 4103 4104 4105 4106 4107 4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 OPCO DE LABEL LOOP1 LOOP MNEM ONICS LXI OPER AND H. of comparisons(n-1) Transfer first data to acc. Increment HL reg.04 MOV INX A. 3. If the accumulator content is smaller. 7. Repeat steps 5 to 8 until the counter reaches zero 10. 6. Department of Electrical and Electronics Engineering . 4. 9. Place all the elements of an array in the consecutive memory locations. SMALLEST ELEMENT IN AN ARRAY ALGORITHM: 1. 2. Decrement the counter by 1. Compare the accumulator content with the memory content (next element). then move the memory content (largest element) to the accumulator. 8. Store the result (accumulator content) in the specified memory location. Initialize a counter (register) with the total number of elements in an array. Decrement the counter by 1. Fetch the first element from the memory location and load it in the accumulator.EE6612 – Microprocessors and Microcontrollers Laboratory d. Increment the memory pointer to point to the next element. Else continue. 5.VEC . VEC .EE6612 – Microprocessors and Microcontrollers Laboratory FLOW CHART: START [HL] Å [4200H] [B] Å 04H [A] Å [HL] [HL Å [HL] + 1 YES IS [A] < [HL]? NO [A]Å [HL] [B] Å [B]-1 IS [B] = 0? NO YES [4205] Å [A] STOP Department of Electrical and Electronics Engineering . Increment HL reg.4200 MVI B.M H CMP JC M LOOP MOV DCR JNZ A.M B LOOP1 STA 4205 HLT COMMENTS Initialize HL reg. Stop the program Department of Electrical and Electronics Engineering .04 MOV INX A. to 4200H Initialize B reg with no.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRE SS 4101 4102 4103 4104 4105 4106 4107 4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 OPCO DE LABEL LOOP1 LOOP MNEM ONICS LXI OPER AND H.VEC . of comparisons(n-1) Transfer first data to acc. to point next memory location Compare M & A If A is lesser than M then go to loop Transfer data from M to A reg Decrement B reg If B is not Zero go to loop1 Store the result in a memory location. EE6612 – Microprocessors and Microcontrollers Laboratory OBSERVATION: A. DESCENDING ORDER INPUT MEMORY DATA LOCATION 4200 4201 4202 4203 4204 OUTPUT MEMORY DATA LOCATION 4200 4201 4202 4203 4204 Department of Electrical and Electronics Engineering .VEC . ASCENDING ORDER INPUT MEMORY DATA LOCATION 4200 4201 4202 4203 4204 OUTPUT MEMORY DATA LOCATION 4200 4201 4202 4203 4204 B. VEC . SMALLEST ELEMENT INPUT MEMORY DATA LOCATION 4200 4201 4202 4203 4204 OUTPUT MEMORY DATA LOCATION 4205 D.EE6612 – Microprocessors and Microcontrollers Laboratory C. LARGEST ELEMENT INPUT MEMORY DATA LOCATION 4200 4201 4202 4203 4204 OUTPUT MEMORY DATA LOCATION 4205 Department of Electrical and Electronics Engineering . EE6612 – Microprocessors and Microcontrollers Laboratory RESULT: Thus the sorting operations of arranging an array in ascending. descending order and the largest and smallest element were found using the 8085 microprocessor. Department of Electrical and Electronics Engineering .VEC . if C ≠0 go to step 5. Decrement C. a. 4. 9. Rotate the obtain data in the form of RAR. 2. Start. 5. and number of positive and negative numbers in a block of data. Move the content of accumulator to D and B register. 8. Load the given data.VEC . Odd and Even Number ALGORITHM: 1. If carry occur increment B else increment D.EE6612 – Microprocessors and Microcontrollers Laboratory Ex. Clear the data in accumulator. Increment HL register pair and move the content of memory to accumulator. Department of Electrical and Electronics Engineering . 3. 6. Stop. Else increment HL pair. No: 3 FIND THE NUMBER OF EVEN AND ODD NUMBER IN A BLOCK OF DATA AIM: To find the number of even and odd number. Move the content of D to memory and increment HL pair and move the content B to memory. 7. 10. [HL] Å B STOP Department of Electrical and Electronics Engineering . [HL] Å D [HL]Å [HL]+1.EE6612 – Microprocessors and Microcontrollers Laboratory START [HL] Å [4200H] [C] Å [HL] [A] Å 00H [B] Å [A] [D] Å [A] [HL Å [HL] + 1 [A] Å [HL] Rotate the A right through carry Yes Is CY=1 No [B]Å [B]+1. for odd [D]Å [D]+1. for even [C] Å [C]-1 Is [C] = 0? No Yes [HL]Å [HL]+1.VEC . VEC Load the number of data Increment H Move D to M Increment H Move B to M Halt the program .EE6612 – Microprocessors and Microcontrollers Laboratory ADDRE SS 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 411A OPCO DE LABEL L3 MNEM ONICS LXI OPER AND H.M L1 Move M to C Exclusive OR reg A Move A to D Move A to B Increment H Move M to A Rotate right through carry Jump no carry INR JMP D L2 Increment D Jump to L2 INR DCR JNZ B C L3 Increment B Decrement C Jump non Zero RAR JNC L1 L2 LOOP INX MOV INX H MOV HLT H M.4200 COMMENTS MOV XRA MOV MOV INX H MOV C. B Department of Electrical and Electronics Engineering . D H M. A B. M A D. A H A. Move the content of D to memory and increment HL pair and move the content B to memory. 3. 9. Start. Increment HL register pair and move the content of memory to accumulator. Clear the data in accumulator. 6. Else increment HL pair. if C ≠0 go to step 5. 7. Load the given data. If carry occur increment B else increment D. Rotate the obtain data in the form of RAL. 4. Decrement C.EE6612 – Microprocessors and Microcontrollers Laboratory b. 5. 8. Positive and Negative Number ALGORITHM: 1. Department of Electrical and Electronics Engineering . Move the content of accumulator to D and B register.VEC . 10. 2. Stop. negative [D]Å [D]+1.VEC . [HL] Å D [HL]Å [HL]+1. [HL] Å B STOP Department of Electrical and Electronics Engineering . positive [C] Å [C]-1 Is [C] = 0? No Yes [HL]Å [HL]+1.EE6612 – Microprocessors and Microcontrollers Laboratory START [HL] Å [4200H] [C] Å [HL] [A] Å 00H [B] Å [A] [D] Å [A] [HL Å [HL] + 1 [A] Å [HL] Rotate the A left through carry Yes Is CY=1 No [B]Å [B]+1. M A D.EE6612 – Microprocessors and Microcontrollers Laboratory ADDRE SS 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 411A OPCO DE LABEL L3 L1 L2 LOOP MNEM ONICS LXI OPER AND H. D H M.M L1 Move M to C Exclusive OR reg A Move A to D Move A to B Increment H Move M to A Rotate left through carry Jump no carry INR JMP D L2 Increment D Jump to L2 INR DCR JNZ B C L3 Increment B Decrement C Jump non Zero INX MOV INX H MOV HLT H M. A H A. A B.4200 COMMENTS MOV XRA MOV MOV INX H MOV RAL JNC C.VEC Load the number of data Increment H Move D to M Increment H Move B to M Halt the program . B Department of Electrical and Electronics Engineering . Positive and negative number INPUT: OUTPUT: 4200 = 04 4205=01 (Negative numbers) 4201= 01 4206=03 (Positive numbers) 4202 = F5 4203 = 03 4204 = 74 RESULT: Thus the number of even and odd number.VEC . Department of Electrical and Electronics Engineering . Odd and even number INPUT: OUTPUT: 4200 = 04 4205=03 (Odd numbers) 4201= 01 4206=01 (Even numbers) 4202 = 05 4203 = 03 4204 = 04 b. and positive and negative number has been found from the given number of list.EE6612 – Microprocessors and Microcontrollers Laboratory Observation a. VEC . 9. a. hexadecimal to ASCII. binary to hexadecimal number and hexadecimal to binary number. 2. No: 4 CODE CONVERSIONS AIM: To write an assembly language program to perform the conversions of ASCII to hexadecimal number. hexadecimal to decimal number. 4. 7.ASCII TO HEXADECIMAL ALGORITHM: 1. 5. 6.EE6612 – Microprocessors and Microcontrollers Laboratory Ex. 3. 8. Start the program Load the data from address 4200 to A Move data from accumulator to C Move data from M to HL pair to accumulator Subtract the data 30 from A Decrement content of register Stop the program if C is zero Jump to Step 5 End the program Department of Electrical and Electronics Engineering . VEC .EE6612 – Microprocessors and Microcontrollers Laboratory FLOWCHART: Start Set the ASCII value Subtract 30 from A Decrement the register content Check for Carry? YES NO Subtract 07 from A Store the hex value Stop Department of Electrical and Electronics Engineering . EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRE SS 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 410A 410B 410C 410D OPCO DE LABEL MNEM ONICS LDA OPER AND H.M 30 Move data from M to A Subtract 30 from A STAX D 410E DCR C 410F 4110 4111 4112 JZ LOOP INX H 4113 INX D 4114 4115 4116 4117 JMP LOOP 1 LOOP HLT LOOP 1 Load data 4200 to A Store data from accumulator to DE Decrement from C register Stop program if C is 0 Increment HL register pair Increment DE register pair Jump to 410A Stop Department of Electrical and Electronics Engineering .4301 Load address 4301 in DF MOV SUI A.4201 Move data from A to C Load address 4201 in HL LXI D.4200 COMMENTS MOV LXI C.VEC .A H. 8. 2. Start the program Load the data from address 4200 to A Move data from accumulator to C Move data from M to HL pair to accumulator Add the data 30 to A Decrement content of register Stop the program if C is zero Jump to Step 5 End the program Department of Electrical and Electronics Engineering . HEXADECIMAL TO ASCII ALGORITHM: 1. 7.EE6612 – Microprocessors and Microcontrollers Laboratory b. 9. 5. 3. 6.VEC . 4. EE6612 – Microprocessors and Microcontrollers Laboratory FLOWCHART: Start Set the ASCII value Add 30 to A Decrement the register content Check for Carry? YES NO Store the decimal value Stop Department of Electrical and Electronics Engineering .VEC . EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRE SS 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 410A 410B 410C 410D OPCO DE LABEL MNEM ONICS LDA OPER AND H.M 30 Move data from M to A Subtract 30 from A STAX D 410E DCR C 410F 4110 4111 4112 JZ LOOP INX H 4113 INX D 4114 4115 4116 4117 JMP LOOP 1 LOOP HLT LOOP 1 Load data 4200 to A Store data from accumulator to DE Decrement from C register Stop program if C is 0 Increment HL register pair Increment DE register pair Jump to 410A Stop Department of Electrical and Electronics Engineering .VEC .4200 COMMENTS MOV LXI C.4301 Load address 4301 in DF MOV ADI A.4201 Move data from A to C Load address 4201 in HL LXI D.A H. VEC . Increment the content of HL register pair 5.EE6612 – Microprocessors and Microcontrollers Laboratory c. Jump to the specified address if carry generated 7. HEXADECIMAL TO BINARY ALGORITHM: 1. Rotate the accumulator right 6. Jump to specified address if there is no zero 11. Start the program 2. Move 01 to memory 10. Move data 0B o register B 4. Move 00 to memory 8. Move the content of memory to accumulator 3. End the program Department of Electrical and Electronics Engineering . Jump to specified address if there is no zero 9. VEC .EE6612 – Microprocessors and Microcontrollers Laboratory FLOWCHART: Start Load address in HL pair Move data from M to A Initialize counter B to 08 Increments HL register pair Rotate accumulator right Check for Carry? YES NO Move data from 00 to M Move data from 01 to M Decrement B register NO If B=0? YES Stop Department of Electrical and Electronics Engineering . VEC COMMENTS Decrement B by 1 Jump to the specified address if no zero Stop the program . 01 Move 01 to M L2 DCR JNZ B L3 L3 4107 4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 4115 HLT Department of Electrical and Electronics Engineering .M B.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRE SS 4100 4101 4102 4103 4104 4105 4106 OPCO DE LABEL MNEM ONICS LXI OPERAND H.4200 Load address in HL pair MOV MVI A. 08 Move content of M to A Move 0B to register pair INX H RRC JC L1 Increment the content of HL pair Rotate accumulator right Jump to specified address if carry MVI JMP M. 00 L2 Move 00 to M Decrement B register L1 MVI M. Add the content of accumulator with previous content of accumulator 7. Move content of M to A 11. Add the content of accumulator with previous content of accumulator 5.EE6612 – Microprocessors and Microcontrollers Laboratory d. Load the address in HL pair 3. BINARY TO HEXADECIMAL ALGORITHM: 1. Move the content of B to accumulator 6. Move the content of memory to accumulator 4. End the program Department of Electrical and Electronics Engineering .VEC . Increment H by 1 10. Repeat step 6 8. Start the program 2. Add B with accumulator content 9. VEC .EE6612 – Microprocessors and Microcontrollers Laboratory FLOWCHART: Start Load address in HL pair Move data from M to A Add content of A to register B Add content of A with itself Add content of A to register B Increment HL reg pair Add content of M with accumulator Increment HL reg pair content Move content of M to accumulator Stop Department of Electrical and Electronics Engineering . A Move content of A to M Add A content with previous content of A Move the content from A to B Add A content with previous content of A Add B content with A Increment H by 1 Add M content with A Increment H by 1 Move content of A to M Stop the program Department of Electrical and Electronics Engineering .VEC .EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRE SS 4100 4101 4102 4103 4104 OPCO DE LABEL MNEM ONICS LXI OPERAND COMMENTS H.A A 4105 MOV B. A 4106 ADD A 4107 4108 4109 410A 410B 410C ADD INX ADD INX MOV HLT B H M H M.4150 Load address in HL pair MOV ADD M. Rotate accumulator left 10. Subtract 0A from A 8. Move the content from HL to A 4. Start the program 2. Jump to address 4207 7. Increment HL pair 9. Subtract 64 from A 5. Increment HL pair 11. HEXADECIMAL TO DECIMAL ALGORITHM: 1.VEC .EE6612 – Microprocessors and Microcontrollers Laboratory e. Increment BC pair 6. End the program Department of Electrical and Electronics Engineering . Load the address in HL pair 3. VEC .EE6612 – Microprocessors and Microcontrollers Laboratory FLOWCHART: Start Load address in HL pair Initialize D register Clear accumulator Move HL to C register Add 01 with A Adjust A to BCD YES Check Carry? NO Increment D register Increment C register NO Check Carry? YES Store A in 4151 H Move D to accumulator Store A in 4150 H Stop Department of Electrical and Electronics Engineering . VEC . 4150 COMMENTS LXI B. M 64 JC L1 Stop if A has carry INR JMP B L4 Increment BC Jump to specified address L1 ADI 64 Add 64 to A L3 SUI 0A Subtract 0A from A JC L2 Stop if A has carry INR JNC C L3 Increment HL Stop if A has no carry ADI INX MOV MOV MOV RLC RLC RLC RLC ADD 0A H M. A A.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRE SS 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 411A 411B 411D 411E 411F 4120 4121 4122 4123 4124 4125 OPCO DE MNEM ONICS LXI OPER AND H. B B. B L4 L2 LABEL B Load data from 4150 to HL pair Move the content from HL to A Subtract 64 from A Add 0A to A Increment HL Move B to M Move A to B Move B to A Rotate accumulator Rotate accumulator Rotate accumulator Rotate accumulator Add B to A Department of Electrical and Electronics Engineering . 0000 Load data from address to BC MOV SUI A. HEXADECIMAL TO ASCII INPUT MEMORY DATA LOCATION 4201 OUTPUT MEMORY DATA LOCATION 4301 c. BINARY TO HEXADECIMAL INPUT MEMORY DATA LOCATION 4150 4151 OUTPUT MEMORY DATA LOCATION 4152 Department of Electrical and Electronics Engineering . A Increment H by 1 Move content of A to M Stop the program OBSERVATION: a. ASCII TO HEXADECIMAL INPUT MEMORY DATA LOCATION 4201 OUTPUT MEMORY DATA LOCATION 4301 b. HEXADECIMAL TO BINARY INPUT MEMORY DATA LOCATION 4200 MEMORY LOCATION 4200 4201 4202 4203 OUTPUT DATA MEMORY DATA LOCATION 4204 4205 4206 4207 d.VEC .EE6612 – Microprocessors and Microcontrollers Laboratory 4126 4127 4128 INX MOV HLT H M. VEC . HEXADECIMAL TO DECIMAL INPUT MEMORY DATA LOCATION 4150 4151 OUTPUT MEMORY DATA LOCATION 4152 RESULT: Thus the assembly language programs for various code conversions are executed using 8085 microprocessor. Department of Electrical and Electronics Engineering .EE6612 – Microprocessors and Microcontrollers Laboratory e. 5. ADC INTERFACING WITH 8085 APPARATUS REQUIRED: SL. Read EOC signal. 2.NO 1 2 3 ITEM Microprocessor kit Power supply ADC Interface board SPECIFICATION 8085.VEC . 3.Vi Microsystems +5 V dc Vi Microsystems QUANTITY 1 1 1 PROBLEM STATEMENT: To program starts from memory location 4100H. The program is executed for various values of analog voltage which are set with the help of a potentiometer. Select the channel and latch the address. Department of Electrical and Electronics Engineering . 6.No:5 INTERFACING A/D AND D/A CONVERTER WITH 8085 AIM: To write an assembly language program to convert an analog signal into a digital signal and a digital signal into an analog signal using an ADC interfacing and DAC interfacing respectively. If EOC =1 continue else go to step (3) Read the digital output. THEORY: An ADC usually has two additional control lines: the SOC input to tell the ADC when to start the conversion and the EOC output to announce when the conversion is complete. The LED display is verified with the digital value that is stored in the memory location 4150H. 4. ALGORITHM: 1. checks the EOC pin of ADC 0419 as to whether the conversion is over and then inputs the data to the processor. It also instructs the processor to store the converted digital data at RAM 4200H.EE6612 – Microprocessors and Microcontrollers Laboratory EX. The following program initiates the conversion process. Send the start conversion pulse. a. Store it in a memory location. 01 Make 01 to accumulator OUT D0 Display the data XRA XRA XRA MVI A.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRESS OPCO DE LABEL 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 410A 410B 410C 410D 410E 410F 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 411A 411B 411C 411D 411E 411F 4120 4121 LOOP MNEMON ICS MVI OPERA ND A.VEC COMMENTS Select channel 0 and to make accumulator low Store the data End the program . 10 OUT C8 Output the data MVI A. 18 Make accumulator high OUT C8 Display the data MVI A. 00 XOR with accumulator XOR with accumulator XOR with accumulator Make 00 to accumulator OUT D0 Load D0 in output port IN D8 ANI 01 Do and operation directly CPI 01 Compare with accumulator JNZ LOOP Jump to specified address IN C0 STA 4150 HLT Department of Electrical and Electronics Engineering . CIRCUIT: SOC JUMPER SELECTION: J2: SOC Jumper selection J5: Channel selection Department of Electrical and Electronics Engineering .VEC .EE6612 – Microprocessors and Microcontrollers Laboratory ADC. EE6612 – Microprocessors and Microcontrollers Laboratory OBSERVATION ANALOG VOLTAGE DIGITAL DATA LED DISPLAY ON HEX CODE LOCATION 4150 Department of Electrical and Electronics Engineering .VEC IN . Load the initial value (00) to Accumulator and move it to DAC. 2.VEC . with FF (Hex) as input. saw tooth wave by means of software. (a) SQUARE WAVE GENERATION: The basic idea behind the generation of waveforms is the continuous generation of Analog output of DAC. the analog output is -5V. Repeat steps 2 to 5. 4. Outputting digital data 00 and FF at regular intervals.EE6612 – Microprocessors and Microcontrollers Laboratory b. 5. Call the delay program. the output is +5V. to DAC2. PROGRAM: ADDRESS 4100 4101 4102 4103 4104 4107 4109 410B OPCO DE LABEL MNEMON ICS OPERAND COMMENT START MVI A. With 00(HEX) as input to DAC2.NO 1 2 3 ITEM Microprocessor kit Power supply DAC Interface board SPECIFICATION 8085. Similarly.Vi Microsystems +5 V dc Vi Microsystems QUANTITY 1 1 1 SOFTWARE EXAMPLES The following examples illustrate how to control the DAC using 8085 and generate sine wave. Call the delay program Load the final value (FF) to accumulator and move it to DAC. 00 Move 00 to A register OUT C8 Load C8 to output port CALL MVI OUT CALL DELAY A. DAC INTERFACING WITH 8085 APPARATUS REQUIRED: SL. 3. FF C8 DELAY Call delay program Load FF to B register Department of Electrical and Electronics Engineering . results in a square wave of amplitude I5 Volts ALGORITHM: 1. FF C L2 B L1 Jump to start of address Move 05 to B register Move FF to C register Decrement C Jump to L2 if no zero Decrement B register Jump to L1 if no zero Execute the program and using a CRO. Increment the accumulator content by 1. Department of Electrical and Electronics Engineering . Move the accumulator content to DAC. Output digital data from 00 to FF constant steps of 01 to DAC1 repeat this sequence again and again. 4. Repeat steps 3 and 4. 05 C. Move the accumulator content to DAC. Modify the frequency of the square-wave. verify that the waveform at the DAC2 output is a square-wave. Load the initial value (00) to Accumulator. 00 C0 A L1 START COMMENT Load 00 to accumulator Load CO in output port Increment A register Jump to L1 if no zero Go to START unconditionally (c) TRIANGULAR WAVE GENERATION: ALGORITHM: 1. Increment the accumulator content by 1. Load the initial value (00) to Accumulator 2. PROGRAM: ADDRESS OPCO DE 4100 4102 4104 4105 4108 LABEL MNEMON ICS START L1 MVI OUT INR JNZ JMP OPERAN D A.VEC . 4. Load value (FF) to accumulator. Else go to step 3.EE6612 – Microprocessors and Microcontrollers Laboratory 410E 4112 4114 4116 4117 411A 411B 411E DELAY L1 L2 JMP START MVI MVI DCR JNZ DCR JNZ RET START B. (b) SAW TOOTH GENERATION: ALGORITHM: 1. 2. by varying the time delay. 3. If accumulator content is zero proceed to next step. As a result a saw – tooth wave will be generated at DAC1 output. 5. 6. Move the accumulator content to DAC 3. The following program will generate a triangular wave at DAC2 output. 8. L Move L to a register C8 Load C8 to output port L Decrement L register L2 Jump to L2 if no zero START Go to START unconditionally Department of Electrical and Electronics Engineering . FF Load FF to L register A. Decrement the accumulator content by 1. If accumulator content is zero go to step 2. L Load L to a register C8 Load c8 to output port L Increment L register L1 Jump to L1 if no zero L.EE6612 – Microprocessors and Microcontrollers Laboratory 7. 00 Move 00 to L register A. Else go to step 2. PROGRAM: ADDRESS 4100 4102 4103 4105 4106 4109 410B 410C 410E 410F 4112 OPCO DE LABEL MNEMON ICS START L1 MVI MOV OUT INR JNZ MVI MOV OUT DCR JNZ JMP L2 OPERA COMMENT ND L.VEC . EE6612 – Microprocessors and Microcontrollers Laboratory DAC .CIRCUIT: WAEFORMS: Department of Electrical and Electronics Engineering .VEC . VEC .EE6612 – Microprocessors and Microcontrollers Laboratory OBSERVATION: WAVE FORMS Square waveform Saw tooth waveform Triangular waveform AMPLITUDE TIME PERIOD Result: Thus the conversion of an analog signal into a digital signal and a digital signal into an analog signal was done using interfacing of ADC and DAC respectively with 8085. Department of Electrical and Electronics Engineering . no movement. Initialize the ports. All ambers are ON. (d) Vehicles from west. 6. indicating the change of sequence.NO 1 2 3 ITEM Microprocessor kit Power supply Traffic light interface kit SPECIFICATION 4185. (c) Each pedestrian can cross the road. APPARATUS REQUIRED: SL. A SAMPLE SEQUENCE: 1. 2. All ambers are ON. (b) Vehicles from west can cross the road. Department of Electrical and Electronics Engineering . 4.Vi Microsystems +5 V dc Vi Microsystems QUANTITY 1 1 1 ALGORITHM: 1. 2. Initialize the memory content. (d) Vehicles from north. (a) Vehicles from east can go straight and left. (e) Vehicles from south can go only straight. (d) Vehicles from east no movement. 5.EE6612 – Microprocessors and Microcontrollers Laboratory EX. 4. All ambers are ON. 3. (c) West pedestrian can cross the road.No:6 TRAFFIC LIGHT CONTROLLERS WITH 8085 AIM To write an assembly language program to simulate the traffic light at an intersection using a traffic light interface. (b) Vehicles from south can go only left. indicating the change of sequence. (b) Vehicles from east can go only left. (a) Vehicles from north can go straight and left. (e) Vehicles from west can go only straight. (c) North pedestrian can cross the road. indicating the change of sequence. repeat from step2. After completing all the sequences. 3. with some address to the data. (a) Vehicles from south can go to straight or left. Read data for each sequence from the memory and display it through the ports.VEC . no movement. (e) Vehicles from north can go only straight. (a) Vehicles from west can go straight and left. 9. (d) Vehicles from south.VEC . (b) Vehicles from north can go only left. (b) All pedestrian can cross the road. indicating the change of sequence. All ambers are ON. 8. BIT ALLOCATION: BIT LED BIT LED BIT LED PA0 PA1 PA2 PA3 PA4 PA5 PA6 PA7 SOUTH LEFT SOUTH RIGHT SOUTH AMBER SOUTH RED EAST LEFT EAST RIGHT EAST AMBER EAST RED PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7 NORTH LEFT NORTH RIGHT NORTH AMBER NORTH RED WEST LEFT WEST RIGHT WEST AMBER WEST RED PC0 PC1 PC2 PC3 PC4 PC5 PC6 PC7 WEST STRAIGHT NORTH STRAIGHT EAST STRAIGHT SOUTH STRAIGHT NORTH PD WEST PD SOUTH PD EAST PD Department of Electrical and Electronics Engineering .EE6612 – Microprocessors and Microcontrollers Laboratory 7. no movement. (c) South pedestrian can cross the road. (e) Vehicles from east can go only straight. (a) All vehicles from all directions no movement. 0C PORT B ----.0D PORT C ----.EE6612 – Microprocessors and Microcontrollers Laboratory PATH REPRESENTATION: CONTROL ----.VEC .0E Department of Electrical and Electronics Engineering .0F (FOR 8255 PPI) PORT A ----. DATA_ SQ D.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADD OPCODE RESS 4100 3E 4102 LABEL D3 4104 REPEAT MNEMON ICS MVI OPERAN D A.VEC COMMENT Move 41H immediately to accumulator Output contents of accumulator to OF port Load address 417B to HL register Load address 4187 to DE register Call out address 4142 Exchange contents of HL with DE pair Move M content to accumulator Load port A into output port Call delay address Exchange content of HL with DE pair Increment the content of D Increment the content of H Call out the address Exchange content of HL with DE pair Move M content to accumulator Load port B into output port Call DELAY address Exchange content of HL with DE pair Increment D register Increment H register Call specified address Exchange content of HL with DE pair Move M content to accumulator Load port C into output port . 41 OUT 0F LXI H. M 410F 4111 4114 D3 CD EB OUT CALL XCHG 0D DELAY1 4115 4116 4117 411A 13 23 CD EB INX INX CALL XCHG D H OUT 411B 7E MOV A. M 411C 411E 4121 D3 CD EB OUT CALL XCHG 0D DELAY1 4122 4123 4124 4127 13 23 CD EB INX INX CALL XCHG D H OUT 4128 7E MOV A. M 4129 D3 OUT 0E Department of Electrical and Electronics Engineering .DATA_ E OUT 4107 11 LXI 410A 410D CD EB CALL XCHG 410E 7E MOV A. M 4136 4138 4139 D3 23 7E OUT INX MOV 0E H A. M 4143 4145 4146 D3 23 7E OUT INX MOV 0E H A. B 415A B1 ORA C 415B 415E 415F C2 2B 7D JNZ DCX MOV LOOP H A.001F 4155 01 LXI B.VEC Call DELAY address Exchange content of HL with DE pair Increment D register Increment H register Call specified address Exchange content of HL with DE pair Move M content to accumulator Load port C into output port Increment H register Move M content to accumulator Load port A into output port Call DELAY address Jump to specified address Move M content to accumulator Load port C into output port Increment H register Move M content to accumulator Load port B into output port Increment H register Move M content to accumulator Load port A into output port Call DELAY address Return to accumulator Push the register H Load 00 1F in HL register pair Load FF FF in DE register pair Decrement B register Move B content to accumulator OR content of C with accumulator Jump to LOOP if no zero Decrement H register Move L content to accumulator . M 413A 413C 413F 4142 D3 CD C3 7E OUT CALL JMP MOV 0C DELAY1 REPEAT A. M 414B 414D 4150 4151 4152 D3 CD C9 E5 21 OUT CALL RET PUSH LXI 0C DELAY H H.FFFF 4158 4159 0B 78 DCX MOV B A. M 4147 4149 414A D3 23 7E OUT INX MOV 0D H A. L OUT DELAY Department of Electrical and Electronics Engineering .EE6612 – Microprocessors and Microcontrollers Laboratory 412B 412E CD EB CALL XCHG DELAY1 412F 4130 4131 4134 13 23 CD EB INX INX CALL XCHG D H OUT 4135 7E MOV A. Department of Electrical and Electronics Engineering . B 416F B1 ORA C 4170 4173 4174 C2 2B 7D JNZ DCX MOV LOOP2 H A. L 4175 B4 ORA H 4176 4179 417A 417B C2 E1 C9 12 27 44 10 2B 92 10 9D 84 48 2E 84 48 4B 20 49 04 JNZ POP RET L2 H 4187 ORA JNZ POP RET DELAY1 PUSH LXI H L1 H OR content of H with accumulator Jump to L1 if no zero Pop the register H Return from subroutine H H.FFFF 416D 416E 0B 78 DCX MOV B A.001F Push the register H Load 00 1F in HL register pair Load FF FF in DE register pair Decrement B register Move B content to accumulator OR content of C with accumulator Jump to LOOP2 if no zero Decrement H register Move L content to accumulator OR content of H with accumulator Jump to L2 if no zero Pop the register H Return to subroutine DATA SEQ DB DATA_E RESULT: Thus an assembly language program to simulate the traffic light at an intersection using a traffic light interfaces was written and implemented.EE6612 – Microprocessors and Microcontrollers Laboratory 4160 B4 4161 4164 4165 4166 4167 C2 E1 C9 E5 21 416A 01 LXI B.VEC . No:7 INTERFACING 8251 WITH 8085 AIM: To write a program to initiate 8251 and to check the transmission and reception of character. The USART accepts data characters from the CPU in parallel format and the converts them in a continuous serial data stream of transmission. it can receive serial data streams and convert them into parallel data characters for the CPU. the 8251 can be operated in synchronous mode. 8 bit data No parity Baud rate factor (16X) 1 stop bit Gives a mode command word of 01001110=4E(X) Department of Electrical and Electronics Engineering . The CPU can read the status of USART at any time. character length.words should be written in to the control register of 8251. Prior to starting data transmission or reception. MODE INSTRUCTION WORD This format defines the BAUD rate.EE6612 – Microprocessors and Microcontrollers Laboratory EX.Thesecontrol words are split into two formats. These include data transmissions errors and control signals. APPARATUS REQUIRED: 1. Control words should be written in to the control register of 8251. 8085 Microprocessor kit 2. MODE INSTRUCTION WORD 2. By selecting the appropriate BAUD factor synchronous mode. the 8251 must be loaded with a set of control words generated by the CPU. Simultaneously. 1. 1. DC regulated power supply THEORY: The 8251 is used as a peripheral device for serial communication and is programmed by the CPU to operate using virtually any serial data transmission technique. 8251 Interface board 3. These control signals define the complete functional definition of the 8251 and must immediately follow a RESET operation. Initializing 8251 using the Mode instructions to the following conditions.VEC . Words should be written in to the control register of 8251. COMMAND INSTRUCTION WORD. parity and stop bits required to work with asynchronous data communication. 4E C2 4113 4115 MVI OUT A. Output it to port address C0. 41 C0 411B 4200 RST1 IN C0 4202 STA 4150 4205 RST1 COMMENT Move 36 to A Output contents of accumulator to CE port Move 0A to accumulator Output contents of accumulator to C8 port Move 00 to accumulator Output contents of accumulator to C8 port Store 4200 address in HL register pair Move 4E to accumulator Output contents of accumulator to C2 port Move 37 to accumulator Output contents of accumulator to C2 port Move 41 to accumulator Output contents of accumulator to C0 port Input the contents from port C0 to accumulator Store the output from accumulator to 4150 Department of Electrical and Electronics Engineering . 37 C2 4117 4119 MVI OUT A. 4200 410F 4111 MVI OUT A. 0A C8 4108 410A MVI OUT A. Store the value in memory 11. 36 CE 4104 4106 MVI OUT A. Reset the system 9. Initialize timer (8253) IC 2. Get the data through input port address C0. 7. 3. Move the command instruction word (37H) to A reg. 5. Output it to port address C2 6. Move the Mode command word (4EH) to A reg. 00 C8 410C LXI H. Move the data to be transfer to A reg.EE6612 – Microprocessors and Microcontrollers Laboratory ALGORITHM 1. 10. Output it port address C2 4.VEC . Reset the system PROGRAM: ADDRESS OPC ODE LAB EL MNEM ONICS OPERA ND 4100 4102 MVI OUT A. 8. Sysdetect is an output SINGLE CHARACTER SYNC 1-Single sync character 0.Double sync character Department of Electrical and Electronics Engineering .VEC .EE6612 – Microprocessors and Microcontrollers Laboratory SYNCHRONOUS MODE: S2 S1 EP PEN L2 L1 B2 B1 0 1 0 1 0 0 1 1 5 BIT 6 BIT 7 BIT 8 BIT PARITY ENABLE 1-Enable 0-Disable EVEN PARITY GENERATION 0-Odd 1-Even EXTERNAL SYNC DETECT 1-Sysdetect is an input 0. EE6612 – Microprocessors and Microcontrollers Laboratory ASYNCHRONOUS MODE: S2 S1 EP PEN L2 L1 B2 B1 0 1 0 1 0 0 1 1 Synch mode (1 X) (16 X) (64 X) 0 1 0 1 0 0 1 1 5 BIT 6 BIT 7 BIT 8 BIT PARITY ENABLE 1-Enable 0-Disable EVEN PARITY GENERATION 0-Odd 1-Even 0 1 0 1 0 0 1 1 Invalid 61BIT 1.5BIT 2 BIT Department of Electrical and Electronics Engineering .VEC . EE6612 – Microprocessors and Microcontrollers Laboratory OBSERVATION: MEMORY LOCATION INPUT DATA OUTPUT DATA RESULT: Thus the program to initiate 8251 was written and the transmission and reception of character was checked by interfacing 8251 with 8085.VEC . Department of Electrical and Electronics Engineering . 2. 4130 4103 MVI D.C. PROGRAM: ADDRESS LABEL MNEMON ICS OPERAN D COMMENT START LXI H. Regulated D. 8279 Interface board 3. 0F Store the 16 bit address in HL pair Move 0F to D register 4105 MVI A. 8 INTERFACING 8279 WITH 8085 AIM: To interface 8279 Programmable Keyboard Display Controller to 8085 Microprocessor. 10 Move 10 to A 4107 OUT C2 Output the contents of A to C2 output port 4109 MVI A. 8085 Microprocessor toolkit.VEC Output the contents of A to C2 output port Move content of M to A . power supply.EE6612 – Microprocessors and Microcontrollers Laboratory Ex No. APPARATUS REQUIRED: 1. M 4112 OUT C0 4114 CALL DELAY Output the contents of M to A Call the delay address 4117 INX H Increment H register 4118 DCR D Decrement D register 4119 JNZ LOOP Jump to specified address 4100 4111 OPCO DE LOOP Department of Electrical and Electronics Engineering . CC Move CC to A 410B OUT C2 410D MVI A. 90 Output the contents of A to C2 output port Move 90 to A 410F OUT C2 MOV A. FF Move FF to C register 4123 LOOP2 DCR C Decrement C register 4124 JNZ LOOP 1 Jump to LOOP 1 if no zero 4127 DCR B Decrement B register 4128 JNZ LOOP 2 Jump to LOOP 2 if no zero 412B RET Pointer equal to 4130 . A0 Move a to B register 4121 LOOP1 MVI C.FF repeated eight times 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 413ª 413B 413C 413D 413E 413F FF FF FF FF FF FF FF FF 98 68 7C C8 1C 29 FF FF SEGMENT DEFINITION: Department of Electrical and Electronics Engineering .EE6612 – Microprocessors and Microcontrollers Laboratory 411C JMP START START Jump to START address 411F DELAY MVI B.VEC . EE6612 – Microprocessors and Microcontrollers Laboratory DATA BUS D7 D6 D5 D4 D3 D2 D1 D0 SEGMETS d c b dp a g f e OBSERVATION: LETTER 7 SEGMENT DATA BUS HEXADECIMAL D7 D6 D5 D4 D3 D2 D1 D0 RESULT: Thus 8279 controller was interfaced with 8085 and program for rolling display was executed successfully. Department of Electrical and Electronics Engineering .VEC . EE6612 – Microprocessors and Microcontrollers Laboratory MICROCONTROLLER Department of Electrical and Electronics Engineering .VEC . Move first data from external memory to accumulator and save it in R1 register. Check for carry. Increment DPTR. a. 9. 3. multiply and divide the given data stored at two consecutive locations using 8051 microcontroller. move carry to accumulator and save it in external memory. Add the content of R1 register to accumulator. Move second data from external memory to accumulator 5. Increment DPTR and save the sum in external memory. Clear R0 register to account for carry. 7.No: 9 8051 – BASIC SIMPLE PROGRAM AIM: To write an assembly language program to add. 6. Increment DPTR.VEC . 10. If carry is not set go to step 8. subtract. Stop Department of Electrical and Electronics Engineering . Otherwise go to next step. ADDITION OF TWO 8 BIT NUMBERS Algorithm: 1. Set DPTR as pointer for data. 8. Increment R0 register. 11.EE6612 – Microprocessors and Microcontrollers Laboratory Ex. 4. 2. EE6612 – Microprocessors and Microcontrollers Laboratory Start LOAD THE ADDRESS IN DPTR MOVE THE 1ST DATA TO A – REG AND SAVE IT IN R1 REG INCREMENT DPTR AND MOVE THE 2ND DATA TO A – REG CLEAR R0 REGISTER ADD A – REG WITH R1 REG TO GET SUM If CY=1 Yes INCREMENT R0 REG No INCREMENT DPTR AND SAVE A – REG CONTENT IN MEMORY INCREMENT DPTR MOVE R0 TO A – REG AND THEN SAVE A – REG CONTENT IN MEMORY Stop Department of Electrical and Electronics Engineering .VEC . R0 Move carry to A reg MOVX A.#00 Clear R0 for the account of carry ADD A.@DPTR Load the 2nd data in A MOV R0.@DPTR Move the 1st data to A MOV R1.@DPTR Save the sum in external memory INC DPTR Increment DPTR MOV A.R1 Get the sum in A reg JNC AHEAD Check carry flag INC R0 If carry is set increment R0 INC DPTR Increment DPTR MOVX A.#4500 Load address of 1st data in DPTR MOVX A.A Save the first data in R1 INC DPTR Increment DPTR to point 2nd data MOVX A.EE6612 – Microprocessors and Microcontrollers Laboratory Label AHEAD: HERE: Program Comments MOV DPTR.@DPTR Save the carry in external memory SJMP HERE Remain idle in infinite loop Observation: Input: 4500: 4501: [Addend] [Augend] Output: 4502: 4503: [Sum] [Carry] Department of Electrical and Electronics Engineering .VEC . EE6612 – Microprocessors and Microcontrollers Laboratory Start LOAD THE ADDRESS IN DPTR MOVE THE MINUEND TO A – REG AND SAVE IT IN R1 REG INCREMENT DPTR AND MOVE THE SUBTRAHEND TO A – REG EXCHANGE R1 WITH A ‐ REG CLEAR R0 REGISTER AND CARRY FLAG SUBTRACT R1 FROM A ‐ REG If Cy=1 Yes COMPLEMENT A AND THEN INCREMENT INCREMENT R0 REG No INCREMENT DPTR AND SAVE A – REG CONTENT (DIFFERENCE) IN MEMORY INCREMENT DPTR MOVE R0 TO A – REG AND THEN SAVE A – REG CONTENT (SIGN) IN MEMORY Stop Department of Electrical and Electronics Engineering .VEC . 14. Otherwise go to next step. 13. 8. Clear R0 register to account for sign. 2. 10. If carry is not set go to step 12. 9. Check for carry. Stop Department of Electrical and Electronics Engineering . Move subtrahend from external memory to accumulator Exchange the contents of R1 and A such that minuend is in A and subtrahend is in R1 6. 4.VEC .EE6612 – Microprocessors and Microcontrollers Laboratory b. 12. move R0 (sign bit) to accumulator and then save it in external memory. SUBTRACTION OF TWO 8 BIT NUMBERS Algorithm: 1. Increment DPTR. Move the minuend from external memory to accumulator and save it in R1 register. Clear carry flag. 3. Increment R0 register. 7. 5. Complement the content of A – reg and increment by 1 to get 2’s complement of result in A – reg 11. Subtract the content of R1 register from accumulator. Increment DPTR. Set DPTR as pointer for data. Increment DPTR and save the result in external memory. #00 Clear R0 for the account of Sign CLR C Clear carry SUBB A. If carry is set then CPL A Get 2’s complement of result in A INC A AHEAD: HERE: INC R0 Set R0 to indicate negative sign INC DPTR Increment DPTR MOVX A.@DPTR Load the subtrahend in A XCH A.R1 Get minuend in A and Subtrahend in R1 MOV R0.R0 Move sign bit to A reg MOVX A.VEC .EE6612 – Microprocessors and Microcontrollers Laboratory Label Program Comments MOV DPTR.#4500 Load address of minuend in DPTR MOVX A.@DPTR Save the sign in external memory SJMP HERE Remain idle in infinite loop Observation: Input: 4500: 4501: Output: 4502: 4503: [Minuend] [Subtrahend] [Difference] [Sign Bit] Department of Electrical and Electronics Engineering .R1 Subtract R1 from A JNC AHEAD Check Carry flag.@DPTR Move the minuend to A MOV R1.A Save the minuend in R1 INC DPTR Increment DPTR to point subtrahend MOVX A.@DPTR Save the result in external memory INC DPTR Increment DPTR MOV A. EE6612 – Microprocessors and Microcontrollers Laboratory Start LOAD THE ADDRESS IN DPTR MOVE THE 1ST DATA TO A – REG AND SAVE IT IN B REG INCREMENT DPTR AND MOVE THE 2ND DATA TO A – REG MULTIPLY A AND B INCREMENT DPTR SAVE A – REG CONTENT (LOWER BYTE OF PRODUCT) IN MEMORY INCREMENT DPTR MOVE B (HIGHER BYTE OF PRODUCT) TO A – REG AND THEN SAVE A – REG CONTENT IN MEMORY Stop Department of Electrical and Electronics Engineering .VEC . Increment DPTR and move second data from external memory to B. 4. move B ( lower byte of product) to A and save it in memory Stop Program Comments MOV DPTR.#4500 Load address of 1st data in DPTR MOVX A.@DPTR Load the 2nd data in A MUL AB Get the product in A and B INC DPTR Increment DPTR MOVX A. Label HERE: Load address of data in DPTR Move the first data from external memory to A and save in B. 3.@DPTR Move the 1st data to A MOV B. 7.@DPTR Save the lower byte of result in external memory INC DPTR Increment DPTR MOV A. 5.@DPTR Save it in external memory SJMP HERE Remain idle in infinite loop Department of Electrical and Electronics Engineering .B Move the higher byte of product to A reg MOVX A. 2.VEC . MULTIPLICATION OF TWO 8 BIT NUMBERS Algorithm: 1. Perform multiplication to get the product in A and B.A Save the 1st data in B INC DPTR Increment DPTR to point 2nd data MOVX A. Increment DPTR and save A ( lower byte of product) in memory Increment DPTR .EE6612 – Microprocessors and Microcontrollers Laboratory c. 6. VEC .EE6612 – Microprocessors and Microcontrollers Laboratory Observation Input: 4500: 4501: [1st data] [2nd data] Output: 4502: 4503: [Lower byte of product] [Higher byte of product] Department of Electrical and Electronics Engineering . VEC .EE6612 – Microprocessors and Microcontrollers Laboratory Start LOAD THE ADDRESS IN DPTR LOAD THE DIVIDEND TO A – REG AND SAVE IT IN R0 REG INCREMENT DPTR LOAD THE DIVISOR IN A – REG AND SAVE IT IN B ‐ REG MOVE THE DIVIDEND FROM R0 TO A ‐ REG DIVIDE A – REG CONTENT BY B – REG INCREMENT DPTR SAVE A – REG CONTENT (QUOTIENT) IN MEMORY INCREMENT DPTR MOVE B (REMAINDER) TO A – REG AND THEN SAVE A – REG CONTENT IN MEMORY Stop Department of Electrical and Electronics Engineering . R0 Move the dividend to A DIV AB Divide the content of A by B INC DPTR Increment DPTR MOVX A. Load address of data in DPTR 2.@DPTR Save the quotient in external memory INC DPTR Increment DPTR MOV A. Stop Label HERE: Program Comments MOV DPTR. Move the remainder (Content of B – reg) to A and save in memory. 9. Increment DPTR and move the divisor from external memory to A and save it in B reg. 5. Move the dividend from R0 to A. 4.#4500 Load address of dividend in DPTR MOVX A. Increment DPTR.@DPTR Save it in external memory SJMP HERE Remain idle in infinite loop Department of Electrical and Electronics Engineering . Move the dividend from external memory to A and save it in R0 register.@DPTR Move the dividend to A MOV R0. 8.A Move the divisor to B MOV A.A Save the dividend in R0 INC DPTR Increment DPTR to point divisor MOVX A.EE6612 – Microprocessors and Microcontrollers Laboratory d.reg) in memory 7. 6.VEC . Increment DPTR and save quotient (content of A .B Move the remainder to A reg MOVX A.@DPTR Load the divisor in A MOV B. 3. DIVISION OF TWO 8 BIT NUMBERS Algorithm: 1. Perform division to get quotient in A and remainder in B. multiplication and division of two numbers were performed using the 8051 microcontroller.EE6612 – Microprocessors and Microcontrollers Laboratory Observation: Input: 4500: 4501: [Dividend] [Divisor] Output: 4502: 4503: [Quotient] [Remainder] Result: Thus the addition. Department of Electrical and Electronics Engineering . subtraction.VEC . EE6612 – Microprocessors and Microcontrollers Laboratory Ex N0. 10a SUM OF ELEMENTS IN AN ARRAY AIM: To find the sum of elements in an array. continue 7. Department of Electrical and Electronics Engineering . Otherwise increment the memory pointer by 1 and go to step 4. Add the register with the accumulator. Load the total number of elements in a separate register as a counter.VEC . ALGORITHM: 1. 4. otherwise. Check for carry. 5. increment the carry register by 1. stop. Load the array in the consecutive memory location and initialize the memory pointer with the starting address. if exist. Load the other register with the value of the memory pointer. 3. Clear the accumulator. Decrement the counter and if it reaches 0. 2. 6. Clear B.VEC . R1 and CY [A] Å [DPTR] [R0] Å [A] [A] Å [DPTR+1] [A] Å [A] +[B] [A] Å [B] No Is Cy=1 Yes [R1]Å [R1]+1 [R0] Å [R0]-1 IS [R0] = 0? No Yes [4500] Å [A] Å [B] [4501] Å[A] Å [R1] STOP Department of Electrical and Electronics Engineering .EE6612 – Microprocessors and Microcontrollers Laboratory START [DPTR] Å [4200H]. A INC DPTR MOV A. R1 MOVX @DPTR.AGAIN Decrement size of array.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: Label Program Comments MOV DPTR. @DPTR Copy array size value to A MOV R0. #4500 Store the result in 4500 memory locations MOV A. R1 & Carry Flag INC DPTR Get value from data pointer MOVX A. B Sum of two numbers MOV B. #4200 Load 4200 to DPTR. A NC JNC NC If no carry jump to NC INC R1 Else increment R1 DJNZ R0. @DPTR ADD A.VEC . B AGAIN CLR C Clear B. A Move contents of A to R0 MOV B. #00 MOV R1. B MOVX @DPTR. A HERE SJMP HERE Department of Electrical and Electronics Engineering . get array size MOVX A. if not zero fetch data from DPTR and add to the resultant value MOV DPTR. VEC .EE6612 – Microprocessors and Microcontrollers Laboratory OBSERVATION: INPUT 4200 OUTPUT 4500 4201 4202 4203 4501 RESULT: The sum of elements in an array is calculated. Department of Electrical and Electronics Engineering . Start 2. No 10(b) 8051 – Check Odd or Even using Call Option AIM: To Check whether given number is Odd or Even using Call Option. Halt Check Function 8. ALGORITHM: 1. Rotate right through carry 9. return Department of Electrical and Electronics Engineering . Call check function whether given number is odd or even 5.EE6612 – Microprocessors and Microcontrollers Laboratory Exp. Else copy EE to B reg (even number) 11. If carry copy 00 to B reg (odd number) 10.VEC . Move the data to DPTR 3. Increment DPTR 6. Move the data to accumulator 4. Resultant value stored in DPTR-4201 7. VEC .EE6612 – Microprocessors and Microcontrollers Laboratory START [DPTR] Å [4200H] [A] Å [DPTR] Check Even & odd [DPTR] Å [DPTR] +1 [A] Å [B] [DPTR] Å [A] STOP Check Even & odd Rotate the A right through carry Yes Is CY=1 No [B]Å EEH. for even [B]Å 00H. for odd Return Department of Electrical and Electronics Engineering . get a number MOVX A.#0EEH Else copy EE to B reg (even number) MOV B.B HERE MOVX @DPTR.#00H RET OBSERVATION: INPUT 4200 OUTPUT 4201 RESULT: Thus the given number is either even or odd has been found using 8051 microcontroller.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: Label Program Comments MOV DPTR. Department of Electrical and Electronics Engineering .VEC . A Resultant value stored in DPTR-4201 SJMP HERE CHECK_EV_OD RRC A L1 Rotate right through carry JC L1 If carry copy 00 to B reg (odd number) MOV B. @DPTR Copy value to A CALL CHECK_EV_OD Call check function whether given number is odd or even INC DPTR MOV A. #4200 Load 4200 to DPTR. 6. Send the start conversion pulse. The program is executed for various values of analog voltage which are set with the help of a potentiometer. THEORY: An ADC usually has two additional control lines: the SOC input to tell the ADC when to start the conversion and the EOC output to announce when the conversion is complete. ALGORITHM: 1. Department of Electrical and Electronics Engineering . Store it in a memory location.EE6612 – Microprocessors and Microcontrollers Laboratory 11 INTERFACING A/D & D/A CONVERTER WITH 8051 a.NO 1 2 3 ITEM Microcontroller kit Power supply ADC Interface board SPECIFICATION 8051.Vi Microsystems +5 V dc Vi Microsystems QUANTITY 1 1 1 PROBLEM STATEMENT: To program starts from memory location 4100H. 5. 4. The LED display is verified with the digital value that is stored in the memory location 4150H. Select the channel and latch the address. 3. It also instructs the processor to store the converted digital data at RAM 4200H. If EOC =1 continue else go to step (3) Read the digital output. 2. Read EOC signal. The following program initiates the conversion process. ADC INTERFACING WITH 8051 APPARATUS REQUIRED: SL. checks the EOC pin of ADC 0419 as to whether the conversion is over and then inputs the data to the processor.VEC . #4150 Store the data in memory location MOVX @DPTR.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: Label Program Comments MOV DPTR.#00 SOC signal low MOVX @DPTR. #FFC8 MOV A. A HERE SJMP HERE Department of Electrical and Electronics Engineering . A MOV DPTR.VEC . A MOV A.@DPTR MOV DPTR. A MOV A.WAIT Check for EOC MOV DPTR. A MOV DPTR.#10 Select Channel 0 and make ALE Low MOVX @DPTR.@DPTR JNB E0.#FFC0 Read ADC data MOVX A. #FFD0 MOV A. #FFD8 WAIT MOVX A.#01 SOC signal High MOVX @DPTR.#18 make ALE High MOVX @DPTR. EE6612 – Microprocessors and Microcontrollers Laboratory ADC.CIRCUIT: SOC JUMPER SELECTION: J2: SOC Jumper selection Department of Electrical and Electronics Engineering .VEC . VEC IN .EE6612 – Microprocessors and Microcontrollers Laboratory J5: Channel selection OBSERVATION ANALOG VOLTAGE DIGITAL DATA LED DISPLAY ON HEX CODE LOCATION 4150 Department of Electrical and Electronics Engineering . 4.NO 1 2 3 ITEM Microprocessor kit Power supply DAC Interface board SPECIFICATION 4185. saw tooth wave etc by means of software. Repeat steps 2 to 5.Vi Microsystems +5 V dc Vi Microsystems QUANTITY 1 1 1 THEORY: SOFTWARE EXAMPLES After going through the software examples you can learn how to control the DAC using 8051 and generate sine wave. 2. Department of Electrical and Electronics Engineering .EE6612 – Microprocessors and Microcontrollers Laboratory (b) INTERFACING D/A CONVERTER WITH 8051 APPARATUS REQUIRED: SL.VEC . Load the final value (FF) to accumulator and move it to DAC. Load the initial value (00) to Accumulator and move it to DAC. 5. Call the delay program. ALGORITHM: (a) SQUARE WAVE GENERATION: 1. Call the delay program 3. EE6612 – Microprocessors and Microcontrollers Laboratory DAC .CIRCUIT: WAVEFORMS: Department of Electrical and Electronics Engineering .VEC . with FF (Hex) as input. Output digital data from 00 to FF constant steps of 01 to DAC1 repeat this sequence again and again.LOOP RET SJMP START Execute the program and using a CRO. ADDRESS LABEL MNEMON ICS OPCODE OPERAND COMMENT MOV DPTR. Similarly.#05 LOO[P MOV R2. 4. by varying the time delay.#FF DJNZ R2. results in a square wave of amplitude I5 Volts. Load the initial value (00) to Accumulator 2. Move the accumulator content to DAC.EE6612 – Microprocessors and Microcontrollers Laboratory OBSERVATION: WAVE FORMS Square waveform Saw tooth waveform Triangular waveform AMPLITUDE TIME PERIOD PROGRAM: The basic idea behind the generation of waveforms is the continuous generation of Analog output of DAC. With 00(HEX) as input to DAC2.#FFC8 START MOV A. to DAC2. the analog output is -5V.HERE DJNZ R1. As a result a saw – tooth wave will be generated at DAC1 output.# FF MOVX @DPTR.VEC .A LCALL DELAY MOV A.#00 MOVX @DPTR.A LCALL DELAY LJMP START DELAY MOV R1. Outputting digital data 00 and FF at regular intervals. Department of Electrical and Electronics Engineering . Repeat steps 3 and 4. 3. verify that the waveform at the DAC2 output is a square-wave. (b) SAW TOOTH GENERATION 1. Increment the accumulator content by 1. the output is +5V. Modify the frequency of the square-wave. Else go to step 3.A DEC A JNZ LOOP2 LJMP START OPCODE OPERAND OBSERVATION: WAVE FORMS Square waveform Saw tooth waveform Triangular waveform AMPLITUDE TIME PERIOD Department of Electrical and Electronics Engineering .#FFC8 MOV A.#00 MOVX @DPTR. Load the initial value (00) to Accumulator. 6. The following program will generate a triangular wave at DAC2 output.#FFC0 MOV A. Load value (FF) to accumulator. Decrement the accumulator content by 1.A INC A JNZ LOOP1 MOV A. The program is self explanatory.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM: ADDRESS LABEL LOOP MNEMON ICS MOV DPTR.A INC A SJMP LOOP OPCODE OPERAND COMMENT (c) TRIANGULAR WAVE GENERATION 1. If accumulator content is zero proceed to next step. ADDRESS LABEL START LOOP1 LOOP2 MNEMON ICS MOV DPTR. Else go to step 2. 5. 4. Increment the accumulator content by 1. Move the accumulator content to DAC. 2. Move the accumulator content to DAC 3. 7. If accumulator content is zero go to step 2. 8.#00 MOVX @DPTR.#FF MOVX @DPTR.VEC COMMENT . EE6612 – Microprocessors and Microcontrollers Laboratory Result: Thus the square, triangular and saw tooth wave form were generated by interfacing DAC with 8051 trainer kit. Department of Electrical and Electronics Engineering - VEC EE6612 – Microprocessors and Microcontrollers Laboratory Ex.No:15 INTERFACING 8253 TIMER WITH 8085 AIM: To interface 8253 Interface board to 8085 microprocessor to demonstrate the generation of square wave. APPARATUS REQUIRED: 1. 8085 microprocessor kit 2. 8253 Interface board 3. DC regulated power supply 4. CRO. . PROGRAM: Address 4100 4102 4104 4106 4108 410A 410C Opcodes 3E 36 D3 CE 3E 0A D3 C8 3E 00 D3 C8 76 Label Mnemonic Operands START: MVI A, 36 OUT CE MVI A, 0A OUT C8 MVI A, 00 OUT C8 HLT Comments Channel 0 in mode 3 Send Mode Control word LSB of count Write count to register MSB of count Write count to register Set the jumper, so that the clock 0 of 8253 is given a square wave of frequency 1.5 MHz. This program divides this PCLK by 10 and thus the output at channel 0 is 150 KHz. Vary the frequency by varying the count. Here the maximum count is FFFF H. So, the square wave will remain high for 7FFF H counts and remain low for 7FFF H counts. Thus with the input clock frequency of 1.5 MHz, which corresponds to a period of 0.067 microseconds, the resulting square wave has an ON time of 0.02184 microseconds and an OFF time of 0.02184 microseconds. To increase the time period of square wave, set the jumpers such that CLK2 of 8253 is connected to OUT 0. Using the above-mentioned program, output a square wave of frequency 150 KHz at channel 0. Now this is the clock to channel 2. Department of Electrical and Electronics Engineering - VEC EE6612 – Microprocessors and Microcontrollers Laboratory CONTROL WORD: SC1 SC2 RW1 RW0 M2 M1 M0 BCD SC-SELECT COUNTER: SC1 SC0 SELECT COUNTER 0 0 Select counter 0 0 1 Select counter 1 1 0 Select counter 2 1 1 Read back command M-MODE: M2 0 0 X X 1 1 M1 0 0 1 1 0 0 M0 0 1 0 1 0 1 MODE Mode 0 Mode 1 Mode 2 Mode 3 Mode 4 Mode 5 READ/WRITE: RW1 RW0 0 0 Counter latch command 0 1 R/W least significant bit only 1 0 R/W most significant bit only 1 1 R/W least sig first and most sig byte Department of Electrical and Electronics Engineering - VEC EE6612 – Microprocessors and Microcontrollers Laboratory BCD: 0 Binary counter 16-bit 1 Binary coded decimal counter Result: Thus the 8253 has been interfaced to 8085 μp and with different modes of 8253 have been studied. Department of Electrical and Electronics Engineering .VEC . the interface circuitry that generates the driving pulses use silicon Darlington pair transistors. B1. disk drives.EE6612 – Microprocessors and Microcontrollers Laboratory Ex. The rotary motion occurs in a step-wise manner from one equilibrium position to the next. etc. The excitation of any one winding generates a North Pole. A2. The switching scheme is shown in the table given below. The Stepper Motor windings A1. This scheme produces more torque. A2. Therefore. THEORY: A motor in which the rotor is able to assume only discrete stationary angular position is a stepper motor.VEC . B2. Stepper Motors are used very wisely in position control systems like printers. The inputs for the interface circuit are TTL pulses generated under software control using the Microcontroller Kit.The 74175 latches the data bus to the stepper motor driving circuitry. process control machine tools. Department of Electrical and Electronics Engineering . It is a permanent magnet with one face as South Pole and the other as North Pole. By reversing the phase sequence as A1. The basic two-phase stepper motor consists of two pairs of stator poles. ANTICLOCKWISE STEP A1 A2 B1 1 2 3 4 1 0 0 1 0 1 1 0 0 0 1 1 B2 DATA 1 1 0 0 9h 5h 6h Ah CLOCKWISE STEP A1 A2 1 2 3 4 1 0 0 1 0 1 1 0 B1 B2 DATA 1 1 0 0 0 0 1 1 Ah 6h 5h 9h ADDRESS DECODING LOGIC: The 74138 chip is used for generating the address decoding logic to generate the device select pulses. A South Pole gets induced at the diametrically opposite side. CS1 & CS2 for selecting the IC 74175. The TTL levels of pulse sequence from the data bus are translated to high voltage output pulses using a buffer 7407 with open collector. 2-PHASE SWITCHING SCHEME: In this scheme. The rotor magnetic system has two end faces. anticlockwise stepping can be obtained.No:15 STEPPER MOTOR INTERFACING WITH 8051 AIM: To interface a stepper motor with 8051 microcontroller and operate it. Each of the four poles has its own winding. B1. any two adjacent stator windings are energized. B2 are cyclically excited with a DC current to run the motor in clockwise direction. Stepper Motor requires logic signals of relatively high power. EE6612 – Microprocessors and Microcontrollers Laboratory BLOCK DIAGRAM: 8051 MICROCONTROLLER 8255 DRIVER CIRCUIT REPRESENTATION: Department of Electrical and Electronics Engineering .VEC STEPPER MOTOR . #0FFh DJNZ R5. DELAY DPL DPH DPTR 411B DJNZ R0. #04 A.EE6612 – Microprocessors and Microcontrollers Laboratory PROGRAM : Address OPCODES Label MNEM ONICS ORG 4100 START MOV 4103 4105 LOOP: OPERAND 4100h DPTR. A 410E 4110 MOV MOV R4. LOOP 411D SJMP START 4112 411F DELA Y: DELA Y1: TABLE DB : Comments 09 05 06 0Ah Department of Electrical and Electronics Engineering . #0FFh R5. #0FFC0h 410D MOVX @DPTR. @DPTR 4106 4108 410A PUSH PUSH MOV DPH DPL DPTR. if not zero repeat the loop Short jump to Start of the program to make the motor rotate continuously Values as per twophase switching scheme .VEC Load the start address of switching scheme data TABLE into Data Pointer (DPTR) Load the count in R0 Load the number in TABLE into A Push DPTR value to Stack Load the Motor port address into DPTR Send the value in A to stepper Motor port address Delay loop to cause a specific amount of time delay before next data item is sent to the Motor POP back DPTR value from Stack Increment DPTR to point to next item in the table Decrement R0. #TABLE MOV MOVX R0. DELAY1 4114 4116 4118 411A DJNZ POP POP INC R4. RESULT: Thus a stepper motor was interfaced with 8051 and run in forward and reverse directions at various speeds. Enter the above program starting from location 4100. 4. 3. Entering the data in the look-up TABLE in the reverse order can vary direction of rotation.and execute the same.VEC . The stepper motor rotates. 2. Varying the count at R4 and R5 can vary the speed. Department of Electrical and Electronics Engineering .EE6612 – Microprocessors and Microcontrollers Laboratory PROCEDURE: 1.
Report "EE6612-Miroprocessor and Microcontroller Laboratory.pdf"