Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/14/05 17:40
Read: times


 
#87403 - FAO Eric the Great.
Responding to: ???'s previous message
I am inputting a 4 bit binary code from the mt8870 which will go to p3.4 p3.5 p3.6 and 3.7 with 3.4 being the least significant bit and so on. I am inputting the codes to control a stepper motor and some led's. Here is my code which is having limited success to say the least. #
Ro. Republic of Ireland.
Thank you for your help any body!



;Take in a 6 digit DTMF code

$MOD831

ORG 000h
MOV P3, #0FFh
JMP MAINCODE

; EXTERNAL INTERRUPT
ORG 000h
CJNE R0, #00h, DIGIT2
SETB P2.2
MOV R1, P3
MOV R0, #01h
JMP EXIT
DIGIT2:
CJNE R0, #01h, DIGIT3
SETB P2.4
MOV R2, P3
MOV R0, #02h
JMP EXIT

DIGIT3:
CJNE R0, #02h, DIGIT4
SETB P2.6
MOV R3, P3
MOV R0, #03h
JMP EXIT

DIGIT4:
CJNE R0, #03h, DIGIT5
MOV R4, P3
MOV R0, #04h
JMP EXIT

DIGIT5:
CJNE R0, #04h, DIGIT6
MOV R5, P3
MOV R0, #05h
JMP EXIT

DIGIT6:
CJNE R0, #05h, EXIT
MOV R6, P3
MOV R0, #06h

EXIT: RETI


MAINCODE:
mov P2, #000h
MOV R0, #00H
SETB EX1
SETB EA

JMP WAIT

REWAIT: MOV R0, #00H

;Wait for DTMF Input
WAIT:SETB P2.0

CJNE R0, #06H, WAIT
CLR P2.0

MOV A, R1
ANL A, #0AAH
MOV R1, A

MOV A, R2
ANL A, #0AAH
MOV R2, A

; 1 = 00010000
; 2 = 00100000
; 3 = 00110000
; 4 = 01000000
; 5 = 01010000
; 6 = 01100000
; 7 = 01110000
; 8 = 10000000
; 9 = 10010000

;r1,r2 Like User Password r1 = 2 r2 = 1
CJNE r1, #20H, WRONGPWD
CJNE r2, #10H, WRONGPWD


; r3 and r4 are the number of steps required r3 - number of tens r4 - number of
;units
; Max of 20
; Add r3 and r4
; Multiply r3 by 10
MOV A, r3
CALL CONVERT
MOV r3, A

MOV A, r4
CALL CONVERT
MOV r4, A

SETB P2.2
MOV A, r3
MOV B, #0Ah
MUL AB
ADD A, r4
MOV r3, A
; r3 now holds number of steps

MOV A, R5
ANL A, #0AAH
MOV R5, A

CJNE R5,#02H, TEMP
SETB P2.1
JMP LOOP
TEMP: CLR P2.1


LOOP: CJNE r3, #00h, STEP
JMP ENDOFLOOP
STEP:SETB P2.3
CALL DELAY
CLR P2.3
CALL DELAY
MOV A, r3
SUBB A,#01h
MOV r3, A
JMP LOOP

ENDOFLOOP: CLR P2.2
MOV R0,#00H
JMP REWAIT

WRONGPWD:JMP REWAIT
MOV R0,#00H


; 1mS DELAY
push 07h
push 06h

DELAY: MOV R7, #02d
rst_inner_loop: MOV R6, #250d
INNERLOOP: DJNZ R6, INNERLOOP
DJNZ R7, rst_inner_loop

pop 06h
pop 07h
RET





CONVERT:
ANL A, #0AAh
;NOW CONVERT DTMF CODE
CJNE A,#02H, NEXT1
MOV A, #01H

NEXT1:CJNE A,#20H, NEXT2
MOV A, #10H

NEXT2:CJNE A,#0AH, NEXT3
MOV A, #03H

NEXT3:CJNE A,#20H, NEXT4
MOV A, #04H

NEXT4:CJNE A,#22H, NEXT5
MOV A, #05H

NEXT5:CJNE A,#28H, NEXT6
MOV A, #06H

NEXT6:CJNE A,#2AH, NEXT7
MOV A, #07H

NEXT7:CJNE A,#80H, NEXT8
MOV A, #08H

NEXT8:CJNE A,#82H, NEXT9
MOV A, #09H

NEXT9: MOV A, #00H
RET



END



List of 15 messages in thread
TopicAuthorDate
4 bit binary input            01/01/70 00:00      
   Swap and Mask            01/01/70 00:00      
   as I read your post            01/01/70 00:00      
      FAO Eric the Great.            01/01/70 00:00      
         oops            01/01/70 00:00      
   Updated profile            01/01/70 00:00      
   It is useful!            01/01/70 00:00      
      already shown            01/01/70 00:00      
   Reformatted Code for readability            01/01/70 00:00      
      Neat            01/01/70 00:00      
         re:neat            01/01/70 00:00      
      risque business            01/01/70 00:00      
   Strobe            01/01/70 00:00      
      Strobe valid?            01/01/70 00:00      
   For any pinout            01/01/70 00:00      

Back to Subject List