MPMC Lab Manual
MPMC Lab Manual
LABORATORY RECORD
Name :…………………………………………………………………
Place:
Date :
DATE:
AIM:
OBJECTIVE:
ALGORITHM:
.
FLOW CHART:
START
[C] 00H
[HL] 4500H
[A] [M]
[HL] [HL]+1
[A] [A]+[M]
NO
Is there a
Carry ? YES
YES
[C] [C]+1
[HL] [HL]+1
[M] [A]
[HL] [HL]+1
[M] [C]
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
4500 4502
4501 4503
RESULT:
Thus the 8 bit numbers stored at 4500 &4501 are added and the result stored at 4502 & 4503.
EX:NO: 8 BIT SUBTRACTION
DATE:
AIM:
OBJECTIVE:
ALGORITHM:
[C] 00H
[HL] 4500H
[A] [M]
[HL] [HL]+1
[A] [A]-[M]
Is there a NO
Borrow ?
YES
Complement [A]
Add 01H to [A]
[C] [C]+1
[HL] [HL]+1
[M] [A]
[HL] [HL]+1
[M] [C]
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
4500 4502
4501 4503
RESULT:
Thus the 8 bit numbers stored at 4500 &4501 are subtracted and the result stored at 4502 & 4503.
EX:NO: 8 BIT MULTIPLICATION
DATE:
AIM:
To multiply two 8 bit numbers stored at consecutive memory locations and store the result in
memory.
OBJECTIVE:
1. To get the 8-bit values from an address to specified internal registers by means of Data
Transfer Instructions.
2. To perform multiplication operation of two 8-bit numbers by means of repeated
Addition technique and by using jump instructions.
3. To familiarize Instructions of Microprocessor 8085
4. Addressing mode of Microprocessor 8085.
5. Flag register of Microprocessor 8085
ALGORITHM:
START
[HL] 4500
B M
[HL] [HL]+1
A 00
C 00
Is there NO
any carry
YES
C C+1
B B-1
NO
IS B=0
YES
A
A
[HL] [HL]+1
[M] [A]
[HL] [HL]+1
[M] [C]
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
4500 4502
4501 4503
RESULT:
Thus the 8-bit multiplication was done in 8085p using repeated addition method.
EX:NO: 8 BIT DIVISION
DATE:
AIM:
OBJECTIVE:
1. To get the 8-bit values from an address to specified internal registers by means of Data
Transfer Instructions.
2. To perform division operation of two 8-bit numbers by means of repeated
Subtraction technique and by using jump instructions.
3. To familiarize Instructions of Microprocessor 8085
4. Addressing mode of Microprocessor 8085.
5. Flag register of Microprocessor 8085
ALGORITHM:
B 00
[HL] 4500
A M
[HL] [HL]+1
M A-M
[B] [B] +1
NO
IS A<0
YES
A A+ M
B B-1
[HL] [HL]+1
[M] [A]
[HL] [HL]+1
[M] [B]
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4500 4502
4501 4503
4500 4502
4501 4503
RESULT:
Thus an ALP was written for 8-bit division using repeated subtraction method and executed using
8085 p kits
EX:NO:
16 BIT ADDITION
DATE:
AIM:
OBJECTIVE:
1. To get the 16-bit values from an address to specified internal registers by means of
Data Transfer Instructions.
2. To use two pairs of internal 8-bit registers to save a 16-bit registers.
3. To perform addition operation of two 16-bit numbers .
4. To store the instruction from a register to specified address in a memory unit by Data
Transfer Instructions.
ALGORITHM:
[L] [4150 H]
[H] [4151 H]
[DE] [HL]
[L] [4152H]
[H] [4153H]
[A] 00H
[HL] [HL]+[DE]
NO
Is there a
Carry?
YES
[A] [A]+1
[4154] [ L]
[4155] [H]
[4156] [A]
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150H 4154H
4151H 4155H
4152H 4156H
4153H
RESULT:
Thus an ALP program for 16-bit addition was written and executed in 8085p using special
instructions.
EX:NO:
16 BIT SUBTRACTION
DATE:
AIM:
OBJECTIVE:
1. To get the 16-bit values from an address to specified internal registers by means of
Data Transfer Instructions.
2. To use two pairs of internal 8-bit registers to save a 16-bit registers.
3. To perform subtraction of two 16-bit numbers.
4. To store the instruction from a register to specified address in a memory unit by Data
Transfer Instructions.
ALGORITHM:
START
[L] [4150 H]
[H] [4151 H]
[DE] [HL]
[L] [4152H]
[H] [4153H]
[HL] [HL]-[DE]
Is there a NO
borrow?
YES
[C] [C]+1
[4154] [ L]
[4155] [H]
[4156] [C]
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150H 4154H
4151H 4155H
4152H 4156H
4153H
RESULT:
Thus an ALP program for subtracting two 16-bit numbers was written and executed.
EX:NO:
16 BIT MULTIPLICATION
DATE:
AIM:
OBJECTIVE:
1. To get the 16-bit values from an address to specified internal registers by means of
Data Transfer Instructions.
2. To use two pairs of internal 8-bit registers to save a 16-bit registers.
3. To perform multiplication of two 16-bit numbers using repeated addition method.
4. To store the instruction from a register to specified address in a memory unit by Data
Transfer Instructions.
ALGORITHM:
START
L [4150]
H [4151]
SP HL
L [4152]
H [4153]
DE HL
HL 0000
BC 0000
HL HL+SP
NO
Is Carry
flag set?
YES
BC BC+1
DE DE+1
NO
Is Zero flag
set?
YES
A
A
[4154] L
[4155] H
[4156] C
[4157] B
STOP
PROGRAM:
ADDRESS LABEL MNEMONICS OPERAND COMMENTS
4100 START LHLD 4150 Load the first No. in stack pointer
4103 SPHL through HL reg. pair
4104 LHLD 4152 Load the 2ndin HL reg. pair
4107 XCHG &Exchange with DE reg. pair.
4108 LXI H, 0000H Clear HL & DE reg. pairs.
410B LXI B, 0000H
410E LOOP DAD SP Add SP with HL pair.
JNC NEXT If there is no carry, go to the
410F
instruction labeled NEXT
4112 INX B Increment BC reg. pair
4113 NEXT DCX D Decrement DE reg. pair.
4114 MOV A,E Move the content of reg. E to Acc.
4115 ORA D OR Acc. with D reg.
JNZ LOOP If there is no zero, go to
4116
instruction labeled LOOP
4119 SHLD 4154 Store the content of HL pair in
411A memory locations 4154 & 4155.
411C MOV A, C Move the content of reg. C to Acc.
STA 4156 Store the content of Acc. in
411D
memory location 4156.
4120 MOV A, B Move the content of reg. B to Acc.
STA 4157 Store the content of Acc. in
4121
memory location 4157.
4124 HLT Stop program execution
OBSERVATION:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150 4154
4151 4155
4152 4156
4153 4157
RESULT:
Thus the 16-bit multiplication was done in 8085p using repeated addition method.
EX:NO:
16- BIT DIVISION
DATE:
AIM:
To divide two 16-bit numbers and store the result in memory using 8085 mnemonics.
OBJECTIVE:
1. To get the 16-bit values from an address to specified internal registers by means of
Data Transfer Instructions.
ALGORITHM:
START
L [4151]
H [4152]
HL DE
L [4150]
H [4151]
BC 0000H
A L; A A- E
L A
A H
A A- H- Borrow
H A
BC BC+ 1
Is Carry NO
flag set ?
YES
A
A
BC BC- 1
HL HL+DE
L [4154]
H [4155]
A C
[4156] A
A B
[4157] A
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150 4154
4151 4155
4152 4156
4153 4157
RESULT:
Thus the 16-bit Division was done in 8085p using repeated subtraction method.
EX:NO:
LARGEST ELEMENT IN AN ARRAY
DATE:
AIM:
To find the largest element in an array.
OBJECTIVE:
1. To get the 8-bit data one by one and it will be saved in the specified registers like an
array using Data Transfer Instructions.
2. To compare the two 8-bit data and the largest number is moved to Accumulator.
3. To store the instruction from a register to specified address in a memory unit by Data
Transfer Instructions.
4. To familiarize Instructions of Microprocessor 8085
5. Addressing mode of Microprocessor 8085.
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.
FLOW CHART:
START
[HL] [4150H]
[B] 04H
[A] [HL]
[HL [HL] + 1
NO IS
[A] < [HL]?
YES
[A] [HL]
[B] [B]-1
IS NO
[B] = 0?
YES
[4155] [A]
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150 4155
4151
4152
4153
4154
RESULT:
Thus the largest number in the given array is found out.
EX:NO:
SMALLEST ELEMENT IN AN ARRAY
DATE:
AIM:
To find the smallest element in an array.
OBJECTIVE:
1. To get the 8-bit data one by one and it will be saved in the specified registers like an
array using Data Transfer Instructions.
2. To compare the two 8-bit data and the smallest number is moved to Accumulator.
3. To store the instruction from a register to specified address in a memory unit by Data
Transfer Instructions.
4. To familiarize Instructions of Microprocessor 8085
5. Addressing mode of Microprocessor 8085.
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.
FLOW CHART:
START
[HL] [4150H]
[B] 04H
[A] [HL]
[HL [HL] + 1
YES IS
[A] < [HL]?
NO
[A] [HL]
[B] [B]-1
IS NO
[B] = 0?
YES
[4105] [A]
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150 4105
4151
4152
4153
4154
RESULT:
Thus the smallest number in the given array is found out.
EX:NO:
ASCENDING ORDER
DATE:
AIM:
To sort the given number in the ascending order using 8085 microprocessor.
OBJECTIVE:
1. To get the 8-bit data one by one and it will be saved in the specified registers like
an array using Data Transfer Instructions.
2. To compare the two 8-bit data and the smallest number is moved to Accumulator.
3. To use the conditional jump instruction and compare instructions the 8-bit data‟s
are arranged internally in the ascending order.
4. To store the instruction from a register to specified address in a memory unit by
Data Transfer Instructions.
ALGORITHM:
[B] 04H
[HL] [4150H]
[C] 04H
[A] [HL]
[HL [HL] + 1
YES IS
[A] < [HL]?
NO
[D] [HL]
[HL] [A]
[HL] [HL] - 1
[HL] [D]
[HL] [HL] + 1
[C] [C] – 01 H
A
A
IS NO
[C] = 0?
YES
[B] [B]-1
IS NO
[B] = 0?
YES
STOP
PROGRAM:
INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION LOCATION
4150 4150
4151 4151
4152 4152
4153 4153
4154 4154
RESULT:
Thus the ascending order program is executed and thus the numbers are arranged in ascending
order.
EX:NO:
DESCENDING ORDER
DATE:
AIM:
To sort the given number in the descending order using 8085 microprocessor.
OBJECTIVE:
1. To get the 8-bit data one by one and it will be saved in the specified registers like an
array using Data Transfer Instructions.
2. To compare the two 8-bit data and the smallest number is moved to Accumulator.
3. To use the conditional jump instruction and compare instructions the 8-bit data‟s are
Arranged internally in the descending order.
4. To store the instruction from a register to specified address in a memory unit by
Data
ALGORITHM:
[B] 04H
[HL] [4150H]
[C] 04H
[A] [HL]
[HL [HL] + 1
NO IS
[A] < [HL]?
YES
[D] [HL]
[HL] [A]
[HL] [HL] - 1
[HL] [D]
[HL] [HL] + 1
[C] [C] – 01 H
A
A
NO
IS
[C] = 0?
YES
[B] [B]-1
NO
IS
[B] = 0?
YES
STOP
YES
PROGRAM:
INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION LOCATION
4150 4150
4151 4151
4152 4152
4153 4153
4154 4154
RESULT:
Thus the descending order program is executed and thus the numbers are arranged in descending
order.
EX:NO:
BIT MANIPULATION
DATE:
AIM:
OBJECTIVE:
1. Students will able to understand the usage of bit manipulation instruction like rotate
right with or without carry and rotate left with or without carry.
ALGORITHM:
PROGRAM:
RESULT:
Thus the ALP was written to perform bit manipulation and executed successfully.
EX:NO:
CODE CONVERSION –ASCII TO DECIMAL
DATE:
AIM:
THEORY:
Any ASCII number can be converted to decimal number by subtracting 30 from it.
OBJECTIVE:
1. Students will able to write the assembly language program for code conversion from ASCII code to
Decimal.
ALGORITHM:
1. Start.
2. Enter the data at 4150.
3. Subtract the data from 30H.
4. If the decimal number is valid, store the result at 4151 or if the decimal number is not valid, store
FF at 4151.
5. Halt.
FLOWCHART:
START
GET DATA
DATA = DATA - 30
NO YES YES
IS
DATA >
09 H?
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150 4151
RESULT:
Thus the ALP was written to convert ASCII number to Decimal number and executed successfully.
EX:NO:
BCD TO HEX CONVERSION
DATE:
6.(b)
AIM:
OBJECTIVE:
1. Students will able to write the assembly language program for code conversion from BCD to HEX
conversion.
ALGORITHM:
1. Start.
2. Enter the data at 4150 and 4151 for execution.
3. Execute the program and check for result at 4152.
4. Stop.
FLOWCHART:
START
GET MOST
SIGNIFICANT DIGIT
(MSD)
MSD = MSD * 10
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150 4152
4151
RESULT:
Thus the ALP was written to convert BCD to Hex number and executed successfully.
EX:NO:
HEX TO DECIMAL CONVERSION
DATE:
AIM:
OBJECTIVE:
The hex number should be converted to its equivalent decimal number using the following logic:
First count the number of hundreds, the number of tens and units present in that hex number. Using these
three, add up to get the equivalent decimal number.
ALGORITHM:
1. Start.
2. Enter data at 4150 for execution.
3. Execute the program and check for the result.
4. Stop.
FLOW CHART:
START
GET DATA
HUNDREDS = 0
TENS = 0
IS NO HUNDREDS =
CARRY HUNDREDS + 1
=1?
YES
DATA = DATA - 10
NO
IS TENS = TENS + 1
CARRY
=1?
YES
DATA = DATA - 10
UNITS = DATA
STORE HUNDREDS,
TENS, UNITS
STOP
PROGRAM:
OBSERVATIONS:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4150 4152
4151
RESULT:
Thus the ALP was written to convert Hex number to decimal number and executed successfully.
EX:NO:
HEX TO BINARY CONVERSION
DATE:
AIM:
To convert an 8-bit hex number to its binary form and store in memory.
OBJECTIVE:
ALGORITHM:
1. Start.
2. Enter the hex number and execute the program.
3. Check for results at locations 4150 through 4157.
4. Stop.
PROGRAM:
OBSERVATION:
OUTPUT
ADDRESS DATA
4150
4151
4152
4153
4154
4155
4156
4157
RESULT:
Thus the ALP was written to convert Hex to Binary number and executed successfully.
EX:NO:
HEX TO BINARY CONVERSION
AIM:
To initialize ADC by means of software and the analog input is given to channel 0 and the digital
outputs are visualized at the LED‟s accordingly.
OBJECTIVE:
To compute the analog to digital data using an 8085 program and hardware
Interface.
APPARATUS REQUIRED:
8085 kit, ADC interface board and power cord.
PROCEDURE:
Initializing the analog to digital conversion process by means of software is sometimes necessary.
Execute the program, which starts from the location 4100H and converts the output through LED‟s.
The jumper settings are accordingly changed for the software initialization.
FLOWCHART:
START
OUTPUT
DIGITAL DATA
STOP
PROGRAM:
RESULT:
Thus the program to initialize ADC by means of software and to convert analog data at channel 0 to
digital form was written and executed.
EX:NO:
INTERFACING OF DAC WITH 8085
DATE: SQUARE WAVE GENERATION
AIM:
To generate a square wave at the DAC2 output.
OBJECTIVE:
1. To generate Square wave and observe it on the C.R.O
2. To learn the working of 8255.
ALGORITHM:
1. Initialize accumulator with 00H
2. Call delay subroutine
3. Initialize accumulator with FFH
4. Output the data to DAC2.
FLOW CHART:
START
RESULT:
Thus a square wave was generated at DAC 2 using DAC interface.
EX:NO:
INTERFACING WITH 8085
DATE: SAW TOOTH WAVE GENERATION
AIM:
To generate saw tooth wave at the output of DAC 1.
ALGORITHM:
1. Initialize accumulator with 00H.
2. Call delay subroutine.
3. Increment accumulator.
4. Output the data to DAC 1.
5. Check if the content of accumulator equal to FF H. if yes go to step 1 else to step 3.
6. Stop.
FLOW CHART:
START
INCREMENT
ACCUMULATOR
YES NO
IS
ACC.=
FFH?
PROGRAM:
RESULT:
Thus the saw tooth wave was generated at the output of DAC 1.
EX:NO:
INTERFACING WITH 8085
DATE: TRIANGULAR WAVE GENERATION
AIM:
To generate a triangular wave at the DAC 2 output.
APPARATUS REQUIRED:
8085 microprocessor kit, 8-bit DAC interface board and power cord.
ALGORITHM:
1. Initialize L register with 00H.
2. Copy contents of L reg. to accumulator.
3. Out the data in DAC.
4. Increment content of H reg.
5. Initialize L reg. with 0FF H.
6. Move the contents of L reg. to A.
7. Out data in DAC.
8. Decrement L reg.
9. Jump on no zero to L2.
10. Jump to start.
FLOWCHART:
START
DECREMENT L REG.
YES NO
IF NO
ZERO
PROGRAM:
RESULT:
Thus the triangular wave at DAC 2 output was generated.
EX:NO:
INTERFACING 8251 WITH 8085
DATE:
AIM:
To initialize 8253 and 8251 and to check the transmission and receiving of a character.
APPARATUS REQUIRED:
ALGORITHM :
For Transmitter:
For Receiver:
ISR:
RESULT:
Thus the program was written to interface two 8085 using 8251 and executed successfully.
EX:NO:
INTERFACING 8279 WITH 8085
DATE:
AIM:
To write a program to interface 8279 (keyboard and display controller) with 8085/8086.
ALGORITHM:
LOOKUP TABLE:
412C FF FF FF FF
4130 FF FF FF FF
4134 98 68 7C C8
4138 1C 29 FF FF
OBSERVATION:
HELP US
RESULT:
Thus the program was written to interface 8279 with 8085 and executed successfully.
EX:NO:
INTERFACING 8253 TIMER WITH 8085
DATE:
AIM:
To interface 8253 Interface board to 8085 p and verify the operation of 8253in six different modes.
APPARATUS REQUIRED:
8085 p kit, 8253 Interface board, DC regulated power supply, VXT parallel bus, CRO.
The output will be initially low after mode set operations. After loading the counter, the output will be
remaining low while counting and on terminal count; the output will become high, until reloaded again.
Let us set the channel 0 in mode 0. Connect the CLK 0 to the debounce circuit by changing the
jumper J3 and then execute the following program.
PROGRAM:
It is observed in CRO that the output of Channel 0 is initially LOW. After giving six clock pulses, the
output goes HIGH.
After loading the counter, the output will remain low following the rising edge of the gate input.
The output will go high on the terminal count. It is retriggerable; hence the output will remain low for the
full count, after any rising edge of the gate input.
Example:
The following program initializes channel 0 of 8253 in Mode 1 and also initiates triggering of Gate
0. OUT 0 goes low, as clock pulse after triggering the goes back to high level after 5 clock pulses. Execute
the program, give clock pulses through the debounce logic and verify using CRO.
PROGRAM:
It is a simple divide by N counter. The output will be low for one period of the input clock. The
period from one output pulse to the next equals the number of input counts in the count register. If the
count register is reloaded between output pulses the present period will not be affected but the subsequent
period will reflect the new value.
Example:
Using Mode 2, Let us divide the clock present at Channel 1 by 10. Connect the CLK1 to PCLK.
PROGRAM:
Address Opcodes Label Mnemonic Operands Comments
4100 3E 74 START: MVI A, 74 Channel 1 in mode 2
4102 D3 CE OUT CE Send Mode Control word
4104 3E 0A MVI A, 0A LSB of count
4106 D3 CA OUT CA Write count to register
4108 3E 00 MVI A, 00 MSB of count
410A D3 CA OUT CA Write count to register
410C 76 HLT
In CRO observe simultaneously the input clock to channel 1 and the output at Out1.
It is similar to Mode 2 except that the output will remain high until one half of count and go low for
the other half for even number count. If the count is odd, the output will be high for (count + 1)/2 counts.
This mode is used of generating Baud rate for 8251A (USART).
Example:
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.
The output is high after mode is set and also during counting. On terminal count, the output will go
low for one clock period and becomes high again. This mode can be used for interrupt generation.
The following program initializes channel 2 of 8253 in mode 4.
Example:
Connect OUT 0 to CLK 2 (jumper J1). Execute the program and observe the output OUT 2.
Counter 2 will generate a pulse after 1 second.
PROGRAM:
Counter starts counting after rising edge of trigger input and output goes low for one clock period
when terminal count is reached. The counter is retriggerable.
Example:
The program that follows initializes channel 0 in mode 5 and also triggers Gate 0. Connect CLK 0 to
debounce circuit.
Execute the program. After giving Six clock pulses, you can see using CRO, the initially HIGH
output goes LOW. The output ( OUT 0 pin) goes high on the next clock pulse.
PROGRAM:
Result:
Thus the 8253 has been interfaced to 8085 p and six different modes of 8253 have been studied.
EX:NO: STEPPER MOTOR CONTROLLER INTERFACE
AIM:
APPARATUS REQUIRED:
1. 8085 MP kit
2. Stepper motor interface kit.
3. Stepper motor.
4. Interface bus
ALGORITHM:
PROGRAM:
RESULT:
Thus the ALP was written to run a stepper motor at different speed in two directions.
EX:NO:
ARITHMETIC OPERATIONS OF 8051
DATE:
AIM:
OBJECTIVE:
ALGORITHM:
1. Start.
2. Get the inputs.
3. Perform the arithmetic operations (addition, subtraction, multiplication and division).
4. Stop.
PROGRAM:
ADDITION:
INPUT OUTPUT
4200 4500
4201
SUBTRACTION:
INPUT OUTPUT
4200 4500
4201
MULTIPLICATION:
INPUT OUTPUT
4200 4500
4201
DIVISION:
INPUT OUTPUT
4200
4500
4201
RESULT:
Thus the ALP was written to perform arithmetic operations using 8051.
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, and 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 CLOCKWISE
STEP A1 A2 B1 B2 DATA STEP A1 A2 B1 B2 DATA
1 1 0 0 1 09H 1 1 0 1 0 0AH
2 0 1 0 1 05H 2 0 1 1 0 06H
3 0 1 1 0 06H 3 0 1 0 1 05H
4 1 0 1 0 0AH 4 1 0 0 1 09H
RESULT:
Thus a stepper motor was interfaced with 8051 and run in forward and reverse directions at various
speeds.
Source Program 1:
MVI A, 80H : Initialize 8255, port A and port B
OUT 83H (CR) : in output mode
START: MVI A, 09H
OUT 80H (PA) : Send data on PA to glow R1 and R2
MVI A, 24H
OUT 81H (PB) : Send data on PB to glow G3 and G4
MVI C, 28H : Load multiplier count (40ıο) for delay
CALL DELAY : Call delay subroutine
MVI A, 12H
OUT (81H) PA : Send data on Port A to glow Y1 and Y2
OUT (81H) PB : Send data on port B to glow Y3 and Y4
MVI C, 0AH : Load multiplier count (10ıο) for delay
CALL: DELAY : Call delay subroutine
MVI A, 24H
OUT (80H) PA : Send data on port A to glow G1 and G2
MVI A, 09H
OUT (81H) PB : Send data on port B to glow R3 and R4
MVI C, 28H : Load multiplier count (40ıο) for delay
CALL DELAY : Call delay subroutine
MVI A, 12H
OUT PA : Send data on port A to glow Y1 and Y2
OUT PB : Send data on port B to glow Y3 and Y4
MVI C, 0AH : Load multiplier count (10ıο) for delay
CALL DELAY : Call delay subroutine
JMP START
Delay Subroutine:
RESULT:
Thus the ALP was written to interface stepper motor using 8051microcontroller.
8051 - SUM USING STACK
AIM:
To find the sum of elements in an array using stack.
ALGORITHM:
1. Start
2. Move the data to stack pointer
3. Move the data to accumulator
4. Move the data to reg B
5. Move the data to DPL
6. Push the value of A to stack
7. Push the value of B to stack
8. Push the value of DPL to stack
9. Halt
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT
4100 MOV SP, #67 67
4103 MOV A, #88 88
4105 MOV B, #66 66
4108 MOV DPL, #43 43
410B PUSH A
410D PUSH B
410F PUSH DPL
4111 SJMP
RESULT:
The sum of elements in an array is calculated.
8051 - SUM USING CALL OPTION
AIM:
To find the sum of elements in an array using call option.
ALGORITHM:
1. Start
2. Move the data to DPTR
3. Move the data to accumulator
4. Adjacent call 4200
5. Add A & R0
6. Move the 16 bit data from A to DPTR
7. Move the data to accumulator
8. Move the data to R0
9. Return to 4107
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT
4100 MOV DPTR,# 4300 43,00
4103 MOV A, # 00 00
4105 ACALL 4200 42,00
4108 ADD A, R0
410B MOVX @DPTR,A 80
410D SJMP
410F MOVA,#02 02
4111 MOV R0, #01 01
RET
OBSERVATION:
INPUT OUTPUT
4200 4300
4202
RESULT:
Statement: Design a microprocessor system to control traffic lights. The traffic light arrangement is as shown in
Fig. The traffic should be controlled in the following manner.
1) Allow traffic from W to E and E to W transition for 20 seconds. 2) Give transition period of 5 seconds (Yellow
bulbs ON) 3) Allow traffic from N to 5 and 5 to N for 20 seconds 4) Give transition period of 5 seconds (Yellow
Fig. shows the interfacing diagram to control 12 electric bulbs. Port A is used to control lights on N-S road and Port
B is used to control lights on W-E road. Actual pin connections are listed in Table 1 below.
The electric bulbs are controlled by relays. The 8255 pins are used to control relay on-off action with the help of
relay driver circuits. The driver circuit includes 12 transistors to drive 12 relays. Fig. also shows the interfacing of
INTERFACING DIAGRAM
SOFTWARE FOR TRAFFIC LIGHT CONTROL
FLOW CHART:
Source code:
MVI A,10
OUT C8
MVI A,18
OUT C8
MVI A,10
OUT D0
XRA A
XRA A
XRA A
MVI A,00
OUT D0
LOOP IN D8
ANI 01
CPI 01
JNZ LOOP
IN C0
STA 4150
HLT
RESULT:
Thus an assembly language program to simulate the traffic light at an intersection using a traffic light
interfaces was written and implemented.
Introduction to Software Tools
MPLAB, PROTEUS, and QL-2006 programmer
Aim:
1. To be familiar with some software tools like MPLAB, PROTEUS, and IC-
PROG.
2. To know how to make a project using MPLAB and then get the hex file of
the software program of the project.
3. How to simulate the hex file using PROTEUS.
Introduction
These programs are the backbone of the microprocessor and microcontroller based
systems; since using MPLAB we can build the software of the project using C or Assembly
language, and then we can simulate the project virtually using PROTEUS, finally we can
download the program on the microcontroller and see the results practically using IC-
PROG.
So this experiment includes all the knowledge the student will need to get started to these
programs.
1. MPLAB Program
• What is MPLAB?
• What is PROTEUS?
Proteus contains everything you need to develop, test and virtually prototype your
embedded system designs based around the Microchip Technologies™ PIC16 series
of microcontrollers. The unique nature of schematic based microcontroller simulation
with Proteus facilitates rapid, flexible and parallel development of both the system
hardware and the system firmware. This design synergy allows engineers to evolve
their projects more quickly, empowering them with the flexibility to make hardware or
firmware changes at will and reducing the time to market.
Proteus VSM models will fundamentally work with the exact same HEX file as you
would program the physical device with, binary files (i.e. Intel or Motorola Hex files)
produced by any assembler or compiler.
1. From start menu chose the PROTEUS, and then chose ISIS(blue).
2. To get a part click on Devices ( P ).
3. Write the name of the PIC16F84A.
4. To get LED write led then chose green led.
5. To get a resistor write 1k and chose the first part.
3. QL-2006 programmer
Hardware Installation
There is no special requirement for installation of this programmer.
Connect programmer to PC through serial port cable or USB cable
and power up, then the programmer works. (This programmer supports
direct USB power supply. If USB cable is connected, you may not
connect external power. However, if current through USB interface is
very low – less than 200MA and insufficient to drive programmer,
connection to external power is required to enable the programmer to
work regularly.)
Software Installation
Running of Software
After proper installation, shortcut of this software will appear on
desktop.We can double click it to run the software.
Result:
Thus the Programming PIC architecture with software tools was done .
EXPERIMENT 11
AIM:
Write a program for blinking of Led using 8051 microcontroller.
HARDWARE USED:
Microcontroller kit, Power supply, connecting wires.
SOFTWARE USED:
Keil µVision 4, Flash Magic.
WORKING OF SOFTWARE:
1. Keil µVision:
The µVision IDE combines project management, run-time environment, build facilities, source
code editing, and program debugging in a single powerful environment. µVision is easy-to-use and
accelerates your embedded software development. µVision supports multiple screens and allows
you to create individual window layouts anywhere on the visual surface.
Procedure of using Keil:
Step 1: Download the Keil Uvision IDE
For learning purposes, you can try the evaluation version of Keil which has code limitation of 2K
bytes. You must download the C51 version for programming on 8051 microcontroller
architecture.
Step 2: To initiate the programming you must create a project using the keil Uvision IDE
The option to create a new project will be available under the project tab in the toolbar. Next, you
have to store the project in a folder and give a suitable name to it.
You must add C file to your project before you begin coding. This can be done by right-clicking
on your project from the project pane and selection “Add a new item to source group 1”. In the
next dialog box, you will be given with the choice on what type of file you want to add such as C,
C++, header, text etc. Since here we are dealing with Embedded C programming, select C File (.c)
option. Provide the necessary name, location and click on add.
Step 5: Coding in C
The main part has finally arrived, so now you can go along with programming in C with your
respective microcontroller.
Example: Blinking of LED connected to Port 1 of 8051(or any other Intel family controller like
Atmel controller in laboratory).
#include <reg51.h>
//delay function declaration
void delay(void);
void main(void)
{
//an infinite loop
while(1)
{
// Turn ON all LED's connected to
Port1 P1 = 0xFF;
delay();
// Turn OFF all LED's connected to
Port1 P1 = 0x00;
delay();
}
}
//delay function definition
void delay(void)
{
int i,j;
for(i=0;i<0xff;i+
+)
for(j=0;j<0xff;j++);
}
Step 6 : Compiling and building the C project using Keil Uvision IDE
In order to build recently created C program go to Project tab and click on Build Target on the
menu bar. An alternate way to do this is by pressing the F7 key. If the code that you have written
is correct, the code will successfully compile without any errors. You can check your output in the
Build Output pane.
Step 7: Generating the hex file using Keil Uvision IDE
The code you compiled cannot be directly fed to the microcontroller, it is not possible. For that
purpose, we have to generate the hex code for your respective file.
In order to generate the hex code, right click on the „Target 1‟ folder and select options for target
„Target 1‟. Select the Output tab in the target „Target 1‟ dialog box. Make sure Create Hex File
option is checked and the HEX format should be HEX-80. Click OK.
Again rebuild your project by pressing F7. Your required hex file would have been generated with
the same as your project in the Objects folder.
If you wish you can also view your hex code by using a notepad.
Flash Magic is a PC tool for programming flash based microcontrollers from NXP using a serial
or Ethernet protocol while in the target hardware.
#inclu
de<re
g51.h
>void
main()
{
unsigned int x;
for(;;)
{
P
2
=
0
x
5
5
;
for( x=0;x<400;x++);
{
}
P
2
=
0
x
A
A
;
for( x=0;x<400;x++);
{
}
}
}
Result
Thus execution of the program the Led start blinking alternatively at odd and
even positions, after some delay.