Dual-cpu data synchronization system and method
By adjusting the pin states and data transmission of the dual CPUs, synchronization of the dual CPU system was achieved, solving the problems of information processing delay and low efficiency, and improving processing speed and work efficiency.
Patent Information
- Application Number
- CN202411285790.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2044-09-13
AI Technical Summary
In existing technologies, dual-CPU systems cannot adjust the two CPUs to the same state, resulting in delays and low efficiency in information processing.
By adjusting the pin states of CPU1 and CPU2, and through the information synchronization module and data transmission module, CPU1 and CPU2 are synchronized to ensure that they reach the same working state within a preset time.
It improves CPU processing speed and efficiency, reduces information processing latency, and enhances the synchronization capability of dual-CPU systems.
Smart Images

Figure CN119226005B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer control, and in particular to a dual-CPU data synchronization system and method. Background Technology
[0002] To improve the product's security performance, a single CPU is no longer sufficient to meet the computational needs during processing.
[0003] In the prior art, a CPU system and its collaborative soft reset method are disclosed. The dual-CPU system includes two CPUs, each with a communication serial port, and both CPUs are connected to at least one GPIO. The dual-CPU system first automatically identifies the master and slave CPUs using the same GPIO state, and then realizes soft reset control signaling communication through the first communication serial port on the master CPU and the second communication serial port on the slave CPU.
[0004] Currently, the relevant technologies can only divide the two CPUs into master and slave CPUs for information processing, but cannot adjust the two CPUs to the same state. This may result in information processing delays and low information processing efficiency. Summary of the Invention
[0005] This application provides a dual-CPU data synchronization system and method to at least solve the problems of information processing delay and low information processing efficiency in related technologies.
[0006] In a first aspect, embodiments of this application provide a dual-CPU data synchronization system, including: CPU1 includes a first signal unit, a first transmission unit, and a first state setting unit. The first signal unit includes a pin group, and each pin group includes a CPU1 transmit pin and a CPU1 receive pin. The first state setting unit is used to set the state of the CPU1 transmit pin. CPU2 includes a second signal unit, a second transmission unit, and a second state setting unit. The second signal unit includes pin groups, each pin group including a CPU2 transmit pin and a CPU2 receive pin. The second state setting unit is used to set the state of the CPU2 transmit pin. In this configuration, one CPU1 transmit pin is matched with one CPU2 receive pin, and one CPU1 receive pin is matched with one CPU2 transmit pin. The information synchronization module is configured to adjust the pin state of the CPU1 transmit pin through the first state setting unit, adjust the pin state of the CPU2 transmit pin through the second state setting unit, and determine whether the state of the CPU1 receive pin is converted to the same state as the CPU2 transmit pin that matches the pin within a first preset time, and whether the state of the CPU2 receive pin is converted to the same state as the CPU1 transmit pin that matches the pin. The data transmission module is configured to send one piece of data to be synchronized to CPU2 through the first transmission unit, and send another piece of data to be synchronized to CPU1 through the second transmission unit, determine whether CPU1 and CPU2 have completed the transmission, and receive data sent by the other party.
[0007] By adjusting the pin states of CPU1 and CPU2, and ensuring that CPU1 and CPU2 respond accordingly to these adjustments, they can be brought to the same operating state. Information synchronization is achieved through data transmission. Simultaneous task processing by CPU1 and CPU2 increases processing speed and improves work efficiency.
[0008] In some embodiments, the information synchronization module is further configured to: The state of the CPU1 transmit pin is adjusted to the first pin state by the first state setting unit, and the state of the CPU2 transmit pin is adjusted to the first pin state by the second state setting unit. It is determined whether the state of the CPU1 receive pin is converted to the same state as the CPU2 transmit pin that matches the pin within a first preset time, and whether the state of the CPU2 receive pin is converted to the same state as the CPU1 transmit pin that matches the pin. If so, the state of the CPU1 transmit pin is adjusted to the second pin state by the first state setting unit, and the state of the CPU2 transmit pin is adjusted to the second pin state by the second state setting unit. It is determined whether the state of the CPU1 receive pin is converted to the same state as the CPU2 transmit pin that matches the pin within the first preset time, and whether the state of the CPU2 receive pin is converted to the same state as the CPU1 transmit pin that matches the pin.
[0009] The information synchronization module can calibrate the task execution time multiple times. After multiple calibrations, the time difference between the information synchronization of the two CPUs will become smaller and smaller. The synchronization efficiency of CPU1 and CPU2 becomes higher and higher, which facilitates the dual-CPU operation and task execution.
[0010] In some embodiments, the data transmission module further includes: The first judgment unit is configured to determine whether the transmit register of CPU1 and the transmit register of CPU2 are both cleared within a second preset time. The second judgment unit is configured to determine whether the DMA receive completion flag of CPU1 and the DMA receive completion flag of CPU2 are both set within a second preset time.
[0011] By checking whether the transmit registers of CPU1 and CPU2 are cleared and whether the DMA receive completion flags of CPU1 and CPU2 are both set, it can be determined whether CPU1 and CPU2 have completed information transmission and reception, thereby achieving dual-CPU data synchronization.
[0012] In some embodiments, both the first transmission unit and the second transmission unit include: One data transmit pin, and one data receive pin; The data transmission pin of the first transmission unit corresponds to the data reception pin of the second transmission unit; The data receiving pin of the first transmission unit corresponds to the data sending pin of the second transmission unit.
[0013] Each CPU has its own data transmission pin and data reception pin for data transmission, which facilitates data transmission, ensures smooth information transmission and reception, and avoids information loss.
[0014] In some embodiments, both CPU1 and CPU2 include multiple pin groups, with one pin group of CPU1 corresponding to one pin group of CPU2. The information synchronization module is configured to adjust the pin states of the corresponding CPU1 pin group and CPU2 pin group, including: Adjust the state of the CPU1 transmit pin in a CPU1 pin group and the state of the CPU2 transmit pin in the CPU2 pin group corresponding to the CPU1 pin group; determine whether the state of the CPU2 receive pin in the CPU2 pin group is adjusted to be the same as the state of the CPU1 transmit pin in the CPU1 pin group within a first preset time period, and whether the state of the CPU1 receive pin in the CPU1 pin group is adjusted to be the same as the state of the CPU2 transmit pin in the CPU2 pin group. If so, adjust the state of the next corresponding CPU1 pin group and CPU2 pin group until the state of all corresponding CPU1 pin groups and CPU2 pin groups has been adjusted.
[0015] Both CPU1 and CPU2 include multiple pin groups. By adjusting these pin groups to appropriate states, signal synchronization between CPU1 and CPU2 can be achieved, providing a foundation for subsequent data synchronization.
[0016] In some embodiments, the information synchronization module is further configured to: Adjust the state of the CPU1 transmit pin in a CPU1 pin group to the first pin state, and adjust the state of the CPU2 transmit pin in the CPU2 pin group corresponding to the CPU1 pin group to the first pin state; determine whether the state of the CPU2 receive pin in the CPU2 pin group is adjusted to be the same as the state of the CPU1 transmit pin in the CPU1 pin group within a first preset time period, and whether the state of the CPU1 receive pin in the CPU1 pin group is adjusted to be the same as the state of the CPU2 transmit pin in the CPU2 pin group. If so, adjust the state of the next corresponding CPU1 pin group and CPU2 pin group until the states of all corresponding CPU1 pin groups and CPU2 pin groups have been adjusted in the first pin state. Further adjust the state of the CPU1 transmit pin in a CPU1 pin group to the second pin state, and adjust the state of the CPU2 transmit pin in the CPU2 pin group corresponding to the CPU1 pin group to the second pin state; determine whether the state of the CPU2 receive pin in the CPU2 pin group is adjusted to be the same as the state of the CPU1 transmit pin in the CPU1 pin group within a first preset time period, and whether the state of the CPU1 receive pin in the CPU1 pin group is adjusted to be the same as the state of the CPU2 transmit pin in the CPU2 pin group. If so, adjust the state of the next corresponding CPU1 pin group and CPU2 pin group until the states of all corresponding CPU1 pin groups and CPU2 pin groups have been adjusted in the second pin state.
[0017] During signal synchronization, the states of the dual CPU pin groups are adjusted sequentially to bring the two CPUs to the same state, reducing latency. By repeatedly adjusting the pin states of CPU1 and CPU2, the time difference in response between the two CPUs can be reduced.
[0018] In some embodiments, the first pin is at a high level and the second pin is at a low level.
[0019] Secondly, embodiments of this application provide a dual-CPU data synchronization method, including: The information synchronization step involves adjusting the pin state of the CPU1 transmit pin and the pin state of the CPU2 transmit pin, and determining whether the state of the CPU1 receive pin is converted to the same state as the CPU2 transmit pin that matches the pin within a first preset time, and whether the state of the CPU2 receive pin is converted to the same state as the CPU1 transmit pin that matches the pin. The data transmission process involves CPU1 sending one piece of data to be synchronized to CPU2, and CPU2 sending another piece of data to be synchronized to CPU1. It also involves determining whether CPU1 and CPU2 have completed the transmission and receiving data sent by the other party.
[0020] By following the steps above, adjusting the pin states achieves state synchronization between the two CPUs, and data transmission achieves data synchronization between them. Adjusting CPU1 and CPU2 to the same operating state results in faster processing speed and higher efficiency.
[0021] In some embodiments, the information synchronization step further includes: S11, adjust the state of the first CPU1 transmit pin to the first pin state, and the state of the first CPU2 transmit pin to the first pin state; determine whether the state of the first CPU2 receive pin that matches the first CPU1 transmit pin has been adjusted to the same state as the first CPU1 transmit pin within a first preset time, and whether the state of the first CPU1 receive pin has been adjusted to the same state as the first CPU2 transmit pin. If so, adjust the state of the next CPU1 transmit pin and the next CPU2 transmit pin to the first pin state, and determine again whether the states of the corresponding CPU2 receive pin and CPU1 receive pin have been adjusted to the first pin state; repeat the process until the states of all pins in the matching CPU1 pin group and the CPU2 pin group are in the first pin state. S12, adjust the state of the first CPU1 transmit pin to the second pin state, and the state of the first CPU2 transmit pin to the second pin state; determine whether the state of the first CPU2 receive pin that matches the first CPU1 transmit pin has been adjusted to the same state as the first CPU1 transmit pin within a first preset time, and whether the state of the first CPU1 receive pin has been adjusted to the same state as the first CPU2 transmit pin. If so, adjust the state of the next CPU1 transmit pin and the next CPU2 transmit pin to the second pin state, and determine whether the states of the corresponding CPU2 receive pin and CPU1 receive pin have been adjusted to the first pin state; repeat the process until the states of all pins in the matching CPU1 pin group and the CPU2 pin group are in the second pin state.
[0022] In the above information synchronization steps, the first CPU1 transmit pin and the first CPU1 receive pin correspond to pins in a CPU1 pin group, and the first CPU2 receive pin and the first CPU2 transmit pin correspond to pins in a CPU2 pin group.
[0023] CPU1 and CPU2 contain multiple pins. To achieve signal synchronization, these pins need to be matched and adjusted to the same state. After several adjustments, CPU1 and CPU2 achieved synchronization, enabling them to process tasks better and increasing operational safety.
[0024] In some embodiments, the data transmission step includes: S21, CPU1 sends the first data to be synchronized, and CPU2 sends the second data to be synchronized; S22, within the second preset time, CPU1 and CPU2 determine whether their respective SCI transmit registers are cleared; S23, within the second preset time, CPU1 and CPU2 determine whether their respective SCIDMA reception completion flags are set; S24, CPU1 reads the second data to be synchronized, and CPU2 reads the first data to be synchronized.
[0025] By checking whether the SCI transmit register is cleared and whether the SCIDMA receive completion flag is set, it can be determined whether CPU1 and CPU2 have sent data to each other. Furthermore, CPU1 and CPU2 read the data to achieve data synchronization. This facilitates simultaneous task processing by both CPUs, improving work efficiency.
[0026] Compared to related technologies, the dual-CPU data synchronization system and method provided in this application adjusts the pin states of the two CPUs to the same working state, calibrates the time for task execution, improves CPU efficiency, and reduces latency.
[0027] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects and advantages of this application more readily apparent. Attached Figure Description
[0028] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a structural block diagram of a dual-CPU data synchronization system according to an embodiment of this application; Figure 2 This is a flowchart of a dual-CPU data synchronization method according to an embodiment of this application; Figure 3 This is a structural block diagram of CPU1 and CPU2 in a dual-CPU data synchronization system according to an embodiment of this application; Figure 4 This is a flowchart of the signal synchronization process in the dual-CPU data synchronization method according to an embodiment of this application; Figure 5 This is a flowchart of the data transmission process in the dual-CPU data synchronization method according to an embodiment of this application. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of this application clearer, the application is described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application.
[0030] Obviously, the accompanying drawings described below are merely some examples or embodiments of this application. Those skilled in the art can apply this application to other similar scenarios based on these drawings without any inventive effort. Furthermore, it is understood that although the efforts made in this development process may be complex and lengthy, for those skilled in the art related to the content disclosed in this application, any changes to design, manufacturing, or production based on the technical content disclosed in this application are merely conventional technical means and should not be construed as insufficient disclosure of the content of this application.
[0031] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment that is mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0032] Unless otherwise defined, the technical or scientific terms used in this application shall have the ordinary meaning understood by one of ordinary skill in the art to which this application pertains. The terms “a,” “an,” “an,” “the,” and similar words used in this application do not indicate quantity limitation and may indicate singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units not listed, or may include other steps or units inherent to these processes, methods, products, or devices. The terms “connected,” “linked,” “coupled,” and similar words used in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. “Multiple” used in this application refers to two or more. “And / or” describes the relationship between related objects, indicating that three relationships may exist; for example, “A and / or B” can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following objects are in an "or" relationship. The terms "first," "second," and "third" used in this application are merely to distinguish similar objects and do not represent a specific ordering of the objects.
[0033] This embodiment provides a dual-CPU data synchronization system. As used below, the terms "module," "unit," "subunit," etc., can refer to a combination of software and / or hardware that performs a predetermined function. Although the system described in the following embodiment is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0034] Figure 1 This is a structural diagram of a dual-CPU data synchronization system according to an embodiment of this application, as shown below. Figure 1 As shown, the system includes: CPU1 includes a first signal unit, a first transmission unit, and a first state setting unit. The first signal unit includes pin groups, each of which includes a CPU1 transmit pin and a CPU1 receive pin. The first state setting unit is used to set the state of the CPU1 transmit pin.
[0035] CPU2 includes a second signal unit, a second transmission unit, and a second state setting unit. The second signal unit includes pin groups, each of which includes a CPU2 transmit pin and a CPU2 receive pin. The second state setting unit is used to set the state of the CPU2 transmit pin.
[0036] In this configuration, one pin group of CPU1 corresponds to one pin group of CPU2. Specifically, one CPU1 transmit pin in one pin group of CPU1 is matched with one CPU2 receive pin in one pin group of CPU2, and one CPU1 receive pin in one pin group of CPU1 is matched with one CPU2 transmit pin in one pin group of CPU2.
[0037] The information synchronization module is configured to adjust the pin state of the CPU1 transmit pin through the first state setting unit, adjust the pin state of the CPU2 transmit pin through the second state setting unit, and determine whether the state of the CPU1 receive pin is converted to the same state as the CPU2 transmit pin that matches the pin within a first preset time, and whether the state of the CPU2 receive pin is converted to the same state as the CPU1 transmit pin that matches the pin.
[0038] The data transmission module is configured to send one piece of data to be synchronized to CPU2 through the first transmission unit, and send another piece of data to be synchronized to CPU1 through the second transmission unit, determine whether CPU1 and CPU2 have completed the transmission, and receive data sent by the other party.
[0039] The system described above adjusts the pin states of CPU1 and CPU2, enabling them to respond accordingly and synchronize their operating states. Information synchronization is achieved through data transmission. Simultaneous task processing by CPU1 and CPU2 increases processing speed and improves efficiency.
[0040] The first preset time is twice the execution time of the tasks already set in CPU1 and CPU2.
[0041] In one embodiment, when two CPUs receive an instruction requiring data synchronization, the data synchronization task is queued in the task lists of the two CPUs. At this time, both CPUs also need to complete the tasks already in their lists: CPU1 needs to complete task 1, and CPU2 needs to complete tasks 1, 2, and 3. CPU1 completes task 1, begins the data synchronization task, adjusts the state of its sending pins, and waits for CPU2 to begin its data synchronization task. CPU2 completes tasks 1, 2, and 3, begins the data synchronization task, and adjusts the state of its sending pins. The first preset time = (time required to complete task 2 + time required to complete task 3). 2. If, within a first preset time period, the state of the CPU1 receive pin is adjusted according to the state of the CPU2 transmit pin that is matched with that pin, and the state of the CPU2 receive pin is adjusted according to the state of the CPU1 transmit pin that is matched with that pin, then the state adjustment is successful.
[0042] The first preset time can be understood as the time taken from when one CPU starts executing a data synchronization task to when another CPU starts executing a data synchronization task.
[0043] In some embodiments, the information synchronization module is further configured to: The first state setting unit adjusts the state of the CPU1 transmit pin to the first pin, and the second state setting unit adjusts the state of the CPU2 transmit pin to the first pin. It is determined whether the state of the CPU1 receive pin is converted to the same state as the CPU2 transmit pin that matches the pin within a first preset time, and whether the state of the CPU2 receive pin is converted to the same state as the CPU1 transmit pin that matches the pin.
[0044] If so, the state of the CPU1 transmit pin is adjusted to the second pin state by the first state setting unit, and the state of the CPU2 transmit pin is adjusted to the second pin state by the second state setting unit. It is determined whether the state of the CPU1 receive pin is converted to the same state as the CPU2 transmit pin that matches the pin within the first preset time, and whether the state of the CPU2 receive pin is converted to the same state as the CPU1 transmit pin that matches the pin.
[0045] The information synchronization module can calibrate the task execution time multiple times. After multiple calibrations, the time difference between the information synchronization of the two CPUs will become smaller and smaller. The synchronization efficiency of CPU1 and CPU2 becomes higher and higher, which facilitates the dual-CPU operation and task execution.
[0046] In some embodiments, the data transmission module further includes: The first judgment unit is configured to determine whether the transmit registers of CPU1 and CPU2 are both cleared within a second preset time.
[0047] The second judgment unit is configured to determine whether the DMA receive completion flag of CPU1 and the DMA receive completion flag of CPU2 are both set within a second preset time.
[0048] By checking whether the transmit registers of CPU1 and CPU2 are cleared and whether the DMA receive completion flags of CPU1 and CPU2 are both set, it can be determined whether CPU1 and CPU2 have completed information transmission and reception, thereby achieving dual-CPU data synchronization.
[0049] In some embodiments, both the first transmission unit and the second transmission unit include: One data transmit pin, and one data receive pin.
[0050] The data transmission pin of the first transmission unit corresponds to the data reception pin of the second transmission unit.
[0051] The data receiving pin of the first transmission unit corresponds to the data sending pin of the second transmission unit.
[0052] Each CPU has its own data transmission pin and data reception pin for data transmission, which facilitates data transmission, ensures smooth information transmission and reception, and avoids information loss.
[0053] In some embodiments, both CPU1 and CPU2 include multiple pin groups, with one pin group of CPU1 corresponding to one pin group of CPU2.
[0054] The information synchronization module is configured to adjust the pin states of the corresponding CPU1 pin group and CPU2 pin group, including: Adjust the state of the CPU1 transmit pin in a CPU1 pin group and the state of the CPU2 transmit pin in the CPU2 pin group corresponding to the CPU1 pin group; determine whether the state of the CPU2 receive pin in the CPU2 pin group is adjusted to be the same as the state of the CPU1 transmit pin in the CPU1 pin group within a first preset time period, and whether the state of the CPU1 receive pin in the CPU1 pin group is adjusted to be the same as the state of the CPU2 transmit pin in the CPU2 pin group.
[0055] If so, adjust the state of the next corresponding CPU1 pin group and CPU2 pin group. During the state adjustment process of each pin group, repeat the above state adjustment steps for the pins of the CPU1 pin group and the CPU2 pin group until the state adjustment of all corresponding CPU1 pin groups and CPU2 pin groups is completed. That is, the state of the CPU2 receive pin is adjusted to be the same as the state of the corresponding CPU1 transmit pin, and the state of the CPU1 receive pin is adjusted to be the same as the state of the corresponding CPU2 transmit pin.
[0056] Both CPU1 and CPU2 include multiple pin groups. By adjusting these pin groups to appropriate states, signal synchronization between CPU1 and CPU2 can be achieved, providing a foundation for subsequent data synchronization.
[0057] In some embodiments, the information synchronization module is further configured to: Adjust the state of the CPU1 transmit pin in a CPU1 pin group to the first pin state, and adjust the state of the CPU2 transmit pin in the corresponding CPU2 pin group to the first pin state. Determine whether, within a first preset time period, the state of the CPU2 receive pin in the CPU2 pin group is adjusted to be the same as the state of the CPU1 transmit pin in the CPU1 pin group, and whether the state of the CPU1 receive pin in the CPU1 pin group is adjusted to be the same as the state of the CPU2 transmit pin in the CPU2 pin group.
[0058] If so, adjust the state of the next corresponding CPU1 pin group and CPU2 pin group. During the state adjustment process of each pin group, repeat the first state adjustment steps of the above CPU1 pin group and CPU2 pin group until the state of all corresponding CPU1 pin groups and CPU2 pin groups is adjusted to the first pin state. That is, the state of the CPU2 receive pin and the corresponding state of the CPU1 transmit pin are both adjusted to the first state, and the state of the CPU1 receive pin and the corresponding state of the CPU2 transmit pin are both adjusted to the first state.
[0059] After synchronizing the first pin state of each CPU1 pin group and CPU2 pin group, further adjust them to synchronize the second pin state.
[0060] Further adjust the state of the CPU1 transmit pin in a CPU1 pin group to the second pin state, and adjust the state of the CPU2 transmit pin in the corresponding CPU2 pin group to the second pin state. Determine whether, within a first preset time period, the state of the CPU2 receive pin in the CPU2 pin group is adjusted to be the same as the state of the CPU1 transmit pin in the CPU1 pin group, and whether the state of the CPU1 receive pin in the CPU1 pin group is adjusted to be the same as the state of the CPU2 transmit pin in the CPU2 pin group.
[0061] If so, adjust the state of the next corresponding CPU1 pin group and CPU2 pin group. During the state adjustment process of each pin group, repeat the second state adjustment steps of the above CPU1 pin group and CPU2 pin group until the state of all corresponding CPU1 pin groups and CPU2 pin groups is adjusted to the second pin state. That is, the state of the CPU2 receive pin and the corresponding state of the CPU1 transmit pin are both adjusted to the second state, and the state of the CPU1 receive pin and the corresponding state of the CPU2 transmit pin are both adjusted to the second state.
[0062] During signal synchronization, the states of the dual CPU pin groups are adjusted sequentially to bring the two CPUs to the same state, reducing latency. By repeatedly adjusting the pin states of CPU1 and CPU2, the time difference in response between the two CPUs can be reduced.
[0063] In some embodiments, the first pin is at a high level and the second pin is at a low level.
[0064] The states of the first and second pins are related to the default voltage level. The first pin state is the opposite of the default voltage level, and the second pin state is the same as the default voltage level. When the default voltage level is low, the first pin state is high and the second pin state is low. When the default voltage level is high, the first pin state is low and the second pin state is high.
[0065] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can reside in the same processor; or the above modules can be located in different processors in any combination.
[0066] This embodiment also provides a dual-CPU data synchronization method. Figure 2 This is a flowchart of a dual-CPU data synchronization method according to an embodiment of this application, such as... Figure 2 As shown, the process includes the following steps: In information synchronization step S201, the pin states of the CPU1 transmit pin and the CPU2 transmit pin are adjusted. It is determined whether, within a first preset time, the state of the CPU1 receive pin changes to the same state as the CPU2 transmit pin that matches it, and vice versa. Once the states are identical, the data synchronization step is initiated.
[0067] In data transmission step S202, CPU1 sends one piece of data to be synchronized to CPU2, and CPU2 sends another piece of data to be synchronized to CPU1. It is determined whether CPU1 and CPU2 have completed the transmission and whether the data sent by the other party has been received.
[0068] By following the steps above, adjusting the pin states achieves state synchronization between the two CPUs, and data transmission achieves data synchronization between them. Adjusting CPU1 and CPU2 to the same operating state results in faster processing speed and higher efficiency.
[0069] In some embodiments, the information synchronization step further includes: S11, adjust the state of the first CPU1 transmit pin to the first pin state, and the state of the first CPU2 transmit pin to the first pin state; determine whether the state of the first CPU2 receive pin that matches the first CPU1 transmit pin is adjusted to the same state as the first CPU1 transmit pin within a first preset time, and whether the state of the first CPU1 receive pin is adjusted to the same state as the first CPU2 transmit pin. If so, adjust the state of the next CPU1 transmit pin and the next CPU2 transmit pin to the first pin state, and determine again whether the states of the corresponding CPU2 receive pin and CPU1 receive pin are both adjusted to the first pin state; repeat the process until the states of all pins in the matching CPU1 pin group and the CPU2 pin group are in the first pin state.
[0070] S12, adjust the state of the first CPU1 transmit pin to the second pin state, and the state of the first CPU2 transmit pin to the second pin state; determine whether the state of the first CPU2 receive pin that matches the first CPU1 transmit pin has been adjusted to the same state as the first CPU1 transmit pin within a first preset time, and whether the state of the first CPU1 receive pin has been adjusted to the same state as the first CPU2 transmit pin. If so, adjust the state of the next CPU1 transmit pin and the next CPU2 transmit pin to the second pin state, and determine whether the states of the corresponding CPU2 receive pin and CPU1 receive pin have been adjusted to the first pin state; repeat the process until the states of all pins in the matching CPU1 pin group and the CPU2 pin group are in the second pin state.
[0071] CPU1 and CPU2 contain multiple pins. To achieve signal synchronization, these pins need to be adjusted to the same state. After several adjustments, CPU1 and CPU2 achieve synchronization, enabling them to process tasks more effectively and increasing operational safety.
[0072] In some embodiments, the data transmission step includes: S21, CPU1 sends the first data to be synchronized, and CPU2 sends the second data to be synchronized.
[0073] S22, within the second preset time, CPU1 and CPU2 determine whether their respective SCI transmit registers are cleared.
[0074] S23, within the second preset time period, CPU1 and CPU2 determine whether their respective SCIDMA reception completion flags are set.
[0075] S24, CPU1 reads the second data to be synchronized, and CPU2 reads the first data to be synchronized.
[0076] By checking whether the SCI transmit register is cleared and whether the SCIDMA receive completion flag is set, it can be determined whether CPU1 and CPU2 have sent data to each other. Furthermore, CPU1 and CPU2 read the data to achieve data synchronization. This facilitates simultaneous task processing by both CPUs, improving work efficiency.
[0077] In one embodiment, during program initialization, CPU1 and CPU2 set the SCI data receiving mode to DMA and set the number of bytes to be sent to N; they also have the same serial port baud rate and the same number of bytes in the DMA receive buffer, C. The number of bytes in the DMA receive buffer, C, is greater than the number of bytes to be sent, N.
[0078] The second preset time is twice the time required to send N bytes at a baud rate, which is twice the time required to send data in step S21.
[0079] In one embodiment, such as Figure 3 The transmit pins of CPU1 include: CPU1.COUPLE1.GPIOA and CPU1.COUPLE2.GPIOA; the receive pins of CPU1 include: CPU1.COUPLE1.GPIOB and CPU1.COUPLE2.GPIOB. The transmit pins of CPU2 include: CPU2.COUPLE1.GPIOA and CPU2.COUPLE2.GPIOA; the receive pins of CPU2 include: CPU2.COUPLE1.GPIOB and CPU2.COUPLE2.GPIOB.
[0080] The state of CPU2.COUPLE1.GPIOB is adjusted based on the state of CPU1.COUPLE1.GPIOA. The state of CPU1.COUPLE1.GPIOB is adjusted based on the state of CPU2.COUPLE1.GPIOA. The state of CPU2.COUPLE2.GPIOB is adjusted based on the state of CPU1.COUPLE2.GPIOA. The state of CPU1.COUPLE2.GPIOB is adjusted based on the state of CPU2.COUPLE2.GPIOA.
[0081] To achieve dual-CPU data synchronization, dual-CPU signal synchronization and data transmission are required.
[0082] When the default level is low, such as Figure 4 The signal synchronization process includes: (1) CPU1 sets the CPU1.COUPLE1.GPIOA pin to a high level and waits for the CPU1.COUPLE1.GPIOB pin to be pulled high. CPU2 sets the CPU2.COUPLE1.GPIOA pin to a high level and waits for the CPU2.COUPLE1.GPIOB pin to be pulled high. If both CPU1.COUPLE1.GPIOB and CPU2.COUPLE1.GPIOB are pulled high within the first preset time, the next operation is executed; otherwise, synchronization fails.
[0083] (2) CPU1 sets CPU1.COUPLE2.GPIOA to a high level and waits for CPU1.COUPLE2.GPIOB to be pulled high. CPU2 sets CPU2.COUPLE2.GPIOA to a high level and waits for CPU2.COUPLE2.GPIOB to be pulled high. If both CPU1.COUPLE2.GPIOB and CPU2.COUPLE2.GPIOB are pulled high within the first preset time, the next operation is executed; otherwise, synchronization fails.
[0084] (3) CPU1 adjusts the state of CPU1.COUPLE1.GPIOA to low and waits for the state of CPU1.COUPLE1.GPIOB to be pulled low. CPU2 adjusts the state of CPU2.COUPLE1.GPIOA to low and waits for the state of CPU2.COUPLE1.GPIOB to be pulled low. If both CPU1.COUPLE1.GPIOB and CPU2.COUPLE1.GPIOB are pulled low within the first preset time, the next operation is executed; otherwise, synchronization fails.
[0085] (4) CPU1 adjusts the state of CPU1.COUPLE2.GPIOA to low level and waits for the state of CPU1.COUPLE2.GPIOB pin to be pulled low. CPU2 adjusts the state of CPU2.COUPLE2.GPIOA to low level and waits for the state of CPU2.COUPLE2.GPIOB pin to be pulled low. If both CPU1.COUPLE2.GPIOB and CPU2.COUPLE2.GPIOB are pulled low within the first preset time, the signal synchronization is completed.
[0086] Once the signal synchronization is complete, CPU1 and CPU2 are in the same state and can transmit data.
[0087] like Figure 3CPU1 is configured with CPU1.SCITX for data transmission and CPU1.SCIRX for data reception. CPU2 is configured with CPU2.SCITX for data transmission and CPU2.SCIRX for data reception.
[0088] like Figure 5 The data transmission process includes: (1) During program initialization, CPU1 and CPU2 set the SCI data receiving mode to DMA and set the number of bytes to be sent to N; they also set the same serial port baud rate and the same number of bytes in the DMA receive buffer to C. Among them, the number of bytes in the DMA receive buffer C is greater than the number of bytes to be sent to N.
[0089] (2) CPU1 sends the N bytes of data to be synchronized through CPU1.SCITX. CPU2 sends the N bytes of data to be synchronized through CPU2.SCITX.
[0090] (3) CPU1 and CPU2 check whether their respective SCI transmit registers are cleared. If they are cleared within the second preset time, it means that the data transmission is successful; otherwise, the data synchronization fails.
[0091] (4) CPU1 and CPU2 check whether their respective SCI DMA receive completion flags are set. If the flags are set at the second preset time, it means that the data DMA receive is complete; otherwise, the data synchronization fails.
[0092] (5) CPU1 and CPU2 read N bytes of data from their respective DMA receive buffers.
[0093] After the data transmission is completed, data synchronization between the two CPUs is achieved.
[0094] In the rail transit industry, functions with a functional safety level of SIL4 require simultaneous processing by dual CPUs. This application enhances product safety and improves data processing accuracy through dual CPU data synchronization. Furthermore, this application considers the possibility of homogeneous and heterogeneous CPUs, using pin-based information exchange for greater stability, reliability, and wider applicability.
[0095] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0096] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A dual CPU data synchronization system, characterized by, include: CPU1 includes a first signal unit, a first transmission unit, and a first state setting unit. The first signal unit includes pin groups, and each pin group includes a CPU1 transmit pin and a CPU1 receive pin. The first state setting unit is used to set the state of the CPU1 transmit pin. CPU2 includes a second signal unit, a second transmission unit, and a second state setting unit. The second signal unit includes pin groups, each pin group including a CPU2 transmit pin and a CPU2 receive pin. The second state setting unit is used to set the state of the CPU2 transmit pin. In this configuration, one CPU1 transmit pin is matched with one CPU2 receive pin, and one CPU1 receive pin is matched with one CPU2 transmit pin. The information synchronization module is configured to adjust the pin state of the CPU1 transmit pin through the first state setting unit, adjust the pin state of the CPU2 transmit pin through the second state setting unit, and determine whether the state of the CPU1 receive pin is converted to the same state as the CPU2 transmit pin that matches the pin within a first preset time, and whether the state of the CPU2 receive pin is converted to the same state as the CPU1 transmit pin that matches the pin. The data transmission module is configured to send one piece of data to be synchronized to CPU2 through the first transmission unit, and send another piece of data to be synchronized to CPU1 through the second transmission unit, determine whether CPU1 and CPU2 have completed the transmission, and receive data sent by the other party. Both CPU1 and CPU2 include multiple pin groups, and each pin group of CPU1 corresponds to one pin group of CPU2. The information synchronization module is configured to adjust the pin states of the corresponding CPU1 pin group and CPU2 pin group, including: Adjust the state of the CPU1 transmit pin in a CPU1 pin group and the state of the CPU2 transmit pin in the CPU2 pin group corresponding to the CPU1 pin group; determine whether the state of the CPU2 receive pin in the CPU2 pin group is adjusted to be the same as the state of the CPU1 transmit pin in the CPU1 pin group within a first preset time period, and whether the state of the CPU1 receive pin in the CPU1 pin group is adjusted to be the same as the state of the CPU2 transmit pin in the CPU2 pin group. If so, adjust the state of the next corresponding CPU1 pin group and CPU2 pin group until the state of all corresponding CPU1 pin groups and CPU2 pin groups has been adjusted.
2. The dual CPU data synchronization system of claim 1, wherein, The information synchronization module is further configured as follows: The state of the CPU1 transmit pin is adjusted to the first pin state by the first state setting unit, and the state of the CPU2 transmit pin is adjusted to the first pin state by the second state setting unit. It is determined whether the state of the CPU1 receive pin is converted to the same state as the CPU2 transmit pin that matches the pin within a first preset time, and whether the state of the CPU2 receive pin is converted to the same state as the CPU1 transmit pin that matches the pin. If so, the state of the CPU1 transmit pin is adjusted to the second pin state by the first state setting unit, and the state of the CPU2 transmit pin is adjusted to the second pin state by the second state setting unit. It is determined whether the state of the CPU1 receive pin is converted to the same state as the CPU2 transmit pin that matches the pin within the first preset time, and whether the state of the CPU2 receive pin is converted to the same state as the CPU1 transmit pin that matches the pin.
3. The dual CPU data synchronization system of claim 1, wherein, The data transmission module further includes: The first judgment unit is configured to determine whether the transmit register of CPU1 and the transmit register of CPU2 are both cleared within a second preset time. The second judgment unit is configured to determine whether the DMA receive completion flag of CPU1 and the DMA receive completion flag of CPU2 are both set within a second preset time.
4. The dual CPU data synchronization system of claim 1, wherein, Both the first transmission unit and the second transmission unit include: One data transmit pin, and one data receive pin; The data transmission pin of the first transmission unit corresponds to the data reception pin of the second transmission unit; The data receiving pin of the first transmission unit corresponds to the data sending pin of the second transmission unit.
5. The dual CPU data synchronization system of claim 1, wherein, The information synchronization module is further configured as follows: Adjust the state of the CPU1 transmit pin in a CPU1 pin group to the first pin state, and adjust the state of the CPU2 transmit pin in the CPU2 pin group corresponding to the CPU1 pin group to the first pin state; determine whether the state of the CPU2 receive pin in the CPU2 pin group is adjusted to be the same as the state of the CPU1 transmit pin in the CPU1 pin group within a first preset time period, and whether the state of the CPU1 receive pin in the CPU1 pin group is adjusted to be the same as the state of the CPU2 transmit pin in the CPU2 pin group. If so, adjust the state of the next corresponding CPU1 pin group and CPU2 pin group until the states of all corresponding CPU1 pin groups and CPU2 pin groups have been adjusted in the first pin state. Further adjust the state of the CPU1 transmit pin in a CPU1 pin group to the second pin state, and adjust the state of the CPU2 transmit pin in the CPU2 pin group corresponding to the CPU1 pin group to the second pin state; determine whether the state of the CPU2 receive pin in the CPU2 pin group is adjusted to be the same as the state of the CPU1 transmit pin in the CPU1 pin group within a first preset time period, and whether the state of the CPU1 receive pin in the CPU1 pin group is adjusted to be the same as the state of the CPU2 transmit pin in the CPU2 pin group. If so, adjust the state of the next corresponding CPU1 pin group and CPU2 pin group until the states of all corresponding CPU1 pin groups and CPU2 pin groups have been adjusted in the second pin state.
6. The dual CPU data synchronization system of claim 2 or 5, wherein, The first pin is in a high state, and the second pin is in a low state.
7. A dual CPU data synchronization method, characterized by, include: In the information synchronization step, CPU1 adjusts the pin state of the CPU1 transmit pin, CPU2 adjusts the pin state of the CPU2 transmit pin, and determines whether the state of the CPU1 receive pin is converted to the same state as the CPU2 transmit pin that matches the receive pin within a first preset time, and whether the state of the CPU2 receive pin is converted to the same state as the CPU1 transmit pin that matches the receive pin. In this configuration, one CPU1 transmit pin is matched with one CPU2 receive pin, and one CPU1 receive pin is matched with one CPU2 transmit pin. The data transmission steps are as follows: CPU1 sends one piece of data to be synchronized to CPU2, and CPU2 sends another piece of data to be synchronized to CPU1. It is also necessary to determine whether CPU1 and CPU2 have completed the transmission and to receive the data sent by the other party. Both CPU1 and CPU2 include multiple pin groups, and each pin group of CPU1 corresponds to one pin group of CPU2. The information synchronization step further includes: adjusting the pin states of the corresponding CPU1 pin group and CPU2 pin group, including: Adjust the state of the CPU1 transmit pin in a CPU1 pin group and the state of the CPU2 transmit pin in the CPU2 pin group corresponding to the CPU1 pin group; determine whether the state of the CPU2 receive pin in the CPU2 pin group is adjusted to be the same as the state of the CPU1 transmit pin in the CPU1 pin group within a first preset time period, and whether the state of the CPU1 receive pin in the CPU1 pin group is adjusted to be the same as the state of the CPU2 transmit pin in the CPU2 pin group. If so, adjust the state of the next corresponding CPU1 pin group and CPU2 pin group until the state of all corresponding CPU1 pin groups and CPU2 pin groups has been adjusted.
8. The dual CPU data synchronization method of claim 7, wherein, The information synchronization step further includes: S11, adjust the state of the first CPU1 transmit pin to the first pin state, and the state of the first CPU2 transmit pin to the first pin state; determine whether the state of the first CPU2 receive pin that matches the first CPU1 transmit pin has been adjusted to the same state as the first CPU1 transmit pin within a first preset time, and whether the state of the first CPU1 receive pin has been adjusted to the same state as the first CPU2 transmit pin. If so, adjust the state of the next CPU1 transmit pin and the next CPU2 transmit pin to the first pin state, and determine again whether the states of the corresponding CPU2 receive pin and CPU1 receive pin have been adjusted to the first pin state; repeat the process until the states of all pins in the matching CPU1 pin group and the CPU2 pin group are in the first pin state. S12, adjust the state of the first CPU1 transmit pin to the second pin state, and the state of the first CPU2 transmit pin to the second pin state; determine whether the state of the first CPU2 receive pin that matches the first CPU1 transmit pin has been adjusted to the same state as the first CPU1 transmit pin within a first preset time, and whether the state of the first CPU1 receive pin has been adjusted to the same state as the first CPU2 transmit pin. If so, adjust the state of the next CPU1 transmit pin and the next CPU2 transmit pin to the second pin state, and determine whether the states of the corresponding CPU2 receive pin and CPU1 receive pin have been adjusted to the first pin state; repeat the process until the states of all pins in the matching CPU1 pin group and the CPU2 pin group are in the second pin state.
9. The dual CPU data synchronization method of claim 7, wherein, The data transmission steps include: S21, CPU1 sends the first data to be synchronized, and CPU2 sends the second data to be synchronized; S22, within the second preset time, CPU1 and CPU2 determine whether their respective SCI transmit registers are cleared; S23, within the second preset time, CPU1 and CPU2 determine whether their respective SCIDMA reception completion flags are set; S24, CPU1 reads the second data to be synchronized, and CPU2 reads the first data to be synchronized.
Citation Information
Patent Citations
FPGA configuration method, FPGA configuration system and processor
CN103927279A
Communication system and method on basis of double-speed synchronous dynamic random access memory interface
CN104111902A
