[Basics of MCU] (4) Pin function of MCU

The 40 pins of MCS-51 series single-chip microcomputers can be divided into 3 categories according to their functions: basic working condition pins, input/output (I/O) pins and control pins.
1. The basic working conditions of the single-chip microcomputer include power supply pin, reset pin and clock pin. Only when the basic working conditions are met, the single-chip microcomputer can start to work.

(1) Pin 40 of the power supply pin is the positive power supply pin (VCC), and pin 20 is the negative power supply pin (VSS). The positive pin of the power supply is generally connected to a 5V power supply, and the negative pin of the power supply is grounded.

(2) The reset pin
9 is the reset pin (RST/VPD).
After the single-chip microcomputer is powered on, in order to make the internal circuit work normally, a reset circuit is required to provide it with a reset signal, so that the internal circuit enters the initial state, and then it starts to work. MCS-51 series single-chip microcomputer adopts high-level reset, that is, after an external reset circuit sends a high-level signal to the reset pin, the internal circuit of the single-chip microcomputer can be reset.
Pin 9 also has a power-down retention function. In order to prevent the data in the internal RAM of the microcontroller from being lost due to power-off, a backup power supply can be connected to this pin. When power is off, the backup power supply provides a voltage of 4.5-5.5V for this pin. The data in RAM can be kept without loss.

(3) Clock pins
18 and 19 are clock pins (XTAL2, XTAL1).
There are a large number of digital circuits inside the single-chip microcomputer, and these digital circuits need to be controlled by a clock signal when they work, so that they can work in an orderly and rhythmic manner. The internal clock oscillator of the single-chip microcomputer and the timing circuit external to the clock pin constitute a clock oscillating circuit, which generates a clock signal for use by the internal circuit; in addition, a clock signal can also be generated by an external oscillator, which is sent to the single-chip microcomputer through the clock pin and supplied to the internal Circuit.

2. MCS-51 series single-chip microcomputer has 4 groups of I/O interfaces P0, P1, P2 and P3, and each group of interfaces has 8 pins:
P0 port pins P0.0~P0.7,
P1 port pins P1 .0~P1.7,
P2 port pins P2.0~P2.7,
P3 port pins P3.0~P3.7.
These 4 groups of interfaces can be used as input ports to input external signals into the single-chip microcomputer, and can also be used as output ports to output signals from the single-chip microcomputer. In addition, these interfaces also have some other functions, which are described in detail as follows.
The functions of P0 port (pins 32 to 39) are: input 8 signals, output 8 signals, used as an 8-bit data bus, or used as the lower 8-bit address bus in the 16-bit address bus.
The functions of the P1 port (pins 1 to 8) are: Input 8 signals and output 8 signals.
The functions of the P2 port (pins 21 to 28) are: Input 8 signals and output 8 signals, which are used as the upper 8-bit address bus in the 16-bit address bus.
The functions of port P3 (pin 10 to 17) are: Input 8 signals and output 8 signals. The 8 pins of the P3 port also have other functions, which are described as follows.
P3.0: Used as serial data input terminal (RXD).
P3.1: Used as serial data output terminal (TXD).
P3.2: Used as the external interrupt 0 request signal input terminal (INT0).
P3.3: Used as the external interrupt 1 request signal input terminal (INT1).
P3.4: Used as the external pulse signal input terminal (T0) of timer/counter T0.
P3.5: Used as the external pulse signal input terminal (T1) of timer/counter T1.
P3.6: This terminal outputs the write control signal (WR) when writing off-chip RAM.
P3.7: This terminal outputs read control signal (WD) when reading off-chip RAM.
Ports P0, P1, P2, and P3 have multiple functions. The specific application of which function is determined by the internal program of the microcontroller. It should be noted that at a certain moment, a certain pin of the port can only be used for one function.

3. The functions of the control pins mainly include: When the single-chip microcomputer is connected to the external memory (RAM or ROM), the external memory is controlled by the control pin, so that the single-chip computer can use the external memory as the internal memory; When writing the programmed program), the programmer makes the MCU enter the programming state through the control pin, and then the program can be written into the MCU.
The function description of the control pin is as follows.
EA/VPP (Pin 31): Memory use control input terminal/program voltage input terminal.
When EA=1 (high level), the microcontroller uses internal memory; when EA=0 (low level), the microcontroller uses external memory. When using the programmer to write the program to the single-chip microcomputer, the programming voltage of 12 ~ 25V should be added to this pin.
PSEN (Pin 29): Program storage allowable output terminal. It is the external ROM read strobe control terminal. When the microcontroller wants to read information from the external ROM, this terminal should output a low level to the external ROM.
ALE/ (30 feet): Low 8-bit address latching enable signal output terminal/programming pulse input terminal.
When an external memory is connected, as shown in Figure 2-3, this pin outputs a control signal to the external latch of the single-chip microcomputer, allowing the latch to latch the 8-bit address signal sent from the P0 port as the lower 8-bit address Signals A0~A7 (the upper 8-bit addresses A8~A15 are sent from the P2 port), so that the P0 port does not need to output an 8-bit address signal, it can be idle and used to transmit an 8-bit data signal. When programming the single-chip microcomputer, the programmer inputs programming pulses into the single-chip microcomputer from this pin.

Guess you like

Origin blog.csdn.net/wsq_666/article/details/113523862