 |
SIGNALS AND PIN DESCRIPTION
Intel 8051 has 40 pins that are dedicated for various functions such as I/O, RD, WR, address, data and interrupts. A total of 32 pins are set aside for the four ports P0, P1, P2 and P3 where each port takes 8 pins. The rest of the pins are designed as VCC, GND, XTAL1, XTAL2, RST, EA, and PSEN. .
Vcc
Pin 40 provides supply voltage to the chip. The voltage source is +5V.
GND
Pin 20 is circuit ground.
XTAL1 AND XTAL2
The 8051 has an on chip oscillator but requires an external clock to run it. Most often a quartz crystal oscillator is connected to inputs XTAL1 (pin 19) andXTAL2 (pin 18). XTAL1 is input to the inverting oscillator amplifier and input to the internal clock generating circuits and XTAL2 is output from the inverting oscillator amplifier.
RST
Pin 9 is the rest pin. It is an input and is active high (normally low). Upon applying a high pulse to this pin, the micro controller will reset and terminate all activities. This is often referred to as a power on reset. Activating a power on rest will cause all values in the registers to be lost.
In order for the RESET input to be effective, it must have a minimum duration of 2
Machine cycles. In other words, the high pulse must be high for a min of two machine cycles before it is allowed to go low. In the 8051 a machine cycle is defined as 12 oscillator periods.
EA/Vpp
The 8051 family members, such as the 8751,89C51, or DS5000, all come with on-chip ROM to store programs. In such cases, the EA pin is connected to V cc' For family members such as the 8031 and 8032 in which there is on-chip ROM, code is stored on an external ROM and is fetched by the 8031 \ 32. Therefore for the 8031 the EA pin must be connected to GND to indicate that the code is connected externally. EA, which stand for "external access," is pin number 31 in DIP package. It is an input pin and is connected to either Vcc or GND. In other words, it cannot be left unconnected.
Vpp pin receives the programming supply voltage (V p) during EPROM programming.
PSEN
This is an output pin. PSEN stands for "program store enable". In an 8031 based system in which an external ROM holds the program code, this pin is connected to the OE pin of the ROM, otherwise no connection is made.
ALE/PROG
ALE (Address latch enable) is an output pin and is active high. When connecting an 8031 to external memory, port 0 provides both address and data. In other words 8031 multiplex address and data through port 0 to save pins. In case of 8051 no connection is made. This pin is also the program pulse input (PROG) during EPROM programming
I/O PORT PINS AND THEIR FUNCTIONS
The four ports P0, P1, P2, and P3 each use 8 pins, making them 8-bit ports. All the ports upon RESET are configured as output, ready to use as output ports. To use any of these ports as an input port, it must be programmed.
PORT 0
Port0 occupies a total of 8 pins (pins 32-39). It can be used for input or output. To use the pins of port 0 as both input and output ports, each pin must be connected externally to a 10K ohm pull up resistor. With external pull-up resistor connected upon reset, port 0 is configured as an output port.
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. The 8051 multiplexes address and data through port 0 to save pins. ALE indicates if P0 has address or data. When ALE = ,0, it provides data D0-D7, but when ALE = 1 it has address A0-A7.
PORT 1
Port1 occupies a total of 8 pins (pins 1 through 8). It can be used as input or output. In contrast to port 0, this port does not need any pull up resistor since it already has pull up resistor internally. Upon reset, port 1 is configured as an output port.
PORT 2
Port 2 occupies a total of 8 pins (pins 21 through 28). It can be used as input or output. Just like P1, port 2 does not need any pull up resistors since it already has pull-up resistors internally. Upon reset, port 2 is configured as an output port.
To make pin 2 as input it must be programmed as such by writing 1 to all its bits.
PORT 3
Port 3 occupies a total of 8-pins 10 through17.it can be used as input or output. P3 does not need any pull up resistor
I/O CONFIGURATIONS
The four ports P0, P1, P2, and P3 each use 8 pins, making them 8-bit ports. Each port has a D-type output latch for each pin. Each port SFR is made up of these eight latches, which can be addressed at the SFR address for that port .The data on the port latches does not have to be same as that on the port pins. All the ports upon RESET are configured as output, ready to use as output ports. To use any of these ports as an input port, it must be programmed.
PORT 0
Port0 occupies a total of 8 pins (pins 32-39). It can be used for input or output. To use the pins of port o as both input and output ports, each pin must be connected externally to a'10K ohm pull up resistor. With external pull-up resistor connected upon reset, port o is configured as an output port. Port o receives the code bytes during EPROM programming, and outputs the code bytes during program verification. External pull ups are required during program verification. Port 0 is also the multiplexed low-order address and data bus during accesses to external memory.
PORT 0 AS OUTPUT
With resistors connected to port 0, in order to make it an input, the port must be programmed by writing 1 to all the bits. In the following code, port 0 is configured first as an input port by writing 1's to it, and then data is received from that port and sent to P1.
MOV A, #OFFH
MOV PO, A
MOV A, PO
MOV PI, A
SJMP BACK
DUAL ROLE OF PORT0
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. ALE indicates if P0 has address or data. When ALE = 0, it provides data D0-D7, but when ALE = 1 it has address A0-A 7.
PORT 1
Port 1 occupies a total of 8 pins (pins 1 through 8). It can be used as input or output. In contrast to port 0, this port does not need any pull up resistor since it already has pull up resistor internally. Upon reset, port 1 is configured as an output port. Port 1 also receives the low-order address during EPROM programming and program verification.
PORT 1 AS INPUT
To make port 1 as input port, it must programmed as such by writing 1 to all its bits.
PORT 2
Port 2 occupies a total of 8 pins (pins 21 through 28). It can be used as input or output. Just like P1, port 2 does not need any pull up resistors since it already has pull-up resistors internally. Upon reset, port 2 is configured as an output port.
Port 2 emits the high-order address byte during fetches from external Program memory and during accesses to external Data Memory that use 16-bit address (MOVX @DPTR). Port 2 also receives some control signals and the high-order address bits during EPROM programming and program verification.
PORT 2 AS INPUT
To make pin 2 as it must be programmed as such by writing 1 to all its bits.
PORT 3
Port3 occupies a total of 8-pins 10 through17. It can be used as input or output. P3 does not need any pull up resistor. Port 3 receives some control signals for EPROM programming and program verification.
Port 3 also serves the functions of various special features of the 8051 microcontroller family,
| Pin |
Name |
Alernate
Function |
| P3.0 |
RXD |
Serial Input Line |
| P3.1 |
TXD |
Serial Output Line |
| 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 stobe |
MEMORY MAPPING
The 8051 has three types of memory. they are
- On-Chip Memory
- External Code Memory
- External RAM.
On-Chip Memory refers to any memory (Code, RAM, or other) that physically exists on the micro controller itself. On-chip memory can be of several types.
External Code Memory is code (or program) memory that resides off-chip. This is Often in the form of an external EPROM.
External RAM is RAM memory that resides off-chip. This is often in the form of standard static RAM of flash RAM.
CODE MEMORY
Code memory is the memory that holds the actual 8051 programs that is to be run. This memory is limited to 64K and comes in many shapes and sizes: Code memory may be found on-chip, either burned into the microcontroller as ROM or EPROM. Code may also be stored completely off-chip in an external ROM or, more commonly, an external EPROM. Flash RAM is also another popular method of storing a program. Various combinations of these memory types may also be used for example, it is possible to have 4K of code memory on-chip and 64k of code memory off-chip in an EPROM.
When the program is stored on-chip the 64K maximum is often reduced to 4k, 8k, or
16k. This varies depending on the version of the chip that is being used. Each version offers specific capabilities and one of the distinguishing factors from chip to chip is how much ROM/EPROM space the chip has.
However, code memory is most commonly implemented as off-chip EPROM, especially in low-cost development systems.
EXTERNAL RAM
As the name suggests, external RAM is any random access memory which is found off-chip. Since the memory is off-chip it is not as flexible in terms of accessing, and is also slower. For example, to increment an internal RAM location by 1 requires only 1 instruction and 1 instruction cycles. To increment a 1-byte value stored in external RAM requires 4 instructions and 7 instructions cycles. In this case, external memory is 7 times slower!
But what external RAM loses in speed and flexibility it gains in quantity. While internal RAM is limited to 128 bytes, the 8051 supports external RAM up to 64K
Note: The only access to external data memory is with the MOVX instruction, using either 16bit data pointer DPTR, R0, or R1 as the address register. The 8051 may only address 64k of RAM. To expand RAM beyond this limit requires programming and hardware modifications.
ON-CHIP MEMORY
The 8051 includes a certain amount of on-chip memory. On-chip memory is really one of two types: Internal RAM and Special Function Register (SFR) memory. The layout of the 8051's internal memory is presented in the following memory map:
The 8051 has a bank of 128 bytes of Internal RAM. This Internal RAM is found on-chip on the 8051 so it is the fastest RAM available, and it is also the most flexible in terms of reading, writing, and modifying it's contents. Internal RAM is volatile, so when the 8051 is reset, this memory is cleared.
The 128 bytes of internal RAM is subdivided as shown on the memory map. The first 8 bytes (00h-07h) are "register bank 0". By manipulating certain SFRs, a program may choose to use register banks 1, 2, or 3. These alternative register banks are located in internal RAM in through 1Fh.
But memory is also a part of internal RAM .Bit memory actually resides in internal
RAM, from addresses 20h through 2Fh.
The 80 bytes remaining of Internal RAM, from addresses 30h through 7Fh, may be used by user variables that need to be accessed frequently or at high-speed. This area is also utilized by the microcontroller as a storage area for the operating stack. This fact severely limits the 8051's stack since, as illustrated in the memory map, the area reserved for the stack is only 80 bytes and usually it is less since these 80 bytes has to be shared between the stack and user variables.
BACK
|
 |