The standard 8051 has a quite simple port circuit on P1. Is it made from an open-drain output and a pull-up circuit. For example:
The open-drain output is realized by n3
. This transistor is capable to drain some current, refer to the data sheet of your controller. It drives the output "low" when you output a 0
.
n1
and n2
form the pull-up, providing some stronger current (n1
) and some weaker current (n2
) to a sink at the port pin. This way a "high" is output.
What is the reason for n1
and its driving circuit? Well, if the output has to change from "low" to "high", it drives for 2 system clock cycles some more current. This way the raising edge at the output is shorter, because the inevitable parasitic capacitance is charged faster.
To use the pin as input, you will output a 1
. This opens n3
and (after the 2 cycles mentioned above) lets n2
provide the "high" level. If you leave the pin unconnected or floating, if will be read as 1
. If you source it with a "high", it will also be read as 1
. To input "low", your external signal source needs to drive the pin to ground. Refer to the data sheet to find out how much current you will need to safely get under the 0
threshold.
In short:
- Output
0
: strong "low" to external circuit
- Output
1
: weak "high" to external circuit
- Output
1
, input "floating": read 1
- Output
1
, input "high": read 1
- Output
1
, input "low": read 0
As we all know
because it is not true, we don't all know \$\endgroup\$if I connect 8 LEDs to those pins
... please draw a diagram of how the LEDs are connected \$\endgroup\$open collector LED
...... duckduckgo.com/… \$\endgroup\$