1. Bus
A circuit is always made up of components connected by wires. In analog circuits, wiring is not a problem because the devices are generally in serial relationship and there are not many wires between the devices. However, computer circuits are different. They are based on microprocessors. All devices must be connected to the microprocessor and the work of each device must be coordinated with each other, so a lot of wires are needed. If the microprocessor and each device are connected separately as in analog circuits, the number of wires will be amazing. Therefore, the concept of bus is introduced in microprocessors. Each device shares the wires. The 8 data lines of all devices are connected to 8 common lines, which is equivalent to connecting each device in parallel. However, this is not enough. If two devices send data at the same time, one is 0 and the other is 1, then what will the receiver receive? This situation is not allowed, so it is necessary to control through control lines to make the devices work in time-sharing mode. Only one device can send data at any time (multiple devices can receive data at the same time). The data line of the device is also called the data bus, and all the control lines of the device are called the control bus. There are storage units inside the microcontroller or in external memory and other devices. These storage units must be assigned addresses before they can be used. The assigned addresses are of course given in the form of electrical signals. Since there are many storage units, there are also many lines used for address allocation. These lines are called address buses.
2. Data, Address, Instruction
The reason why these three are put together is that the essence of these three is the same - numbers, or a sequence of '0' and '1'. In other words, addresses and instructions are also data. Instruction: A number specified by the designer of the microcontroller chip. It has a strict one-to-one correspondence with the instruction mnemonics we commonly use and cannot be changed by the developer of the microcontroller. Address: It is the basis for finding the internal and external storage units and input and output ports of the microcontroller. 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 microcontroller developer, but some address units must be there (see the execution process of the program for details). Data: This is the object processed by the microprocessor. It is different in various application circuits. Generally speaking, the data being processed may be in the following situations:
1 Address (such as MOV DPTR, 1000H), that is, address 1000H is sent to DPTR.
2 Mode word or control word (such as MOV TMOD, #3), 3 is the control word.
3 Constant (such as MOV TH0, #10H) 10H is the timing constant.
4 Actual output value (e.g. if the P1 port is connected to a colored light, and you want all the lights to be bright, execute the command: MOV P1, #0FFH, if you want all the lights to be dark, execute the command: MOV P1, #00H) Here 0FFH and 00H are both actual output values. Another example is the font code used for LED, which is also the actual output value.
Once you understand the nature of addresses and instructions, it is not difficult to understand why the program may run wild during execution and why data may be executed as instructions.
3. Secondary Function Usage of P0, P2 and P3
When you are a beginner, you are often confused about the usage of the second functions of ports P0, P2, and P3. You think that there must be a switching process between the second function and the original function, or that there must be an instruction. In fact, the second function of each port is completely automatic and does not require instructions to switch. For example, P3.6 and P3.7 are WR and RD signals respectively. When the microprocessor is connected to an external RAM or has an external I/O port, they are used as the second function and cannot be used as general I/O ports. As long as the microprocessor executes the MOVX instruction, a corresponding signal will be sent from P3.6 or P3.7, and there is no need to use instructions in advance. In fact, "cannot be used as a general I/O port" does not mean "cannot" but (the user) "will not" use it as a general I/O port. You can arrange a SETB P3.7 instruction in the instruction, and when the microcontroller executes this instruction, P3.7 will also become a high level, but users will not do this because it usually causes the system to crash. 4. Program execution process
After the microcontroller is powered on and reset, the value of the program counter (PC) in the 8051 is '0000', so the program always starts executing from the '0000' unit. In other words, the unit '0000' must exist in the system's ROM, and there must be an instruction stored in the '0000' unit.
5. Stack
The stack is an area used to store data. This area itself has nothing special about it. It is just a part of the internal RAM. What is special is the way it stores and retrieves data, which is the so-called "first in, last out, last in, first out". The stack has special data transfer instructions, namely "PUSH" and "POP", and there is a special unit dedicated to it, namely the stack pointer SP. Whenever a PUSH instruction is executed, SP automatically increases by 1 (based on the original value), and whenever a POP instruction is executed, SP automatically decreases by 1 (based on the original value). Since the value in SP can be changed by instructions, as long as the value of SP is changed at the beginning of the program, the stack can be set in the specified memory unit. For example, at the beginning of the program, a MOV SP, #5FH instruction is used to set the stack in the unit starting from memory unit 60H. Generally, there is always an instruction to set the stack pointer at the beginning of a program. Because when the computer is turned on, the initial value of SP is 07H, so the stack starts from unit 08H and goes backwards. The area from 08H to 1FH is the second, third, and fourth working register area of 8031, which is often used, which will cause data confusion. When different authors write programs, the initialization instructions for the stack are not exactly the same. This is a matter of habit. When the stack area is set, it does not mean that the area becomes a special memory. It can still be used like a normal memory area, but programmers generally do not use it as normal memory.
6. MCU Development Process
The development process mentioned here is not the one that starts with task analysis as described in general books. We assume that the hardware has been designed and manufactured, and the next step is to write the software. Before writing the software, we must first determine some constants and addresses. In fact, these constants and addresses have been determined directly or indirectly during the design stage. For example, when the connection of a device is designed, its address is also determined. When the function of the device is determined, its control word is also determined. Then use a text editor (such as EDIT, CCED, etc.) to write the software. After writing, use a compiler to compile the source program file and check for errors until there are no syntax errors. Except for very simple programs, the software is generally debugged using an emulator until the program runs correctly. After running correctly, you can write the chip (solidify the program in the EPROM). After the source program is compiled, a target file with the extension HEX is generated. Generally, programmers can recognize files in this format. As long as this file is loaded, the chip can be written.
Previous article:Single chip microcomputer is everywhere. A practical online UPS circuit is explained in detail.
Next article:Design of analog voltage acquisition card for STM32 microcontroller
- Popular Resources
- Popular amplifiers
- MathWorks and NXP Collaborate to Launch Model-Based Design Toolbox for Battery Management Systems
- STMicroelectronics' advanced galvanically isolated gate driver STGAP3S provides flexible protection for IGBTs and SiC MOSFETs
- New diaphragm-free solid-state lithium battery technology is launched: the distance between the positive and negative electrodes is less than 0.000001 meters
- [“Source” Observe the Autumn Series] Application and testing of the next generation of semiconductor gallium oxide device photodetectors
- 采用自主设计封装,绝缘电阻显著提高!ROHM开发出更高电压xEV系统的SiC肖特基势垒二极管
- Will GaN replace SiC? PI's disruptive 1700V InnoMux2 is here to demonstrate
- From Isolation to the Third and a Half Generation: Understanding Naxinwei's Gate Driver IC in One Article
- The appeal of 48 V technology: importance, benefits and key factors in system-level applications
- Important breakthrough in recycling of used lithium-ion batteries
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- Thank you for being here
- Tuya Sandwich Wi-Fi & BLE SoC NANO Main Control Board WBRU Zero Code Development IoT Fan
- Since the signal that needs to be sampled is 0.01uA-10uA, is there any low-voltage MOS with Ids leakage current in nA or pA level?
- Forum Prize: Texas Instruments TI-36X Pro Scientific Calculator Disassembly and Analysis
- Why does Kalman filter need to do the prediction step?
- Misiqi's project cooperation based on ESP32 development board IOT Bluetooth WIFI
- Is this a circuit that can prevent the MCU from hanging?
- When southern girls start soldering irons to do projects, what do science and engineering men need? - Arduino, hardware, project tutorials
- The principle and method of generating multiple PWM waveforms using one timer
- The impact of 5G on positioning technology