MP Manual
MP Manual
IV Semester IT
Syllabus
Keyboard control
Display
File Manipulation
6. Mini- Project
CYCLE I
8085 Programming
1. Introduction to 8085
2. 8 bit Addition and Subtraction
3. 8 bit Multiplication and Division
4. 16 bit Addition and Subtraction
5. 16 bit Multiplication and Division
6. Largest and Smallest number in an array
7. Sorting in Ascending and Descending Order
8. BCD Addition and Subtraction
CYCLE II
8086 Programming
BIOS/DOS calls
Interfacing
16. Interfacing 8255 PPI IC with 8085
17. Interfacing 8253 Timer IC with 8085
18. Interfacing 8279 Keyboard/Display IC with 8085/8086
19. Interfacing 8251 Serial communication IC with 8085/8086
8051 Programming
1. INTRODUCTION TO 8085
INTEL 8085 is one of the most popular 8-bit microprocessor capable of addressing 64
KB of memory and its architecture is simple. The device has 40 pins, requires +5 V power
supply and can operate with 3MHz single phase clock.
Register array
The 8085 has six general purpose registers to store 8-bit data during program execution.
These registers are identified as B, C, D, E, H and L. they can be combined as BC, DE and
HL to perform 16-bit operation.
Accumulator
Accumulator is an 8-bit register that is part of the ALU. This register is used to store 8-bit
data and to perform arithmetic and logic operation. The result of an operation is stored in the
accumulator.
Program counter
The program counter is a 16-bit register used to point to the memory address of the next
instruction to be executed.
Stack pointer
It is a 16-bit register which points to the memory location in R/W memory, called the
Stack.
Communication lines
8085 microprocessor performs data transfer operations using three communication lines
called buses. They are address bus, data bus and control bus.
Address bus – it is a group of 16-bit lines generally identified as A 0 – A15. The
address bus is unidirectional i.e., the bits flow in one direction from
microprocessor to the peripheral devices. It is capable of addressing 2 16 memory
locations.
Data bus – it is a group of 8 lines used for data flow and it is bidirectional. The
data ranges from 00 – FF.
Control bus – it consist of various single lines that carry synchronizing signals.
The microprocessor uses such signals for timing purpose.
2(A). 8 BIT DATA ADDITION
AIM:
ALGORITHM:
RESULT:
Thus the 8 bit numbers stored at 4500 &4501 are added and the result stored at 4502 & 4503.
FLOW CHART:
START
[C] 00H
[HL] 4500H
NO
Is there a
YES
Carry ?
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
4500 4502
4501 4503
2(B). 8 BIT DATA SUBTRACTION
AIM:
ALGORITHM:
RESULT:
Thus the 8 bit numbers stored at 4500 &4501 are subtracted and the result stored at 4502 &
4503.
FLOW CHART:
START
Is there a
Borrow ? NO
YES
Complement [A]
Add 01H to [A]
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
4500 4502
4501 4503
3(A). 8 BIT DATA MULTIPLICATION
AIM:
To multiply two 8 bit numbers stored at consecutive memory locations and store the
result in memory.
ALGORITHM:
RESULT:
Thus the 8-bit multiplication was done in 8085p using repeated addition method.
FLOW CHART:
START
[HL] 4500
B M
[HL] [HL]+1
A 00
C 00
YES
C C+1
B B-1
NO IS B=0
YES
A
A
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
4500 4502
4501 4503
3(B). 8 BIT DIVISION
AIM:
ALGORITHM:
RESULT:
Thus an ALP was written for 8-bit division using repeated subtraction method and
executed using 8085 p kits
FLOWCHART:
START
B 00
[HL] 4500
A M
[HL] [HL]+1
M A-M
[B] [B] +1
IS A<0 NO
YES
A A+ M
B B-1
STOP
PROGRAM:
OBSERVATION:
AIM:
ALGORITHM:
RESULT:
Thus an ALP program for 16-bit addition was written and executed in 8085p using
special instructions.
FLOW CHART:
START
[L] [4050 H]
[H] [4051 H]
[DE] [HL]
[L] [4052H]
[H] [4053H]
Is there a NO
Carry?
YES
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
ADDRES DATA ADDRESS DATA
S
4050H 4054H
4051H 4055H
4052H 4056H
4053H
4(B). 16 BIT DATA SUBTRACTION
AIM:
ALGORITHM:
RESULT:
Thus an ALP program for subtracting two 16-bit numbers was written and executed.
FLOW CHART:
START
[L] [4050 H]
[H] [4051 H]
[DE] [HL]
[L] [4052H]
[H] [4053H]
[HL] [HL]-[DE]
Is there a
borrow? NO
YES
[C] [C]+1
[4054] [ L]
[4055] [H]
[4056] [C]
STOP
PROGRAM:
ADDRESS OPCODE LABEL MNEMO OPER COMMENTS
NICS AND
4000 START MVI C, 00 Initialize C reg.
4001
4002 LHLD 4050H Load the subtrahend in DE
4003 reg. Pair through HL reg.
4004 pair.
4005 XCHG
4006 LHLD 4052H Load the minuend in HL reg.
4007 Pair.
4008
4009 MOV A, L Move the content of reg. L to
Acc.
400A SUB E Subtract the content of reg.
E from that of acc.
400B MOV L, A Move the content of Acc. to
reg. L
400C MOV A, H Move the content of reg. H to
Acc.
400D SBB D Subtract content of reg. D
with that of Acc.
400E MOV H, A Transfer content of acc. to
reg. H
400F SHLD 4054H Store the content of HL pair
4010 in memory location 8504H.
4011
4012 JNC NEXT If there is borrow, go to the
4013 instruction labeled NEXT.
4014
4015 INR C Increment reg. C
4016 NEXT MOV A, C Transfer the content of reg. C
to Acc.
4017 STA 4056H Store the content of acc. to
4018 the memory location 4506H
4019
401A HLT Stop the program execution.
OBSERVATION:
INPUT OUTPUT
ADDRES DATA ADDRESS DATA
S
4050H 4054H
4051H 4055H
4052H 4056H
4053H
5(A). 16 BIT MULTIPLICATION
AIM:
ALGORITHM:
RESULT:
Thus the 16-bit multiplication was done in 8085p using repeated addition method.
FLOWCHART:
START
DE HL
YES
YES
A
A
[4054]L
[4055]H
[4056]C
[4057]B
STOP
ADDRESS OPCOD LABEL MNEM OPERAN COMMENTS
E ONICS D
8001 START LHLD 4050 Load the first No. in stack pointer
4001 through HL reg. pair
4002
4003 SPHL
4004 LHLD 4052 Load the second No. in HL reg.
4005 pair
4006 & Exchange with DE reg. pair.
4007 XCHG
4008 LXI H, 0000H
4009
400A Clear HL & DE reg. pairs.
400B LXI B, 0000H
400C
400D
400E LOOP DAD SP Add SP with HL pair.
400F JNC NEXT If there is no carry, go to the
4010 instruction labeled NEXT
4011
4012 INX B Increment BC reg. pair
4013 NEXT DCX D Decrement DE reg. pair.
4014 MOV A,E Move the content of reg. E to Acc.
4015 ORA D OR Acc. with D reg.
4016 JNZ LOOP If there is no zero, go to instruction
4017 labeled LOOP
4018
4019 SHLD 4054 Store the content of HL pair in
401A memory locations 4054 & 4055.
401B
401C MOV A, C Move the content of reg. C to Acc.
401D STA 4056 Store the content of Acc. in
401E memory location 4056.
401F
4020 MOV A, B Move the content of reg. B to Acc.
4021 STA 4057 Store the content of Acc. in
4022 memory location 4056.
4023
4024 HLT Stop program execution
OBSERVATION:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4050 4054
4051 4055
4052 4056
4053 4057
5(B). 16- BIT DIVISION
AIM:
To divide two 16-bit numbers and store the result in memory using 8085 mnemonics.
ALGORITHM:
RESULT:
Thus the 16-bit Division was done in 8085p using repeated subtraction method.
FLOWCHART:
START
HL DE
YES
A
A
STOP
PROGRAM:
ADDRESS OPCODE LABEL MNEM OPERA COMMENTS
ONICS ND
4000 START LHLD 4052 Load the first No. in stack pointer
4001 through HL reg. pair
4002
4003 XCHG
4004 LHLD 4050 Load the second No. in HL reg. pair
4005 & Exchange with DE reg. pair.
4006
4007 LXI B, 0000H
4008 Clear BC reg. pair.
4009
400A LOOP MOV A, L Move the content of reg. L to Acc.
400B SUB E Subtract reg. E from that of Acc.
400C MOV L, A Move the content of Acc to L.
400D MOV A, H Move the content of reg. H Acc.
400E SBB D Subtract reg. D from that of Acc.
400F MOV H, A Move the content of Acc to H.
4010 INX B Increment reg. Pair BC
4011 JNC LOOP If there is no carry, go to the location
4012 labeled LOOP.
4013
4014 DCX B Decrement BC reg. pair.
4015 DAD D Add content of HL and DE reg. pairs.
4016 SHLD 4054 Store the content of HL pair in 4054 &
4017 4055.
4018
4019 MOV A, C Move the content of reg. C to Acc.
401A STA 4056 Store the content of Acc. in memory
401B 4056
401C
401D MOV A, B Move the content of reg. B to Acc.
401E STA 4057 Store the content of Acc. in memory
401F 4057.
4020
4021 HLT Stop the program execution.
OBSERVATION:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4050 4054
4051 4055
4052 4056
4053 4057
6(A). LARGEST ELEMENT IN AN ARRAY
AIM:
To find the 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.
RESULT:
Thus the largest number in the given array is found out.
FLOW CHART:
START
[HL] [4100H]
[B] 04H
[A] [HL]
[HL [HL] + 1
NO IS
[A] < [HL]?
YES
[A] [HL]
[B] [B]-1
IS NO
[B] = 0?
YES
[4105] [A]
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4100 4105
4101
4102
4103
4104
6(B). SMALLEST ELEMENT IN AN ARRAY
AIM:
To find the smallest 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.
RESULT:
Thus the smallest number in the given array is found out.
FLOW CHART:
START
[HL] [4100H]
[B] 04H
[A] [HL]
[HL [HL] + 1
IS
YES [A] < [HL]?
NO
[A] [HL]
[B] [B]-1
IS
[B] = 0? NO
YES
[4105] [A]
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
4100 4105
4101
4102
4103
4104
7(A).ASCENDING ORDER
AIM:
To sort the given number in the ascending order using 8085 microprocessor.
ALGORITHM:
RESULT:
Thus the ascending order program is executed and thus the numbers are arranged in
ascending order.
FLOWCHART: START
[B] 04H
[HL] [4100H]
[C] 04H
[A] [HL]
[HL [HL] + 1
IS
YES [A] < [HL]?
NO
[D] [HL]
[HL] [A]
[HL] [HL] - 1
[HL] [D]
[HL] [HL] + 1
[C] [C] – 01 H
A
A
IS
[C] = 0? NO
YES
[B] [B]-1
IS
[B] = 0? NO
YES
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION LOCATION
4100 4100
4101 4101
4102 4102
4103 4103
4104 4104
7(B). DESCENDING ORDER
AIM:
To sort the given number in the descending order using 8085 microprocessor.
ALGORITHM:
RESULT:
Thus the descending order program is executed and thus the numbers are arranged in
descending order.
FLOWCHART: START
[B] 04H
[HL] [4100H]
[C] 04H
[A] [HL]
[HL [HL] + 1
IS
NO [A] < [HL]?
YES
[D] [HL]
[HL] [A]
[HL] [HL] - 1
[HL] [D]
[HL] [HL] + 1
[C] [C] – 01 H
A
A
IS
[C] = 0? NO
YES
[B] [B]-1
IS
[B] = 0? NO
YES
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION LOCATION
4100 4100
4101 4101
4102 4102
4103 4103
4104 4104
ALGORITHM:
RESULT:
Thus the 8 bit BCD numbers stored at 4500 &4501 are added and the result stored at 4502 &
4503.
FLOW CHART:
START
[C] 00H
[HL] 4500H
NO
Is there a
Carry ? YES
STOP
PROGRAM:
OBSERVATION:
INPUT OUTPUT
4500 4502
4501 4503
ALGORITHM:
RESULT:
Thus the 8 bit BCD numbers stored at 4500 &4501 are subtracted and the result stored at 4502 &
4503.
FLOW CHART:
START
Is there a
Carry ?
YES
NOSTOP
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT
4100 START MVI D, 00 Clear D reg.
4101
4102 LXI H, 4500 Initialize HL reg. to
4103 4500
4104
4105 MOV B, M Transfer first data to
accumulator
4106 INX H Increment HL reg. to
point next mem.
Location.
4107 MOV C, M Move second no. to B
reg.
4108 MVI A, 99 Move 99 to the
4109 Accumulator
410A SUB C Subtract [C] from acc.
Content.
410B INR A Increment A register
410C ADD B Add [B] with [A]
410D DAA Adjust Accumulator
value for Decimal digits
410E JC LOOP Jump on carry to loop
410F
4110
4111 INR D Increment D reg.
4112 LOOP INX H Increment HL register
pair
4113 MOV M,A Move the Acc.content to
the memory location
4114 INX H Increment HL reg. to
point next mem.
Location.
4115 MOV M, D Transfer D register
content to memory.
4116 HLT Stop the program
OBSERVATION:
INPUT OUTPUT
4500 4502
4501 4503
10. 2 X 2 MATRIX MULTIPLICATION
AIM:
ALGORITHM:
1. Load the 2 input matrices in the separate address and initialize the HL and the DE register
pair with the starting address respectively.
2. Call a subroutine for performing the multiplication of one element of a matrix with the
other element of the other matrix.
3. Call a subroutine to store the resultant values in a separate matrix.
RESULT:
Thus the 2 x 2 matrix multiplication is performed and the result is stored at 4700,4701 , 4702 &
4703.
FLOW CHART:
START A
C 00H
HL 8500H
DE 8600H
Call subroutine
MUL
Call subroutine
MUL A A+B
B A Call subroutine
STORE
Call subroutine
MUL Is A=04H?
YES
A A+B
NO
Increment HL
Call subroutine reg. pair
STORE
STOP
B
Call subroutine
MUL
B A
BA A
MUL
STORE
Is H=0 ?
YES
RET
NO
Is H=0 ?
NO
YES
RET
PROGRAM:
OBSERVATION:
INPUT OUTPUT
4500 4600 4700
4501 4601 4701
4502 4602 4702
4503 4603 4703
11. BIOS/DOS CALLS – DISPLAY
AIM:
To display a message on the CRT screen of a microcomputer using DOS calls.
ALGORITHM:
1. Initialize the data segment and the message to be displayed.
2. Set function value for display.
3. Point to the message and run the interrupt to display the message in the CRT.
PROGRAM:
RESULT:
A message is displayed on the CRT screen of a microcomputer using DOS calls
12. BIOS/DOS CALLS – FILE MANIPULATION
AIM:
To open a file using DOS calls.
ALGORITHM:
1. Initialize the data segment, file name and the message to be displayed.
2. Set the file attribute to create a file using a DOS call.
3. If the file is unable t o create a file display the message
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
FILENAME DB “SAMPLE.DAT”, “$”
MSG DB 0DH, 0AH, “FILE NOT CREATED”, ODH, OAH, “$”
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV DX, OFFSET FILENAME
MOV CX, 00H
MOV AH, 3CH
INT 21H
JNC LOOP1
MOV AX, DATA
MOV DS, AX
MOV DX, OFFSET MSG
MOV AH, 09H
INT 21H
LOOP1 MOV AH, 4CH
INT 21H
CODE ENDS
END START
RESULT:
A file is opened using DOS calls.
13. BIOS/DOS CALLS – DISK INFORMATION
AIM:
To display the disk information.
ALGORITHM:
1. Initialize the data segment and the message to be displayed.
2. Set function value for disk information.
3. Point to the message and run the interrupt to display the message in the CRT.
PROGRAM:
RESULT:
The disk information is displayed.
1.8086 STRING MANIPULATION – SEARCH A WORD
AIM:
To search a word from a string.
ALGORITHM:
1. Load the source and destination index register with starting and the ending
address respectively.
2. Initialize the counter with the total number of words to be copied.
3. Clear the direction flag for auto incrementing mode of transfer.
4. Use the string manipulation instruction SCASW with the prefix REP to search a
word from string.
5. If a match is found (z=1), display 01 in destination address. Otherwise, display 00
in destination address.
RESULT:
A word is searched and the count of number of appearances is displayed.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DW 53H, 15H, 19H, 02H
DEST EQU 3000H
COUNT EQU 05H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, 15H
MOV SI, OFFSET LIST
MOV DI, DEST
MOV CX, COUNT
MOV AX, 00
CLD
REP SCASW
JZ LOOP
MOV AX, 01
LOOP MOV [DI], AX
MOV AH, 4CH
INT 21H
CODE ENDS
END START
INPUT:
LIST: 53H, 15H, 19H, 02H
OUTPUT:
3000 01
2.8086 STRING MANIPULATION –FIND AND REPLACE A WORD
AIM:
To find and replace a word from a string.
ALGORITHM:
1. Load the source and destination index register with starting and the ending
address respectively.
2. Initialize the counter with the total number of words to be copied.
3. Clear the direction flag for auto incrementing mode of transfer.
4. Use the string manipulation instruction SCASW with the prefix REP to search
a word from string.
5. If a match is found (z=1), replace the old word with the current word in
destination address. Otherwise, stop.
RESULT:
A word is found and replaced from a string.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DW 53H, 15H, 19H, 02H
REPLACE EQU 30H
COUNT EQU 05H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, 15H
MOV SI, OFFSET LIST
MOV CX, COUNT
MOV AX, 00
CLD
REP SCASW
JNZ LOOP
MOV DI, LABEL LIST
MOV [DI], REPLACE
LOOP MOV AH, 4CH
INT 21H
CODE ENDS
END START
INPUT:
LIST: 53H, 15H, 19H, 02H
OUTPUT:
LIST: 53H, 30H, 19H, 02H
3. 8086 STRING MANIPULATION – COPY A STRING
AIM:
To copy a string of data words from one location to the other.
ALGORITHM:
6. Load the source and destination index register with starting and the ending
address respectively.
7. Initialize the counter with the total number of words to be copied.
8. Clear the direction flag for auto incrementing mode of transfer.
9. Use the string manipulation instruction MOVSW with the prefix REP to copy a
string from source to destination.
RESULT:
A string of data words is copied from one location to other.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
SOURCE EQU 2000H
DEST EQU 3000H
COUNT EQU 05H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV SI, SOURCE
MOV DI, DEST
MOV CX, COUNT
CLD
REP MOVSW
MOV AH, 4CH
INT 21H
CODE ENDS
END START
INPUT: OUTPUT:
2000 48 3000 48
2001 84 3001 84
2002 67 3002 67
2003 90 3003 90
2004 21 3004 21
4.8086 STRING MANIPULATION – SORTING
AIM:
To sort a group of data bytes.
ALGORITHM:
Place all the elements of an array named list (in the consecutive memory
locations).
Initialize two counters DX & CX with the total number of elements in the
array.
Do the following steps until the counter B reaches 0.
o Load the first element in the accumulator
o Do the following steps until the counter C reaches 0.
1. Compare the accumulator content with the next element present in
the next memory location. If the accumulator content is smaller go
to next step; otherwise, swap the content of accumulator with the
content of memory location.
2. Increment the memory pointer to point to the next element.
3. Decrement the counter C by 1.
Stop the execution.
RESULT:
A group of data bytes are arranged in ascending order.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DW 53H, 25H, 19H, 02H
COUNT EQU 04H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV DX, COUNT-1
LOOP2: MOV CX, DX
MOV SI, OFFSET LIST
AGAIN: MOV AX, [SI]
CMP AX, [SI+2]
JC LOOP1
XCHG [SI +2], AX
XCHG [SI], AX
LOOP1: ADD SI, 02
LOOP AGAIN
DEC DX
JNZ LOOP2
MOV AH, 4CH
INT 21H
CODE ENDS
END START
INPUT:
LIST: 53H, 25H, 19H, 02H
OUTPUT:
LIST: 02H, 19H, 25H, 53H
4. INTERFACING 8255 WITH 8085
AIM:
To interface programmable peripheral interface 8255 with 8085 and study its
characteristics in mode0,mode1 and BSR mode.
APPARATUS REQUIRED:
8085 p kit, 8255Interface board, DC regulated power supply, VXT parallel bus
I/O MODES:
Control Word:
MAIN PROGRAM:
Sub program:
ADDRESS OPCODES LABEL MNEMONICS OPERAND COMMENTS
405E JMP 4200 Go to 4200
405F
4060
PROGRAM:
RESULT:
Thus 8255 is interfaced and its characteristics in mode0,mode1 and BSR mode is
studied.
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.
output will be remaining low while counting and on terminal count; the output will become
Program:
Address Opcodes Label Mnemonic Operands Comments
4100 START: MVI A, 30 Channel 0 in mode 0
4102 OUT CE Send Mode Control word
4104 MVI A, 05 LSB of count
4106 OUT C8 Write count to register
4108 MVI A, 00 MSB of count
410A OUT C8 Write count to register
410C HLT
It is observed in CRO that the output of Channel 0 is initially LOW. After giving six clock
pulses, the output goes HIGH.
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.
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.
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:
We utilize Mode 0 to generate a square wave of frequency 150 KHz at channel 0.
Address Opcodes Label Mnemonic Operands Comments
4100 3E 36 START MVI A, 36 Channel 0 in mode 3
:
4102 D3 CE OUT CE Send Mode Control word
4104 3E 0A MVI A, 0A LSB of count
4106 D3 C8 OUT C8 Write count to register
4108 3E 00 MVI A, 00 MSB of count
410A D3 C8 OUT C8 Write count to register
410C 76 HLT
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.
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.
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.
output will be remaining low while counting and on terminal count; the output will become
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:
Address Opcodes Label Mnemonic Operands Comments
4100 START: MVI A, 30 Channel 0 in mode 0
4102 OUT CE Send Mode Control word
4104 MVI A, 05 LSB of count
4106 OUT C8 Write count to register
4108 MVI A, 00 MSB of count
410A OUT C8 Write count to register
410C HLT
It is observed in CRO that the output of Channel 0 is initially LOW. After giving six clock
pulses, the output goes HIGH.
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.
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.
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:
We utilize Mode 0 to generate a square wave of frequency 150 KHz at channel 0.
Address Opcodes Label Mnemonic Operands Comments
4100 3E 36 START MVI A, 36 Channel 0 in mode 3
:
4102 D3 CE OUT CE Send Mode Control word
4104 3E 0A MVI A, 0A LSB of count
4106 D3 C8 OUT C8 Write count to register
4108 3E 00 MVI A, 00 MSB of count
410A D3 C8 OUT C8 Write count to register
410C 76 HLT
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.
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:
MOV DPTR, #4500
MOVX A, @DPTR
MOV B, #0A
MUL A, B
MOV B, A
INC DPTR
MOVX A, @DPTR
ADD A, B
INC DPTR
MOVX @DPTR, A
HLT: SJMP HLT
INPUT OUTPUT
4500 23 4501 17
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 CLOCKWISE
STEP A1 A2 B1 B2 DATA STEP A1 A2 B1 B2 DATA
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
Address
OPCODES
Label Comments
ORG 4100h
PROCEDURE:
Enter the above program starting from location 4100.and execute the same. The stepper
motor rotates. Varying the count at R4 and R5 can vary the speed. Entering the data in the look-
up TABLE in the reverse order can vary direction of rotation.
RESULT:
Thus a stepper motor was interfaced with 8051 and run in forward and reverse directions
at various speeds.