Communication processing system and method
By designing a communication processing system, including data exchange module, communication handshake module, data answer module, high-speed data cache module and mode switching module, the problem of slow data transmission rate and insufficient accuracy in the existing communication technology is solved, and efficient Flexible data communication and save CPU resources.
Patent Information
- Application Number
- CN202411100627.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-11-15
AI Technical Summary
The existing communication technology bus has shortcomings in data transmission rate, accuracy and line complexity, and cannot be compatible with different application scenarios, and the communication rate is inconsistent, which takes up a lot of CPU time.
A communication processing system is designed, including a data exchange module, a communication handshake module, a data answering module, a high-speed data cache module, a data detection module and a mode switching module. High-speed data cache module and a data detection module are used to realize high-speed data processing and error checking. , the mode switching module is controlled by the CPU to select the synchronous or asynchronous communication method.
The data transmission rate is improved, the communication rate is slow and data transmission abnormalities is solved, flexible data communication is realized, data size limitations and line complexity are avoided, and CPU resources are saved.
Smart Images

Figure CN118972196A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a communication processing system and method. Background Art
[0002] The existing communication technologies mainly include SPI, IIC, UART and other buses, which usually adopt direct communication methods, such as SPI, IIC, UART and other peripheral communication buses. Figure 1 As shown in the figure, the SPI data transmission rate is high but there is no verification, so the data accuracy cannot be guaranteed, and the large number of communication lines makes the MCU lines complicated; Figure 2 As shown, IIC half-duplex communication lines are few but the communication rate is not high. The broadcast addressing time will take up a certain amount of data transmission time, and there are strict restrictions on the size of data transmission. Figure 3 As shown, UART communication does not require a clock signal and has fewer communication lines and a data verification function, but UART has certain restrictions on the size of the data frame and does not support multi-machine communication, and the communication rate is slow. These bus communications require the preparation of many different interfaces for use, and the application scenarios are not very different. The communication rates are fast and slow, and it is easy to take up a lot of CPU time. Each has its own advantages and disadvantages and is not compatible. Summary of the invention
[0003] In view of the deficiencies in the prior art, the present invention adopts a technical solution to solve the technical problems thereof: a communication processing system, comprising a data exchange module, a communication handshake module, a data response module, a high-speed data cache module, a data detection module and a mode switching module, wherein the input end of the communication handshake module is respectively connected to the output end of the mode switching module and the communicating parties, the output ends of the communication handshake module and the data response module are respectively connected to the input end of the data exchange module, the output end of the data exchange module is connected to the communicating receiving party through the high-speed data cache module, one end of the output of the high-speed data cache module is connected to the data response module through the data detection module, and the other end is respectively connected to the communicating parties, and the input end of the mode switching module is externally connected to a CPU.
[0004] Preferably, the high-speed data cache module includes two buffers for caching data sent by both communicating parties.
[0005] Preferably, the data exchange module comprises two shift registers, which are respectively installed in the communicating parties, and the data exchange module is used to shift the data in the buffer of the high-speed data cache module to the shift register of the other party.
[0006] Preferably, the communication handshake module includes multiple two-bit buffers, the upper bit of each buffer is set as a handshake bit for establishing communication between the two machines, and the lower bit is set as a communication direction bit for specifying the sender and the receiver. The communication handshake module is used to establish communication between the two communicating parties to meet data communication requirements.
[0007] Preferably, the data response module is configured to respond in four bytes, and after the data transmission in one buffer is completed, the communicating two or more parties give each other a response bit when they receive the corresponding communication data.
[0008] Preferably, the data detection module is used to detect whether there is an abnormality in the data transmitted by both parties, by real-time detection of the data in the buffers of both parties, calculation using a set logic, and judging the accuracy of data transmission based on the calculation results.
[0009] Preferably, the mode switching module is directly controlled by a CPU, and the CPU issues corresponding instructions to control the selection of synchronous communication or asynchronous communication.
[0010] Preferably, it further comprises a data clearing module, wherein the data clearing module is used to clear the originally set mechanism and data content in the buffer after completing one transmission.
[0011] The present invention also discloses a communication processing method, comprising the following steps:
[0012] S1. When two parties need to communicate data, the CPU first sends a signal of communication between the two parties to the system, and agrees on the communication mode, SPI, UART or IIC, and synchronous communication or asynchronous communication, and connects to the mode switching module to issue instructions to it. After the mode switching module receives the relevant instructions from the CPU, it starts the corresponding communication bus and chooses whether to enable the clock according to the selection of synchronous or asynchronous.
[0013] S2. Start the communication handshake module, and the two communicating parties establish communication. The high bit of each buffer in the communication handshake module is set as the handshake bit. The data sent by both parties to the communication handshake module are set to 1 or 0 to establish communication between the two machines. The low bit is set as the communication direction bit. The party whose data sent to the communication handshake module is 1 is the sender, and the party whose data sent to the communication handshake module is 0 is the receiver. If the high bits of the two buffers receive the same data, the two communicating parties can establish data communication.
[0014] S3. After the two communicating parties establish communication, they start the data exchange module. The sender shifts the data in its shift register to the receiver's shift register one by one through the communication line. If the receiver has data, in the synchronous mode, when the clock rises, the sending shift register shifts the data to the receiving shift register, and when the clock falls, the data in the receiving shift register shifts the data to the sender's shift register, and then the data is stored in the buffers of both parties. When the data exchange between the two parties is completed, it means that the data communication is completed.
[0015] S4. After completing a data communication, the system sends an interrupt to the CPU to end the data transmission and sends instructions back to the data clearing module to clear the internal signal of the data transmission to facilitate the next data communication.
[0016] As a preference, the shift register size is set to 8 bits per byte, and when one byte is transmitted, the data exchange between the two communicating parties is completed.
[0017] The beneficial effects of the present invention are as follows:
[0018] The present invention establishes a high-speed data processing station, connects the high-speed data processing station to the AHB bus inside the MCU, performs data transmission and exchange therein, establishes data communication, quickly caches data transmitted by both communicating parties, and performs high-speed processing of exchanged data, thereby effectively improving the data transmission rate and solving the problem of slow communication rate of some buses. At the same time, a data transmission error checking mechanism is added to perform real-time checking to avoid the problem of abnormal data transmission. Before data communication, both communicating parties can establish communication by handshaking through two bits of data, without limiting the transmission size of data communication, and without establishing communication through a multi-bit broadcast address, thereby solving the problems of data transmission byte size limitation, excessive occupation of master and slave data transmission signal lines, and master and slave limitation. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 This is a schematic diagram of the SPI master-slave direct communication method;
[0020] Figure 2 This is a schematic diagram of the IIC direct communication method;
[0021] Figure 3 This is a schematic diagram of the UART direct communication method;
[0022] Figure 4 is a system block diagram of the present invention;
[0023] Figure 5 It is a schematic diagram of the interface of the mode switching module in the present invention. DETAILED DESCRIPTION
[0024] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:
[0025] like Figure 4 As shown, a communication processing system includes a data exchange module, a communication handshake module, a data response module, a high-speed data cache module, a data detection module, a mode switching module and a data clearing module, wherein the input end of the communication handshake module is respectively connected to the output end of the mode switching module and the communicating parties, the output ends of the communication handshake module and the data response module are respectively connected to the input end of the data exchange module, the output end of the data exchange module is connected to the communication receiving party through the high-speed data cache module, one end of the output of the high-speed data cache module is connected to the data response module through the data detection module, and the other end is respectively connected to the communicating parties, and the input end of the mode switching module is externally connected to the CPU.
[0026] The high-speed data cache module is used to cache the data sent by the communicating parties, including two buffers, which can be set to a maximum of 32-bit buffer size. 32-bit data can be cached at a time, with one buffer for each sender and receiver.
[0027] The data exchange module includes two shift registers, which are installed in the communicating parties respectively. The data exchange module is used to shift the data in the buffer of the high-speed data cache module to the shift register of the other party; the data shift module is that the sender and the receiver each have one shift register, and the sender shifts the data of its shift register to the shift register of the receiver one bit at a time through the communication line. If the receiver has data, in the synchronous mode, when the clock rises, the sending shift register shifts the data to the receiving shift register, and when the clock falls, the data of the receiving shift register shifts the data to the shift register of the sender. The size of the shift register can be set to 8 bits per byte. When one byte is transmitted, the data exchange between the communicating parties is completed, and then it is stored in the buffers of both parties.
[0028] The communication handshake module includes multiple two-bit buffers, the upper bit of each buffer is set as the handshake bit, which is used to establish communication between the two machines, and the lower bit is set as the communication direction bit, which is used to specify the sender and the receiver. The communication handshake module is used to establish communication between the two parties to meet data communication requirements.
[0029] The data response module is set to respond once every four bytes. During the data exchange process, when the data transmission of a buffer is completed, the communicating parties or multiple parties need to give each other a response bit when they receive the corresponding communication data, so as to monitor whether the data of both parties is being transmitted steadily.
[0030] The data detection module is used to detect whether the data transmitted by both parties is abnormal. It detects the data of the buffers of both parties in real time, uses the set logic to calculate, and collects the data being transmitted on the bus and the data of the initial handshake byte to calculate a corresponding data (one byte). If the length of the bit is inconsistent, zero is padded from the high bit until the bit length is consistent before calculation. The calculation method is to obtain a value through the logic and operation of the gate circuit of the two data, and then send the data to the data response unit, and send each other every four bytes together with the data response bit to achieve the desired calculation result, and judge the accuracy of data transmission by the calculation result.
[0031] like Figure 5 As shown in the figure, the mode switching module is directly controlled by the CPU, and the CPU issues corresponding instructions to control the selection of synchronous communication or asynchronous communication. The mode switching module actually selects the mode by some gate circuits, and its internal data temporary buffer and shift module are common, as shown in the following table:
[0032] model Tdata Rdata CLK CS UART - Asynchronous 1 1 0 0 SPI-Synchronous 1 1 1 1 IIC-Synchronization 1 0 1 0 SPI - Asynchronous 1 1 0 1 IIC-Asynchronous 1 0 0 0
[0033] Each data line represents one bit, and the four lines together represent four bits. The instructions sent by the CPU determine which signal lines are enabled. If "1" is set, the current signal line will be enabled.
[0034] The main function of the data clearing module is to clear the original mechanism and data content in the buffer after completing a transmission, in preparation for the next data transmission.
[0035] A communication processing method comprises the following steps:
[0036] S1. When two parties need to communicate data, the CPU first sends a signal of communication between the two parties to the system, and agrees on the communication mode, SPI, UART or IIC, and synchronous communication or asynchronous communication, and connects to the mode switching module to issue instructions to it. After the mode switching module receives the relevant instructions from the CPU, it starts the corresponding communication bus and chooses whether to enable the clock according to the selection of synchronous or asynchronous.
[0037] S2. Start the communication handshake module, and the two communicating parties establish communication. The high bit of each buffer in the communication handshake module is set as the handshake bit. The data sent by both parties to the communication handshake module are set to 1 or 0 to establish communication between the two machines. The low bit is set as the communication direction bit. The party whose data sent to the communication handshake module is 1 is the sender, and the party whose data sent to the communication handshake module is 0 is the receiver. If the high bits of the two buffers receive the same data, the two communicating parties can establish data communication.
[0038] S3. After the two communicating parties establish communication, they start the data exchange module. The sender shifts the data in its shift register to the receiver's shift register one by one through the communication line. If the receiver has data, in the synchronous mode, when the clock rises, the sending shift register shifts data to the receiving shift register, and when the clock falls, the data in the receiving shift register shifts data to the sender's shift register. The shift register size is set to 8 bits per byte. When one byte is transmitted, the data exchange between the two communicating parties is completed, and then stored in the buffers of both parties. When the data exchange between the two parties is completed, it means that the data communication is completed.
[0039] S4. After completing a data communication, the system sends an interrupt to the CPU to end the data transmission and sends instructions back to the data clearing module to clear the internal signal of the data transmission to facilitate the next data communication.
[0040] This patented technology can support multiple communication methods, such as UART, SPI and IIC. The communication method can be selected arbitrarily according to actual application requirements. The shared register is in a section of address space mapped by the CPU, saving CPU space resources. It also integrates multiple communication methods and shares the communication bus, such as clock, data line or address line, which greatly saves the complexity and space occupation of the internal layout and wiring of the MCU. At the same time, the entire system is connected to the AHB bus inside the MCU, which greatly improves the efficiency of data processing, and there is no need for the CPU to process data all the time. The CPU will be started to instruct related operations only when the system issues a certain request.
[0041] In addition, some communication buses have very strict agreements on master and slave machines. In this patented technology, any chip or module can be used as a sender without such restrictions, which improves the flexibility of data communication. At the same time, the increase in data buffer size has no certain restrictions on the size of data transmission. Within the maximum capacity of the buffer and shift register in the shift module, the size of the data can be transmitted arbitrarily according to actual needs.
[0042] Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field and related fields without creative work should fall within the scope of protection of the present invention. The structures, devices and operating methods not specifically described and explained in the present invention are implemented according to the conventional means in the field unless otherwise specified and limited.
Claims
1. A communication processing system, Features: It includes a data exchange module, a communication handshake module, a data response module, a high-speed data cache module, a data detection module and a mode switching module. The input end of the communication handshake module is respectively connected to the output end of the mode switching module and the communicating parties. The output ends of the communication handshake module and the data response module are respectively connected to the input end of the data exchange module. The output end of the data exchange module is connected to the communication receiving party through the high-speed data cache module. One end of the output of the high-speed data cache module is connected to the data response module through the data detection module, and the other end is respectively connected to the communicating parties. The input end of the mode switching module is externally connected to the CPU.
2. A communication processing system according to claim 1, Features: The high-speed data cache module includes two buffers for caching data sent by both communicating parties.
3. A communication processing system according to claim 2, Features: The data exchange module includes two shift registers, which are respectively installed in the communicating parties. The data exchange module is used to shift the data in the buffer of the high-speed data cache module to the shift register of the other party.
4. A communication processing system according to claim 1, Features: The communication handshake module includes multiple two-bit buffers, the upper bit of each buffer is set as a handshake bit for establishing communication between two machines, and the lower bit is set as a communication direction bit for specifying the sender and the receiver. The communication handshake module is used to establish communication between the two communicating parties to meet data communication requirements.
5. A communication processing system according to claim 2, Features: The data response module is set to respond with four bytes. When the data transmission in a buffer is completed, the two or more communicating parties give each other a response bit when they receive the corresponding communication data.
6. A communication processing system according to claim 2, Features: The data detection module is used to detect whether there is any abnormality in the data transmitted by both parties. It detects the data in the buffers of both parties in real time, performs calculations using the set logic, and determines the accuracy of data transmission based on the calculation results.
7. A communication processing system according to claim 1, Features: The mode switching module is directly controlled by the CPU, and the CPU issues corresponding instructions to control the selection of synchronous communication or asynchronous communication.
8. A communication processing system according to claim 4, Features: It also includes a data clearing module, which is used to clear the originally set mechanism and data content in the buffer after completing one transmission.
9. A communication processing method, It is characterized in that The following steps are involved: S1. When two parties need to communicate data, the CPU first sends a signal of communication between the two parties to the system, and agrees on the communication mode, SPI, UART or IIC, and synchronous communication or asynchronous communication, and connects to the mode switching module to issue instructions to it. After the mode switching module receives the relevant instructions from the CPU, it starts the corresponding communication bus and chooses whether to enable the clock according to the selection of synchronous or asynchronous. S2. Start the communication handshake module, and the two communicating parties establish communication. The high bit of each buffer in the communication handshake module is set as the handshake bit. The data sent by both parties to the communication handshake module are set to 1 or 0 to establish communication between the two machines. The low bit is set as the communication direction bit. The party whose data sent to the communication handshake module is 1 is the sender, and the party whose data sent to the communication handshake module is 0 is the receiver. If the high bits of the two buffers receive the same data, the two communicating parties can establish data communication. S3. After the two communicating parties establish communication, they start the data exchange module. The sender shifts the data in its shift register to the receiver's shift register one by one through the communication line. If the receiver has data, in the synchronous mode, when the clock rises, the sending shift register shifts the data to the receiving shift register, and when the clock falls, the data in the receiving shift register shifts the data to the sender's shift register, and then the data is stored in the buffers of both parties. When the data exchange between the two parties is completed, it means that the data communication is completed. S4. After completing a data communication, the system sends an interrupt to the CPU to end the data transmission and sends instructions back to the data clearing module to clear the internal signal of the data transmission to facilitate the next data communication.
10. A communication processing method according to claim 9, Features: The shift register size is set to 8 bits per byte, and when one byte is transmitted, the data exchange between the communicating parties is completed.
