The computer's brain-single chip microcontroller (3) The CPU of the microcontroller 8051 consists of an arborator and a controller.
First, the operator operator is carried out by completing the binary arithmetic / logical arithmetic component ALU, plus the temporary depositor TMP, accumulator ACC, register B, program status flag register PSW and Boolean processor. The accumulator ACC is an eight-bit register that is the most frequent register working in the CPU. When arithmetic, logical operation, accumulator ACC tends to temporarily save an operand (such as plus) before operation, while the operation is saved (such as algebra and). Register B is mainly used for multiplication and division operations. The logo register PSW is also an eight-bit register that stores some features of the calculation result, such as if there is no access, borrowing, and the like. The specific integration of each part is as follows. PSW CY AC FO RS1 RS0 OV - P Tell the following four digits. 1 carry sign CY (psw7). It indicates whether the operation is carry (or borrow). If the results have a carry (addition) or borrow (subtraction), the bit is 1, otherwise 0. 2 Auxiliary carry mark AC. Also known as the semi-carry flag, it reflects whether the two eight-digit operations have a half-in-one, that is, the low four-bit addition (or minus) has a carry (or borrow), if there is a status, Otherwise 0. 3 Overflow flag OV. The MCS-51 reflects whether the calculation result of the strip number has overflow. When there is overflow, this bit is 1, otherwise 0. 4 Parity Sign P. Reflecting the parity of the accumulator ACC content, if the result of the calculation in the ACC has even 1 (such as 11001100B, 4 1), then P is 0, otherwise, p = 1. Other bits of PSW will be described later. Due to the state in which the PSW storage program is executed, it is also called the program status word. There is also a bit bit (BIT) logic (also known as the Boolean processor) in a bit (BIT). Its functions will be described when the bit command is introduced.
Second, the controller
The controller is the nerve center of the CPU, which includes a timing control logic circuit, an instruction register, a decoder, an address pointer DPTR, and a program counter PC, a stack pointer SP. Here the program counter PC is a counter consisting of 16-bit registers. To perform a program with a single-chip microcomputer, you must preload a region of the memory ROM in order. The command should be taken out in order to perform a single-chip action. Therefore, there must be a circuit that can find the unit address where the instruction is located, which is the program counter PC. When the single-chip is started to execute the program, load the address of the first instruction to the PC, each of which takes an instruction (such as multi-byte instruction, then one instruction byte), the content of the PC will automatically add 1 to point to The address of the next instruction makes the instructions. Only when the program encounters the transfer instruction, the subroutine call command, or when the interrupt is encountered (later introduced), the PC will go to the required place. 8051 CPU 碢 c Specifies the address, remove the command byte from the ROM corresponding unit, place the instruction register, and then the instruction code in the instruction register is translated into various forms of control signals, these signals and microcontrollers clocks. The clock pulse generated by the oscillator is combined with the control circuit in the timing to form the level and clock, the so-called control information, and the operation, etc. between the CPU internal coordination registers.
Third, memory
The memory is still another important part of the microcontroller, and FIG. 6 shows a schematic diagram of a memory structure having a storage capacity of 256 units. Each of the memory cells corresponds to an address, 256 units have a total of 256 addresses, represented by two bits 16, that is, the address of the memory (00h ~ ffh). Each of the memory cells can store an eight-bit binary information, usually used in the number of two-digit 16, which is the content of the memory. The memory cell address of the memory and the content of the storage unit are two concepts, and cannot be confused. First, the program memory program is a series of commands that control computer actions, and the microcontroller only recognizes machine instructions consisting of "0" and "1" code. Command MOV A, # 20H, which is written as described above, replaces code 74h, 20h, 20h: (written into binary is 01110100b and 00100000b). The monolithic program, form, and constant assembly into a machine code, called a program memory before the microcontroller is handled, and the memory is stored in the memory. The program memory can be placed in the inner or outer, and can also be set simultaneously outside the sheet. Since the PC program counter is 16 bits, the program memory can use a 16-bit binary address, so the address of the internal and external memory can be up to 1000h to FFFFH. In the 8051, there is a 4K byte of ROM, which takes up the minimum 4K byte of 0000H ~ 0FFFH. At this time, the external expansion program memory address number should start from 1000 hours. If you use 8051 to do 8031, don't want to use 4krom , Full-size sheet memory, then the address number can still start from 0000H. However, at this time, 8051 should be maintained low (ie, EA pin) at this time. When the EA is high, the user uses an internal ROM within a range of 0000h to 0FFFH, which is greater than 0FFFH, and the microcontroller CPU automatically accesses the external program memory. Second, data storage
The data memory of the single chip microcomputer consists of the read and write memory RAM. Its maximum capacity can be extended to 64K, which is used to store data entered in real time. There is 256 internal data memories of 256 units inside 8051, where 00h ~ 7FH is the internal random memory RAM, 80H ~ FFH is a dedicated register area. The internal memory should first be taken out with the actual use, from the perspective, the structure and address assignments of the internal data storage are very important. They are often used in future learning instruction systems and program design. The 8051 internal data memory address has a total of 256 bytes of address spaces from 00h to FFH, which is divided into two parts, wherein the address of the internal data RAM is 00h ~ 7FH (ie 0 to 127). And use the address of the special function register to be 80h ~ ffh. In this 256 bytes, there is also a so-called "bit address" area that can be addressed by "bit (bit)" in this area. For those data that need to be operated, you can store this area. Four sets of working registers from 00h to 1FH, each set occupied 8 RAM bytes, and remembered R0 ~ R7. The set of registers is selected by the RS1 and RS0 in the aforementioned flag registers. Different binary numbers are placed on both positions, that is, different register groups are available, as shown in Schedule 1.
Third, special function registers