Microprocessor and Microcontroller Laboratory Assignment
Microprocessor and Microcontroller Laboratory Assignment
Microprocessor and Microcontroller Laboratory Assignment
LABORATORY ASSIGNMENT
PROGRAM:
MANUAL VERIFICATION
Input :
20H - 5FH
21H - D8H
30H - 00H
31H - 00H
Output:
20H - 5FH
21H - D8H
30H - 01H
31H - 37H
RESULT:
Addition of two 8 bit numbers using 8051
microcontroller is done succesfully.
PROGRAM:
20H to R0
MOVR1,#30H;set destination
address 30H to R1
source to register A
R5
store borrow
source to register A
MOVR3,A; store second byte
MOVA,R5;get back the first operand
SUBBA,R3; Subtract R3 from A
JNCSAVE
INCR4; Increment R4 to get borrow
MOVB,R4;Get borrow to register B
MOV@R1,B; Store the borrow first
INCR1; Increase R1 to point to the
next address
MANUAL VERIFICATION
Input :
20H - 73H
21H - BDH
30H - 00H
31H - 00H
Output:
20H - 73H
21H - BDH
30H - 01H
31H - B6H
RESULT:
Subtraction of two 8 bit numbers using 8051
microcontroller is done succesfully.
PROGRAM:
MANUAL VERIFICATION
Input :
20H - FFH
21H - FFH
30H - 00H
31H - 00H
Output:
20H - FFH
21H - FFH
30H - FEH
31H - 01H
RESULT:
Multiplication of two 8 bit numbers using 8051
microcontroller is done succesfully.
PROGRAM:
DIV AB ; Divide A by B
MANUAL VERIFICATION
Input :
20H - 0EH
21H - 03H
30H - 00H
31H - 00H
Output:
20H - 0EH
21H - 03H
30H - 04H
31H - 02H
RESULT:
Division of two 8 bit numbers using 8051
microcontroller is done succesfully.
PROGRAM(8051)
Main : MOV A,#0FF H ;
Initializationof Port 1
MOV P1, A ;
MOV A,#77 H ;
Codefor the Phase 1
MOV P1, A ;
ACALL DELAY ; Delay
subroutine
MOV A, #BB H ;
Codefor the Phase II
MOV P1,A ;
ACALL DELAY ;
Delay subroutine.
MOV A, #DD H ;
Codefor the Phase III
MOV P1, A ;
ACALL DELAY ;
Delaysubroutine
MOV A, #EE H ;
Code for the Phase 1
MOV P1,A ;
ACALL DELAY ;
Delay subroutine
SJMP MAIN; Keepthe motor rotating
continuously.
DELAY Subroutine
MOV R4, #0FF H
; Load R4 with FF
MOV R5, #0FF
; Load R5 with FF
LOOP1: DJNZ R4, LOOP1 ;
Decrement R4 until zero,wait
LOOP2: DJNZ R5, LOOP2 ;
Decrement R5 until zero,wait
RET ; Return to
main program .
PROGRAM(8085)
Main : MVI A, 80 ; 80H →Control word
to configure PA,PB,PC in O/P
OUT CWR_Address ;Write control word in CWR of
8255
MVIA,77 ; Codefor the Phase 1
OUT PortA_Address ; sent to motor via port A of
8255;
CALL DELAY ; Delay subroutine
MVIA, BB ; Codefor the Phase II
OUT PortA_Address ; sent to motor via port A of 8255
CALL DELAY ; Delay subroutine.
MVIA, DD ; Codefor the Phase III
OUT PortA_Address ; sent to motor via port A of 8255
;CALL DELAY ; Delaysubroutine
MVIA, EE H ; Code for the Phase 1
OUT PortA_Address ; sent to motor via port A of 8255;
CALL DELAY ; Delay subroutine
JMP MAIN ; Keepthe motor rotating
continuously.
DELAY Subroutine
MVIC, FF ;Load Cwith FF--
Change it for the speed variation
LOOP1: MVI D,FF ;Load Dwith FF
LOOP2: DCR D
JNZ LOOP2
DCR C
JNZ LOOP1
RET ; Return to main program
Interfacing to 8086 and programming to control
stepper motor.
1. To rotate stepper motor in clock direction
Program:
.OUTPUT 2500AD
;EQUATES
PORT_C .EQUAL FFC4H ;PORT C ADDRESS
CTL_PORT .EQUAL FFC6H ;CONTROL PORT ADDRESS
CTL_BYTE .EQUAL 80H ;CONTROL BYTE FOR C PORT
= ON
PHASE_A .EQUAL 0cH ;BYTE TO SWTICH ON A PHASE
PHASE_B .EQUAL 06H ;BYTE TO SWTICH ON B
PHASE
PHASE_C .EQUAL 03H ;BYTE TO SWTICH ON C
PHASE
PHASE_D .EQUAL 0DH ;BYTE TO SWTICH ON D
PHASE
DSEG SEGMENT
org 0000 : 3000H
DELAY_COUNT DW 0
DSEG ENDS
CSEG SEGMENT
ASSUME CS : CSEG, DS : DSEG
ORG 0000 : 4000H
;Start of Test Program
MOV AL, CTL_BYTE ;8255 INITIALISATION
.OUTPUT 2500AD
; EQUATES
PORT_C .EQUAL FFC4H; PORT C
ADDRESS
CTL_PORT .EQUAL FFC6H; CONTROL
PORT ADDRESS
CTL_BYTE .EQUAL 80H ; CONTROL
BYTE FOR C PORT = ON
PHASE_A .EQUAL 0CH ; BYTE TO
SWTICH ON A PHASE
PHASE_B .EQUAL 06H ; BYTE TO
SWTICH ON B PHASE
PHASE_C .EQUAL 03H ; BYTE TO
SWTICH ON C PHASE
PHASE_D .EQUAL 0DH ;BYTE TO
SWTICH ON D PHASE
DSEG SEGMENT
org 0000 : 3000H
DELAY_COUNT DW 0
DSEG ENDS
; In a one-phase on scheme (anti
clockwise) half step
CSEG SEGMENT
ASSUME CS : CSEG, DS : DSEG
INITIALISATION
MOV DX, CTL_PORT
OUT DX, AL
SWITCHING OF PHASES
MOV AL, BBH ;PHASE_B
MOV DX, PORT_C
CALL DELAY
;DELAY BET. SWTICHING OF
PHASES
;Delay subroutine
DELAY1:
RET
CSEG ENDS
.END
Result:
stepper motor is interfaced to 8086 and
rotated in anticlockwise direction.
END RESULT:
Interfacing stepper motor with 8085, 8086,
and 8051 is done succesfully