02-01-2013, 12:11 PM
The 8051 Microcontroller and Embedded Systems
8051 Microcontroller.ppt (Size: 1.56 MB / Downloads: 107)
OBJECTIVES
List the 4 ports of the 8051
Describe the dual role of port 0 in providing both data and addresses
Code Assembly language to use the ports for input or output
Explain the dual role of port 0 and port 2
Code 8051 instructions for I/O handling
Code I/O bit-manipulation programs for the 8051
8051 I/O PROGRAMMING
All the ports upon RESET are configured as inputs, ready to be used as input ports.
When the first 0 is written to a port, it becomes an output.
To reconfigure it as an input, a 1 must be sent to the port.
To use any of these ports as an input port, it must be programmed.
Dual role of port 0
Port 0 is also designated as AD0 - AD7, allowing it to be used for both address and data.
When connecting an 8051/31 to an external memory, port 0 provides both address and data.
The 8051 multiplexes address and data through port 0 to save pins. We discuss that in Chapter 14.
I/O BIT MANIPULATION PROGRAMMING
A powerful feature of 80511/0 ports is their capability to access individual bits of the port without altering the rest of the bits in that port.
Of the four 8051 ports, we can access either the entire 8 bits or any single bit without altering the rest.
"SETB X. Y" where X is the port number 0, 1, 2, or 3, and Y is the desired bit number from 0 to 7 for data bits DO to D7.
"SETB P1.5" sets high bit 5 of port 1.