A method for improving MCU bus efficiency and data transmission security
By adding dedicated instructions to the MCU instruction set and combining it with CRC checking, the problems of inefficiency and software overhead caused by frequent and complex MCU operations are solved, and efficient and secure data transmission is achieved.
Patent Information
- Application Number
- CN202210512016.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-12
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2042-05-12
AI Technical Summary
In some application scenarios, the frequent and complex operations of the MCU lead to many repetitive operations, low execution efficiency, and increased power consumption. In addition, adding data transmission protocols through software increases software overhead and reduces data transmission efficiency.
Add dedicated instructions to the MCU instruction set, generate specific function instructions through the host computer compiler, and combine CRC check values to achieve fast data transmission and security verification at the hardware level, including read, modify and write operations.
It improves the execution efficiency of the MCU bus, reduces software overhead, ensures the security and efficiency of data transmission, and is particularly suitable for high-frequency operation scenarios of specific users.
Smart Images

Figure CN114896642B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data transmission, and more particularly to a method for improving MCU bus efficiency and data transmission security. Background Art
[0002] Commands that instruct the MCU to perform certain calculations or processing functions are called instructions. Instructions are the smallest functional unit of an MCU, and the hardware is responsible for completing the functions specified by each instruction. The collection of all instructions on an MCU is its instruction set. This instruction set, also known as the instruction set, embodies the MCU's full functionality. When designing an MCU, the primary consideration is its functionality. This means first designing the instruction set based on its functional capabilities and then implementing it in hardware according to the requirements of the instruction set. An instruction set is more than just a collection of instructions; it also encompasses the instruction format, addressing mode, and data format of all instructions. Therefore, the instruction set executed by each MCU determines not only the required capabilities of the machine but also the instruction format and machine structure. Conversely, machines with different architectures and instruction formats require corresponding instruction sets. Therefore, when designing an instruction set, due attention must be paid to the instruction format, type, and operational functions. Software is a variety of system and user programs written to utilize the MCU. Programs consist of a sequence of MCU instructions. From this perspective, instructions are the computer language units used to design programs.
[0003] Instructions are instructions and commands that direct the operation of the MCU chip. Programs are a series of instructions arranged in a certain order. The process of executing a program is the working process of the MCU. The instruction set is a set of instructions used by the MCU to calculate and control the computer system. Each new type of MCU specifies a series of instruction systems that cooperate with other hardware circuits during design. The advancement of the instruction set is also related to the performance of the MCU. It is also an important indicator of the MCU's performance. The strength of the instruction is also an important indicator of the MCU. The instruction set is one of the most effective tools to improve the efficiency of the microprocessor.
[0004] The instruction set currently used by MCUs is relatively simple, requiring only a limited set of commonly used instructions to be executed by the hardware. Most complex operations are synthesized from multiple simple instructions using sophisticated compilation techniques. In certain application scenarios, complex operations frequently occur. Using a synthesis of multiple simple instructions can lead to repeated operations, low execution efficiency, and increased power consumption. Furthermore, when using an MCU for data transmission, it is often necessary to implement application-layer data transmission protocols through software to verify correct data transmission. This approach significantly increases software overhead, increases software programming difficulty, and reduces data transmission efficiency. Summary of the Invention
[0005] The purpose of the present invention is to provide a method for improving the efficiency of the MCU bus and the security of data transmission, so as to solve the problem that in certain application scenarios, there are some complex operations that frequently occur. If a method of synthesizing multiple simple instructions is used, problems such as many repeated operations, low execution efficiency, and increased power consumption will occur. In addition, when using the MCU for data transmission, it is often necessary to add an application layer data transmission protocol by software to perform verification to ensure correct data transmission. This method will greatly increase software overhead, increase the difficulty of software programming, and reduce data transmission efficiency.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a method for improving MCU bus efficiency and data transmission security, comprising: a host computer compiler compiling and generating instructions for specific functions, and the MCU executing the corresponding functional operations according to the instructions as follows:
[0007] Step 1: The compiler generates preset instructions;
[0008] Step 2: The MCU reads the original data A at the corresponding address of the source register according to the preset instruction;
[0009] Step 3: The MCU modifies the original data A into the expected data B according to the preset instructions;
[0010] Step 4: Calculate the CRC check value C1 of the expected data B in the MCU;
[0011] Step 5: Write data B together with the calculated CRC check value C1 into the corresponding address of the target register;
[0012] Step 6: Calculate the CRC check value of the data C1 written into the corresponding address of the target register;
[0013] Step 7: Compare the two CRC check values. If they are the same, the operation is successful. If they are different, an error message is reported.
[0014] As a preferred embodiment of the present invention, the method for improving MCU bus efficiency further includes: when all values in the target register are modified, all values are modified and stored in the target register.
[0015] As a preferred embodiment of the present invention, the MCU obtains the preset instruction specifically including: when modifying part of the value in the target register, obtaining the preset instruction, and calling the system register according to the preset instruction.
[0016] As a preferred embodiment of the present invention, the preset instruction is stored in a system register. The preset instruction is a machine instruction.
[0017] As a preferred embodiment of the present invention, writing the second value into the target register specifically includes: the system register initiates a bus write request, the target register receives the write request, and writes the second value into the target register, where the target register is a peripheral register.
[0018] Compared with the prior art, the present invention has the following beneficial effects:
[0019] The present invention targets operations frequently performed in specific usage scenarios of specific users, adds special instructions to the MCU instruction set to solve specific problems, and generates machine code corresponding to the special instructions in the upper computer compiler, which can quickly and efficiently execute the corresponding operations, speed up operation, and improve execution efficiency. The special instructions also add a CRC check code function applied to data transmission. Executing the special instructions can automatically generate a CRC check code for the current data to be transmitted. The CRC check generated by the MCU chip at the hardware bottom layer can ensure communication security, improve transmission efficiency, and reduce software overhead compared to the method in which application developers generate CRC check codes through software code. In order to improve MCU bus efficiency and data transmission security, a special instruction and its execution circuit are designed for high-frequency operations of specific users in specific usage scenarios. The special instruction and execution circuit can efficiently, quickly and safely execute the "read-write-modify-CRC check" operation, avoid the use of a combination of multiple general instructions for execution, and facilitate compiler compilation. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 Schematic diagram of the system flow of the present invention. DETAILED DESCRIPTION
[0021] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0022] See also Figure 1 The present invention provides a technical solution: a method for improving MCU bus efficiency and data transmission security, comprising: a host computer compiler compiles and generates instructions for specific functions, and the MCU performs corresponding functional operations according to the instructions as follows:
[0023] Step 1: The compiler generates preset instructions;
[0024] Step 2: The MCU reads the original data A at the corresponding address of the source register according to the preset instruction;
[0025] Step 3: The MCU modifies the original data A into the expected data B according to the preset instructions;
[0026] Step 4: Calculate the CRC check value C1 of the expected data B in the MCU;
[0027] Step 5: Write data B together with the calculated CRC check value C1 into the corresponding address of the target register;
[0028] Step 6: Calculate the CRC check value of the data C1 written into the corresponding address of the target register;
[0029] Step 7: Compare the two CRC check values. If they are the same, the operation is successful. If they are different, an error message is reported.
[0030] The system register obtains a preset instruction, and performs the following operations according to the preset instruction: read the first value in the target register; modify the first value to the second value; write the second value to the target register. The present invention sets a preset instruction, and the processor obtains the preset instruction, reads the first value in the target register according to the preset instruction, and loads the first value into the system register for modification, modifies it to the second value, and calculates the CRC check value of the second value and sends it to the target address of the recipient. The recipient can perform CRC check on the received data again. If the CRC check value is consistent, the execution of this instruction is successful when data communication is performed. The process implemented by the present invention only needs to obtain the preset instruction once to be implemented, and does not need to obtain the instruction multiple times. Therefore, the time interval generated by obtaining the instruction multiple times is saved, and the execution efficiency of the MCU bus is improved. The existing MCU performs the following operations during use: after reading the data at an address in the target register, modify the read data, and then write the new data formed after the modification to the address.
[0031] The C language codes for reading and writing using MCU are listed as follows:
[0032] *(unsigned int*)0×00001000|=0×01;
[0033] *(unsigned int*)0×00001000&=0×0efffffc;
[0034] For example, the C language code *(unsigned int*)0×00001000|=0×01 has the function of setting the lower two bits of the register of bus address 0×00001000 to 1, and the other bits of the address register (target register) remain unchanged.
[0035] The entire assembly process requires multiple assembly instructions to complete a "read-modify-write" C language operation, necessitating multiple instruction fetches. For the same address (addr), two instruction fetches are required—the first to read, the second to write. This delay between the two fetches affects code execution efficiency. Similarly, write and read operations on the AHB bus also experience delays.
[0036] To address the aforementioned issue of low MCU bus operation efficiency, the present invention provides a method for improving MCU bus efficiency and data transmission security. The method comprises reading original data A from a corresponding memory address into an internal data register; processing original data A according to the read instruction to obtain data B; calculating a CRC checksum C1 for data B; and transmitting data B along with the calculated CRC checksum C1 to a destination address on the receiving end. The receiving end can then perform a CRC check on the received data. If the CRC checksum values match, the instruction is successfully executed. If the checksum values do not match, an error has occurred during data transmission or storage, and the data will be retransmitted.
[0037] As a further improvement, the method for improving the MCU bus efficiency further includes: when all values in the target register are modified, all values are modified and stored in the target register.
[0038] Further improved, the MCU obtains the preset instruction specifically including: when modifying part of the value in the target register, obtaining the preset instruction, and calling the system register according to the preset instruction.
[0039] As a further improvement, the preset instruction is stored in a system register. The preset instruction is a machine instruction.
[0040] Further improved, writing the second value into the target register specifically includes: the system register initiates a bus write request, the target register receives the write request, and writes the second value into the target register, where the target register is a peripheral register.
[0041] The present invention targets operations frequently performed in specific usage scenarios of specific users, adds special instructions to the MCU instruction set to solve specific problems, and generates machine code corresponding to the special instructions in the upper computer compiler, which can quickly and efficiently execute the corresponding operations, speed up operation, and improve execution efficiency. The special instructions also add a CRC check code function applied to data transmission. Executing the special instructions can automatically generate a CRC check code for the current data to be transmitted. The CRC check generated by the MCU chip at the hardware bottom layer can ensure communication security, improve transmission efficiency, and reduce software overhead compared to the method in which application developers generate CRC check codes through software code. In order to improve MCU bus efficiency and data transmission security, a special instruction and its execution circuit are designed for high-frequency operations of specific users in specific usage scenarios. The special instruction and execution circuit can efficiently, quickly and safely execute the "read-write-modify-CRC check" operation, avoid the use of a combination of multiple general instructions for execution, and facilitate compiler compilation.
[0042] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art will be able to modify the technical solutions described in the aforementioned embodiments or substitute equivalents for some of the technical features. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.
Claims
1. A method for improving MCU bus efficiency and data transmission security, characterized by: include: The host computer compiler compiles and generates instructions for specific functions, and the MCU performs the corresponding functional operations according to the instructions as follows: Step 1: The compiler generates preset instructions; Step 2: The MCU reads the original data A at the corresponding address of the source register according to the preset instruction; Step 3: The MCU modifies the original data A into the expected data B according to the preset instructions; Step 4: Calculate the CRC check value C1 of the expected data B in the MCU; Step 5: Write data B together with the calculated CRC check value C1 into the corresponding address of the target register; Step 6: Calculate the CRC check value of the data C written into the corresponding address of the target register; Step 7: Compare the two CRC check values. If they are the same, the operation is successful. If they are different, an error message is reported.
2. The method for improving MCU bus efficiency and data transmission security according to claim 1, wherein: The method for improving the MCU bus efficiency further includes: when all values in the target register are modified, all values are modified and stored in the target register.
3. The method for improving MCU bus efficiency and data transmission security according to claim 1, wherein: The MCU obtains the preset instruction specifically including: when modifying part of the value in the target register, obtaining the preset instruction, and calling the system register according to the preset instruction.
4. The method for improving MCU bus efficiency and data transmission security according to claim 3, characterized in that: The preset instruction is stored in a system register, and the preset instruction is a machine instruction.
5. The method for improving MCU bus efficiency and data transmission security according to claim 3, characterized in that: Writing the second value into the target register specifically includes: the system register initiates a bus write request, the target register receives the write request, and writes the second value into the target register, where the target register is a peripheral register.
Citation Information
Patent Citations
SoC system verification method
CN105653390A
Method for improving MCU bus efficiency, intelligent terminal, storage medium and chip
CN110609705A