Pins Description Of The 8051 Microcontroller

Pins On The 8051 Microcontroller:

1–8 (Port 1): Each of these pins can be used as either input or output according to functionality. Also, pins 1 and 2 (P1.0 and P1.1) have special functions associated with Timer 2.

9-Reset Signal: high logical state on this input halts the MCU and clears all the registers. Bringing this pin back to logical state zero starts the program anew as if the power had just been turned on. In another words, positive voltage impulse on this pin resets the MCU. Depending on the device's purpose and environs, this pin is usually connected to the push-button, reset-upon-start circuit or a brown out reset circuit. The image shows one simple circuit for safe reset upon starting the controller. It is utilized in situations when power fails to reach its optimal voltage.  

10-17 (Port 3): as with Port 1, each of these pins can be used as universal input or output. However, each pin of Port 3 has an alternative function:
Pin 10: RXD - serial input for asynchronous communication or serial output for synchronous communication.
Pin 11: TXD - serial output for asynchronous communication or clock output for synchronous communication
Pin 12: INT0 - input for interrupt 0
Pin 13: INT1 - input for interrupt 1
Pin 14: T0 - clock input of counter 0
Pin 15: T1 - clock input of counter 1
Pin 16: WR - signal for writing to external (add-on) RAM memory
Pin 17: RD - signal for reading from external RAM memory
18-19: X2 and X1: Input and output of internal oscillator. Quartz crystal controlling the frequency commonly connects to these pins. Capacitances within the oscillator mechanism (see the image) are not critical and are normally about 30pF. Instead of a quartz crystal, miniature ceramic resonators can be used for dictating the pace. In that case, manufacturers recommend using somewhat higher capacitances (about 47 pf). New MCUs work at frequencies from 0Hz to 50MHz+.
20-GND: Ground.

21- 28(Port 2): if external memory is not present, pins of Port 2 act as universal input/output. If external memory is present, this is the location of the higher address byte, i.e. addresses A8 – A15. It is important to note that in cases when not all the 8 bits are used for addressing the memory (i.e. memory is smaller than 64kB), the rest of the unused bits are not available as input/output.

29-PSEN: MCU activates this bit (brings to low state) upon each reading of byte (instruction) from program memory. If external ROM is used for storing the program, PSEN is directly connected to its control pins.

30-ALE: before each reading of the external memory, MCU sends the lower byte of the address register (addresses A0 – A7) to port P0 and activates the output ALE. External register (74HCT373 or 74HCT375 circuits are common), memorizes the state of port P0 upon receiving a signal from ALE pin, and uses it as part of the address for memory chip. During the second part of the mechanical MCU cycle, signal on ALE is off, and port P0 is used as Data Bus. In this way, by adding only one cheap integrated circuit, data from port can be multiplexed and the port simultaneously used for transferring both addresses and data.

31-EA: Bringing this pin to the logical state zero (mass) designates the ports P2 and P3 for transferring addresses regardless of the presence of the internal memory. This means that even if there is a program loaded in the MCU it will not be executed, but the one from the external ROM will be used instead. Conversely, bringing the pin to the high logical state causes the controller to use both memories, first the internal, and then the external (if present).

32-39(Port 0): Similar to Port 2, pins of Port 0 can be used as universal input/output, if external memory is not used. If external memory is used, P0 behaves as address output (A0 – A7) when ALE pin is at high logical level, or as data output (Data Bus) when ALE pin is at low logical level.
40-VCC: Power +5V.