ADDITION
MOV R0,#00
MOV A,#DATA1
ADD A, #DATA2
JNC LABEL
INC R0
LABEL: MOV DPTR,#4150
MOVX @DPTR,A
INC DPTR
MOV A,R0
MOVX @DPTR,A
HERE: SJMP HERE
SUBTRACTION
CLR C
MOV B,#00
MOV A,#DATA1
SUBB A,#DATA2
JNC LABEL
CPL A
INC A
INC B
LABEL: MOV DPTR,#4150
MOVX @DPTR, A
INC DPTR
MOV A,B
MOVX @DPTR,A
HERE: SJMP HERE
MULTIPLICATION
MOV A, #DATA1
MOV B, A
MOV A, #DATA2
MUL AB
MOV DPTR, #4150
MOVX @DPTR, A
INC DPTR
MOV A, B
MOVX @DPTR, A
LOOP: SJMP LOOP
DIVISION
MOV A, #DATA1
MOV B,A
MOV A, #DATA2
DIV AB
MOV DPTR, #4150
MOVX @DPTR, A
INC DPTR
MOV A, B
MOV @DPTR, A
LOOP SJMP LOOP
INTERFACING OF DAC (Digital to Analog Converter)
GENERATING WAVEFORMS:-
SQUARE WAVE GENERATION
START MOV DPTR,#FFC8
MOV A,#00
MOVX @DPTR,A
LCALL DELAY
MOV A,#FF
MOVX @DPTR,A
LCALL DELAY
LJMP START
DELAY MOV R1, #05
LOOP MOV R2, #FF
HERE DJNZ R2, HERE
DJNZ R1, LOOP
RET
SAWTOOTH WAVEFORM
MOV DPTR, #FFC8
MOV A,#00
LOOP: MOVX @DPTR,A
INC A
SJMP LOOP
TRIANGULAR WAVEFORM
MOV DPTR, #FFC8
START MOV A, #00
LOOP1 MOV @DPTR,A
INC A
JNZ LOOP1
MOV A, #FF
LOOP2 MOVX @DPTR,A
DEC A
JNZ LOOP2
LJMP START
STEPPER MOTOR
Start: MOV DPTR,#4500
MOV R0,#04H
JO : MOVX A,@DPTR
PUSH DPH
PUSH DPL
MOV DPTR,#FFC0
MOV R2,#04
MOV R1,#0F
DLY1: MOV R3,#0F
DLY: DJNZ R3,DLY
DJNZ R1,DLY1
DJNZ R2,DLY1
MOVX @DPTR,A
POP DPL
POP DPH
INC DPTR
DJNZ R0,JO
SJMP START
Address For Clockwise Rotation For Anticlockwise Rotation
4500 08 08
4501 01 02
4502 04 04
4503 02 01
No comments:
Post a Comment