1. Bus: we know that a circuit is always made up of components connected by wires. In a analog circuit, the connection is not a problem because the devices are generally in a serial relationship, there are not many connections between each device, but the computer circuit is different. It is based on a microprocessor. Each device must be connected to a microprocessor, and the work of each device must be coordinated, therefore, a lot of connections are needed. If you are still connected separately between the microprocessor and the device like a analog circuit, the number of lines will be amazing, therefore, the concept of bus is introduced in the microprocessor, and each device can share the connection. All eight data lines of all devices are connected to eight public online lines, which is equivalent to the parallel connection of each device, however, this is not the case. If two devices send data at the same time, one is 0 and the other is 1, what exactly does the receiver receive? This situation is not allowed. Therefore, you must control the control line so that the device can work at a time. At any time, only one device can send data (multiple devices can receive data at the same time ). The device data line is also called the data bus, and all the control lines of the device are called the control bus. There are storage units in the microcontroller internal or external memory and other devices. These storage units must be allocated addresses before they can be used. The allocated addresses are also provided in the form of electrical signals, because there are many storage units, there are also many lines for Address Allocation. These lines are called address bus.
2. Data, addresses, and commands: Put the three together because they are essentially the same-numbers, or a string of '0' and '1. In other words, the address and command are also data. Command: A number specified by the designer of the single chip microcomputer. It has a strict one-to-one correspondence with commonly used command mnemonic, which cannot be changed by the single chip microcomputer developer. Address: it is the basis for finding internal and external storage units and input and output ports of single-chip microcomputer. The address value of the internal unit has been specified by the chip designer and cannot be changed, the external unit can be determined by the single-chip microcomputer developer, but some address units are mandatory (see the Program Execution Process for details ). Data: This is an object processed by a microprocessor, which varies in different application circuits. Generally, the processed data may be in the following situations:
1 • Address (such as mov dptr, 1000 H), that is, the address 1000H is sent to DPTR.
2 • Mode word or control word (such as mov tmod, #3), 3 is control word.
3 • Constant (e.g. MOV TH0, #10 H) 10 H is the timing constant.
4 • actual output value (for example, if the P1 port is connected with a colorful light and the light must be fully lit, run the command MOV P1, # 0FFH. If the light is dark, run the command MOV P1, #00 H) Here, both 0FFH and 00H are actual output values. Another example is the font code used for the LED, which is also the actual output value.
After understanding the essence of addresses and commands, it is not difficult to understand why the program runs and runs data as commands.
Iii. Second functional usage of P0 port, P2 port and P3: The second functional usage of P0 port, P2 port, and P3 port is often puzzled at the beginning of school, it is believed that there must be a switching process between the second function and the original function, or an instruction. In fact, the second function of each port is completely automatic, and no command is needed for conversion. For example, P3.6 and P3.7 are WR and RD signals respectively. When the microprocessor external RAM or has an external I/O port, they are used as the second function, it cannot be used as a general I/O port. As long as a microprocessor executes the MOVX command, a corresponding signal will be sent from P3.6 or P3.7 without instructions. In fact, 'cannot be used as a general I/O port' or 'cannot', but (User) 'won't' use it as a general I/O port. You can arrange a SETB P3.7 command in the command, and when the MCU executes this command, it also changes P3.7 to a high level, but the user does not do this, this usually causes system crashes.
4. Program Execution process: the value of the single-chip microcomputer in the program counter (PC) within 8051 after power-on Reset is '123', so the program is always executed from the '123' unit, that is: in the system ROM, the Unit '200' must exist, and it must be an instruction stored in the unit '200.
5. STACK: A stack is a region used to store data. There is nothing special about this region, that is, a portion of internal RAM, specifically, it stores and uses data, that is, the so-called 'first-in-first-out, later-in-first-out ', and the stack has special data transmission commands, namely, 'push' and 'pop ', there is a special unit specifically designed for its service, that is, the stack pointer SP. Every time a PUSH command is executed, the SP (based on the original value) automatically adds 1, each time you execute a POP command, SP automatically minus 1 (based on the original value. Since the value in the SP can be changed using commands, you can set the stack to a specified memory unit as long as the SP value is changed in the initial stage of the program. For example, when the program starts, with an mov sp, # 5FH command, the stack is set to the unit starting from the memory unit 60 h. Generally, there is always such a command to set the stack pointer at the beginning of the program, because the initial value of SP is 07 H at startup, so that the stack starts from Unit 08H, the 08H to 1FH area is the second, third, and fourth working register area of 8031, which is frequently used, which may cause data confusion. The initialization stack commands are not identical when different authors write programs, which is a habit of the authors. After the stack area is set, it does not mean that the region becomes a dedicated memory. It can still be used like the normal memory area, in general, programmers will not regard it as common memory.
6. Single-Chip Microcomputer Development Process: The development process mentioned here is not from the task analysis mentioned in the general book. We assume that the hardware has been designed and prepared, and the following is the work of writing software. Before writing software, you must first determine some constants and addresses. In fact, these constants and addresses have been determined directly or indirectly in the design phase. For example, after a device is connected, its address is determined. When the device's function is determined, its control word is also determined. Then write the software in a text editor (such as EDIT and CCED). After the software is compiled, compile the source program file with the compiler and check for errors until there are no syntax errors, except for very simple programs, generally, the application simulator debugs the software until the program runs correctly. After running properly, you can write a piece (program is solidified in EPROM ). After the source program is compiled, a target file with the extension HEX is generated. Generally, the programmer can identify the file in this format and write the file as long as the file is transferred.
Here, we would like to give you an explanation of the entire process:
ORG 0000 H
ORG 040 H
START: mov sp, # 5FH; set the stack
Ljmp loop; LOOP