Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Slide 1

The internal structure of ports in 8051 microcontroller. Since all ports of 8051, they all have 3
component in their structure. D latch output driver and an input buffer. D latch holds one bit of
information. Output driver to drive the pin. An input buffer to read status from the pin. The
diagram shows a typical 8051 port 1 Architects TB1 and TB2 are 2 tristate buffer. The input given
to tristate buffer is given to the output side base on the status of control pin L1 is an internal
pull-up resistor. Let's see how to write data to Port pin of 8051. This is the internal diagram of a
single pin of Port 1 similar diagram would be there for other port pins of Port 1 .

Smart Logic Academy © All copyrights reserved


Slide 2

Let’s try to write logic 0 to this port pin P1.x. That case first in assembly language you have to
send logic 0 to port 1 like MOV P1,#00h and in C-language P1=0x00. So whenever such
instruction get executed since we are writing zero internal CPU bus you will get logic 0
Whenever there is a clock this input is given to the D latch output. Q becomes 0 and Q bar
become 1. For logic 1 the MOSFET of driver circuit will turn on and hence you will get logic 0 on
port pin. This is how you write logic 0 to a port pin.

Smart Logic Academy © All copyrights reserved


Slide 3

Let's see how to write logic 1. Let’s say we are sending logic high to port P1 hence internal data
bus will get logic 1. Then, in this case, the MOSFET is turned off and hence port 1 pin get logic 1.
This is how you will write logic 1 to port pin.

Smart Logic Academy © All copyrights reserved


Slide 4

Let's see how to read the content of Port pin in 8051. To read the content of Port pin in 8051
first we have to make that pin as an input pin. To make a pin as an input pin you have to give
logic 1 to that pin first. For example if I want to read the content from port P1(MOV A, P1) in
that case first I will write FF to P1 (MOV P1,#0FFh) that means I am giving logic 1 to entire port
P1 and then I am reading the content from Port P1 to register A. We have to do this just to make
sure that the M1 that is the MOSFET of the output driver circuitry to get turn off. Now let's see
in animation whenever the first instruction (MOV P1,#0FFh) get executed The MOSFET of the
driver circuit in goes off. Hence what may ever be the status on the Pin P1.x, it will come here to
(TB1). When MOV A,P1 i.e when you try to read content of port P1 to accumulator (A) in that
case “Read Pin” will enable tristate buffer (TB1) and what may ever be the input will be given to
output of buffer (TB1) and out of buffer is connected to internal CPU bus. This is how we read
the port pin in 8051.

Smart Logic Academy © All copyrights reserved

You might also like