Professional Documents
Culture Documents
L
AB MANUAL
VI SEM
Prepared By
T.SENTHILKUMA
MPMC T. SENTHILKUMAR
SYLLABUS
AIM
1. To understand programming using instruction sets of processors.
2. To study various digital & linear.
8-bit Microprocessor
1. Simple arithmetic operations:
Multi precision addition / subtraction / multiplication / division.
2. Programming with control instructions:
Increment / Decrement, Ascending / Descending order, Maximum / Minimum of
numbers, Rotate instructions - Hex / ASCII / BCD code conversions.
3. Interface Experiments:
• A/D Interfacing.
• D/A Interfacing.
• Traffic light controller.
4. Interface Experiments: Simple experiments using 8251, 8279, 8254.
8-bit Microcontroller
5. Demonstration of basic instructions with 8051 Micro controller execution,
including:
• Conditional jumps, looping
• Calling subroutines.
• Stack parameter testing
6. Parallel port programming with 8051 using port 1
facility: Stepper motor and D / A converter.
7. Study of Basic Digital IC’s
(Verification of truth table for AND, OR, EXOR, NOT, NOR, NAND, JK FF, RS FF,
D FF)
8. Implementation of Boolean Functions, Adder / Subtractor circuits.
9. Combination Logic; Adder, Subtractor, Code converters, Encoder and Decoder.
10. Sequential Logic; Study of Flip-Flop, Counters (synchronous and asynchronous),
Shift Registers.
MPMC T. SENTHILKUMAR
LIST OF EXPERIMENTS
MPMC T. SENTHILKUMAR
6(b) Interfacing: 8279 with 8085
6(c) Interfacing: 8253/8254 with 8085
MICROCONTROLLER (8051)
7(a) Sum of elements in an array
MPMC T. SENTHILKUMAR
EX.No:1 SIMPLE ARITHMETIC OPERATIONS USING 8085
AIM:
To write 8085 assembly language programs to perform arithmetic operations like
Addition, Subtraction, Multiplication and Division over 8-bit data and to test the programs.
APPARATUS REQUIRED:
S.No Descripti Quantity
on
1 8085Microprocessor Trainer kit 1
2 DC Power supply 1
a) 8-bit addition
Algorithm:
Step1: Initialize carry with zero.
Step2: Get the Augend.
Step3: Get the Addend.
Step4: Perform addition operation between Augend and Addend.
Step5: Check whether carry =1 If Yes increment Carry, otherwise go to SAVE.
Step6: Store the Sum and Carry.
Program:
Memo Instructions
Lab Hex Comme
el ry Mnemoni Opera nts
Code
Addre cs nd
ss
41 MVI C, 00H 0E 00 Initialize C register (carry) with zero.
00
41 LDA 4200H 3A 00 42 Load the first data (Augend) from
02 memory into the accumulator.
41 MOV B, A 47 Move Accumulator content to B register.
05
41 LDA 4201H 3A 01 42 Load the second data (Addend)
06 from memory into the
accumulator.
41 ADD B 80 Add accumulator content with B register.
09
41 JNC SAVE D2 0E 41 If there is no carry, go to SAVE.
MPMC T. SENTHILKUMAR
0A
41 INR C 0C Increment the C register (carry).
0D
SAV 41 STA 4202H 32 02 42 Store the accumulator (sum) content in
E 0E the location 4202H.
41 MOV A, C 79 Move C register (carry) content
11 to accumulator.
MPMC T. SENTHILKUMAR
41 STA 4203H 32 03 42 Store the accumulator (carry) content in
12 the location 4203H.
41 HLT 76 Stop the program
15
Output:
Memor Data Samples
y I. II. III. IV Comments
Locatio .
n
I 4200H Augend
/ 4201H Addend
P
O/P 4202H Sum
4203H Carry
b) 8-bit subtraction
Algorithm:
Step1: Initialize borrow with zero.
Step2: Get the Subtrahend.
Step3: Get the Minuend.
Step4: Perform subtraction operation between Subtrahend and Minuend.
Step5: Check whether borrow =1, If Yes increment borrow and complement
Differences then add 01H, otherwise go to SAVE.
Step6: Store the Difference and borrow.
Program:
Memo Instructions
Lab Hex Comme
el ry Mnemoni Opera nts
Code
Addre cs nd
ss
41 MVI C, 00H 0E 00 Initialize C register (borrow) with zero.
00
41 LDA 4201H 3A 01 42 Load the first data (subtrahend)
02 from memory into the
accumulator.
41 MOV B, A 47 Move Accumulator content to B register.
05
41 LDA 4200H 3A 00 42 Load the second data (minuend)
06 from memory into the
accumulator.
41 SUB B 90 Subtract B register from accumulator.
09
MPMC T. SENTHILKUMAR
41 JNC SAVE D2 11 41 If there is no borrow, go to SAVE.
0A
41 INR C 0C Increment the C register (borrow).
0D
41 CMA 2F Complement the accumulator.
0E
41 ADI 01H C6 01 Add 01 to the accumulator to get
0F 2’s complement.
SAV 41 STA 4202H 32 02 42 Store the accumulator (difference)
E 11 content in the location 4202H.
MPMC T. SENTHILKUMAR
41 MOV A, C 79 Move C register (borrow) content
14 to accumulator.
41 STA 4203H 32 03 42 Store the accumulator (borrow) content
15 in the location 4203H.
41 HLT 76 Stop the program.
18
Output:
Memor Data Samples
y I. II. III. IV Comments
Locatio .
n
I/ 4200H Minuend
P 4201H Subtrahend
O/ 4202H Difference
P 4203H Borrow
c) 8-bit multiplication
Algorithm:
Step1: Initialize memory pointer and product with zero.
Step2: Get the multiplier and Multiplicand.
Step3: Add product with multiplicand.
Step4: Check whether carry =1, If Yes increment MSB of product by one.
Step5: Decrement multiplier by one.
Step6: Check whether multiplier is zero, if NO go to step3 and repeat this until multiplier
Becomes zero.
Step7: Save product (LSB & MSB).
Program:
Memo Instructions
Label Mnem Hex Comme
ry Operan nts
oni cs Code
Addre d
ss
4100 MVI C, 00H 0E 00 Initialize C register (carry) with zero.
4102 LXI H,4200 21 00 42 Load H-L pair with the address 4200H.
H
4105 XRA A AF Clear Accumulator.
4106 MOV B, M 46 Get the first data (multiplier) in B register.
4107 INX H 23 Increment to the memory location to get
the next value.
4108 MOV D, M 56 Get the second data (multiplicand) in
D register.
MPMC T. SENTHILKUMAR
LOOP 4109 ADD D 82 Add accumulator content with D register.
2
410A JNC LOOP D2 0E 41 If CY=0, go to LOOP 1.
1
410D INR C 0C If CY=1, Increment the C register.
LOOP 410E DCR B 05 Decrement the B Register.
1
410F JNZ LOOP C2 09 41 Repeat addition until ZF=1.
2
MPMC T. SENTHILKUMAR
4112 INX H 23 Increment to the memory location to get
the next value.
4113 MOV M, A 77 Store LSB of product in memory.
4114 INX H 23 Increment to the memory location to get
the next value.
4115 MOV M,C 71 Store MSB of product in memory.
4116 HLT 76 Stop the program.
Output:
Memor Data Samples
y I. II. III. IV Comments
Locatio .
n
I/P 4200H Multiplier
4201H Multiplicand
O/P 4202H LSB of
Product
4203H MSB of
Product
d) 8-bit division
Algorithm:
Step1: Initialize Quotient with zero.
Step2: Get the divisor and dividend.
Step3: Compare divisor and dividend.
If divisor < dividend then go to SAVE.
If dividend < divisor then go to next step.
Step5: Subtract divisor from dividend.
Step6: Increment quotient by one and go to step3.
Step7: Store quotient and remainder.
Program:
Memo Instructions
Lab Hex Comme
el ry Mnemoni Opera nts
Code
Addre cs nd
ss
4100 MVI C, 00H 0E 00 Clear C register (quotient) with zero.
4102 LDA 4201H 3A 01 42 Load the first data (divisor) in accumulator.
4105 MOV B, A 47 Move Accumulator content to B register.
MPMC T. SENTHILKUMAR
4106 LDA 4200H 3A 00 42 Load the second data (dividend)
in accumulator.
REP 4109 CMP B B8 Compare the content of B and A register.
T
410A JC SAVE DA 12 If divisor is less than dividend then go
41 to SAVE.
410D SUB B 90 Subtract divisor from dividend.
410E INR C OC Increment C register (quotient).
MPMC T. SENTHILKUMAR
410F JMP REPT C3 09 41 Continue the subtraction.
SAV 4112 STA 4203H 32 03 42 Store the remainder.
E
4115 MOV A,C 79 Move the content of C to A.
4116 STA 4202H 32 02 42 Store the quotient.
4119 HLT 76 Stop the program.
Output:
Memor Data Samples
y I. II. III. IV Comments
Locatio .
n
I/ 4200H Dividend
P 4201H Divisor
O/ 4202H Quotient
P 4203H Remainder
MPMC T. SENTHILKUMAR
Flow chart: a) 8-bit addition
Start
Perform Addition
Is YES
CY=1?
N
Increment Carry
Stop
MPMC T. SENTHILKUMAR
Flow chart: b) 8-bit subtraction
Start
Perform Subtraction
Is Borrow=1? N
Increment Borrow
Stop
MPMC T. SENTHILKUMAR
Flow chart: c) 8-bit multiplication
Start
Y
Is
ES
CY=1?
NO
YES NO
Is
Save Product
CY=1?
Start
YES
Is
Divisor<
Dividend?
NO
Reminder= Dividend - Divisor
Stop
MPMC T. SENTHILKUMAR
PROCEDURE:
RESULT:
MPMC T. SENTHILKUMAR
EX.No:2 SORTING AND SEARCHING OF AN ARRAY USING 8085
AIM:
To write 8085 assembly language programs to arrange the array in ascending,
descending order and also find the largest, smallest number in an array.
APPARATUS REQUIRED:
S.No Descripti Quantity
on
1 8085Microprocessor Trainer kit 1
2 DC Power supply 1
MPMC T. SENTHILKUMAR
ss
4100 LDA 4200H 3A 00 42 Load the count value in A-register.
MPMC T. SENTHILKUMAR
4103 MOV B,A 47 Set count for N-1 repetitions Of
N-1 comparisons.
4104 DCR B 05 Decrement comparison counter for
(N-1) operations
LOOP 4105 LXI H,4200 21 00 42 Set pointer for array.
3 H
4108 MOV C,M 4E Set count for N-1 comparisons.
4109 DCR C 0D
410A INX H 23 Increment Pointer.
LOOP 410B MOV A,M 7E Get one data of array in A.
2
410C INX H 23
410D CMP M BE Compare next data with A-register.
410E JC LOOP DA 16 If content of A is less than memory then
1 41 go to LOOP1.
4111 MOV D,M 56 If the content of A is greater than the
content of memory.
4112 MOV M,A 77
4113 DCX H 2B Exchange the content of memory.
4114 MOV M,D 72 Pointed by HL and previous location.
4115 INX H 23
LOOP 4116 DCR C 0D
1
4117 JNZ LOOP2 C2 0B Repeat comparisons until C count is
41 zero.
411A DCR B 0D
411B JNZ LOOP3 C2 05 41 Repeat N-1 comparisons until B count
is zero.
411E HLT 76 Stop the program.
4202 4202
4203 4203
4204 4204
MPMC T. SENTHILKUMAR
b) Descending order
Note:
1) For descending order program, Change the instruction JC as JNC.
Load the count value from memory to A-register and save it in B-register.
Using data pointer, load the count value from memory to C-register.
YES
Decrement C-register
YES
Decrement B-register
NO
If ZF=0
Stop
Algorithm
Step1: Load the address of the first element of the array in HL register pair (Pointer).
Step2: Move the count to B-register.
Step3: Increment the pointer.
Step4: Get the first data in accumulator.
Step5: Decrement the count.
Step6: Increment the pointer.
Step7: Compare the content of memory addressed by HL pair with that of accumulator.
Step8: If carry=1, go to step 10 or if carry=0, go to step 9.
Step9: Move the content of memory addressed HL to accumulator.
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.
Step12: Store the smallest data in memory.
Step13: Stop the program.
Program
MPMC T. SENTHILKUMAR
Memo Instructions
Labe Hex Comme
l ry Mnemoni Opera nts
Code
Addre cs nd
ss
4100 LXI H,4200 21 00 42 Set pointer for array.
H
4103 MOV B,M 46 Set count for number of elements in
array.
4104 INX H 23
4105 MOV A,M 7E Set first element of array as smallest
data.
4106 DCR B 05 Decrement the count.
LOO 4107 INX H 23 Compare an element of array.
P
4108 CMP M BE With current smallest data.
4109 JC AHEA DA 0D If CY=1, go to AHEAD.
D 41
410C MOV A,M 7E If CY=0 then content of memory is
smaller than A. Hence if CY=0, make
memory as smallest by moving to A.
AHE 410D DCR B 05
AD
410E JNZ LOOP C2 07 41 Repeat comparison until count is zero.
4111 STA 4300H 32 00 43 Store the smallest data in memory.
4114 HLT 76
Input:
Memory Address
Count=07H Data I
Data II
Array= Data1H 4200
Data2H 07
Data3H 07
Data4H 4201
Data5H
Data6 4202
H
Data7H
Output: DataX H (Smallest Data) 4203
MPMC T. SENTHILKUMAR
Note:
1) For largest data program, Change the instruction JC as JNC.
MPMC T. SENTHILKUMAR
Flow chart: c) Smallest Data in an array
Start
Using data pointer, load the count value from memory to B-register
Increment the data pointer and move the first data to A-register. Decrement the count (B-register)
If CY=1 N
Yes
Move the content of memory addressed by HL to A-registe
Decrement the count
Yes
If ZF=0
No
Stop
PROCEDURE:
RESULT:
MPMC T. SENTHILKUMAR
EX.No: 3 CODE CONVERSIONS USING 8085
AIM:
To write an assembly language program to perform the conversions of
hexadecimal to ASCII, ASCII to hexadecimal number, BCD to hexadecimal,
hexadecimal to BCD number.
APPARATUS REQUIRED:
S.No Descripti Quantity
on
1 8085Microprocessor Trainer kit 1
2 DC Power supply 1
a) HEXADECIMAL to ASCII
Algorithm:
Step1: Load the given data in A-register and move to B-register.
Step2: Mask the upper nibble of the binary (Hexa) data in A-register.
Step3: Call subroutine ACODE to get ASCII code of the lower nibble and store in
memory.
Step4: Move B-register to A-register and mask the lower nibble.
Step5: Rotate the upper nibble to lower nibble position.
Step6: Call subroutine ACODE to get the ASCII code of upper nibble and store in
memory.
Step7: Stop.
Algorithm for subroutine code:
Step1: Compare the content of A-register with OAH.
Step2: If CY=1 go to step4. If CY=0, go to next step.
Step3: Add 07H to A-register.
Step4: Add 30H to A-register.
Step5: Return to main program.
Program:
Memo Instructions
Labe Hex Comme
l ry Mnemonic Operan nts
Code
MPMC T. SENTHILKUMAR
Addre s d
ss
MPMC T. SENTHILKUMAR
4100 LDA 4200H Get binary data in A.
4103 MOV B, A Save the binary data in B-register.
4104 ANI OF H Mask the upper nibble.
4106 CALL ACOD Call subroutine to get ASCII code for
E
4109 STA 4201H lower nibble in A and store in memory.
410C MOV A, B Get data in A-register.
410D ANI FO H Mask the lower nibble.
410F RLC Rotate upper nibble to lower
nibble position.
4110 RLC
4111 RLC
4112 RLC
4113 CALL ACOD Call subroutine to get ASCII code for
E
4116 STA 4202H upper nibble in A and store in memory.
4119 HLT
SUBROUTINE
ACODE
ACO 411A CPI OA H If the content of A is less than OA H
DE
411C JC SKIP Then add 30 H to A otherwise
411F ADI 07 H Add 37 H to A-register.
SK 4121 ADI 30 H
IP
4123 RET Return to main program.
MPMC T. SENTHILKUMAR
Step1: Subtract 30H from A-register.
Step2: Compare the content of A-register with OAH.
Step3: If CY=1 go to step5. If CY=0, go to next step.
Step4: Subtract 07H from A-register.
Step5: Return to main program.
Program:
Memo Instructions
Labe Hex Comme
l ry Mnemoni Opera nts
Code
Addre cs nd
ss
4100 LXI H,4200 Set pointer for ASCII array.
H
4103 MOV D, M Set count for number of data.
4104 LXI B,4300 Set pointer for binary (Hex) array.
H
LO 4107 INX H
OP
4108 MOV A, M Get an ASCII data in A-register.
4109 CALL BIN Call subroutine to get binary
410C STAX B value in A and store in memory.
410D INX B Increment the binary array pointer.
410E DCR D
410F JNZ LOOP Repeat conversion until count is zero.
4112 HLT
SUBROUTINE BIN
BIN 4113 SUI 30H Subtract 30 H from the data.
4115 CPI OAH
4117 RC If CY=1, Return to main program.
4118 SUI 07H If data is greater than OA H then subtract
411A RET 07 H and return to main program.
4202 4302
4203 4303
4204
MPMC 4304 T. SENTHILKUMAR
c) BCD to HEXADECIMAL
Algorithm:
Program:
Memo Instructions
Labe Hex Comme
l ry Mnemoni Operan nts
Code
Addre cs d
ss
4100 LDA 4200 H Get the BCD number.
MOV B, A Save BCD number.
ANI OF H Mask most significant four bits.
MOV C, A Save unpacked BCD1 in C register.
MOV A, B Get BCD again.
ANI FO H Mask least significant four bits.
RRC Convert most significant four bits into
RRC unpacked BCD 2.
RRC
RRC
MOV B, A Save BCD 2 in B-register.
XRA A Clear accumulator (sum=0)
MVI D, OA Set D as a multiplier of 10
H
SU ADD D Add 10 until (B)=0
M
DCR B Decrement BCD 2 by one
JNZ SUM Is multiplication complete? If not, go
back
ADD C and add again. Add BCD 1.
STA 4201 Store the result.
HLT Stop the program.
Tabulation:
MPMC T. SENTHILKUMAR
d) HEXADECIMAL to BCD
Algorithm:
MPMC T. SENTHILKUMAR
Program:
Memo Instructions
Labe H Comme
l ry Mnemoni Operand ex nts
cs Co
Addre
de
ss
4100 LXI SP,4300 Initialize stack pointer.
H
LDA 4400H Get the binary number in accumulator.
CALL NUMS Call subroutine NUMS.
HLT Stop the program.
NUM PUSH B Save BC register pair contents.
S
PUSH D Save DE register pair contents.
MVI B, 64 H Load divisor decimal 100 in B-register.
MVI C, 0A H Load divisor decimal 10 in C-register.
MVI D, 00 H Initialize Digit 2 (BCD2)
MVI E, 00 H Initialize Digit 3 (BCD3)
STEP CMP B Check if number < Decimal 100.
1
JC STEP 2 If yes go to step 2
SUB B Subtract decimal 100.
INR E Update quotient.
JMP STEP 1 Go to step 1.
STEP CMP C Check if number < Decimal 10.
2
JC STEP3 If yes go to step 3
SUB C Subtract decimal 10.
INR D Update quotient.
JMP STEP 2 Continue division by 10.
STEP STA 4500 H Store digit 1, BCD1
3
MOV A, D Get digit 2, BCD2
STA 4501 H Store digit 2, BCD2
MOV A, E Get digit 3, BCD3
STA 4502 H Store digit 3, BCD3
POP D Restore DE register pair contents.
POP B Restore BC register pair contents.
RET Return to main program.
MPMC T. SENTHILKUMAR
RESULT:
MPMC T. SENTHILKUMAR
EX.No: 4 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.
APPARATUS REQUIRED:
S. Descripti Quantity
No on
1 8085Microprocessor Trainer kit 1
2 DC Power supply (+5v) 1
3 ADC Interface board (Vi Microsystems) 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. The
LED display is verified with the digital value that is stored in the memory location
4150H.
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 following program initiates the conversion process, 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.
Algorithm:
1. Select the channel and latch the address.
2. Send the start conversion pulse.
MPMC T. SENTHILKUMAR
3. Read EOC signal.
4. If EOC =1 continue else go to step (3)
MPMC T. SENTHILKUMAR
5. Read the digital output.
6. Store it in a memory location.
Program:
Memo Instructions
Labe H Comme
l ry Mnemoni Operand ex nts
cs Co
Addre
de
ss
41 MVI A, 10 3E 10 Select channel 0 and to make
00 accumulator
low
41 OUT C8 H D3 C8 Output the data
02
41 MVI A, 18 3E 18 Make accumulator high
04
41 OUT C8 H D3 C8 Display the data
06
41 MVI A, 01 3E 01 Make 01 to accumulator
08
41 OUT D0 H D3 D0 Display the data
0A
41 XRA A AF XOR with accumulator
0C
41 XRA A AF XOR with accumulator
0D
41 XRA A AF XOR with accumulator
0E
41 MVI A, 00 3E 00 Make 00 to accumulator
0F
41 OUT D0 H D3 D0 Load D0 in output port
11
LOO 41 IN D8 H DB D8
P 13
41 ANI 01 E6 01 Do and operation directly
15
41 CPI 01 FE 01 Compare with accumulator
17
41 JNZ LOOP C2 13 Jump to specified address
19 41
41 IN C0 H DB C0
1C
41 STA 4150 H 32 50 41 Store the data
1E
41 HLT 76 End the program
MPMC T. SENTHILKUMAR
21
MPMC T. SENTHILKUMAR
ADC- Circuit:
SOC Jumper Selection:
Tabulation:
Analog Voltage Digital data on LED Hex code in the memory location
display 4150
MPMC T. SENTHILKUMAR
b) DAC INTERFACING WITH 8085
APPARATUS REQUIRED:
S. Descripti Quantity
No on
1 8085Microprocessor Trainer kit 1
2 DC Power supply (+5v) 1
3 DAC Interface board (Vi Microsystems) 1
SOFTWARE EXAMPLES
The following examples illustrate how to control the DAC using 8085 and
generate sine wave, saw tooth wave by means of software.
The basic idea behind the generation of waveforms is the continuous generation
of Analog output of DAC. With 00(HEX) as input to DAC2, the analog output is -
5V. Similarly, with FF (Hex) as input, the output is +5V. Outputting digital data 00
and FF at regular intervals, to DAC2, results in a square wave of amplitude I5 Volts
Algorithm:
Program:
Memo Instructions
Label H Comme
ry Mnemonics Operan ex nts
d Co
Addre
de
ss
STAR 4100 MV A, 00 H Move 00 to A register
T I
4102 OU C0 H Load C0 to output port
T
MPMC T. SENTHILKUMAR
4104 CALL DELAY Call delay program
MPMC T. SENTHILKUMAR
4109 OU C0H
T
410B CA DEL
LL AY
410E JMP STAR Jump to start of address
T
DEL 4112 MV B, 05 Move 05 to B register
AY I H
L1 4114 MV C, FF Move FF to C register
I H
L2 4116 DC C Decrement C
R
4117 JNZ L2 Jump to L2 if no zero
411E RE
T
Execute the program and using a CRO, verify that the waveform at the DAC2 output is a
square-wave. Modify the frequency of the square-wave, by varying the time delay.
Algorithm:
Program:
Memo Instructions
Label H Comme
ry Mnemonic Operan ex nts
s d Co
Addre
de
ss
STAR 4100 MVI A, 00 H Load 00 to accumulator
T
L1 4102 OUT C0 H Load C0 in output port
MPMC T. SENTHILKUMAR
4104 INR A Increment A register
4105 JNZ L1 Jump to L1 if no zero
4108 JMP START Go to START unconditionally
MPMC T. SENTHILKUMAR
(iii) TRIANGULAR WAVE GENERATION:
Algorithm:
Program:
MPMC T. SENTHILKUMAR
DAC - CIRCUIT:
Waveforms:
Tabulation:
Triangular waveform
RESULT:
MPMC T. SENTHILKUMAR
EX.No:5 TRAFFIC LIGHT CONTROLLER WITH 8085
AIM
To write an assembly language program to simulate the traffic light at an
intersection using a traffic light interface.
APPARATUS REQUIRED:
S. Descripti Quanti
No on ty
1 Microprocessor kit (Vi Microsystems) 1
2 Power supply (+5V dc) 1
3 Traffic light interface kit (Vi Microsystems) 1
Algorithm:
1. Initialize the ports.
2. Initialize the memory content, with some address to the data.
3. Read data for each sequence from the memory and display it through the ports.
4. After completing all the sequences, repeat from step2.
A SAMPLE SEQUENCE:
1. (a) Vehicles from south can go to straight or left.
(b) Vehicles from west can cross the road.
(c) Each pedestrian can cross the road.
(d) Vehicles from east no movement.
(e) Vehicles from north, can go only straight.
MPMC T. SENTHILKUMAR
(b) Vehicles from east, can go only left.
(c) West pedestrian can cross the road.
(d) Vehicles from west, no movement.
(e) Vehicles from south, can go only straight.
BIT ALLOCATION:
MPMC T. SENTHILKUMAR
PA6 EAST AMBER PB WEST AMBER P SOUTH PD
6 C
6
PA7 EAST RED PB WEST RED P EAST PD
7 C
7
PATH REPRESENTATION:
MPMC T. SENTHILKUMAR
CONTROL ----- 0F (FOR 8255 PPI)
PORT A 0C
PORT B 0D
PORT C 0E
Program:
MPMC T. SENTHILKUMAR
410A CALL OUT CD 42,41 Call out address
MPMC T. SENTHILKUMAR
410D XCHG EB Exchange contents of HL with DE
pair
410E MOV A,M 7E Move M content to accumulator
MPMC T. SENTHILKUMAR
B D
MPMC T. SENTHILKUMAR
412 XCHG E Exchange content of HL with DE pair
E B
412F INX D 13 Increment D register
MPMC T. SENTHILKUMAR
4151 PUSH H E5 Push the register H
MPMC T. SENTHILKUMAR
4175 ORA H B4 OR content of H with accumulator
RESULT:
MPMC T. SENTHILKUMAR
EX.No:6 6(a) INTERFACING 8251 WITH 8085
AIM:
To write a program to initiate 8251 and to check the transmission and reception
of character.
APPARATUS REQUIRED:
1. 8085 Microprocessor kit
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. The USART
accepts data characters from the CPU in parallel format and the converts them in a continuous
serial data stream of transmission. Simultaneously, it can receive serial data streams and convert
them into parallel data characters for the CPU. The CPU can read the status of USART at any
time. These include data transmissions errors and control signals.
Prior to starting data transmission or reception, the 8251 must be loaded with a set of
control words generated by the CPU.These control signals define the complete functional
definition of the 8251 and must immediately follow a RESET operation. Control words should
be written in to the control register of 8251. Words should be written in to the control register of
8251.words should be written in to the control register of 8251.Thesecontrol words are split into
two formats.
1. MODE INSTRUCTION WORD
2. COMMAND INSTRUCTION WORD
This format defines the BAUD rate, character length, parity and stop bits required
to work with asynchronous data communication. by selecting the appropriate BAUD factor
synchronous mode, the 8251 can be operated in synchronous mode.
MPMC T. SENTHILKUMAR
8 bit data
No parity
Baud rate factor (16X)
1 stop bit
Gives a mode command word of 01001110=4E(X)
ALGORITHM
1. Initialize timer (8253) IC
2. Move the Mode command word (4EH) to A reg.
3. Output it port address C2
4. Move the command instruction word (37H) to A reg.
5. Output it to port address C2
6. Move the data to be transfer to A reg.
7. Output it to port address C0.
8. Reset the system
9. Get the data through input port address C0.
10. Store the value in memory
11. Reset the system
PROGRAM:
MPMC T. SENTHILKUMAR
41 OUT C2 Output contents of accumulator to C2 port
11
MPMC T. SENTHILKUMAR
41 MVI A 37 Move 37 to accumulator
13
41 OUT C2 Output contents of accumulator to C2 port
15
41 MVI A 41 Move 41 to accumulator
17
41 OUT C0 Output contents of accumulator to C0 port
19
41 RST1
1B
42 IN C0 Input the contents from port C0
00 to accumulator
42 STA 4150 Store the output from accumulator
02 to 4150
42 RST1
05
SYNCHRONOUS MODE:
MPMC T. SENTHILKUMAR
ASYNCHRONOUS MODE:
OBSERVATION:
RESULT:
MPMC T. SENTHILKUMAR
6(b) 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:
Memo Instructions H
Label Comme
ry Mnemoni Operand ex nts
Addre c s co
ss de
STAR 4100 MVI A, 36 3E 36 Channel 0 in mode 3
T
4102 OUT CE D3 CE Send Mode Control word
4104 MVI A, 0A 3E 0A LSB of count
4106 OUT C8 D3 C8 Write count to register
4108 MVI A, 00 3E 00 MSB of count
410A OUT C8 D3 C8 Write count to register
410C HLT 76
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
MPMC T. SENTHILKUMAR
frequency 150 KHz at channel 0. Now this is the clock to channel 2.
MPMC T. SENTHILKUMAR
CONTROL WORD:
SC-SELECT COUNTER:
S S SELECT
C C COUNTER
1 0
0 0 Select counter 0
0 1 Select counter 1
1 0 Select counter 2
1 1 Read back command
M-MODE:
M M1 M MODE
2 0
0 0 0 Mode 0
0 0 1 Mode 1
X 1 0 Mode 2
X 1 1 Mode 3
1 0 0 Mode 4
1 0 1 Mode 5
READ/WRITE:
R R Status
W1 W0
0 0 Counter latch command
MPMC T. SENTHILKUMAR
BCD:
RESULT:
MPMC T. SENTHILKUMAR
6(c) INTERFACING 8279 WITH 8085
AIM:
To interface 8279 Programmable Keyboard Display Controller to 8085 Microprocessor.
APPARATUS REQUIRED:
PROGRAM:
Memo Instructions
Label Opcod Comme
ry Mnemoni Operan e nts
Addre cs d
ss
41 STA LXI H, Store the 16 bit address in HL pair
00 RT 4130H
41 MVI D, 0FH Move 0F to D register
03
41 MVI A, 10H Move 10 to A
05
41 OUT C2 Output the contents of A to C2 output
07 port
41 MVI A, CCH Move CC to A
09
41 OUT C2 Output the contents of A to C2 output
0B port
41 MVI A, 90H Move 90 to A
0D
41 OUT C2 Output the contents of A to C2 output
0F port
41 LOO MOV A, M Move content of M to A
11 P
41 OUT C0 Output the contents of M to A
12
41 CALL DELAY Call the delay address
14
41 INX H Increment H register
17
41 DCR D Decrement D register
18
MPMC T. SENTHILKUMAR
41 JNZ LOOP Jump to specified address
19
41 JMP START Jump to START address
1C
MPMC T. SENTHILKUMAR
41 DELA MVI B, A0H Move a to B register
1F Y
41 LOOP MVI C, FFH Move FF to C register
21 1
41 LOOP DCR C Decrement C register
23 2
41 JNZ LOOP 1 Jump to LOOP 1 if no zero
24
41 DCR B Decrement B register
27
41 JNZ LOOP 2 Jump to LOOP 2 if no zero
28
41 RET
2B
Pointer equal to 4130 .FF repeated eight times
4130 FF
4131 FF
4132 FF
4133 FF
4134 FF
4135 FF
4136 FF
4137 FF
4138 98
4139 68
413ª 7C
413B C8
413C 1C
413D 29
413E FF
413F FF
SEGMENT DEFINITION:
MPMC T. SENTHILKUMAR
DATA D D D D D3 D D D
BUS 7 6 5 4 2 1 0
SEGMEN d c b a dp g f e
TS
OBSERVATION:
LETTE 7 DATA
R SEGME BUS HEXADECIMA
NT D D D D D D D D L
7 6 5 4 3 2 1 0
RESULT:
MPMC T. SENTHILKUMAR
Ex.No:7 7(a) 8051 - SUM OF ELEMENTS IN AN ARRAY
AIM:
To find the sum of elements in an array.
ALGORITHM:
1. Load the array in the consecutive memory location and initialize the memory
pointer with the starting address.
2. Load the total number of elements in a separate register as a counter.
4. Load the other register with the value of the memory pointer.
6. Check for carry, if exist, increment the carry register by 1. otherwise, continue
7. Decrement the counter and if it reaches 0, stop. Otherwise increment the memory
pointer by 1 and go to step 4.
PROGRAM:
Memo Instructions
Label Comme
ry Mnemonic Operand nts
Addre s
ss
41 MOV DPTR, #4200
00
41 MOVX A, @DPTR
03
41 MOV R0, A
04
41 MOV B, #00
05
41 MOV R1, B
08
41 ADD CLR C
0A
41 INC DPTR
0B
41 MOVX A, @DPTR
0C
41 ADD A, B
MPMC T. SENTHILKUMAR
0D
41 MOV B, A
0F
MPMC T. SENTHILKUMAR
41 JNC NC
11
41 INC R1
13
41 N DJNZ R0, ADD
14 C
41 MOV DPTR, #4500
16
41 MOV A, R1
19
41 MOVX @DPTR, A
1A
41 INC DPTR
1B
41 MOV A, B
1C
41 MOVX @DPTR, A
1E
41 HLT SJMP HLT
1F
OBSERVATION:
INPU OUTPU
T T
4200 03 (Count) 4500
(MSB)
4201
4202 4501
(LSB)
4203
RESULT:
MPMC T. SENTHILKUMAR
7(b) 8051 - SUM USING STACK
AIM:
To find the sum of elements in an array using stack.
ALGORITHM:
1. Start
9. Halt
PROGRAM:
Memo Instructions
Labe Comme
ry Mnemoni Opera
l nts
Addr cs nd
ess
41 MOV SP, #10 SP initialized to 10 of internal RAM
00
41 MOV A, #88 A has 88
03
41 MOV B, #67 B has 67
05
41 MOV DPL, DPL has 43
08 #43
41 PUSH A SP incremented by 1 and (A) is stored here.
0B
41 PUSH B SP incremented by 1 and (B) is stored here.
0D
41 PUSH DPL SP incremented by 1 and (DPL) is stored here.
0F
41 HLT SJMP HLT
11
MPMC T. SENTHILKUMAR
STACK OPERATIONS:
MPMC T. SENTHILKUMAR
Stack operations move data between register and the top of the stack. It is
incremented before data is stored during PUSH and CALL executions. While the stack
may reside anywhere in the chip RAM, the stack pointer is initialized to 07 after a reset.
This causes the stack to begin at location 08.
STACK CONTENTS AFTER INSTRUCTION PUSH A
10 XX
11 88
XX 10
88 11
67
43 12
13
RESULT:
MPMC T. SENTHILKUMAR
7(c) 8051 - SUM USING CALL OPTION
AIM:
To find the sum of elements in an array using call option.
ALGORITHM:
1. Start
5. Add A & R0
9. Return to 4107
PROGRAM:
4103 MOV A, # 00
4108 ADD A, R0
410D SJMP
RET
OBSERVATION:
MPMC T. SENTHILKUMAR
INPUT OUTP
UT
42
00 43
00
42
02
RESULT:
MPMC T. SENTHILKUMAR
Ex.No:8 8(a) STEPPER MOTOR INTERFACING WITH 8051
AIM:
To interface a stepper motor with 8051 microcontroller and operate it.
THEORY:
A motor in which the rotor is able to assume only discrete stationary angular
position is a stepper motor. The rotary motion occurs in a step-wise manner from one
equilibrium position to the next. Stepper Motors are used very wisely in position control
systems like printers, disk drives, process control machine tools, etc.
The basic two-phase stepper motor consists of two pairs of stator poles. Each of
the four poles has its own winding. The excitation of any one winding generates a North
Pole. A South Pole gets induced at the diametrically opposite side. The rotor magnetic
system has two end faces. It is a permanent magnet with one face as South Pole and the
other as North Pole.
The Stepper Motor windings A1, A2, B1, B2 are cyclically excited with a DC
current to run the motor in clockwise direction. By reversing the phase sequence as A1,
B2, A2, B1, anticlockwise stepping can be obtained.
ANTICLOCKWISE CLOCKWI
SE
ST A A B B DA ST A A B B2 DA
EP 1 2 1 2 TA EP 1 2 1 TA
1 1 0 0 1 9h 1 1 0 1 0 Ah
2 0 1 0 1 5h 2 0 1 1 0 6h
3 0 1 1 0 6h 3 0 1 0 1 5h
4 1 0 1 0 Ah 4 1 0 0 1 9h
MPMC T. SENTHILKUMAR
control using the Microcontroller Kit. The TTL levels of pulse sequence from the data
bus is translated to high voltage output pulses using a buffer 7407 with open collector.
BLOCK DIAGRAM:
REPRESENTATION:
8051
MICROCONTROLL 825
ER
5 DRIVER CIRCUIT STEPPER MOTOR
PROGRAM:
MPMC T. SENTHILKUMAR
4111 DELAY 1 MOV R3, #FF H
4123 END
4500 TABLE DB 09 05 06 0A H
PROCEDURE:
1. Enter the above program starting from location 4100.and execute the same.
2. The stepper motor rotates.
3. Varying the count at R4 and R5 can vary the speed.
4. Entering the data in the look-up TABLE in the reverse order can vary direction of
rotation.
RESULT:
MPMC T. SENTHILKUMAR
8 (b) INTERFACING D/A
CONVERTER WITH 8051
AIM:
APPARATUS REQUIRED:
THEORY:
SOFTWARE EXAMPLES
After going through the software examples you can learn how to control
the DAC using 8051 and generate sine wave, saw tooth wave etc by means of software.
ALGORITHM:
DAC - CIRCUIT:
MPMC T. SENTHILKUMAR
WAVEFORMS:
MPMC T. SENTHILKUMAR
OBSERVATION:
Triangular waveform
4109 MOV A, # FF H
411A RET
MPMC T. SENTHILKUMAR
411B SJMP START
Execute the program and using a CRO, verify that the waveform at the DAC2
output is a square-wave. Modify the frequency of the square-wave, by varying the time
delay.
4106 INC A
The following program will generate a triangular wave at DAC2 output. The
MPMC T. SENTHILKUMAR
program is self-explanatory.
MPMC T. SENTHILKUMAR
Addre Labe Mnemonics Operand Comments
ss l
4100 MOV DPTR,#FFC0
H
4103 STA MOV A,#00 H
RT
4105 LOO MOVX @DPTR, A
P1
4106 INC A
OBSERVATION:
Saw tooth
waveform
Triangular
waveform
RESULT:
MPMC T. SENTHILKUMAR