actually, the program i written by another one, while testing, A can receive signal "1" and B can receive signal "0"; then it is expected to get a result--motor move clockwise...
the program is as follows:
;************************************************************
org 00h
jmp Initial
org 0bh
ajmp SystemClockInt
Initial:
Receiver equ p1 ; first 3 bits are device number, p1.3 is for ON-OFF
DeepSwitch equ p1 ; only last 4 bits (p1.4-p1.7) are used
TempMem equ 20h ; temp variable
DeepMem equ 21h
Signal equ 22h
;
; ::::::: Turn Off the Motor :::::::
;
clr p2.0
clr p2.1
;
; :::::: Initialize memory ::::::
;
mov Signal, #00h
;
; :::::: Initialize timer ::::::
;
mov ie, #10000010b ; Enable tf0
mov ip, #01h ; High Priority
mov tmod, #01h ; Timer 0
;
; ::::::: Get Switch Number :::::::
;
mov a, DeepSwitch
anl a, #01110000b
swap a
mov DeepMem, a
;
; ::::::: Get Receiver signal :::::::
;
Start:
mov a, Receiver
mov TempMem, a
anl a, #00000111b
cjne a, DeepMem, Start
mov a, TempMem
anl a, #00001000b
cjne a, Signal, IsNewSig
jmp Start
IsNewSig:
mov Signal, a ; Update info.
mov r7, #00h
mov r6, #00h
acall StartSystemClock
cjne a, #00h, IsLeft
IsRight:
mov p2, #00000010b
mov Receiver, #0ffh
TurningRight:
mov a, r6
cjne a, #20, TurningRight
acall StopSystemClock
mov p2, #00000000b
jmp Start
IsLeft:
cjne a, #00001000b, start
mov p2, #00000001b
TurningLeft:
mov a, r6
cjne a, #20, TurningLeft
acall StopSystemClock
mov p2, #00000000b
jmp Start
;******************************************************************************
;*
;* Timer Interrupt
;*
;******************************************************************************
SystemClockInt:
inc r7
acall StartSystemClock
reti
;-------------------------------------------------------------------------
StartSystemClock:
mov th0, #03ch ; 50000 machine cycle = 3CAF
mov tl0, #0afh
setb tr0 ; start timer
mov a, r7
cjne a, #0ff, QuitStartSystemClock
inc r6
mov r7, #00h
QuitStartSystemClock:
ret
;-------------------------------------------------------------------------
StopSystemClock:
clr tr0 ; stop timer
ret
end
;************************************************************
but I dun know why it cannot run while both input A and input B connected.
Without connected to At89C51, It really works when I just apply +9V to either input A or B...
I am a new learner for this ee field...so I could not slove this,but the deadline comes soon...
Thus, help me pls....^-^
Thanks alot...