Electronic – can we use 8051 pin as Input and output at a time


is it possible to use 8051 microcontroller as input as well as output at a time? if i use particular pin as input and then how to make it as output as well.tell me please i born just now in microcontroller

Best Answer

The original 8051 and 80C51 has so-called pseudo-bidirectional I/O pins- they are open drain, with internal pullups (some pins may require external pullup resistors). So, they don't have (or need) the direction registers you may be familiar with from more modern microcontroller families than the rather long-in-the-tooth MCS-51).

So to use a pin as an input you write a '1' to the particular bit and read the pin. Whatever is connected to the 'input' must be able to sink more current than the pullup delivers.

It is not possible to use a pin as an input if it is set to '0' (the pull down transistor is quite strong).

The source current capability of the pin when used as an output is limited to what the pullup can deliver (though there is a 'strong' source transistor that comes on briefly when the pin is switched from '0' to '1' in order to charge stray capacitance connected to the pin quickly.

Edit :

Here is the bidirectional port image which might help beginners and others like me who just added an image to this wonderful answerenter image description here

Edit: The above is a simplified view that was added know my answer, I will leave it as it may be useful, but for a more complete view, check this more recent answer.

Related Topic