Unibus communication method and system
By using initialization and answer timing signals in single bus communication, combined with predefined slave selection and functional communication commands, the problem of low efficiency of single bus data communication is solved, and more efficient data transmission is achieved.
Patent Information
- Application Number
- CN202510073252.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-05-13
AI Technical Summary
In the existing single bus communication method, the read operation and write operation of the slave device require the receiver to verify the data content, resulting in low data communication efficiency.
The initialization timing signal and the response timing signal are sent through the master device, and based on the predefined binary slave selection command and function communication command, the specified slave device is found and the read or write operation is performed by verifying the transmission data length.
It effectively improves the efficiency of single-bus data communication and reduces verification and retransmission operations during data transmission.
Smart Images

Figure CN119988262A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of communication technology, and in particular relates to a single bus communication method and system. Background Art
[0002] The single bus protocol uses a single signal line to transmit both clock and data, and the data transmission is bidirectional. It has many advantages such as saving I / O port line resources and facilitating bus expansion and maintenance. As a communication protocol method, the single bus needs to be able to control one or more slave devices, just like protocols such as I2C.
[0003] At present, both the read and write operations of slave devices on a single bus require the receiver to verify whether the data content is successfully transmitted after receiving the data. For example, when performing a write operation, the write data, address and command need to be sent to the slave device respectively. The slave device determines whether the data is wrong one by one, and then feeds back the verification result and resends the data for the erroneous part, which results in low data communication efficiency. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a single bus communication method and system, which are used to solve the problem of low efficiency of current single bus data communication.
[0005] In a first aspect of an embodiment of the present invention, a single bus communication method is provided, comprising: The master device sends an initialization timing signal to the slave device connected by a single bus. After receiving the initialization timing signal, the slave device feeds back a response timing signal. After the master device detects the response timing signal, it searches for the slave device specified by the master device based on the predefined binary slave selection command, and performs the corresponding read operation or write operation on the specified slave device by verifying the transmission data length based on the predefined binary functional communication command.
[0006] In a second aspect of an embodiment of the present invention, a single bus communication system is provided, comprising a master device and at least one slave device, wherein the master device and the at least one slave device are physically connected using a single bidirectional bus; The master device is used to send an initialization timing signal to a slave device connected using a single bus, and after detecting a response timing signal from the slave device, based on a predefined binary slave selection command, find a matching designated slave device, and based on a predefined binary functional communication command, instruct the slave device to perform a read operation or a write operation by verifying the transmission data length; The slave device is used to feed back a response timing signal after receiving the initialization timing signal, and to perform a read operation or a write operation according to a command of the master device.
[0007] In a third aspect of an embodiment of the present invention, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first aspect of the embodiment of the present invention when executing the computer program.
[0008] In a fourth aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method provided in the first aspect of the embodiment of the present invention are implemented.
[0009] In the embodiment of the present invention, by defining a slave selection command and a functional communication command, executing corresponding slave device selection operations and slave device read and write operations, and verifying the transmission data length, the single bus data communication efficiency can be effectively improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0011] Figure 1 A schematic flow chart of a single bus communication method provided by one embodiment of the present invention; Figure 2 A schematic diagram of the structure of a single bus communication system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0012] In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described below are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0013] It should be understood that the term "including" and other similar expressions in the specification or claims of the present invention and the above-mentioned drawings are intended to cover non-exclusive inclusions, such as a process, method, system, or device including a series of steps or units is not limited to the listed steps or units. In addition, "first" and "second" are used to distinguish different objects, not to describe a specific order.
[0014] See also Figure 1, a schematic flow diagram of a single - bus communication method provided by an embodiment of the present invention, includes: S101. The master device sends an initialization timing signal to the slave device connected by a single bus. After receiving the initialization timing signal, the slave device feeds back an acknowledgment timing signal; The single bus communicates through a single signal line. Data exchange between the master device and the slave device is only through one signal line, which transmits both the clock and data, and the data transmission is bidirectional. The host and the slave device are connected to the data line through an open - drain or tri - state port, and a pull - up resistor needs to be added. When the host sends a logic signal 0, the data line is pulled low to the ground; when sending a logic signal 1, the data line remains high, and the slave device responds according to the received signal.
[0015] The initialization process consists of an initialization timing sent by the host and an acknowledgment pulse responded by the slave. The initialization timing is a low - level duration greater than 2T. After the master device sends the initialization timing, it releases the single bus, and at this time the single bus is pulled high by the pull - up resistor. After receiving the initialization timing, the slave device sends an initialization acknowledgment timing, and the acknowledgment timing is the number "0", that is, the slave device pulls the single bus low, and the low - level time < 1 / 4T. The acknowledgment pulse enables the host to know that there is a slave device on the bus and it is ready.
[0016] It can be understood that the underlying physical layer defines the electrical parameters of digital 1 and digital 0. The period of the signal is T, and a valid digital timing is composed of a low - level duration of T LOW and a high - level duration of T - T LOW . Digital 0 and digital 1 are determined by the length of T LOW . The specific definition method is as follows: when T LOW < 1 / 4T, this sequence is the digital "0" timing; when 2 / 3T < T LOW < T, this sequence is the digital "1" timing.
[0017] S102. After the master device detects the acknowledgment timing signal, based on a predefined binary slave selection command, it searches for the slave device that matches the one specified by the master device, and based on a predefined binary functional communication command, it performs a corresponding read operation or write operation on the specified slave device by verifying the transmission data length.
[0018] After the host detects the acknowledgment timing, the slave selection process can be carried out. The slave selection process is related to the unique 64 - bit UID code in each slave device, allowing the host to specify an operation on a certain slave device based on the UID code when connecting multiple slave devices on the single bus.
[0019] Among them, the binary slave selection command at least includes a UID search command, a UID read command, a UID match command, a UID skip command, and a UID reset command; The UID search command is used to search for UID codes of all slave devices connected to the master device on the single bus; When the system is initially powered on, the host must find out the UID codes of all slave devices on the bus, so that the host can determine the number and type of slaves. The host repeatedly executes the UID search command (SEARCH UID command followed by bit data exchange) to find out all slave devices on the bus; if there is only one slave device on the bus, the UID read command can be used instead of the search command.
[0020] The UID read command is used to directly read the UID code of the slave device when there is only one slave device connected to the master device on the single bus; This command is only applicable when there is only one slave device on the bus. It allows the host to directly read the slave's 64-bit UID code without performing the UID search process. This command cannot be used in a multi-node system, which will inevitably result in data conflicts because each slave device will respond to this command.
[0021] The UID matching command is used to instruct the slave device to actively compare its own UID code with the UID code in the master device instruction, and respond to the master device instruction when the comparison is consistent; The UID skip command is used for the master device to directly access the only connected slave device; This command can save interaction time for single slave access in a bus system by allowing the bus master to access device functions without providing a 64-bit ID.
[0022] The UID reset command is used to repeatedly access the slave device without re-executing the UID search command or UID match command after the slave device successfully executes the UID search command or UID match command and sets the skip state to 1, and when the master device accesses another slave device on the single bus, the skip state is set to 0.
[0023] This command is used to check the status of the slave RC bit. If the RC (skip status) bit is set to 1, the slave directly enters the receive function command state. The only way to set the RC (skip status) bit is by successfully executing the SEARCH UID or MARCH UID command. Once the slave device sets the RC (skip status) bit, the slave device can be accessed repeatedly through the reset command without the need for the UID search and UID matching process. Accessing another device on the bus will clear this RC (status) bit to prevent two or more slave devices from responding to the UID reset command at the same time. The RC (skip status) bit can simplify the communication process to some extent, thereby speeding up the communication transmission process.
[0024] The binary-based slave selection command can effectively improve the communication efficiency of a single slave device, facilitate the master device to quickly select the slave device, and avoid frequent UID code matching.
[0025] After the slave device is selected, the binary function communication command is based on performing the corresponding read or write operation on the slave device.
[0026] Wherein, the binary function communication command includes at least a CMD START command, a Write Mem command, a ReadMem command and a Read Status command; The CMD START command is used to start an executable program or open a file; The Write Mem command is used to perform a write register operation; The Read Mem command is used to perform a register read operation; The Read Status command is used to instruct to perform a quick read status operation on the selected slave device.
[0027] Preferably, the binary slave selection command and the binary functional communication command are both composed of 8-bit binary codes, and the numbers of 0s and 1s in the binary codes are equal, and the number of different bits in the binary codes between two adjacent commands is greater than 3 bits.
[0028] The number of 0s and 1s in the 8-bit binary code is set to be equal, that is, the number of 0s and 1s in the 8-bit code is as close to 4 as possible, and the number of different bits between two adjacent 8-bit binary commands is greater than 3. In this way, the reliability of single bus communication can be improved and the probability of misidentification of communication commands under interference can be reduced. Exemplarily, the binary slave select command and the binary function communication command are defined as shown in the following table:
[0029] In this embodiment, when executing a binary function communication command, the data transmission efficiency can be improved by verifying the transmission data length and performing a corresponding read operation or write operation.
[0030] In one embodiment, when executing the Write Mem command, the master device sends the pre-transmitted data length to the slave device, and sends the Write Mem command, the write data address, and the write data content. After receiving the Write Mem command, the write data address, and the write data content, the slave device verifies the data length of the received data. The slave device generates a CRC16 check code based on the data length verification result and sends the CRC16 check code to the master device. After the master device determines that the data transmission is successful based on the CRC16 check code, the master device sends a preset signal to the slave device, and the slave device performs a write operation after receiving the preset signal.
[0031] The host sends a CMD START command, and then sends the total data length (write Data Byte Length) of this transmission to the slave device. This data length can ensure the integrity of the data, and the device can also know the end length of this transmission. Then, send a Write Mem command to indicate that this communication is a write operation to the selected device, and send Parameter, which contains the specific write data and address. This complete command length should be the length of WriteData Byte Length. The slave device will reply with a CRC16 check of all the data received in this communication to ensure that the data in this data transmission process is correct. The host sends a preset signal (Release Byte, that is, the release byte signal). After the slave device receives the Release Byte, it means that the host has determined that the transmission process is correct and can start the write operation.
[0032] In one embodiment, when executing a READ Mem command, the master device sends the pre-transmitted data length to the slave device, and sends the READ Mem command and the read operation address. After receiving the READ Mem command and the read operation address, the slave device verifies the data length of the received data. The slave device generates a first CRC16 check code according to the data length verification result, and sends the first CRC16 check code to the master device. After the master device determines that the data transmission is successful according to the first CRC16 check code, the master device sends a preset signal (i.e., Release Byte) to the slave device. After receiving the preset signal, the slave device performs a read operation; The slave device respectively obtains the transmission data length, the read operation execution status and the transmission data content, and generates a second CRC16 verification code. The master device receives the transmission data length, the read operation execution status, the transmission data content and the second CRC16 verification code, and checks whether the received data is correct and complete based on the second CRC16 verification code.
[0033] In one embodiment, when executing the READ STATUS command, after sending the CMD START command, the total data length (write Data Byte Length) of this transmission is sent. This data length can ensure the integrity of the data, and the slave device can also know the end length of this transmission. Then send the Read Status command to indicate that this communication is a quick read status operation of the selected device. Send Parameter, which contains the specific status classification of the read status operation to be performed. The complete command length is the length of the Write Data Byte Length.
[0034] The slave device replies with the CRC16 check of the data received in this communication to ensure that the data in this data transmission process is correct. Receive and send Release Byte. After the device receives Release Byte (AAH), it means that the host has determined that the transmission process is correct and can start the read operation.
[0035] Waiting for the device to operate, the receiving sequence starts to receive the length of the data to be received this time (Length Byte), and then receives the status indicating whether the read operation is executed correctly (Result Byte). When the status is AA, it indicates a correct operation, and when the status is not AA, it indicates an error or abnormal operation. Receive the data read out of this read status operation (Result Data), and then receive the CRC16 check of all the data in this complete receiving process to check the correctness and integrity of the data.
[0036] It should be understood that the serial numbers of the steps in the above embodiments do not imply a sequence of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0037] Figure 2 A schematic diagram of a single bus communication system provided by an embodiment of the present invention. It includes a master device 210 and at least one slave device 220, and the master device and the at least one slave device are physically connected by a single bidirectional bus; The master device 210 is used to send an initialization timing signal to a slave device connected to a single bus, and after detecting a response timing signal from the slave device, based on a predefined binary slave selection command, find a matching specified slave device, and based on a predefined binary function communication command, instruct the slave device to perform a read operation or a write operation by verifying the transmission data length; The slave device 220 is used to feed back a response timing signal after receiving the initialization timing signal, and to perform a read operation or a write operation according to a command of the master device.
[0038] Wherein, the binary slave selection command includes at least a UID search command, a UID read command, a UID match command, a UID skip command and a UID reset command; The UID search command is used to search for UID codes of all slave devices connected to the master device on the single bus; The UID read command is used to directly read the UID code of the slave device when there is only one slave device connected to the master device on the single bus; The UID matching command is used to instruct the slave device to actively compare its own UID code with the UID code in the master device instruction, and respond to the master device instruction when the comparison is consistent; The UID skip command is used by the master device to directly access the only slave device; The UID reset command is used to repeatedly access the slave device without re-executing the UID search command or UID match command after the slave device successfully executes the UID search command or UID match command and sets the skip state to 1, and when the master device accesses another slave device on the single bus, the skip state is set to 0.
[0039] Wherein, the binary function communication command includes at least a CMD START command, a Write Mem command, a ReadMem command and a Read Status command; The CMD START command is used to start an executable program or open a file; The Write Mem command is used to perform a write register operation; The Read Mem command is used to perform a register read operation; The Read Status command is used to instruct to perform a quick read status operation on the selected slave device.
[0040] Preferably, the binary slave selection command and the binary function communication command are both composed of 8-bit binary codes, and the numbers of 0s and 1s in the binary codes are equal, and the number of different bits between two adjacent commands is greater than 3 bits.
[0041] When executing the Write Mem command, the master device sends the pre-transmitted data length to the slave device, and sends the Write Mem command, the write data address and the write data content. After receiving the Write Mem command, the write data address and the write data content, the slave device verifies the data length of the received data. The slave device generates a CRC16 check code based on the data length verification result and sends the CRC16 check code to the master device. After the master device determines that the data transmission is successful based on the CRC16 check code, the master device sends a preset signal to the slave device, and the slave device performs a write operation after receiving the preset signal.
[0042] When executing the READ Mem command, the master device sends the pre-transmitted data length to the slave device, and sends the READ Mem command and the read operation address. After receiving the READ Mem command and the read operation address, the slave device verifies the data length of the received data. The slave device generates a first CRC16 check code according to the data length verification result, and sends the first CRC16 check code to the master device. After the master device determines that the data transmission is successful according to the first CRC16 check code, the master device sends a preset signal to the slave device, and the slave device performs a read operation after receiving the preset signal; The slave device respectively obtains the transmission data length, the read operation execution status and the transmission data content, and generates a second CRC16 verification code. The master device receives the transmission data length, the read operation execution status, the transmission data content and the second CRC16 verification code, and checks whether the received data is correct and complete based on the second CRC16 verification code.
[0043] A person skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be implemented by an electronic device, wherein the electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed, part or all of the processes in steps S101 to S102 are implemented.
[0044] Those skilled in the art may also understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it implements part or all of the processes in steps S101 to S102, and the storage medium includes ROM / RAM, etc. In the above-mentioned embodiments, the description of each embodiment has its own emphasis. For the part that is not described or recorded in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0045] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and modules described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0046] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0047] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A single bus communication method, characterized in that: include: The master device sends an initialization timing signal to the slave device connected by a single bus. After receiving the initialization timing signal, the slave device feeds back a response timing signal. After the master device detects the response timing signal, it searches for the slave device specified by the master device based on the predefined binary slave selection command, and performs the corresponding read operation or write operation on the specified slave device by verifying the transmission data length based on the predefined binary functional communication command.
2. The method according to claim 1, characterized in that The binary slave selection command includes at least a UID search command, a UID read command, a UID match command, a UID skip command and a UID reset command; The UID search command is used to search for UID codes of all slave devices connected to the master device on the single bus; The UID read command is used to directly read the UID code of the slave device when there is only one slave device connected to the master device on the single bus; The UID matching command is used to instruct the slave device to actively compare its own UID code with the UID code in the master device instruction, and respond to the master device instruction when the comparison is consistent; The UID skip command is used for the master device to directly access the only connected slave device; The UID reset command is used to repeatedly access the slave device without re-executing the UID search command or UID match command after the slave device successfully executes the UID search command or UID match command and sets the skip state to 1, and when the master device accesses another slave device on the single bus, the skip state is set to 0.
3. The method according to claim 1, characterized in that The binary function communication commands at least include a CMDSTART command, a Write Mem command, a Read Mem command and a Read Status command; The CMD START command is used to start an executable program or open a file; The Write Mem command is used to perform a write register operation; The Read Mem command is used to perform a register read operation; The Read Status command is used to instruct to perform a quick read status operation on the selected slave device.
4. The method according to claim 1, characterized in that: The binary slave selection command and the binary function communication command are both composed of 8-bit binary codes, and the numbers of 0 and 1 in the binary code are equal. The number of different bits of binary codes between two adjacent commands in the command set is greater than 3 bits.
5. The method according to claim 3, characterized in that: The performing of a corresponding read operation or write operation on a specified slave device based on a predefined binary function communication command by verifying the transmission data length comprises: When executing the Write Mem command, the master device sends the pre-transmitted data length to the slave device, and sends the Write Mem command, write data address and write data content. After receiving the Write Mem command, write data address and write data content, the slave device verifies the data length of the received data. The slave device generates a CRC16 check code based on the data length verification result and sends the CRC16 check code to the master device. After the master device determines that the data transmission is successful based on the CRC16 check code, the master device sends a preset signal to the slave device, and the slave device performs a write operation after receiving the preset signal.
6. The method according to claim 3, characterized in that The performing of a corresponding read operation or write operation on a specified slave device based on a predefined binary function communication command by verifying the transmission data length comprises: When executing the READ Mem command, the master device sends the pre-transmitted data length to the slave device, and sends the READ Mem command and the read operation address. After receiving the READ Mem command and the read operation address, the slave device verifies the data length of the received data. The slave device generates a first CRC16 check code according to the data length verification result, and sends the first CRC16 check code to the master device. After the master device determines that the data transmission is successful according to the first CRC16 check code, the master device sends a preset signal to the slave device, and the slave device performs a read operation after receiving the preset signal; The slave device respectively obtains the transmission data length, the read operation execution status and the transmission data content, and generates a second CRC16 verification code. The master device receives the transmission data length, the read operation execution status, the transmission data content and the second CRC16 verification code, and checks whether the received data is correct and complete based on the second CRC16 verification code.
7. A single bus communication system, characterized in that: The device comprises a master device and at least one slave device, wherein the master device and the at least one slave device are physically connected by a single bidirectional bus; The master device is used to send an initialization timing signal to a slave device connected using a single bus, and after detecting a response timing signal from the slave device, based on a predefined binary slave selection command, find a matching designated slave device, and based on a predefined binary functional communication command, instruct the slave device to perform a read operation or a write operation by verifying the transmission data length; The slave device is used to feed back a response timing signal after receiving the initialization timing signal, and to perform a read operation or a write operation according to a command of the master device.
8. The system according to claim 7, characterized in that The binary slave selection command includes at least a UID search command, a UID read command, a UID match command, a UID skip command and a UID reset command; The UID search command is used to search for UID codes of all slave devices connected to the master device on the single bus; The UID read command is used to directly read the UID code of the slave device when there is only one slave device connected to the master device on the single bus; The UID matching command is used to instruct the slave device to actively compare its own UID code with the UID code in the master device instruction, and respond to the master device instruction when the comparison is consistent; The UID skip command is used for the master device to directly access the only connected slave device; The UID reset command is used to repeatedly access the slave device without re-executing the UID search command or UID match command after the slave device successfully executes the UID search command or UID match command and sets the skip state to 1, and when the master device accesses another slave device on the single bus, the skip state is set to 0.
9. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Cited By
Method for realizing multiple functions based on single GPIO (General Purpose Input / Output), storage medium and signal transmission structure
CN120892365A