Structure block diagram of 89C51 Single Chip Microcomputer
1. An 8-bit microprocessor CPU.
2. On chip data memory (ram128b / 256b): used to store data that can be read / written, such as intermediate results, final results and data to be displayed.
3. On chip 4KB program memory flash ROM (4KB): used to store programs, some original data and tables.
4. Four 8-bit parallel I / O (input / output) interfaces P0 ~ P3: each port can be used as input or output.
5. Two or three timing / counters: each timing / counter can be set as counting mode to count external events, or as timing mode, and computer control can be realized according to the results of counting or timing
6. A full duplex UART serial I / O port: it can realize the serial communication between single chip microcomputer and single chip microcomputer or other microcomputers.
7. On chip oscillator and clock generation circuit: but external crystal oscillator and capacitor are required.
8. Interrupt control system with five interrupt sources.
9. Power saving working mode: leisure mode and power down mode.
In idle mode, the CPU stops working, while ram, timer / counter, serial port and interrupt system continue to work. At this time, the current can be reduced to about 15% of the normal working mode. In the power down mode, the on-chip oscillator stops working. Because the clock is “frozen”, all functions are suspended, so only the contents of the on-chip RAM are saved until the next hardware reset. In this way, the current can be reduced to 15 μ Below a, the minimum can be reduced to 0.6 μ A。
It is composed of central processing unit (CPU), memory (ROM and RAM) and I / O interface. The internal structure of 89C51 single chip microcomputer is shown in the figure:
The following is MCS-51
Configuration characteristics of MCS-51 single chip microcomputer memory
① 4K program memory ROM is integrated inside;
② 256b internal data memory ram;
③ 64K program memory ROM and data memory RAM can be connected externally.
From the perspective of physical structure, the storage system of 51 single chip microcomputer can be divided into four storage spaces: on-chip ROM, ram and off-chip ROM and ram.
Logically speaking (from the perspective of programming), the storage system of 51 single chip microcomputer is actually divided into three storage spaces.
1. On chip data memory ram;
2. Off chip data memory ram;
3. On chip or off chip program memory ROM (determined by EA level).
1. Program memory ROM is used to store programs, constants or tables.
2. In 51 single chip microcomputer, when the internal and external ROM are selected by the level on pin / EA: EA = 1, the CPU executes the program in 4krom in the chip; When EA = 0, the CPU selects the program in the off chip ROM.
3. Whether using on-chip or off chip ROM, the starting address of the program starts from the 0000H unit of ROM.
4. Although the system can have on-chip ROM and external ROM at the same time, under normal use, select one of them through the setting of / EA (either use internal ROM or use external ROM).
5. If EA = 1 (when executing the program in the on-chip program memory): if the pointer PC value of the program counter exceeds 0fffh (4K), the single chip microcomputer will automatically turn to the off-chip ROM memory and execute the program from the 1000h unit (the low 4K space of the off-chip ROM cannot be used).
6. When the program exceeds 4K, there are two ways to use the program memory ROM:
① Set EA = 0 and use external ROM. Starting from address = 0000H;
② Set EA = 1 and use internal 4krom and external ROM (units with addresses starting from 1000h).
Program memory has six special units:
There are six units in ROM with specific functions.
0000H unit: the unit pointed by the program counter PC during reset, so it is used to store the first instruction in the program;
0003h unit: vector entry address of external interrupt / INT0;
000BH unit: vector entry address of timer T0 overflow interrupt;
0013h unit: vector entry address of external interrupt / INT1;
001bh unit: overflow interrupt vector entry address of timer T1;
0023h unit: interrupt vector entry address received and transmitted by serial port.
Vector entry unit: when writing interrupt program, write corresponding “springboard instruction”
Two characteristics of the first instruction of single chip microcomputer:
① 0000H unit stored in ROM;
② It must be a “jump instruction” to skip the following five interrupt vectors and go to the following real main program entry 0100h unit.
ORG 0000H LJMP 0100H
START： MOV A，#00H
External program memory:
When the single chip microcomputer uses external ROM memory (expansion system), it must set / EA = 0. At this time, the port function of the single chip microcomputer will change accordingly:
① P0 and P2 are used as the address and data bus of external ROM;
② The pin / PSEN signal is used to gate the data three state output of the external ROM.
Internal data memory RAM:
Whether physically or logically, RAM in the system can be divided into two independent spaces: internal and external RAM. Accessed by different instructions.
1. Use MOV instruction when accessing internal data storage unit;
2. Use MOVX instruction when accessing external data memory. The internal RAM functionally divides the 256b space into two different blocks:
1. Low 128B ram block;
2. 128B high SFR (special function register) block.
In the low 128B RAM storage unit, it can be divided into:
1. Work register area;
2. Bit addressing area;
3. “Note area” for general data storage.
Only 21 registers (51 Series) are used in the high 128B special register area SFR, and the other 107 units cannot be used.