A bus communication method
By verifying the address and data fields in bus communication, the problems of complex circuit design and high cost in the prior art are solved, realizing the flexibility of multi-master communication and low-cost bus communication.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-10
- Publication Date
- 2026-03-17
AI Technical Summary
Existing bus communication technologies require multiple communication lines, resulting in complex and costly circuit designs, and do not support multi-master communication modes.
By verifying the address and data fields when the bus is idle, and ensuring there are no conflicts, the right to use the bus is granted, thus enabling multi-master communication.
It enables multi-master communication with low cost and simple hardware overhead, simplifies circuit design and improves flexibility.
Smart Images

Figure CN121277862B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, specifically to a bus communication method. Background Technology
[0002] Bus technology is an important technology for communication between chips or devices. Compared with point-to-point communication technology, bus communication can effectively reduce the complexity of wiring and improve the utilization rate of wiring.
[0003] Existing buses can be divided into serial buses and parallel buses according to the data transmission method. Common serial buses include SPI, I2C, USB, IEEE1394, RS232, CAN, etc., while there are relatively fewer types of parallel buses, such as IEEE1284, ISA, PCI, etc.
[0004] However, whether it is a serial bus or a parallel bus, bus communication requires the support of multiple communication lines, which will bring difficulties to the circuit design where data transceiver interface resources are very precious. Summary of the Invention
[0005] This application provides a bus communication method that can save data transceiver interface resources at low cost, while supporting multi-host communication mode and improving usage flexibility.
[0006] In a first aspect, embodiments of this application provide a bus communication method, the method comprising the following steps:
[0007] If the bus is idle during the current time period, the address is verified based on the first address field sent during the current time period and the second address field received during the current time period; the second address field and the first address field are obtained simultaneously by the same communication device;
[0008] If no address conflict is determined, data verification is performed based on the first data field sent and the second data field received during the current time period; the second data field and the first data field are obtained simultaneously.
[0009] If it is determined that there is no data conflict, the right to use the bus in the current time period is obtained in order to send the first data field through the bus.
[0010] In some embodiments, the step of prior to the bus being in an idle state during the current time period includes the following steps:
[0011] Obtain the bus level value during the current time period;
[0012] If the voltage level is the first level in the current time period, it is determined that the bus is in the idle state in the current time period;
[0013] If the voltage level is the second level during the current time period, it is determined that the bus is in a busy state during the current time period, and the second level is less than the first level.
[0014] In some embodiments, the address verification based on the first address field sent in the current time period and the second address field received in the current time period includes the following steps:
[0015] Compare whether the first address field and the second address field are the same in the current time period;
[0016] If the first address field and the second address field are the same in the current time period, the verification result of the address is no address conflict;
[0017] If the first address field and the second address field are different in the current time period, the address verification result is an address conflict, and a new first address field is generated for address verification in the next time period.
[0018] In some embodiments, after comparing whether the first address field and the second address field are the same in the current time period, the method further includes the step of:
[0019] Compare whether there is a conflict between the first address field generated in the current time period and the first address field generated by any other communication device in the current time period;
[0020] If the first address field generated in the current time period is the same as the first address field generated by any other communication device in the current time period, it is determined that there is no address conflict, and the next stage of data segment transmission is initiated.
[0021] If the first address field generated in the current time period is different from the first address field generated by any other communication device in the current time period, an address conflict is determined, and a new first address field is generated for address arbitration in the next time period.
[0022] In some embodiments, the data verification based on the first data field sent and the second data field received in the current time period includes the following steps:
[0023] Compare whether the first data field and the second data field are the same in the current time period;
[0024] If the first data field and the second data field are the same in the current time period, the data verification result is no data conflict.
[0025] If the first data field and the second data field are different in the current time period, the data verification result is that there is a data conflict.
[0026] In some embodiments, the first address field sent to the bus by at least two of the communication devices has the same byte size, and the first data field sent to the bus by at least two of the communication devices has the same or different byte sizes.
[0027] In some embodiments, the first address field sent to the bus by at least two of the communication devices is 2 bytes. n n is a positive integer ≥ 3.
[0028] In some embodiments, each of the communication devices randomly generates the first address field upon power-up.
[0029] Secondly, this application also provides a bus communication system, including a bus and at least two communication devices, wherein the at least two communication devices are all connected to the bus; wherein,
[0030] If the bus is idle during the current time period, the current communication device performs address verification based on the first address field sent during the current time period and the second address field received during the current time period; the current communication device is any one of the at least two communication devices, and the second address field and the first address field are obtained by the current communication device simultaneously;
[0031] If no address conflict is determined, the current communication device performs data verification based on the first data field sent and the second data field received in the current time period; the second data field and the first data field are obtained by the current communication device simultaneously.
[0032] If it is determined that there is no data conflict, the current communication device acquires the right to use the bus in the current time period in order to send the first data field through the bus.
[0033] Thirdly, this application also provides a computer-readable storage medium storing a program that can be executed by a processor to implement the method described in the first aspect.
[0034] This application provides a bus communication method, system, and storage medium. The method includes: if the bus is idle during the current time period, performing address verification based on a first address field sent during the current time period and a second address field received during the current time period; the second address field and the first address field are obtained simultaneously by the same communication device; if no address conflict is determined, performing data verification based on a first data field sent during the current time period and a second data field received during the current time period; the second data field and the first data field are obtained simultaneously by the same device; if no data conflict is determined, acquiring the right to use the bus during the current time period to send the first data field through the bus. This application simplifies the circuitry, reduces hardware overhead, lowers costs, and supports multi-master communication modes. Attached Figure Description
[0035] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0036] Figure 1 This is a schematic flowchart of a bus communication method provided in an embodiment of this application;
[0037] Figure 2 This is a schematic diagram of a bus communication system provided in an embodiment of this application;
[0038] Figure 3 This is a timing diagram of the bus communication method provided in the embodiments of this application. Detailed Implementation
[0039] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0040] In the description of this application, it should be understood that the terms "one end," "the other end," etc., indicating the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the stated features. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.
[0041] In the description of this application, it should be noted that, unless otherwise expressly specified and limited, the terms "connected" and "linked" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection, a link, or a connection that allows for communication; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances.
[0042] The following disclosure provides many different implementations or examples for carrying out different structures of this application. To simplify the disclosure, specific examples of components and arrangements are described below. Of course, these are merely examples and are not intended to limit the scope of this application. Furthermore, reference numerals and / or letters may be repeated in different examples; such repetition is for simplification and clarity and does not in itself indicate a relationship between the various implementations and / or arrangements discussed. In the above embodiments, the descriptions of each embodiment have their own emphasis; parts not described in detail in a certain embodiment can be referred to in the relevant descriptions of other embodiments.
[0043] To reduce the complexity of circuit design, single-bus communication technology emerged. Single-bus communication uses a single signal line for both data transmission and clock signal transmission, allowing a master device to communicate with multiple slave devices via a single data line. This communication method is bidirectional; data can be sent from the master device to the slave device and vice versa. This design results in simple wiring, low hardware overhead, low cost, and facilitates bus expansion and maintenance.
[0044] While a single bus can connect one master and multiple slave devices, saving data transmission and reception interface resources and reducing costs, it does not support multi-master communication modes. Therefore, this application aims to provide a solution that addresses the aforementioned technical problems, the details of which will be described in subsequent embodiments.
[0045] Reference Figure 2 As shown, this application provides a bus communication system. Figure 2 This is a schematic diagram of the bus communication system in an embodiment of this application, as shown below. Figure 2 As shown, the bus communication system includes: a bus 20 and at least two communication devices 10, wherein the at least two communication devices 10 are all connected to the bus 20; wherein,
[0046] If the bus 20 is idle during the current time period, the current communication device 10 performs address verification based on the first address field sent during the current time period and the second address field received during the current time period; the current communication device 10 is any one of the at least two communication devices 10, and the second address field and the first address field are obtained by the current communication device 10 simultaneously;
[0047] If no address conflict is determined, the current communication device 10 performs data verification based on the first data field sent and the second data field received in the current time period; the second data field and the first data field are obtained by the current communication device 10 simultaneously;
[0048] If it is determined that there is no data conflict, the current communication device 10 obtains the right to use the bus 20 in the current time period in order to send the first data field through the bus 20.
[0049] Specifically, such as Figure 2 As shown, at least two communication devices 10 each include a data transceiver interface 30 (an I / O interface that can perform both data transmission (TX) and data reception (RX) functions), and at least two communication devices 10 include as follows: Figure 2The example uses four communication devices: a first communication device 11, a second communication device 12, a third communication device 13, and a fourth communication device 14. Each communication device 10 has a data transceiver interface 30 connected to the bus 20. Communication devices 10 can be various types of computer devices, including but not limited to personal computers (PCs), industrial control computers, tablet computers, touchscreens, and mobile phones. Each communication device 10 can act as either a master or a slave device. The identity type of a communication device 10 at any given time depends on whether it has acquired the right to use the bus 20. If any one of at least two communication devices 10 acquires the right to use the bus 20 at any given time, then the identity type of this current communication device 10 is master. Conversely, if this current communication device 10 does not acquire the right to use the bus 20 at any given time, then its identity type is slave.
[0050] This application, based on this, enables multi-master communication via an MCU, offering greater flexibility. While the basic hardware structure remains the same, this application directly implements single-bus communication for over 20 hosts on the existing MCU's serial port peripheral. This results in simpler wiring, lower hardware overhead, lower cost, and support for multi-master communication modes.
[0051] In some embodiments, the bus 20 communication system further includes a pull-up resistor R1, one end of which is connected to the bus 20 and the other end of which is connected to the power supply VCC.
[0052] In this application, bus 20 is for asynchronous communication, and bus 20 is divided into address field and data field. In this application, all communication devices 10 are connected to bus 20 in open-drain mode. There is a pull-up resistor R1 on bus 20, which pulls it to a high level. Therefore, the default hidden level is high (i.e., the detected character is 1), which is also the idle level. The dominant level is low (i.e., the detected character is 0). If one device detects a low level, it means that bus 20 is low, which is a wired-AND relationship.
[0053] Reference Figure 1 As shown, this application provides a bus 20 communication method. Figure 1 This is a flowchart illustrating the communication method of bus 20 in an embodiment of this application. Figure 1 As shown, the method includes:
[0054] Step S100: If the bus 20 is in an idle state during the current time period, the address is verified based on the first address field sent during the current time period and the second address field received during the current time period; the second address field and the first address field are obtained simultaneously by the same communication device 10.
[0055] Step S200: If it is determined that there is no address conflict, the data is verified based on the first data field sent and the second data field received in the current time period; the second data field and the first data field are obtained simultaneously.
[0056] Step S300: If it is determined that there is no data conflict, obtain the right to use the bus 20 in the current time period, so as to send the first data field through the bus 20.
[0057] Specifically, such as Figure 2 As shown, at least two communication devices 10 each include a data transceiver interface 30 (an I / O interface that can perform both data transmission (TX) and data reception (RX) functions), and each communication device 10's data transceiver interface 30 is connected to the bus 20. The communication devices 10 can be various types of computer devices, including but not limited to personal computers (PCs), industrial control computers, tablet computers, touchscreens, and mobile phones. Each communication device 10 can act as either a master or a slave device. The identity type of a communication device 10 in the current time period depends on whether the communication device 10 has obtained the right to use the bus 20 in the current time period. If the bus 20 is idle in the current time period, address verification is performed based on the first address field sent and the second address field received in the current time period; the second address field and the first address field are obtained simultaneously by the same communication device 10. If no address conflict is determined, data verification is performed based on the first data field sent and the second data field received in the current time period; the second data field and the first data field are obtained simultaneously by the same communication device 10. If no data conflict is determined, the right to use the bus 20 in the current time period is obtained. If any one of the at least two communication devices 10 obtains the right to use the bus 20 in the current time period, then the identity type of the current communication device 10 is the master. Of course, if the current communication device 10 does not obtain the right to use the bus 20 in the current time period, then the identity type of the current communication device 10 is the slave device.
[0058] This application, based on this, enables multi-master communication via an MCU, offering greater flexibility. While the basic hardware structure remains the same, this application directly implements single-bus communication for over 20 hosts on the existing MCU's serial port peripheral. This results in simpler wiring, lower hardware overhead, lower cost, and support for multi-master communication modes.
[0059] In some embodiments, the step of if the bus 20 is in an idle state during the current time period includes the following steps:
[0060] Obtain the level value of the bus 20 during the current time period;
[0061] If the voltage level is the first level in the current time period, it is determined that the bus 20 is in the idle state in the current time period;
[0062] If the voltage level is the second level during the current time period, it is determined that the bus 20 is in a busy state during the current time period, and the second level is less than the first level.
[0063] The bus 20 in this application uses asynchronous communication and is divided into an address field and a data field. All communication devices 10 in this application are connected to the bus 20 in open-drain mode, forming a wired-AND connection. That is, the bus 20 has a pull-up resistor R1 pulled high (i.e., the first level, which can be represented by the character "1"), so the default implicit level is high, which is also the idle level, determining that the bus 20 is in the idle state during the current time period. The dominant level is low (i.e., the second level, which can be represented by the character "0"). If one device detects a low level, it means that the bus 20 is low, determining that the bus 20 is in a busy state during the current time period.
[0064] In some embodiments, the address verification based on the first address field sent in the current time period and the second address field received in the current time period includes the following steps:
[0065] Compare whether the first address field and the second address field are the same in the current time period;
[0066] If the first address field and the second address field are the same in the current time period, the verification result of the address is no address conflict;
[0067] If the first address field and the second address field are different in the current time period, the address verification result is an address conflict, and a new first address field is generated for address verification in the next time period.
[0068] Specifically, assuming the first communication device 11 sends a high level and device B sends a low level, then the high-level transmission by the first communication device 11 fails. The address field received by the first communication device 11 is different from the address field sent by the first communication device 11, indicating a conflict in the arbitration process. Therefore, the first communication device 11 withdraws from the current arbitration of bus 20, and the address is reallocated in the next round. If the address fields are the same, further evaluation of the data fields follows.
[0069] In some embodiments, after comparing whether the first address field and the second address field are the same in the current time period, the method further includes the step of:
[0070] Compare whether the first address field generated in the current time period conflicts with the first address field generated by any other communication device 10 in the current time period;
[0071] If the first address field generated in the current time period is the same as the first address field generated by any other communication device 10 in the current time period, it is determined that there is no address conflict, and the next stage of data segment transmission is initiated.
[0072] If the first address field generated in the current time period is different from the first address field generated by any other communication device 10 in the current time period, an address conflict is determined, and a new first address field is generated for address arbitration in the next time period.
[0073] Specifically, if bus 20 is randomly connected, each device will randomly generate a corresponding address field. Assuming two address fields collide, it's equivalent to multiple devices having identical address fields. If they are all identical, the system checks which device sends the data field. If the sent and received data fields are different, an error has occurred. For any communication device 10, for example, a first communication device 11 connected to bus 20, and a second communication device 12, both devices generate their own address fields after powering on. Assuming the address fields generated by first and second communication devices 11 and 12 are identical, they simultaneously send their address fields to bus 20. First communication device 11 will receive the address fields sent back by second communication device 12 via bus 20. After the address fields are processed, the next stage is the data field arbitration stage. The judgment method for data field arbitration is the same as for address field arbitration. Essentially, if the sent and received data fields of first communication device 11 are different, then that device will stop sending data.
[0074] In some embodiments, the data verification based on the first data field sent and the second data field received in the current time period includes the following steps:
[0075] Compare whether the first data field and the second data field are the same in the current time period;
[0076] If the first data field and the second data field are the same in the current time period, the data verification result is no data conflict.
[0077] If the first data field and the second data field are different in the current time period, the data verification result is that there is a data conflict.
[0078] In some embodiments, the first address field sent by at least two of the communication devices 10 to the bus 20 has the same byte size, and the first data field sent by at least two of the communication devices 10 to the bus 20 may have the same or different byte sizes.
[0079] Specifically, data field arbitration and address field arbitration are similar. If the data fields are different, arbitration is terminated, and communication device 10 withdraws from the current arbitration on bus 20, and the address is reassigned in the next round. If multiple hosts on bus 20 attempt to send data to control bus 20, there will be a bus 20 arbitration process. Through arbitration, only one host is allowed to control bus 20, and the message is not corrupted. First, the address field is arbitrated. If the address field arbitration passes, arbitration continues in the data field. If the current communication device 10 finds that the arbitration was lost in the data field, then the current communication device 10 has an address conflict. The current communication device 10 that lost the arbitration will randomly assign an address for the next communication, and repeat the above process of address field verification. When a current communication device 10 sends an address and data to bus 20, all other communication devices 10 can receive it. If it finds that the address sent by another communication device 10 is the same as the address of the current communication device 10, then the current communication device 10 also needs to randomly assign an address for the next communication.
[0080] In some embodiments, at least two of the communication devices 10 send 2 bytes of the first address field to the bus 20. n n is a positive integer ≥ 3.
[0081] Specifically, when the address field is one byte, the bus 20 can connect up to 256 devices by default. Based on this address field, it can also be extended by two bytes or more.
[0082] In some embodiments, each of the communication devices 10 randomly generates the first address field upon power-up.
[0083] Specifically, when the communication device 10 is powered on, it will randomly connect to the bus 20. Each device connected to the bus 20 will generate a random first address field after power-on. If any two address fields collide, that is, if the address fields of any two devices are the same, they will be identified as the same device. This will cause a data transmission conflict, resulting in the loss of data field of at least one device.
[0084] In some embodiments, this application also provides a computer-readable storage medium storing a program that can be executed by a processor to implement the methods described in the above embodiments.
[0085] The above provides a detailed description of a bus communication method, system, and storage medium provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the technical solutions and core ideas of this application. Those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A bus communication method characterized by, A method for a bus communication system, the bus communication system comprising a bus and at least two communication devices, the at least two communication devices are connected to the bus, the method comprising steps of: if the bus is idle in a current time period, a current communication device performs an address check according to a first address field sent in the current time period and a second address field received in the current time period, the current communication device is any one of the at least two communication devices, the second address field and the first address field are obtained by the current communication device simultaneously; if the first address field and the second address field in the current time period are the same, and the address check result is determined to be no address conflict, the current communication device performs a data check according to a first data field sent in the current time period and a second data field received in the current time period; the second data field and the first data field are obtained by the current communication device simultaneously; if the first data field and the second data field in the current time period are the same, and the data check result is determined to be no data conflict, the current communication device acquires the right to use the bus in the current time period to send the first data field through the bus.
2. The bus communication method according to claim 1, wherein, The method further comprises steps of: obtaining a level value of the bus in the current time period; if the level value is a first level in the current time period, it is determined that the bus is in the idle state in the current time period; if the level value is a second level in the current time period, it is determined that the bus is in a busy state in the current time period, the second level is less than the first level.
3. The bus communication method according to claim 1, wherein The method further comprises steps of: comparing whether the first address field and the second address field in the current time period are the same; if the first address field and the second address field in the current time period are the same, the address check result is no address conflict; if the first address field and the second address field in the current time period are different, the address check result is address conflict, a new first address field is generated for the next time period to perform the address check.
4. The bus communication method according to claim 3, wherein The method further comprises steps of: comparing whether the first address field generated in the current time period conflicts with the first address field generated by any other communication device in the current time period; if the first address field generated in the current time period is the same as the first address field generated by any other communication device in the current time period, it is determined that there is no address conflict, and the next stage of data segment transmission is entered; if the first address field generated in the current time period is different from the first address field generated by any other communication device in the current time period, it is determined that there is address conflict, and a new first address field is generated for the next time period to perform address arbitration.
5. The bus communication method according to claim 1, wherein The data verification according to the first data field sent in the current time period and the second data field received includes the steps of: comparing whether the first data field and the second data field in the current time period are the same; if the first data field and the second data field in the current time period are the same, the data verification result is no data conflict; if the first data field and the second data field in the current time period are different, the data verification result is data conflict.
6. The bus communication method according to claim 1, wherein The byte size of the first address field sent by the at least two communication devices to the bus is the same, and the byte size of the first data field sent by the at least two communication devices to the bus is the same or different.
7. The bus communication method according to claim 6, wherein, The first address field sent by at least two of the communication devices to the bus is 2 bytes n n is a positive integer greater than or equal to 3.
8. The bus communication method according to any one of claims 1 to 7, characterized by, Each communication device randomly generates the first address field when powered on.
9. A bus communication system, characterized by The bus and at least two communication devices are included, and the at least two communication devices are connected with the bus; wherein, if the bus is in an idle state in a current time period, a current communication device verifies an address according to a first address field sent in the current time period and a second address field received in the current time period; the current communication device is any one of the at least two communication devices, and the second address field and the first address field are obtained by the current communication device at the same time; if the first address field and the second address field in the current time period are the same, it is determined that the address verification result is no address conflict, and the current communication device verifies data according to a first data field sent in the current time period and a second data field received; the second data field and the first data field are obtained by the current communication device at the same time; if the first data field and the second data field in the current time period are the same, it is determined that the data verification result is no data conflict, and the current communication device obtains the right to use the bus in the current time period to send the first data field through the bus.
10. A computer-readable storage medium, characterized in that, The medium stores a program, and the program can be executed by a processor to implement the method of any one of claims 1-8. The medium stores a program, and the program can be executed by a processor to implement the method of any one of claims 1-8.
Citation Information
Patent Citations
Serial ring communication arrangement and corresponding method
CN102420736A
Communication recovery method, device and system and readable storage medium
CN116302687A