8051 IO Ports
8051 IO Ports
I/O Ports
8051 I/O Ports
• Every pin have D-latch and port SFR is made up of
these latches (8 latches per port).
• To configure a port as input port write 1 to it.
• To configure a port as port does not require any
special setting. Writing a logic status to latch will
output same at port pin.
• After RESET all the port SFRs contain 1 i.e. they are
ready to be used as input as well as ready to output
Logic 1.
TB1
Read pin
8051 IC
8051 I/O Ports – Manish Tiwari 4
Writing “0” to Output Pin P1.X
TB1
Read pin
8051 IC
8051 I/O Ports – Manish Tiwari 5
Reading “High” at Input Pin
1 1 P1.X pin
Internal CPU bus D Q
P1.X
0 M1
Write to latch Clk Q
TB1
Read pin
3. Read pin=1 Read latch=0
Write to latch=1
8051 IC
TB1
Read pin
3. Read pin=1 Read latch=0
Write to latch=1
8051 IC
END
Address Data
51H 02
52H 03
74LS244
LOOK_UP DB C0H, F9H, A4H, B0H, 99H, 92H, 82H, F8H, 80H, 90H
8051 I/O Ports – Manish Tiwari 25
Alternate P2: 7-Segment Display
Address Data
51H 02
52H 03
P1.4