Microprocessor Lab Manual - Final
Microprocessor Lab Manual - Final
Lab Manual
Of
Microprocessor and Microcontroller
Lab
1
Do’s
• Be punctual.
Don’ts
3
Sl. Name of the Experiment Page No.
No
4
Experiment 1
Brief Introduction of 8085 Microprocessor and its Trainer Kit.
5
• RD − This signal indicates that the selected IO or memory device is to be read and is
ready for accepting data available on the data bus.
• WR − This signal indicates that the data on the data bus is to be written into a selected
memory or IO location.
• ALE − It is a positive going pulse generated when a new operation is started by the
microprocessor. When the pulse goes high, it indicates address. When the pulse goes
down it indicates data.
Three status signals are IO/M, S0 & S1:-
IO/M - This signal is used to differentiate between IO and Memory Operations, i.e.,
when it is high indicates IO operation and when it is low then it indicates memory
operation.
S1 & S0: These signals are used to identify the type of current operation.
Power supply: There are 2 power supply signals − VCC & VSS. VCC indicates +5v
Power supply and VSS indicates ground signal.
Clock signals: There are 3 clock signals, i.e. X1, X2, CLK OUT.
• X1, X2 − A crystal (RC, LC N/W) is connected at these two pins and is used to set
frequency of the internal clock generator. This frequency is internally divided by 2 .
• CLK OUT − This signal is used as the system clock for devices connected with the
microprocessor.
• Interrupts & externally initiated signals: Interrupts are the signals generated by
external devices to request the microprocessor to perform a task. There are 5 interrupt
signals, i.e., TRAP, RST 7.5, RST 6.5, RST 5.5, and INTR.
• INTA − It is an interrupt acknowledgment signal.
• RESET IN − This signal is used to reset the microprocessor by setting the program
counter to zero.
• RESET OUT − This signal is used to reset all the connected devices when the
microprocessor is reset.
• READY − This signal indicates that the device is ready to send or receive data. If
READY is low, then the CPU has to wait for READY to go high.
• HOLD − this signal indicates that another master is requesting the use of the address
and data buses.
6
• HLDA (HOLD Acknowledge) − It indicates that the CPU has received the HOLD
request and it will relinquish the bus in the next clock cycle. HLDA is set to low after the
HOLD signal is removed.
• Serial I/O signals: There are 2 serial signals, i.e., SID and SOD and these signals are
used for serial communication.
• SOD (Serial output data line) – The output SOD is set/reset as specified by the SIM
instruction.
• SID (Serial input data line) – The data on this line is loaded into accumulator
whenever a RIM instruction is executed.
Architecture of 8085 Microprocessor:
1. General purpose register: It is an 8 bit register i.e. B, C, D, E, H, L. The combination
of 8 bit register is known as register pair, which can hold 16 bit data. The HL pair is
used to act as memory pointer is accessible to program.
2. Accumulator: It is an 8 bit register which hold one of the
Data to be processed by ALU and stored the result of the operation.
3. Program counter (PC): It is a 16 bit pointer which maintain the address of a
byte entered to line stack.
4. Stack pointer (SP): It is a 16 bit special purpose register which is used to hold line
memory address for line next instruction to be executed.
5. Arithmetic and logical unit: It carries out arithmetic and logical operation by 8 bit
address it uses the accumulator content as input the ALU result is stored back into
accumulator.
6. Temporary register: It is an 8 bit register associated with ALU hold data,
entering an operation, used by the microprocessor and not accessible to
programs.
7. Flags: Flag register is a group of fire, individual flip flops line content of line flag
register will change after execution of arithmetic and logic operation.
7
8. Timing and control unit: Synchronous all microprocessor, operation
with the clock and generator and control signal from it necessary to
communicate between controller and peripherals.
9. Instruction registers and decoder: Instruction is fetched from line
memory and stored in line instruction register decoder the stored information.
10. Register Array: These are used to store 8-bit data during execution of some
instruction.
8
8279 (Keyboard and Display Controller)
8279 is a general-purpose programmable keyboard and display i/o interface device
designed for use with the 8085 microprocessor.it provides a scanned interface to 28
contact key matrix provided in VMC-850X and scanned interface for the six seven
segment display.8279 has got 16 X 8 display RAM which can be loaded or interrogated
by the CPU. When a key is pressed, its corresponding code is entered in the FIFO queue
of 8279 and can now be read by the microprocessor.
Display
VMC-850x provides 6 digits of seven segment display .Four digits are for displaying
the address of any location or name of any register, whereas the rest of the two digits are
meant for displaying the contents of a memory location or of a register. All the six digits
of the display ae n hexadecimal notation.
1. Enter the Starting address, press NEXT, the contents of the entered address is
displayed.
2. On pressing NEXT, one instruction is executed and the address of the next
instruction will be displayed with its data in the data field.
3. If one wants to terminate and command at any stage, one can do that using (.)
key, a’-‘is displayed in the address field.
Result:
Thus 8085 microprocessors were studied successfully.
10
Experiment No 2
Write an assembly language program to add, subtract, multiply and
divide two 8 bit numbers.
Objective:
1. To learn and understand the assembly instructions
2. To develop an 8085-assembly language program to add, sub,
Program:
Addition of two 8-bit number
Procedure: -
5. Type the Opcode of the program from starting to End by Pressing Next Key.
9. Press ‘REL EXMEM’ key then type the o/p address (i.e., 200B)
Accumulator Register B
11 12
11
Multiplication of two numbers
13
Experiment 3
Sorting of 10 numbers in ascending order
Address Data
8040 06
8041 06
8042 05
8043 04
8044 01
8045 02
8046 03
14
Steps of Experiment:
15
Program-
16
Address Labels Mnemonics Comments
17
Address Labels Mnemonics Comments
Address Data
8041 01
8042 02
8043 03
8044 04
8045 05
8046 06
Precautions:
1. Memory is set to be clear after the end of the program.
2. Memory should be interred carefully otherwise its shows program has some error or it
will interrupt the program differently and executed accordingly which cannot be
mitigated.
3. After editing the code, the assembly button must be preset before executing.
18
Experiment 4
Find the factorial of a given number and searching the smallest number in
a given array
Aim: To find the factorial of a given number and searching the smallest number in a
given array in 8085 microprocessors
19
Program:
Address Data
8000 06
8001 55
20
Address Data
8002 22
8003 44
8004 11
8005 33
8006 66
Step 1: Load the address of the first element of the array in HL pair
Step 2: Move the count to C
Step 3: Increment the pointer
Step 4: Get the first data in B
Step 5: Decrement the count
Step 6: Increment the pointer H
Step 7: Compare the content of memory addressed by HL pair with that of A
Step8: If carry = 1, go to step 10 or if Carry = 0 go to step 9.
Step9: Move the content of memory addressed by HL to A
Step10: Decrement the count
Step11: Check for Zero of the count. If ZF = 0, go to step 6, or if ZF = 1 go to next step
Step 12: Store the smallest data in memory.
Step 13: Terminate the program
21
22
Address Labels Mnemonics Remarks
F000 LXI H,8000H Point to get array size
F003 MOV C, M Get the size of array
F004 INX H Point to actual array
F005 MOV B, M Load the first number
into B
F006 DCR C Decrease C
F007 LOOP INX H Point to next location
F008 MOV A, M Get the next number
from memory to Acc
F009 CMP B Compare Acc and B
F00A JNC SKIP if B <= A, then skip
F00D MOV B, A If CY is 1, update B
F00E SKIP DCR C Decrease C
F00F JNZ LOOP When count is not 0,
go to LOOP
F012 LXI H,9000H Point to destination
address
F015 MOV M, B Store the minimum
number
F016 HLT Terminate the
program
Precautions:
23
Experiment 5
Find the sum of a series of numbers
Objective:
Input:
24
Flow Diagram:
25
Program:
26
Output:
Precautions:
1. Memory is set to be clear after the end of the program.
2. Memory should be interred carefully otherwise its shows program has some
error or it will interrupt the program differently and executed accordingly which
cannot be mitigated.
3. After editing the code, the assembly button must be preset before executing.
Conclusion: The program iterates over all the given (n number) and adds repeatedly. Thus, if
we conclude that time taken to perform one addition is constant, then time complexity of the
program is of O (n).
27
Experiment 6
Design and Implementation of 4 Bit Binary Counter Using 8051
Microcontroller
28
Circuit Diagram :
29
Steps of Experiment:
Step 1: Set any port as an output port. Here port 1 has been used and initialized
its value as FFH.
Step 2: Provide delay using internal timer or by making use of processing delay
during jump operations and decreasing general purpose register (GPR) values. To
increase delay nesting may be done.
Step 3: Put this calculated delay values in the GPR (here R0 and R1).
a) Put the calculated delay value in any GPR.
b) Decrease the GPR value.
c) Repeat step 3.b till the GPR value is 00H.
Step 4: Decrement the output port (port 1).
Step 5: Same as Step 3 to provide delay.
Step 6: Jump to Step 4 for continuous decrement.
30
Experiment 7
Implementation of Up/Down Counter Using Following Input
Specifications
(a). Two General Purpose I/O Pins as Control Inputs
(b). One Interrupt Pin as a Control Pin
Experiment 7 (a):
Circuit Diagram:
31
Steps of Experiment:
Step 1: Set P1 to input by putting data FFH and P2 as output by putting data 00H.
Step 2: Apply a nested loop delay using register R0 and R1.
Step 3: Check the content of P1.1 and P1.0 by ANDING P1 with 03H.
(a) If value is P1.1 is not set we jump to Step 5.
(b) Else we continue with Step 4.
Step 4: Decrease the content of output port P2 and jump to step 2.
Step 5: Check the content of P1.0.
a) If value of P1.0 is not set jump to Step 7
b) Else continue with Step 6.
Step 6: Increase content of output port P2 and jump to step 2.
Step 7: If none of the above condition is met we jump to step 2 from here
(no change in output port P2).
Program with Hex Codes:
Address Code Mnemonics Remarks
0000 75 90 FF MOV P1,#FF MOVE FF DATA TO P1
0003 75 A0 00 MOV P2,#00 MOVE 00 DATA TO P2
0006 AA A0 MOV R2,P2 COPY DATA FROM P2 TO R2
0008 79 FF MOV R1,#FF STORE DATA FF IN R1
000A 78 FF MOV R0,#FF STORE FF DATA IN R0
DECREASE R0 AND JUMP TO 000C
000C D8 FE DJNZ R0,000C IF R0
IS NOT ZERO
DECREAS R1 AND JUMP TO 000A
000E D9 FA DJNZ R1,000A IF R1
IS NOT ZERO
MOVE IMMEDIATE DATA 03H TO
0010 74 D3 MOV A,#03
ACCUMULATOR
0012 52 90 ANL P1,A AND P1 TO ACCUMULATOR
0014 E5 90 MOV A, P1 `MOVE DATA P1 TO
ACCUMULATOR
32
0016 B4 00 05 CJNE A,#10,001E COMPARE ACCUMULATOR
CONTENT
WITH 10H AND JUMP TO ADDRESS
001E IF NOT EQUAL
0019 15 A0 DEC P2 DECREMENT REGISTOR P2
001B 02 00 06 LJMP 0006 JUMP TO ADDRESS 0006
CAMPARE ACCUMULATOR
001E B4 01 05 CJNE A,#01,0026 CONTENT
WITH 01H AND JUMP TO ADDRESS
0026 IF NOT EQUAL
0021 05 A0 INC P2 INCREMENET REGISTER P2
0023 02 00 06 LJMP 0006 JUMP TO ADDRESS 0006
CAMPARE ACCUMULATOR
0026 B4 10 08 CJNE A,#10,0031 CONTENT
WITH 10H AND JUMPTO ADDRESS
0031 IF NOT EQUAL
0029 7A 00 MOV R2 ,#00 MOVE DATA 00H TO R2
002B 75 A0 00 MOV P2, #00 MOVE DATA 00H TO P2
002E 02 00 06 LJMP 0006 JUMP TO ADDRESS 0006
0031 8A AD MOV P2, R2 MOVE CONTENT OF R2 IN P2
0033 02 00 06 LJMP 0006 JUMP TO ADDRESS 0006
33
Experiment 7 (b)
Circuit Diagram:
Steps of Experiment:
Step 1: Set P1 to input by putting data FFH and P2 as output by putting data 00H.
Step 2: Apply a nested loop delay using register R0 and R1.
Step 3: Check the content of P1.1 and P1.0 by ANDING P1 with 03H.
(a) If value is P1.1 is not set we jump to step 5.
(b) Else we continue with step 4.
Step 4: Decrease the content of output port P2 and jump to step 2.
Step 5: Check the content of P1.0.
(a) If value of P1.0 is not set jump to step 7
35
MOVE IMMEDIATE DATA 03H TO
0020 74 D3 MOV A,#03
ACCUMULATOR
36
0068 D0 81 POP SP POP ADDRESS TO STACK POINTER
006A D0 81 POP SP POP ADDRESS TO STACK POINTER
006C 32 RETI RETURN FROM INTERRUPT
37
Experiment 8
Interfacing Two Seven Segment Displays (in Multiplexing Modes)
with an 8051 microcontroller
Circuit Diagram:
38
Steps of Experiment:
Step 1: Save lookup table at location 0500 and initialize it at beginning of code here.
Step 2: Set value of Register R1
to 00H Step 3: Set R0 to 32H (60
in decimal) Step 4: Take units
place of R1 to A.
Step 5: Using this value find corresponding value in lookup table for that value
and save it in ACC.
Step 6: Set P2 to print ACC value to 1st Seven Segment display (P2.0 = 0 and P2.1 = 1).
Step 7: Apply delay for some ms.
Step 8: Again take R1 value to A, take 10‟s places to A, and use this value to
save corresponding value in lookup table in ACC.
Step9: Set P2 to print ACC value in 2nd Seven Segment display (P2.0 = 1 and P2.1 = 0).
Step 10: Apply 1 sec delay.
Step 11: Increment value of R1 and Put Decimally adjusted value in A and
then this value in R1.
Step 12: Compare R1 to 60, and jump to Step3 if not equal.
Step 13: If R is 60, Jump to Step 2.
39
0008 ANL A,#0F FOR KNOWING DIGIT AT UNITS
PLACE
000A MOVC A,A+DPTR
000B CLR P2.0
000D SETB P2.1
0011 MOV R2,#FF DELAY FOR SWITCHING PLACES
0013 DJNZ R2,0013
0015 MOV A,R1
0016 ANL A,#F0 FOR KNOWING DIGIT AT TENS
PLACE
0018 SWAP A
0019 MOVC A,@A+DPTR
001A SETB P2.0
001C CLR P2.1
001E MOV P1,A
0020 MOV R2,#FF
0022 DJNZ R2,0022 DELAY FOR 1SEC
0024 DJNZ R0,0007
0026 INC R1
0027 MOV A,R1
0028 DA A DECIMALLY ADJUSTING IT
0029 MOV R1,A
002A CJNE R1,#60,0005 TO STOP AFTER 59 AND START
FROM 0
002B LJMP 0003
40
Experiment 9.
Interface a DAC with 8051 Microcontroller and Generate a Ramp Output
Through It.
41
Steps of Experiment:
Step 1: Set P1 as output port by putting data 00h to P1.
Step 2: Apply delay using nested loops using register R0 and R1.
Step 3: Increase the value of output port P1 and jump to step 2.
Ramp output is obtained at DAC output port and with value proportional to
input digital value from micro-controller.
42
Experiment 10.
Interface an ADC with 8051 Microcontroller and Show the
Corresponding Output in Two Seven Segment Displays.
43
Steps of Experiment:
Step 1: Set +/- Vref.
Step 2: Select Input signal by sending select lines in ADC pins A, B, C.
Step 3: Send Start of conversion signal to ADC 0809.
Step 4: When EOC signal is received, set output enable signal of ADC.
Step 5: Output is received at output port selected say P2.
Step 6: Put P2 value in R1.
Step 7: Save lookup table at location 0500 and initialize it at beginning of code here.
Step 8: Take upper nibble of R1 to A by ANDING it with F0.
Step 9: Swap upper and lower nibble of ACC.
Step 10: Using this value find corresponding value in lookup table for that
value and save it in ACC.
Step 11: Set P2 to print ACC value to 1st Seven Segment display (P2.0 = 0 and P2.1 = 1).
Step 12: Apply delay for some ms.
Step 13: Take lower nibble of R1 to A by ANDING it with 0F, and use this value to
save corresponding value in lookup table in ACC.
Step 14: Set P2 to print ACC value in 2nd Seven Segment display (P2.0 = 1 and P2.1 = 0).
Step 15: Apply 0.3 sec delay.
Step 16: Jump to Step.
44
List of Experiments of Microprocessor and Microcontroller Lab
(Course code: ECC 211)
45