Single-chip microcomputer peripheral atomic operation control method, system and single-chip microcomputer
By determining the peripheral atomic operations and configuring the alias register space in the microcontroller, the problem of low efficiency and atomic damage caused by the CPU's multiple accesses to the bus is solved, and faster peripheral register reading and writing and lower power consumption operations are achieved. The atomicity and correctness of the operation are ensured.
Patent Information
- Application Number
- CN202311574790.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-22
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2043-11-22
AI Technical Summary
In the existing bit-band technology, the CPU needs to access the bus multiple times to perform RM-W operations, which results in low efficiency, high power consumption, and may destroy atomicity. Due to the triggering of interrupts, peripherals may receive incorrect data.
A method for controlling atomic operations on peripherals of a microcontroller is provided. By determining whether to perform atomic operations on peripherals, obtaining the atomic address decoding results, and selecting write operations to peripheral registers based on the results, the atomicity and efficiency of the atomic operations are ensured. The method includes configuring the unused address space of the peripheral as an alias register space and writing atomic operation data when needed.
It improves the execution efficiency of the CPU, reduces the power consumption of the microcontroller, and ensures the atomicity of peripheral register operations, avoiding configuration errors caused by interrupts or high-priority access, and ensuring the integrity of operations.
Smart Images

Figure CN117471976B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of single-chip microcomputer (Micro Control Unit, MCU) technology, and in particular to a single-chip microcomputer peripheral atomic operation control method, system and single-chip microcomputer. Background Art
[0002] Bit-band technology is an operation to read and write a single bit of a multi-bit wide register. This technology can directly assign 0 or 1 to a bit of data in a GPIO register or SRAM, so as to control the output of the GPIO port or change the value of a bit of SRAM data. The operation object of bit-band can be SRAM, I / O space, and the implementation principle is as follows: in the addressing space (for example, a 32-bit processor with an addressing space of 4GB), find an unused area and name it as an alias space. From the starting address of the alias space, each word (word 32bit) corresponds to a bit of the SRAM or I / O register. For example, 1MB SRAM requires 32MB of alias space to access each bit of the SRAM. By operating a word in the alias space (setting it to 0 or 1), it has the same effect as directly operating a bit of the corresponding address of the SRAM or I / O.
[0003] In the existing Bit-band technology, the Bit-band area provided by the Cortex-m3 / 4 CPU is used by the CPU to perform read, modify, and write operations (Read, Modify, Write, R-M-W). Such continuous multiple bus accesses have the following problems: the CPU needs to access the bus multiple times, and the R-M-W operation needs to access the bus multiple times, which is inefficient; for Bit-band operations, the compiler usually compiles the C code into load / store instructions. These two instructions occupy the CPU processing time, which to a certain extent reduces the CPU utilization and increases the power consumption of the MCU; during the execution of the R-M-W instruction, if the interrupt of another bus master such as DMA is triggered, the CPU will stop executing the current instruction and instead execute the DMA data transmission first, and then continue to execute the R-M-W after the DMA transmission is completed. During the execution of the DMA transmission, if data is written to the same peripheral, the peripheral will receive incorrect data, destroying the atomicity of the original operation.
[0004] Therefore, the prior art still needs to be improved and developed. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, the purpose of the present invention is to provide a single-chip microcomputer peripheral atomic operation control method, system and single-chip microcomputer, so as to solve the problems that the CPU in the existing Bit-band needs to access the bus multiple times to execute R-M-W, resulting in low efficiency and high power consumption, and if an interrupt occurs, the atomicity of the original operation may be destroyed.
[0006] The technical solution of the present invention is as follows:
[0007] In a first aspect, the present invention provides a method for controlling atomic operations of a single-chip microcomputer peripheral, comprising:
[0008] Determine whether to perform peripheral atomic operations;
[0009] When it is necessary to perform an atomic operation on a peripheral, the atomic address decoding result is obtained, and a write operation is performed on a peripheral register of the peripheral register group according to the atomic address decoding result;
[0010] The atomic operation data is selected according to the atomic address decoding result, and the atomic operation data is written into the current peripheral register.
[0011] According to a further configuration of the present invention, the single-chip microcomputer peripheral atomic operation control method further includes:
[0012] Configure the address space not used by the peripheral as the peripheral alias register space.
[0013] According to a further configuration of the present invention, the single-chip microcomputer peripheral atomic operation control method further includes:
[0014] When no peripheral atomic operation is in progress, bus data is selected and written to the current peripheral register.
[0015] According to a further configuration of the present invention, when no peripheral atomic operation is performed, the step of selecting bus data and writing the bus data into the current peripheral register comprises:
[0016] The CPU reads the value of the current peripheral register;
[0017] Modify the current peripheral register value read back to the corresponding bit;
[0018] Write the modified value back to the current peripheral register.
[0019] According to a further configuration of the present invention, the step of selecting atomic operation data according to the atomic address decoding result comprises:
[0020] When the result of the atomic address decoding is that the data selected to be written into the current peripheral register is bus data, the bus data is written into the current peripheral register.
[0021] According to a further configuration of the present invention, the single-chip microcomputer peripheral atomic operation control method further includes:
[0022] When the microcontroller starts up, the peripherals of the microcontroller are enabled to communicate with the peripherals.
[0023] In a second aspect, the present invention provides a control system for implementing the above-mentioned single-chip peripheral atomic operation control method, which includes: a CPU, an atomic operation judgment module, an atomic address decoding module, a write data preparation module, a selector and a peripheral register group; wherein,
[0024] The CPU is connected to the atomic operation judgment module and the write data preparation module via a bus, and is used to communicate with the peripheral register group;
[0025] The atomic operation judgment module is connected to the atomic address decoding module and is used to judge whether to execute the peripheral atomic operation;
[0026] The atomic address decoding result is connected to the selector, and is used to select a peripheral register of the peripheral register group to perform a write operation according to the atomic address decoding result;
[0027] The selector is connected to the peripheral register group and is used to select whether the data written into the peripheral register group is bus data or atomic operation data according to the atomic address decoding result;
[0028] The write data preparation module is connected to the selector and the peripheral register group respectively, and is used to write the atomic operation data to the peripheral register group.
[0029] According to a further configuration of the present invention, the bus is an AHB bus, an APB bus or an AXI bus.
[0030] According to a further configuration of the present invention, the peripheral register group includes a control register and a status register.
[0031] In a third aspect, the present invention provides a single-chip microcomputer, which includes the single-chip microcomputer peripheral atomic operation control system described above.
[0032] The present invention provides a single-chip microcomputer peripheral atomic operation control method, system and single-chip microcomputer, the method comprising: determining whether to execute peripheral atomic operation; obtaining the atomic address decoding result when the peripheral atomic operation needs to be executed, and selecting a peripheral register of the peripheral register group to perform a write operation according to the atomic address decoding result; selecting atomic operation data according to the atomic address decoding result, and writing the atomic operation data into the current peripheral register. By performing peripheral atomic operations on peripheral registers, the present invention can implement faster read and write operations on peripheral registers, improve the execution efficiency of the CPU and reduce the power consumption of the single-chip microcomputer, and at the same time ensure that the operation of the peripheral register is fully effective, will not be interrupted by interrupts or high-priority accesses to cause configuration errors, and ensure the atomicity of the original operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary personnel in this field, other drawings can be obtained based on the structures shown in these drawings without paying any creative work.
[0034] Figure 1 It is a flow chart of the single chip microcomputer peripheral atomic operation control method of the present invention.
[0035] Figure 2 It is a flow chart of a method for controlling atomic operations of peripherals of a single-chip microcomputer in one embodiment of the present invention.
[0036] Figure 3 It is a principle block diagram of the single-chip microcomputer peripheral atomic operation control system in the present invention.
[0037] Figure 4 It is a schematic diagram of accessing the general register of the peripheral device in the embodiment of the present invention in which the CPU individually accesses bit[0] and bit[1] of the GPIOA ODR register.
[0038] Figure 5 It is a schematic diagram of accessing an alias register of a peripheral device in an embodiment of the present invention in which a CPU individually accesses bit[0] and bit[1] of a GPIOA ODR register.
[0039] Figure 6 The present invention is a schematic diagram of CPU0 and CPU1 in a multi-core MCU simultaneously accessing bit [0] and bit [1] of the GPIOA ODR register to access a general register of a peripheral.
[0040] Figure 7The present invention is a schematic diagram of CPU0 and CPU1 in a multi-core MCU simultaneously accessing the alias register of the peripheral in bit[0] and bit[1] of the GPIOA ODR register.
[0041] The marks in the attached drawings are: 100, atomic operation judgment module; 200, atomic address decoding module; 300, write data preparation module; 400, selector; 500, peripheral register group. DETAILED DESCRIPTION
[0042] The present invention provides a single-chip microcomputer peripheral atomic operation control method, system and single-chip microcomputer. In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0043] In the embodiments and the scope of the patent application, unless the text specifically defines the article, "a", "an", "the" and "the" may also include plural forms. If there are descriptions involving "first", "second", etc. in the embodiments of the present invention, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "second" may explicitly or implicitly include at least one of the features.
[0044] It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when an element is said to be "connected" or "coupled" to another element, it can be directly connected or coupled to the other element, or there can also be intermediate elements. In addition, the "connection" or "coupling" used herein can include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.
[0045] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as herein.
[0046] In addition, the technical solutions between the various embodiments can be combined with each other, but it must be based on the fact that ordinary technicians in the field can implement it. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0047] Please also see Figure 1 and Figure 2 The present invention provides a preferred embodiment of a single-chip microcomputer peripheral atomic operation control method.
[0048] The present invention provides a single chip microcomputer peripheral atomic operation control method, such as Figure 1 As shown, it includes:
[0049] S100, determining whether to execute peripheral atomic operation;
[0050] S200, when it is necessary to perform an atomic operation on a peripheral, obtaining an atomic address decoding result, and selecting a peripheral register of the peripheral register group to perform a write operation according to the atomic address decoding result;
[0051] S300 , selecting atomic operation data according to the atomic address decoding result, and writing the atomic operation data into the current peripheral register.
[0052] Specifically, the CPU of the microcontroller communicates with the peripherals through the bus, such as reading and writing the peripheral registers in the specified peripheral register group. Figure 2 When the CPU communicates with peripherals, it first determines whether to perform peripheral atomic operations. If so, it selects a peripheral register in the peripheral register group for write operation based on the atomic decoding result, and selects the atomic operation data through the selector, and writes the atomic operation data into the current peripheral register. Otherwise, the bus data is written into the current peripheral register.
[0053] In the above technical scheme, the present invention can implement faster read and write operations on peripheral registers by performing peripheral atomic operations on peripheral registers, thereby improving the execution efficiency of the CPU and reducing the power consumption of the microcontroller. At the same time, it can ensure that the operations on the peripheral registers are fully effective and will not be interrupted by interruptions or high-priority accesses to cause configuration errors, thereby ensuring the atomicity of the original operations.
[0054] In some embodiments, the single-chip microcomputer peripheral atomic operation control method further includes the steps of:
[0055] S101. Configure the unused address space of the peripheral as the peripheral alias register space.
[0056] Specifically, an independent space address is allocated to each peripheral inside the single-chip microcomputer. There are many unused address spaces in the general peripherals of the single-chip microcomputer. For example, the control registers and status registers of the peripherals will not use up the entire address segment, and there is a large redundancy, so that the remaining address space can be used as the alias space of the peripherals. A peripheral alias register space is set in the address space of the peripheral to access the corresponding bit of the general register of the peripheral, so that the peripheral can directly execute Bit-band, and the peripheral alias register space can be accessed through the bus.
[0057] In some embodiments, the single-chip microcomputer peripheral atomic operation control method further includes the steps of:
[0058] S400: When no peripheral atomic operation is performed, bus data is selected and written into the current peripheral register.
[0059] Specifically, Figure 2 As shown, when the result of the atomic address decoding is that the data to be written to the current peripheral register is selected as bus data, the bus data is written to the current peripheral register, that is, when no peripheral atomic operation is performed, the CPU reads the value of the current peripheral register, modifies the read-back value of the current peripheral register to the corresponding bit, and then writes the modified value back to the current peripheral register to complete the process of reading back, modifying, and writing back.
[0060] In some embodiments, the single-chip microcomputer peripheral atomic operation control method further includes the steps of:
[0061] S102: When the single-chip microcomputer is started, the peripherals of the single-chip microcomputer are enabled to communicate with the peripherals.
[0062] Specifically, the operation starts when the single-chip microcomputer is reset or powered on, for example, the corresponding peripherals are enabled so that the CPU can communicate normally with the peripherals.
[0063] In some embodiments, Figure 3As shown, the present invention provides a control system for implementing the above-mentioned single-chip microcomputer peripheral atomic operation control method, which includes: a CPU, an atomic operation judgment module 100, an atomic address decoding module 200, a write data preparation module 300, a selector 400 and a peripheral register group 500. Among them, the CPU is connected to the atomic operation judgment module and the write data preparation module 300 through a bus for communicating with the peripheral register group 500; the atomic operation judgment module 100 is connected to the atomic address decoding module 200 for judging whether to perform peripheral atomic operations; the atomic address decoding module 200 is connected to the selector 400 for selecting a peripheral register of the peripheral register group 500 to perform a write operation according to the atomic address decoding result; the selector 400 is connected to the peripheral register group 500 for selecting whether the data written to the peripheral register group 500 is bus data or atomic operation data according to the atomic address decoding result; the write data preparation module 300 is respectively connected to the selector 400 and the peripheral register group 500 for writing atomic operation data to the peripheral register group 500.
[0064] Specifically, the CPU and the peripherals communicate with each other using a bus, and the bus is an AHB bus, an APB bus, an AXI bus, etc. The peripheral register group 500 includes a control register and a status register, etc., which can be used to control the functions of the peripherals, such as enabling the peripherals, configuring the reception, transmission and corresponding status indication of the peripherals. It should be noted that the peripherals of the single-chip microcomputer include but are not limited to GPIO, I2C, SPI, etc., and include the original registers of the peripherals and the peripheral alias space registers, wherein the original registers and the peripheral alias space registers can be configured by the CPU.
[0065] In the present embodiment, after the single-chip microcomputer is powered on and reset, the peripherals will first be enabled to complete the communication between the CPU and the peripherals. In the process of communication, the atomic operation judgment module 100 will be used to determine whether it is necessary to perform an atomic operation. If so, the atomic address decoding module 200 will be used to perform atomic address decoding to obtain the atomic address decoding result. According to the atomic address decoding result, the peripheral register that needs to be written can be selected. At the same time, the selection can also be selected according to the atomic address decoding result to select whether the data written into the current peripheral register is atomic operation data or bus data. If an atomic operation is performed, the atomic operation data is written to the current peripheral register by the write data preparation module 300, wherein the write data preparation module 300 will compare the atomic operation data with the value of the current peripheral register and generate the final data to be written into the current peripheral register. If it is not necessary to perform an atomic operation, the corresponding peripheral register is read by the CPU, and the bit of the corresponding peripheral register is modified thereafter, and the modified value is written back to the value peripheral register, thereby writing the bus data into the current peripheral register.
[0066] In the above technical scheme, the present invention implements faster read and write operations on peripheral registers by performing peripheral atomic operations on peripheral registers, thereby improving the execution efficiency of the CPU and reducing the power consumption of the microcontroller. At the same time, it can ensure that the operations on the peripheral registers are fully effective and will not be interrupted by interruptions or high-priority accesses to cause configuration errors, thereby ensuring the atomicity of the original operations.
[0067] In some embodiments, the present invention provides a single-chip microcomputer, which includes the single-chip microcomputer peripheral atomic operation control system described above.
[0068] Specific application example 1: The present invention is described by assuming that the CPU accesses bit[0] and bit[1] of the GPIOA ODR register independently.
[0069] This embodiment shows the situation when the CPU accesses the 0th bit and the 1st bit of the ODR register of GPIOA alone. The correspondence between the original register and the alias register of GPIOA is as follows:
[0070]
[0071] In the case where the peripheral alias register space is not accessed, such as Figure 4 As shown, the CPU performs the following operations on the peripheral register: the first time is to set bit [0] to 1. At this time, the interrupt is not triggered. The specific process is: 1. Read the value of the GPIOA ODR register (32 bits); 2. Set bit [0] of the 32-bit register to 1; 3. Write the value back to the ODR register.
[0072] The second time, bit[0] is set to 0, but an interrupt is triggered during the execution. The specific process is: 1. Read the value of the GPIOAODR register (32 bits); 2. Set bit[0] of the 32-bit register to 0; 3. The interrupt occurs and the content of the interrupt function is executed. The interrupt function changes
[0073] The structure of bit[1] of the ODR register is that the value 3 appears in the ODR register, which is not the value expected by the program; 4. After the interrupt function ends, the CPU writes the value changed in step 2 back to the ODR register. In this case, the ODR register is written with an incorrect value, causing the program to run incorrectly.
[0074] When using peripheral bit-band, the CPU performs the following operations on the peripheral registers:
[0075] like Figure 5 As shown in the figure, the first time is to set bit[0] to 1 (this operation is automatically completed by the hardware, will not be interrupted by the interrupt, and the speed is very fast). At this time, the interrupt is not triggered. The specific process is: 1. The CPU writes the address of ODRbit[0] corresponding to the peripheral alias register space; 2. The hardware automatically maps the value to ODR bit[0]. The second time, bit[0] is set to 0 (this operation is automatically completed by the hardware, will not be interrupted by the interrupt, and the speed is very fast), but the interrupt is triggered during the execution process. The specific process is: 1. The CPU writes the address of ODR bit[0] corresponding to the peripheral alias register space; 2. The hardware automatically maps the value to ODRbit[0], so the register value is 0; 3. The interrupt function writes ODR bit[1] to 1. Finally, the register value is still 2, which is what the program expects.
[0076] It can be seen from the above embodiments that the present invention can ensure that the operation on the register is fully effective and will not be interrupted by interruptions or high-priority accesses, resulting in configuration errors.
[0077] Specific application example 2: CPU0 and CPU1 in a multi-core MCU simultaneously access bit [0] and bit [1] of the GPIOA ODR register. This example shows the situation in a multi-core MCU when CPU0 and CPU1 are both accessing bit 0 and bit 1 of the ODR register.
[0078] The correspondence between the original registers and alias registers of GPIOA is as follows:
[0079]
[0080]
[0081] In the case where the peripheral alias register space is not accessed, such as Figure 6 As shown in the figure, CPU0 and CPU1 simultaneously perform the following operations on the peripheral registers: the first time is to set bit[0] to 1. At this time, the interrupt is not triggered. The specific process is: 1. CPU0 reads the value of the GPIOA ODR register (32 bits); 2. CPU0 sets bit[0] of the 32-bit register to 1; 3. CPU0 writes the value back to the ODR register.
[0082] The second time, bit[0] is set to 0, but an interrupt is triggered during the execution. The specific process is as follows: 1. CPU1 reads the value of the GPIOA ODR register (32 bits); 2. CPU1 sets bit[0] of the 32-bit register to 0; 3. CPU0 interrupt occurs and the content of the interrupt function is executed. The interrupt function changes bit[1] of the ODR register. The structure is that the value 3 appears in the ODR register, which is not the value expected by the program; 4. After the interrupt function ends, CPU1 writes the value changed in step 2 back to the ODR register. In this case, the ODR register is written with an incorrect value, causing the program to run incorrectly.
[0083] In the case of using peripheral alias register space, such as Figure 7 As shown in the figure, CPU0 performs the following operations on the peripheral register: the first time is to set bit[0] to 1 (this operation is automatically completed by the hardware, will not be interrupted by the interrupt, and the speed is very fast), and the interrupt is not triggered at this time. The specific process is: 1. CPU0 writes the address of ODR bit[0] corresponding to the peripheral alias register space; 2. The hardware automatically maps the value to ODR bit[0]. The second time, bit[0] is set to 0 (this operation is automatically completed by the hardware, will not be interrupted by the interrupt, and the speed is very fast), but the interrupt is triggered during the execution process. The specific process is: 1. CPU1 writes the address of ODR bit[0] corresponding to the peripheral alias register space; 2. The hardware automatically maps the value to ODR bit[0], so the register value is 0; 3. The CPU0 interrupt function writes ODR bit[1] to 1, and the final register value is still 2, which is what the program expects.
[0084] It can be seen from the above embodiments that in a multi-core system, even if multiple CPUs access the same peripheral device, correct access can be guaranteed.
[0085] In summary, the present invention provides a single-chip microcomputer peripheral atomic operation control method, system and single-chip microcomputer, the method comprising: determining whether to perform peripheral atomic operation; obtaining the atomic address decoding result when the peripheral atomic operation needs to be performed, and selecting a peripheral register of the peripheral register group to perform a write operation according to the atomic address decoding result; selecting atomic operation data according to the atomic address decoding result, and writing the atomic operation data into the current peripheral register. The present invention can implement faster read and write operations on the peripheral register by performing peripheral atomic operations on the peripheral register, improve the execution efficiency of the CPU and reduce the power consumption of the single-chip microcomputer, and at the same time ensure that the operation of the peripheral register is fully effective, and will not be interrupted by interrupts or high-priority accesses to cause configuration errors, thereby ensuring the atomicity of the original operation, and in multi-tasking and multi-core situations, the peripheral can also ensure the correct behavior of the program.
[0086] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A method for controlling atomic operations of a single-chip microcomputer peripheral, characterized in that: include: Determine whether to perform peripheral atomic operations; When it is necessary to perform an atomic operation on a peripheral, the atomic address decoding result is obtained, and a write operation is performed on a peripheral register of the peripheral register group according to the atomic address decoding result; Select atomic operation data according to the atomic address decoding result, and write the atomic operation data into the current peripheral register; The unused address space of the peripheral is configured as the peripheral alias register space; wherein each peripheral is separately configured with an independent address space, and a peripheral alias register space is set in the address space of the peripheral to access the corresponding bit of the general register of the peripheral, so that the peripheral can directly access the bit-band; and further comprising: When no peripheral atomic operation is in progress, bus data is selected and written to the current peripheral register.
2. The single-chip microcomputer peripheral atomic operation control method according to claim 1, characterized in that: The step of selecting bus data and writing the bus data into the current peripheral register when no peripheral atomic operation is performed comprises: The CPU reads the value of the current peripheral register; Modify the current peripheral register value read back to the corresponding bit; Write the modified value back to the current peripheral register.
3. The single chip microcomputer peripheral atomic operation control method according to claim 1, characterized in that: The step of selecting atomic operation data according to the atomic address decoding result comprises: When the result of the atomic address decoding is that the data selected to be written into the current peripheral register is bus data, the bus data is written into the current peripheral register.
4. The single-chip microcomputer peripheral atomic operation control method according to claim 1, characterized in that: Also includes: When the microcontroller starts up, the peripherals of the microcontroller are enabled to communicate with the peripherals.
5. A control system for implementing the single-chip microcomputer peripheral atomic operation control method according to any one of claims 1 to 4, characterized in that: include: CPU, atomic operation judgment module, atomic address decoding module, write data preparation module, selector and peripheral register group; among them, The CPU is connected to the atomic operation judgment module and the write data preparation module via a bus, and is used to communicate with the peripheral register group; The atomic operation judgment module is connected to the atomic address decoding module and is used to judge whether to execute the peripheral atomic operation; The atomic address decoding result is connected to the selector, and is used to select a peripheral register of the peripheral register group to perform a write operation according to the atomic address decoding result; The selector is connected to the peripheral register group and is used to select whether the data written into the peripheral register group is bus data or atomic operation data according to the atomic address decoding result; The write data preparation module is connected to the selector and the peripheral register group respectively, and is used to write the atomic operation data to the peripheral register group.
6. The single-chip microcomputer peripheral atomic operation control system according to claim 5, characterized in that: The bus is an AHB bus, an APB bus or an AXI bus.
7. The single-chip microcomputer peripheral atomic operation control system according to claim 5, characterized in that: The peripheral register group includes a control register and a status register.
8. A single chip microcomputer, characterized in that: It comprises a single chip microcomputer peripheral atomic operation control system as described in any one of claims 5 to 7.
Citation Information
Patent Citations
Method for improving MCU bus efficiency, intelligent terminal, storage medium and chip
CN110609705A
Atomic operation device, method, equipment and medium
CN117056255A
