VCC
Supply voltage.
GND
Ground.
Port 0
Port 0 is another 8-bit input/output (I/O) port with some unique characteristics. It can be used to connect different devices and sensors to the microcontroller.
When we use Port 0 as an output port, each pin can control the flow of information for up to eight devices. If we write a '1' to any of the Port 0 pins, those pins become high-impedance inputs, meaning they can receive information without affecting other devices connected to them.
Port 0 is important for accessing external programs and data memory. It can be configured to act as a multiplexed low-order address/data bus, which means it helps with sending and receiving information to and from external memory. In this mode, Port 0 has internal pullups to help with stable data transmission.
During Flash programming, Port 0 receives the code bytes, and during program verification, it outputs the code bytes. For program verification, we need to connect external pullups to ensure reliable data transmission.
Port 1
Port 1 is an 8-bit input/output (I/O) port that can be used to connect devices to the microcontroller. It has some special features and uses internal pullups, which are like little helpers that make things easier.
When we write a '1' to any of the Port 1 pins, the internal pullups pull the pin to a high voltage level, and we can use those pins as inputs to get information from external devices. If an external device connected to a Port 1 pin pulls it low, the pin can provide a small amount of current because of the internal pullups.
Port 1 is also involved in programming and verifying the flash memory. It receives the low-order part of the address bytes during these operations.
Port 2
Port 2 is an 8-bit input/output (I/O) port that can be used to connect various devices and sensors to the microcontroller. It has some special features and uses internal pullups, which are like little helpers that make things easier.
When we write a '1' to any of the Port 2 pins, the internal pullups pull the pin to a high voltage level, and we can use those pins as inputs to get information from external devices. If an external device connected to a Port 2 pin pulls it low, the pin can provide a small amount of current because of the internal pullups.
Port 2 is important for reading data from external memory. It helps with fetching instructions and accessing data stored outside the microcontroller.
When we need to get data from a specific memory address, Port 2 sends the high-order part of that address.
It also helps with certain control signals during programming and checking the flash memory.
Port 3
Port 3 is an 8-bit input/output (I/O) port that can be used to connect devices to the AT89C51 microcontroller. It has some convenient features, including internal pullups.
When we write a '1' to any of the Port 3 pins, the internal pullups pull the pin to a high voltage level. This allows us to use those pins as inputs to receive information from external devices.
If an external device connected to a Port 3 pin pulls it low, the pin can provide a small amount of current because of the pull-ups.
Port 3 serves additional functions in the AT89C51 microcontroller. It receives control signals during Flash programming and verification. These signals are important for programming and verifying flash memory.
Port Pin |
Alternate Functions |
P3.0 |
RXD (serial input port) |
P3.1 |
TXD (serial output port) |
P3.2 |
INT0 (external interrupt 0) |
P3.3 |
INT1 (external interrupt 1) |
P3.4 |
T0 (timer 0 external input) |
P3.5 |
T1 (timer 1 external input) |
P3.6 |
WR (external data memory write strobe) |
P3.7 |
RD (external data memory read strobe) |
Alternate Functionality
Port 3 pins can serve as alternate function pins for certain special features and peripherals of the microcontroller. These functions can include serial communication interfaces (such as UART), interrupt inputs, and external memory control signals.
External Memory Interface
Port 3 can be used as an address/data bus when accessing external programs or data memory. It provides the necessary signals for addressing memory locations and transferring data between the microcontroller and external memory devices.
Interrupt Inputs
Some of the Port 3 pins can be configured as external interrupt inputs. These pins can detect specific events or signals from external devices and generate interrupts to the microcontroller. Interrupts are used to handle time-critical tasks or respond to external events in a timely manner.
Timer/Counter Inputs
Port 3 pins can also be used as inputs for capturing external events or generating input signals for timers and counters. This feature enables precise timing and counting operations by synchronizing with external events.
External Reset Input
One of the Port 3 pins, commonly referred to as RST, serves as an external reset input. Applying a reset signal to this pin forces the microcontroller to restart execution from the beginning of the program.
Control Signals
Port 3 may receive various control signals during specific operations, such as Flash programming and verification. These signals help coordinate and regulate the programming or verification process, ensuring reliable and accurate data transfer.
RST
Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device.
ALE/PROG
Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming.
In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes.
Note, however, that one ALE pulse is skipped during each access to external Data Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high.
PSEN
Program Store Enable is the read strobe to external program memory. When the AT89C51 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.
EA/VPP
External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH.
Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming, for parts that require 12-volt VPP.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2
Output from the inverting oscillator amplifier.
AT89C51 Memory Organization
The AT89C51 microcontroller has a total of 4KB of on-chip program memory. This program memory is organized into 8KB address space, from address 0000H to 1FFFH.
The program memory is further divided into two parts:
Code Memory
The code memory of the AT89C51 contains the user's program code. It occupies the address range from 0000H to 0FFFH (4KB) and is non-volatile, meaning it retains the program even when the power is turned off.
Data Memory
The data memory of the AT89C51 is divided into two parts:
Internal RAM
The internal RAM provides 128 bytes of data storage. It is organized as four 8-bit registers (R0 to R7) and three 16-bit register banks (R0-R1, R2-R3, and R4-R7) that can be accessed using different addressing modes.
Special Function Registers (SFR)
The AT89C51 has a set of special function registers, which are memory-mapped registers used for controlling various on-chip peripherals and functions. These registers are accessed using direct addressing.
Apart from the program memory and data memory, the AT89C51 also supports external memory interfacing through the address bus (16 bits) and data bus (8 bits).
AT89C51 Memory Map
Memory |
Address Range |
Description |
Code Memory |
0000H - 0FFFH |
User's program code, non-volatile |
Internal RAM |
00H - 7FH |
128 bytes of data storage |
Special Function Registers (SFR) |
80H - FFH |
Memory-mapped registers for controlling on-chip peripherals |