Part I. Introduction to single chip microcomputer
MSC-51 single chip microcomputer refers to the single chip microcomputer with 8051 as the core. It was launched by Intel company in the United States in 1980. 80C51 is a typical variety of MCS-51 series; The CMOS process MCU products developed by other manufacturers with 8051 as the base core are collectively referred to as 80C51 series.
Single chip microcomputer: microprocessor (CPU), memory (ROM and RAM) and I / O interface circuit are integrated on an integrated circuit chip to form a single chip microcomputer, that is, single chip microcomputer, also known as microcontroller (MCU).
CPU (central processing unit): it is composed of operation and control logic, and also includes interrupt system and some external special function registers;
RAM (random access memory): used to store data that can be read and written, such as intermediate results, final results and data to be displayed;
ROM (read only memory): used to store programs, some original data and tables;
I / O (input / output) port: four 8-bit parallel I / O ports, which can be used as input and output;
T/C (timer / counter): two timing / counters, which can work in both timing mode and counting mode;
There are only two levels in a digital circuit: high and low
Single chip microcomputer is TTL level: high + 5V low 0V
RS232 level: computer serial port high – 12V Low + 12V
Therefore, the communication between computer and MCU needs to add level conversion chip MAX232 and other chips
According to the evaluation characteristics of digital circuits, he can only use the two-level system:
Binary logic operations, and or, non and XOR
Because 51 MCU is 8 bits, its data type is generally unsigned char
Part II. Pin introduction
one Power pin: VCC (40 pin): power terminal, connected to + 5V power supply.
VSS (GND) (20 pins): ground terminal, connected to + 5V power supply ground terminal
2. External crystal pins: xtal1 and xtal2
89C51 has an oscillator and clock generation circuit.
Xtal1 (19 pin): On chip oscillation circuit inverting amplifier input
Xtal2 (18 pin): on chip oscillation circuit inverting amplifier output. When the internal clock is used, the quartz crystal and fine-tuning capacitor are connected outside the chip to generate the original oscillation pulse signal.
When the external clock is used, xtal1 inputs the external clock pulse signal, and xtal2 is suspended
3. Control signal pins: rst, ale, PSEN, EA
Rst (pin 9): reset signal input terminal, high level is valid.
Maintain the high level of two machine cycles and complete the reset operation.
Ale / prog (30 pins):
Address latch enable output / programming pulse input
Under normal conditions, 1 / 6 positive pulse signal of oscillator frequency is continuously output.
When accessing off chip memory:
As the control signal to latch the low 8-bit address of port P0.
When programming and writing the 8751 on-chip ROM: it is used as the programming pulse input.
PSEN (pin 29): external program memory read strobe output signal
When accessing off chip ROM, negative pulse is output as read ROM strobe
The output permissive terminal (OE) often connected to the off chip ROM chip is used as the read strobe signal of the external ROM.
EA / VPP (31 pins):
External program memory address enable input / programming voltage input Normally, when “1” is connected, the CPU accesses the on-chip 4KB Rom. when the address exceeds 4KB, it automatically turns to the program in the off-chip ROM. When “0” is connected, the CPU only accesses the off chip ROM. 2nd function VPP When programming 8051, program the voltage input.
4. Input / output port pins P0, P1, P2, P3
Four 8-bit parallel I / O ports with 32 pins in total. As a universal I / O port
Universal I / O port
Quasi bidirectional port: When making input, write “1” to the latch first. The default startup initialization is high
P0 port (p0.0-p0.7, pins 39-32):
The quasi two-way port with open drain has no pull-up resistance inside. It is in the resistance state and can not normally output high and low levels. It needs to be connected with the pull-up resistance (10K) for I / O
P1 port (p1.0-p1.7, pins 1-8):
The quasi two-way port with pull-up resistance inside shall be 1 when making input
P2 port (p2.0-p2.7, pins 21-28):
Quasi bidirectional port with pull-up resistance inside, similar to P1
P3 port (p3.0-p3.7, pins 10-17):
The quasi bidirectional port with pull-up resistor inside is similar to P1 for I / O. in addition, it has a second function
Second function of P3 port