Download - Etheses

Transcript
2. Since Q = 0 and is connected to the transistor M1 gate, the M1 transistor is off.
3. When the M1 transistor is off, it blocks any path to the ground for any signal
connected to the input pin and the input signal is directed to the tri-state
BUF2.
4. When reading the input port in instructions such as “MOV A, P1” we are
really reading the data present at the pin. In other words, it is bringing into the
CPU the status of the external pin. This instruction activates the read pin of
BUF2 (TRI-STATE buffer2) and lets data at the pins flow into the CPU’s
internal bus.
•
WRITING “0” TO THE PORT
Now what happens if we write a “0” to a port that was configured as an input port?
If we write a 0 (low) to port bits, then Q = 0 and Q = 1. As a result of Q = 1. As a
result of Q = 1, the M1 transistor is “on”. If M1 is “on”, it provides the path to ground
for both R1 and input pin.
Therefore any attempt to read the input pin will always get the “low” ground signal
regardless of the status of the input pin. This can also lead to damage the port, as
explained next.
•
AVOID DAMAGING THE PORT
When connecting a switch to an input port of the 89C51 we must be very careful. This
is due to the fact that the wrong kind of connection can damage the port. Never
connect direct VCC to the 89C51 port pin.
If a switch with VCC and ground is connected directly to the pin and the M1 transistor
is “on” it will sink current from both internal load R1 and external VCC. This can be
too much current for M1 and will blow the transistor and, as a result, damage the port
bit. We are using buffer/driver IC, to convert any input switch to a buffer/driver IC
before it is fed to the 89C51 pin.
•
INSTRUCTIONS READING THE STATUS OF INPUT PORT:
Mnemonics
Examples
MOV A, Px
MOV A, P1
JNB
Px.y, …
JNB
P1.2, TARGET
JB
Px.y, …
JB
P1.3, TARGET
MOV C, Px.y
MOV C, P1.4
CJNE A, Px, …
CJNE A, P1, TARGET
58