lanceaustin
Programmer
Iam looking forward to learn to use 8051 controller to work for multi-purpose at the same time but don't understand how.
Lets suppose;
I want the controller to monitor P2.0 to P2.4 ,
when ever a bit is High i.e SET controller jumps to a specific Label to perform certain task like connecting a analog switch like MT8816 but at the same time controller should also keep on monitoring other pins and the pin which is just set whether the pin which is just set goes low or not...
e.g.
using 89c52 & MT8816 analog switch
; P2.0 is connected with a device which will sents a high or low signal.
; Port 1 is connected with a analog switch to sent 8 bit data when ever the P2.0 goes High.
; the analog switch remain connected for 10 seconds using timer 0 in 16-bit mode and then gets disconnected but at the same time controller also keep track whether P2.0 goes low if this happens then every thing is stopped.
; cs PIN IS Permittely high.
; strobe pin of MT8816 connected with Pin15 i.e P3.5
; address lines of MT8816 connected on P1.0 to P1.7 and DATA pin is connected with controllers P1.8
; I want to connect X0 with Y0
ORG 00H
LJMP MAIN
ORG 000BH ;timer 0 vector address
LJMP T0_ISR
MAIN:
MOV P2.0,#00H ;clearing Pin2.0
JNB P2.0,$ ;do nothing except for checking High signal
MOV TMOD,#02 ;timer 0 in mode 2
MOV R7,#100 ;10 X 5000 = 10 SECONDS.
MOV P3.5,#01H ;strobe pin is set high
MOV P1,#00000001B ;address for MT8816 and 1 for DATA pin.
MOV IE,#82H
SETB TR0
JNB P2.0
MOV P2.0,#00H ;clearing Pin2.0
END
T0_ISR:
CLR TR0 ;stop timer
DJNZ R7,SKIP ; decrement for 10 seconds.
CLR TR0
LJMP EXIT
SKIP:
MOV THO,#HIGH(-50000)
MOV TLO,#LOW(-50000)
SETB TR0
EXIT: RETI
the above programs may have some bugs or many more than enough but the idea is to keep connecting X0 with YO untill the bit P2.0 is set low or 10 seconds are passed, if the bit P2.0 is not goes low uptill 20 seconds then also the connection get disconnected.
But Here if there are four device connected at
P2.0
P2.1
P2.2
P2.3
and controller has to check all bits at all times and which ever goes high is connected with Y0.
how to provide all the above bit same facility at the same time.
the condition is if all four are High at the same time all should be connected with Y0, all these devices connected to these bits are also connected with X0, X1,X2,X3 rows of MT8816.
Lets suppose;
I want the controller to monitor P2.0 to P2.4 ,
when ever a bit is High i.e SET controller jumps to a specific Label to perform certain task like connecting a analog switch like MT8816 but at the same time controller should also keep on monitoring other pins and the pin which is just set whether the pin which is just set goes low or not...
e.g.
using 89c52 & MT8816 analog switch
; P2.0 is connected with a device which will sents a high or low signal.
; Port 1 is connected with a analog switch to sent 8 bit data when ever the P2.0 goes High.
; the analog switch remain connected for 10 seconds using timer 0 in 16-bit mode and then gets disconnected but at the same time controller also keep track whether P2.0 goes low if this happens then every thing is stopped.
; cs PIN IS Permittely high.
; strobe pin of MT8816 connected with Pin15 i.e P3.5
; address lines of MT8816 connected on P1.0 to P1.7 and DATA pin is connected with controllers P1.8
; I want to connect X0 with Y0
ORG 00H
LJMP MAIN
ORG 000BH ;timer 0 vector address
LJMP T0_ISR
MAIN:
MOV P2.0,#00H ;clearing Pin2.0
JNB P2.0,$ ;do nothing except for checking High signal
MOV TMOD,#02 ;timer 0 in mode 2
MOV R7,#100 ;10 X 5000 = 10 SECONDS.
MOV P3.5,#01H ;strobe pin is set high
MOV P1,#00000001B ;address for MT8816 and 1 for DATA pin.
MOV IE,#82H
SETB TR0
JNB P2.0
MOV P2.0,#00H ;clearing Pin2.0
END
T0_ISR:
CLR TR0 ;stop timer
DJNZ R7,SKIP ; decrement for 10 seconds.
CLR TR0
LJMP EXIT
SKIP:
MOV THO,#HIGH(-50000)
MOV TLO,#LOW(-50000)
SETB TR0
EXIT: RETI
the above programs may have some bugs or many more than enough but the idea is to keep connecting X0 with YO untill the bit P2.0 is set low or 10 seconds are passed, if the bit P2.0 is not goes low uptill 20 seconds then also the connection get disconnected.
But Here if there are four device connected at
P2.0
P2.1
P2.2
P2.3
and controller has to check all bits at all times and which ever goes high is connected with Y0.
how to provide all the above bit same facility at the same time.
the condition is if all four are High at the same time all should be connected with Y0, all these devices connected to these bits are also connected with X0, X1,X2,X3 rows of MT8816.