Communication device, communication system and communication method based on UART protocol

By using a communication method between a master device and multiple slave devices in UART communication, and setting the transmission port of an unselected slave device to a high-impedance state when a slave device is selected to execute a command, the reliability and stability issues of UART communication in complex electromagnetic environments are solved, and the reliability of long-distance data transmission and complex data verification is realized.

CN121509136APending Publication Date: 2026-02-10JOULWATT TECH INC LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510207256.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-24
Publication Date
2026-02-10

AI Technical Summary

Technical Problem

UART communication is susceptible to interference in complex electromagnetic environments, making it difficult to meet the reliability and stability requirements of LED matrix controllers. In particular, traditional UART communication protocols are unable to meet the data volume and reliability requirements when transmitting signals between boards over long distances.

Method used

In the communication method between the master device and multiple slave devices, if a slave device is selected to execute a command but not selected, the sending port will be kept in a high-impedance state. The reliability and stability of data transmission are ensured by combining the boot field, device field, register address field and check field.

Benefits of technology

It improves the reliability and stability of UART communication, reduces transmission interference, supports long-distance data transmission and complex data verification, and meets the data volume and reliability requirements of LED matrix controllers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121509136A_ABST
    Figure CN121509136A_ABST
Patent Text Reader

Abstract

The invention discloses a communication device, a communication system and a communication method based on a UART (Universal Asynchronous Receiver / Transmitter) protocol. In a communication system, a master device is connected to a plurality of slave devices via a UART bus, and the master device and the plurality of slave devices respectively include a transmission port and a reception port. The communication method comprises the following steps: a selected slave device in a plurality of slave devices executes a command sent by a master device; the non-selected slave devices in the multiple slave devices maintain the sending port to be in a high resistance state when the selected slave device executes the command, and recover the sending port to be in a normal state after the selected slave device finishes executing the command. The slave devices respond to the command sent by the master device and set respective sending port states respectively, so that transmission interference can be avoided, and the reliability and stability of data communication are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and more specifically, to communication devices, communication systems, and communication methods based on the UART protocol. Background Technology

[0002] In the automotive electronics field, due to the complex application environment, especially the increasingly harsh electromagnetic environment, highly reliable Controller Area Network (CAN) communication has been widely adopted. CAN communication uses differential signal transmission, which can effectively suppress electromagnetic interference during signal transmission and achieve high-speed, reliable, and real-time communication. This characteristic has led to its extensive application and verification in the automotive communication field. However, traditional CAN communication protocols require shared access, resulting in relatively low bandwidth.

[0003] With the development of automotive electronics, LED light sources are increasingly being used in car headlights. LED matrix controllers can control these LEDs to achieve complex control functions such as intelligent lighting, intelligent tracking, intelligent adjustment, and intelligent display. This not only avoids driver glare and ensures driving safety but also improves the reliability of intelligent interactive lighting control systems, providing a pixelated, scalable, and efficient automotive lighting solution. The LED matrix controller is located separately from its electronic control unit (ECU), and data is transmitted between them via board-level communication.

[0004] In existing board-level communication, asynchronous communication protocols are needed to meet the requirements of long-distance communication. For example, the Universal Asynchronous Receiver / Transmitter (UART) protocol is a common asynchronous communication protocol. In UART communication, the TX line of the transmitting end is connected to the RX line of the receiving end, and vice versa; bidirectional communication can be achieved using one transmit line (TX) and one receive line (RX). This communication mode is simple and efficient, enabling full-duplex communication directly between two UART devices, that is, simultaneous data transmission and reception. The LED matrix controller adopts the UART communication protocol, which not only achieves low-cost data transmission but also simplifies system design and wiring.

[0005] However, UART communication also has some limitations. It is easily affected by the surrounding environment during data transmission, and traditional UART communication is difficult to meet the design requirements for high reliability and stability.

[0006] Therefore, it is desirable to further improve the reliability and stability of UART communication, thereby enabling long-distance signal transmission between boards, while meeting the increasing demands of LED matrix controllers for data volume and reliability. Summary of the Invention

[0007] In view of the above problems, the purpose of this invention is to provide a communication device, communication system and communication method based on the UART protocol, wherein a master device communicates with multiple slave devices, and the multiple slave devices respond to commands sent by the master device and set their respective transmission port states to avoid transmission interference, thereby solving the technical problems mentioned in the prior art.

[0008] According to one aspect of the present invention, a communication method based on the UART protocol is provided for data communication between a master device and multiple slave devices. The master device is connected to the multiple slave devices via a UART bus. The master device and the multiple slave devices each include a transmitting port and a receiving port. The communication method includes: a selected slave device among the multiple slave devices executing a command sent by the master device; and an unselected slave device among the multiple slave devices maintaining the transmitting port in a high-impedance state during the execution of the command by the selected slave device, and restoring the transmitting port to a normal state after the execution of the command by the selected slave device ends.

[0009] Optionally, the command includes at least a boot field, a device field, a register address field, and a verification field.

[0010] Optionally, the guide field identifies the command type and data length.

[0011] Optionally, the device field includes a device address and a register identifier.

[0012] Optionally, the verification field includes verification data for CRC verification.

[0013] Optionally, the command includes any one of a broadcast command, a write command, and a read command, and the broadcast command and the write command further include a data field.

[0014] Optionally, the device field of the broadcast command is a predetermined value, used to write data in the data field to the plurality of slave devices; the device address of the write command is a selection identifier, used to write data in the data field to a selected slave device of the plurality of slave devices; and the device address of the read command is a selection identifier, used to read local data from a selected slave device of the plurality of slave devices.

[0015] Optionally, after receiving the last byte of the command, the unselected slave device sets the sending port to a high-impedance state after a first buffer time, and the selected slave device executes the command after receiving the last byte of the command and after the first buffer time and the second buffer time.

[0016] Optionally, after the selected slave device finishes executing the command, the unselected slave device restores the sending port to normal status after a third buffer period.

[0017] Optionally, the command is a read command, the selected slave device executes the command to send local data, and the selected slave device ends the execution of the command after the last byte of the local data is sent.

[0018] Optionally, the command is a write command, the selected slave device executes the command to receive data sent by the master device, and the selected slave device ends the execution of the command after the last byte of data received by the selected slave device.

[0019] Optionally, each of the plurality of slave devices includes a tri-state buffer, and the unselected slave device generates an enable signal according to the command to control the data transmission state of the tri-state buffer, thereby controlling the state of the sending port.

[0020] Optionally, the master device is directly connected to the plurality of slave devices via a UART bus, and the unselected slave device estimates the end time of the selected slave device's execution of the command based on the data length indicated by the command's boot field.

[0021] Optionally, the master device is connected to the plurality of slave devices in sequence via a relay bus and a UART bus. The unselected slave device obtains the end time of the selected slave device executing the command based on the data length indicated by the command's boot field and the data length of the local data sent by the selected slave device.

[0022] Optionally, the relay bus includes any one selected from CAN bus and LIN bus.

[0023] Optionally, a first transceiver is used to implement data forwarding between the master device and the relay bus, and a second transceiver is used to implement data forwarding between the multiple slave devices and the relay bus.

[0024] Optionally, when the selected slave device sends local data to the master device via the TX line of the UART bus, the second transceiver also forwards the local data to the unselected slave device via the RX line of the UART bus.

[0025] According to another aspect of the present invention, a communication device based on the UART protocol is provided, comprising: a read buffer connected to the RX line of a UART bus via a receive port for buffering received external commands; a write buffer connected to the TX line of the UART bus via a transmit port for buffering local data to be transmitted; and a UART controller cooperating with the read buffer and the write buffer to receive the commands and transmit the local data via the UART bus in an asynchronous data transmission manner, wherein the communication device generates an enable signal according to the command to control the data transmission state of the write buffer, thereby controlling the state of the transmit port to be either a normal state or a high impedance state.

[0026] Optionally, the communication device determines whether it is a selected communication device based on the device address indicated by the command, and estimates the end time of the selected communication device executing the command based on the data length indicated by the command. During the execution of the command by the selected communication device, the communication device maintains its own transmission port in a high-impedance state. After the execution of the command by the selected communication device ends, the communication device restores its own transmission port to a normal state.

[0027] Optionally, the write buffer is a tri-state buffer.

[0028] According to another aspect of the present invention, a communication system based on the UART protocol is provided, comprising: a master device; a plurality of slave devices; and a UART bus, wherein the master device is connected to the plurality of slave devices via the UART bus, and wherein the plurality of slave devices respectively execute the above-described communication method.

[0029] Optionally, the master device is an electronic controller in the automotive system, and the plurality of slave devices are LED matrix controllers in the automotive system, the LED matrix controllers being used to control the LED light sources used as vehicle lights.

[0030] Optionally, it also includes a relay bus, via which the master device is connected to the UART bus.

[0031] Optionally, the relay bus includes any one selected from CAN bus and LIN bus.

[0032] According to embodiments of the UART protocol-based communication device, system, and method of the present invention, a master device is connected to multiple slave devices via a UART bus, and the multiple slave devices set their respective transmit port states according to commands sent by the master device. During the execution of a command by a selected slave device, the transmit ports of unselected slave devices are set to a high-impedance state to avoid interference with the transmission of the selected slave device, thereby improving the reliability and stability of data communication.

[0033] In a preferred embodiment, the command sent by the master device includes a bootstrap field that identifies the command type and data length. The plurality of slave devices respond to the commands sent by the master device and set their respective sending port states according to the bootstrap field of the command, thereby improving the reliability and stability of data communication.

[0034] In a preferred embodiment, the command sent by the master device includes a check field, the check data of which is used for CRC verification. The plurality of slave devices respectively respond to the commands sent by the master device and perform synchronous verification based on the check field of the commands to improve the effectiveness of data transmission. This application employs CRC (Cyclic Redundancy Check) to satisfy complex data verification, which can ensure the reliability of data transmission.

[0035] In a preferred embodiment, the master device is directly connected to multiple slave devices via a UART bus. Each of the multiple slave devices responds to a read command sent by the master device. A selected slave device sends data according to the read command, while other slave devices determine the number of bytes they need to wait for based on the read command, and determine the time required for their transmit port to switch from a high-impedance state to a normal state based on the number of bytes.

[0036] In a preferred embodiment, the master device is sequentially connected to multiple slave devices via a relay bus and a UART bus. The transceiver of the relay bus forwards data sent by a selected slave device to the receiving port of an unselected slave device. Each of the multiple slave devices responds to a read command sent by the master device. Specifically, the selected slave device sends data according to the read command, and the unselected slave device determines the number of bytes of the forwarded data based on the read command, and determines the time required for its transmitting port to switch from a high-impedance state to a normal state based on the number of bytes.

[0037] In a preferred embodiment, a selected slave device among the plurality of slave devices responds to a write command sent by the master device. After receiving the write command via a receiving port and performing a write operation according to the write command, the slave device sends an ACK signal to the master device via a sending port to ensure the reliability of data transmission. Attached Figure Description

[0038] The above and other objects, features and advantages of the present invention will become more apparent from the following description of embodiments of the invention with reference to the accompanying drawings, in which: Figure 1 A schematic block diagram of a direct communication system according to an embodiment of the present invention is shown; Figure 2 A schematic block diagram of a hybrid communication system according to an embodiment of the present invention is shown; Figure 3This diagram illustrates a schematic data structure for a write command in a communication method according to an embodiment of the present invention; Figure 4 This illustration shows a schematic data structure for a read command in a communication method according to an embodiment of the present invention; Figure 5 This illustration shows a schematic data structure that returns read data in response to a read command in a communication method according to an embodiment of the present invention.

[0039] Figure 6 This illustrates a UART communication state machine used in a communication system according to an embodiment of the present invention; Figure 7 This diagram illustrates a data frame buffer for a UART bus signal in a direct-connect communication system according to an embodiment of the present invention. Figure 8 A schematic diagram of a data frame buffer for a CAN bus signal in a hybrid communication system according to an embodiment of the present invention is shown. Detailed Implementation

[0040] The present invention is described below based on embodiments, but the invention is not limited to these embodiments. In the detailed description of the invention below, certain specific details are described in detail. Those skilled in the art will fully understand the invention even without these details. To avoid obscuring the essence of the invention, well-known methods, processes, flows, elements, and circuits are not described in detail.

[0041] Furthermore, those skilled in the art should understand that the accompanying drawings provided herein are for illustrative purposes only and are not necessarily drawn to scale.

[0042] Furthermore, it should be understood that in the following description, "circuit" refers to a conductive loop consisting of at least one element or sub-circuit connected by an electrical or electromagnetic connection. When an element or circuit is said to be "connected" to another element or "connected" between two nodes, it can be directly coupled or connected to another element, or there may be intermediate elements. The connection between elements can be physical, logical, or a combination thereof. Conversely, when an element is said to be "directly coupled to" or "directly connected" to another element, it means that there are no intermediate elements between them.

[0043] Unless the context explicitly requires it, the words "comprising," "including," or similar terms throughout the specification and claims should be interpreted as including rather than exclusive or exhaustive; that is, meaning "including but not limited to."

[0044] In this description, it should be understood that the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, in this description, unless otherwise stated, "multiple" means two or more.

[0045] The inventors noted that when applying the existing UART communication protocol to a master-slave architecture communication system, the master device sends commands via the UART bus, selects a slave device to execute the command, and then sends data to the master device via the transmit port TX. At this time, the transmit port TX of any unselected slave device is at a high or low level, interfering with the data transmission of the selected slave device. To solve this problem, separate enable lines can be connected between the master device and multiple slave devices, with the master device enabling only one slave device. However, this solution would increase the UART bus to three lines, complicating system design and wiring.

[0046] Therefore, this invention proposes that in a master-slave communication system, both selected and unselected slave devices respond to commands sent by the master device. Unselected slave devices generate an enable signal according to the command and maintain their own transmit port TX in a high-impedance state during the execution of commands by the selected slave device, thereby improving the reliability and stability of data communication.

[0047] Figure 1 A schematic block diagram of a direct-connect communication system according to an embodiment of the present invention is shown. The communication system 100 includes a master device 110, two slave devices 120 and 130, and a UART bus 111 connecting the master device 110 to the two slave devices 120 and 130. However, the present invention is not limited thereto, and the communication system 100 may include any number of slave devices.

[0048] In an automotive system, the main device 110 is, for example, an electronic control unit (ECU) mounted on the console, while the slave devices 120 and 130 are, for example, LED matrix controllers mounted on the headlight assembly. The LED matrix controller controls the LED light source to achieve complex control functions, such as intelligent lighting, intelligent tracking, intelligent adjustment, and intelligent display. Intelligent lighting automatically adjusts the brightness and illumination range of the lights according to ambient light and driving conditions, providing the driver with optimal visibility. Intelligent tracking adjusts the direction of the lights to follow the vehicle's steering, enhancing safety when cornering. Intelligent adjustment changes the color and effect of the lights according to different driving modes or scenarios. Intelligent display controls the LED light source with pixel-level precision to achieve image display, improving vehicle recognition and personalization.

[0049] In this embodiment, the master device 110 is directly connected to the slave devices 120 and 130 via the UART bus 111. The UART bus 111 includes an RX line and a TX line, wherein the RX line is used for the slave device to receive data sent by the master device, and the TX line is used for the master device to receive data sent by the slave device, thereby realizing full-duplex communication.

[0050] In this embodiment, a resistor R1 is connected between the TX line of the UART bus 111 and the reference voltage, and a resistor R2 is connected between the RX line of the UART bus 111 and the reference voltage. In the idle state of the UART bus 111, the TX and RX lines of the UART bus 111 are pulled up to predetermined levels via resistors R1 and R2, respectively, to suppress signal jitter or bit errors caused by interference and ensure the stability of data transmission.

[0051] The master device 110 includes a microcontroller (MCU). The MCU's transmit port TX is connected to the RX line of the UART bus 111, and its receive port RX is connected to the TX line of the UART bus 111. Slave devices 120 and 130 each include a UART communication device. Further, the UART communication device includes a UART controller U1, a read buffer U2, and a write buffer U3. The UART communication device's transmit port TX is connected to the TX line of the UART bus 111, and its receive port RX is connected to the RX line of the UART bus 111.

[0052] It is understood that devices 120 and 130 include not only the aforementioned UART communication device, but also an LED drive control device for performing corresponding functions according to commands. For clarity, in Figure 1 Only the UART communication devices of devices 120 and 130 are shown; the LED drive control device is not shown.

[0053] Within slave devices 120 and 130, the UART controller U1 works in conjunction with read buffer U2 and write buffer U3. The UART controller U1 includes a first-in, first-out (FIFO) buffer to support asynchronous data transmission. Further, read buffer U2 buffers commands sent by master device 110, and write buffer U3 buffers data sent by slave devices 120 and 133. By using read buffer U2 and write buffer U3, the integrity of commands received and data sent by slave devices 120 and 130 is guaranteed even if there is a difference in processing speed between master device 110 and slave devices 120 and 130.

[0054] During data communication, master device 110 sends commands to the RX line of UART bus 111 via transmit port TX, and slave devices 120 and 130 receive commands via receive port RX. Read buffer U2 is used to buffer received commands until the UART controller U1 in slave devices 120 and 130 has time to read the received commands from read buffer U2. After executing the read command from master device 110, the selected slave device in slave devices 120 and 130 sends data to the TX line of UART bus 111 via transmit port TX. Write buffer U3 is used to buffer the data to be sent, and master device 110 receives the data via receive port RX.

[0055] Unlike existing UART communication systems, in the communication system according to an embodiment of the present invention, the write buffer U3 in slave devices 120 and 130 is a tri-state buffer. The tri-state buffer has three output states: high level, low level, and high impedance state.

[0056] The UART controller U1 in devices 120 and 130 generates an enable signal EN to control the data transmission state of the corresponding write buffer U3 to either a normal state or a disabled state.

[0057] In normal data transmission mode, write buffer U3 functions like a regular buffer, setting the output signal level based on the data value. For example, logic 0 in binary can correspond to a low signal level or a specific sequence of level states, while logic 1 can correspond to a high signal level or another specific sequence of level states. In this state, write buffer U3 of devices 120 and 130 transmits the level signal corresponding to the data value to the transmit port TX, thereby transmitting it to the TX line of the UART bus 111. In disabled data transmission mode, write buffer U3 of devices 120 and 130 maintains the transmit port TX in a high-impedance state to prevent the TX line of the UART bus 111 from being affected by the internal data processing of devices 120 and 130.

[0058] During data communication, master device 110 sends commands to slave device 120 via UART bus 111. Both slave devices 120 and 130 receive and respond to the commands. Slave device 120 identifies itself as the selected slave device based on the command and executes the action corresponding to the command, maintaining the enable signal EN in a valid state during the execution of the command by the selected slave device, thereby enabling the data output function of write buffer U3. Slave device 130 identifies itself as an unselected slave device based on the command and, based on the estimated execution period of the command by the selected slave device, maintains the enable signal EN in an invalid state during the execution of the command by the selected slave device, thereby disabling the data output function of write buffer U3.

[0059] According to an embodiment of the communication system of the present invention, a master device is connected to multiple slave devices via a UART bus, and the multiple slave devices set their respective transmit port states according to commands sent by the master device. During the execution of a command by a selected slave device, the transmit ports of the unselected slave devices are set to a high-impedance state to avoid interference with the transmission of the selected slave device, thereby improving the reliability and stability of data communication.

[0060] Figure 2 A schematic block diagram of a hybrid communication system according to an embodiment of the present invention is shown. The communication system 200 includes a master device 110, two slave devices 120 and 130, two CAN transceivers U11 and U12, and a CAN bus 112 and a UART bus 111 connecting the master device 110 to the two slave devices 120 and 130. However, the invention is not limited thereto; the communication system 200 may include any number of slave devices, and the CAN transceivers U11 and U12 may be replaced with any relay transceiver capable of forwarding data, and the CAN bus 112 may be replaced with any relay bus corresponding to the type of relay transceiver, such as a Local Interconnect Network (LIN) bus for distributed electronic system control in automobiles.

[0061] exist Figure 1 and Figure 2 In this document, the same reference numerals are used to denote the same modules in the hybrid communication system and the direct-connect communication system, and the same modules will not be described in detail again. The difference between the hybrid communication system according to the embodiments of the present invention and the direct-connect communication system according to the embodiments is only that it includes a relay transceiver and a relay bus.

[0062] In the automotive system, the master device 110 is, for example, an electronic controller (ECU) mounted on the console, and the slave devices 120 and 130 are, for example, LED matrix controllers mounted on the headlight assemblies. For example, slave devices 120 and 130 are each mounted in their respective headlight assemblies and interconnected via a UART bus, with a CAN transceiver U12 mounted in one headlight assembly.

[0063] See Figure 2 The communication system 200 is a hybrid system that transmits data sequentially via CAN bus 112 and UART bus 111.

[0064] Both the CAN bus 112 and the UART bus 111 use two signal lines to transmit data. However, the two signal lines of the UART bus 111 are the TX line and the RX line, used for transmitting and receiving data respectively, thus achieving full-duplex communication. The two signal lines of the CAN bus 112 are differential signal lines, using the differential signal between them to transmit data. As an event-driven communication protocol, the CAN bus 112 allows a selected node to transmit data at any given time. Furthermore, the data frame formats of the UART bus 111 and the CAN bus 112 are different from each other.

[0065] CAN transceiver U11 is used for data forwarding between master device 110 and CAN bus 112. On one hand, CAN transceiver U11 receives data from master device 110, converts it into a differential signal format suitable for transmission on CAN bus 111, and sends it to CAN bus 112. On the other hand, CAN transceiver U11 receives data from CAN bus 112, decodes and restores the differential signal data, and then sends it to master device 110.

[0066] The CAN transceiver U12 is used for data forwarding between the CAN bus 112 and the UART bus 111. On one hand, the CAN transceiver U12 receives data in differential signal form from the CAN bus 112, decodes the differential signal and converts it into a data format conforming to the UART protocol, and then sends it to the UART bus 111. On the other hand, the CAN transceiver U12 receives data from the UART bus 111, converts it into a differential signal form suitable for transmission on the CAN bus 112, and then sends it to the CAN bus 112.

[0067] In the aforementioned hybrid communication system, to ensure compatibility with the physical layer of the CAN protocol, the UART controllers in multiple slave devices can only support half-duplex protocols, meaning that data transmission and reception cannot overlap in time. Due to the physical layer characteristics of the CAN protocol, the CAN transceiver U12 also has data forwarding capabilities.

[0068] During data communication, master device 110 sends commands to slave device 120 via UART bus 111. Both slave devices 120 and 130 receive and respond to commands. Slave device 120 identifies itself as the selected slave device based on the command and executes the corresponding action, maintaining the enable signal EN in a valid state during command execution by the selected slave device, thereby enabling the data output function of write buffer U3. While CAN transceiver U12 receives data via the TX line of UART bus 111, it also forwards the received data to the RX line of UART bus 111. Slave device 130 identifies itself as an unselected slave device based on the command, setting the enable signal EN to an invalid state when the selected slave device starts sending data, and setting the enable signal EN to a valid state when the number of bytes of data sent by the selected slave device reaches a predetermined number of bytes, thereby disabling the data output function of write buffer U3 during command execution by the selected slave device.

[0069] According to the communication system of this invention, a master device is sequentially connected to multiple slave devices via a CAN bus and a UART bus to form a hybrid communication system. On the UART bus, the multiple slave devices set their respective transmit port states according to commands sent by the master device. During the execution of a command by a selected slave device, the transmit ports of unselected slave devices are set to a high-impedance state to avoid interference with the transmission of the selected slave device, thereby improving the reliability and stability of data communication. On the CAN bus, the master device and slave devices are connected to each other via differential signal lines for long-distance data transmission. The use of differential signal transmission can cancel out some interference signals and has a strong ability to suppress electromagnetic noise interference, thus providing improved anti-interference performance and preventing faults in the cable harness.

[0070] In the aforementioned communication systems 100 and 200, the commands sent by the master device 110 to the slave devices 120 and 130 consist of multiple bytes. According to the UART communication protocol, each byte includes one start bit, eight data bits, and one stop bit, for a total of 10 data bits.

[0071] The communication method according to embodiments of the present invention further defines a command format for UART communication to support multiple slave devices in setting the status of their transmission ports according to commands sent by the master device. The command includes a bootstrap field INIT, a device field DEVID, a register address field REGADDR, and a checksum field CRC. The bootstrap field INIT is used to identify the command type and data length.

[0072] During data communication, multiple slave devices receive and respond to commands. The slave devices identify the command type and data length based on the INIT field. Furthermore, the slave devices identify whether they are selected or not based on the DEVID field. While the selected slave device executes the command, the unselected slave device maintains its transmit port in a high-impedance state.

[0073] For example, the command's bootstrap field INIT is 1 byte. Based on the configuration table shown in Table 1, the command type and data length can be obtained by looking up the value of the bootstrap field INIT.

[0074] Table 1 Configuration table for the bootstrap field INIT Data length Write command Read command 1 byte 0x87 0x4B 2 bytes 0x99 0xCC 3 bytes 0x1E 0xD2 4 bytes 0xAA 0x55 5 bytes 0xAD 0xE5 8 bytes 0x13 0x26 12 bytes 0x2D 0xE1 16 bytes 0x33 0x66 20 bytes 0xB5 0x7A 32 bytes 0xB4 0x78 Referring to Table 1, if the value of the INIT field of the command sent by the master device is equal to 0x99, it indicates that the command is a write command and contains 2 bytes of data to be written; if the value of the INIT field of the command sent by the master device is equal to 0xCC, it indicates that the command is a read command and the selected slave device needs to return 2 bytes of data.

[0075] The UART communication commands can support data to be written up to 32 bytes, thus providing the large amount of data required for image driving to support pixel-level image display. However, the invention is not limited to this; by using a multi-byte boot field INIT, it can support data to be written exceeding 32 bytes.

[0076] For example, the device field DEVID of the command is 1 byte. According to the configuration table shown in Table 2, the device address DEVADDR and register identifier REGID can be obtained by looking up the value of the device field DEVID.

[0077] Table 2 Configuration table for the device field DEVID Device address (decimal) MTP (hexadecimal) VOLATILE (hexadecimal) 0 0x80 0x20 1 0xC1 0x61 2 0x42 0xE2 3 0x03 0xA3 4 0xC4 0x64 5 0x85 0x25 6 0x06 0xA6 7 0x47 0xE7 8 0x08 0xA8 9 0x49 0xE9 10 0xCA 0x6A 11 0x8B 0x2B 12 0x4C 0xEC 13 0x0D 0xAD 14 0x8E 0x2E 15 0xCF 0x6F Referring to Table 2, if the value of the device field DEVID in the command sent by the master device is equal to 0x42, it means that the device address DEVADDR of the selected slave device is equal to 2, and the register identifier REGID indicates the selected slave device's multiple programmable (MTP) register; if the value of the device field in the command sent by the master device is equal to 0xA3, it means that the device address DEVADDR of the selected slave device is equal to 3, and the register identifier REGID indicates the selected slave device's volatile register.

[0078] The commands for UART communication can support 16 slave devices and access two registers in each slave device. However, the present invention is not limited thereto. By using a multi-byte device field DEVID, a larger number of slave devices and a larger number of registers can be supported.

[0079] See Figure 3 , the write command format for UART communication according to an embodiment of the present invention includes: a leading field INIT, a device field DEVID, a register address field REGADDR, a data field DATA, and a check field CRC.

[0080] In this embodiment, the length of the write command is variable. The number of bytes n of the data field DATA is defined in the leading field INIT of the write command. For example, 0 < n <= 32. The selected slave device analyzes the write command according to the number of bytes n indicated by the leading field INIT to obtain all the data of the data field DATA.

[0081] The check field CRC is 2-byte check data, including 1-byte low significant bit check data CRCL and 1-byte high significant bit check data CRCH. When the master device 110 sends a write command, 16-bit check data of the check field CRC is calculated according to the cyclic redundancy check algorithm of the CRC16 (IBM) specification, and is encoded in the order of the low significant bit check data CRCL and the high significant bit check data CRCH after the data field DATA.

[0082] During data communication, the selected slave device 120 among multiple slave devices 120 and 130 executes the write command. For example, the selected slave device 120 responds to the write command, receives a large amount of display data required for image driving from the master device 110, and writes the display data into a local register to support pixel-level image display. Preferably, after executing the write command, the selected slave device 120 sends an acknowledgment signal to the master device 110 via the transmit port TX. The acknowledgment signal is, for example, acknowledgment data of a predetermined value (e.g., one-byte hexadecimal data 0x7F).

[0083] Referring to the example in Table 3, the value of the leading field INIT of the write command is 0x1E, indicating that the type of this command is a write command for writing data with a length of 3 bytes; the value of the device field DEVID is 0x64, indicating that it is used to write to the volatile register in the slave device with device address 4. The subsequent register address field REGADDR, data field DATA, and check field CRC respectively represent: the register address to be written is 0x29, the data to be written is three-byte data: 0x55, 0x56, 0x57, and the low significant bit check data CRCL and the high significant bit check data CRCH are 0x14 and 0x64 respectively.

[0084] Table 3 Example data structure of write command

[0085] See Figure 4 , the read command format of UART communication according to an embodiment of the present invention includes: a leading field INIT, a device field DEVID, a register address field REGADDR, a data field DATA, and a check field CRC.

[0086] In this embodiment, the length of the read command is variable. The number of bytes n of the data field DATA is defined in the leading field INIT of the read command. For example, 0 < n <= 32. The selected slave device returns local data according to the number of bytes n indicated by the leading field INIT.

[0087] The check field CRC is 2-byte check data, including 1-byte low significant bit check data CRCL and 1-byte high significant bit check data CRCH. When the master device 110 sends a read command, 16-bit check data of the check field CRC is calculated according to the cyclic redundancy check algorithm of the CRC1X (IBM) specification, and is encoded in the order of the low significant bit check data CRCL and the high significant bit check data CRCH after the data field DATA.

[0088] During data communication, the selected slave device 120 among multiple slave devices 120 and 130 executes the read command. For example, the selected slave device 120 responds to the read command and obtains local data according to the number of bytes n indicated by the leading field INIT of the read command to generate the data field DATA. See Figure 5 , when the selected slave device 120 returns local data, 16-bit check data of the check field CRC is calculated according to the cyclic redundancy check algorithm of the CRC16 (IBM) specification, and is encoded in the order of the low significant bit check data CRCL and the high significant bit check data CRCH after the data field DATA. The selected slave device 120 sequentially sends the data field DATA and the check data CRC to the master device 110 via the sending port TX.

[0089] See the example in Table 4. The value of the leading field INIT of the read command is 0xCC, indicating that the type of this command is a read command for reading data with a length of 2 bytes; the value of the device field DEVID is 0x25, indicating that it is used to read the volatile register in the slave device with a device address of 5. The subsequent register address field REGADDR, data field DATA, and check field CRC respectively represent: the register address to be read is 0x00, and the low significant bit check data CRCL and the high significant bit check data CRCH are 0xA2 and 0xAF respectively.

[0090] Table 4 Example data structure for read commands INIT DEVID REGADDR CRCL CRCH 0xCC 0x25 0x00 0xA2 0xAF Referring to the example in Table 5, the selected slave device executes the read command described above, sequentially sending the data field DATA and checksum CRC to the master device via the transmit port TX. The data field DATA includes two bytes of local data 0x40 and 0x10 as indicated by the read command. The least significant bit CRCL and most significant bit CRCCH in the checksum CRC are 0x30 and 0x0C, respectively.

[0091] Table 5. Example return data structure of the read command

[0092] In addition, the write command sent by the master device 110 also includes a special broadcast command. The write command format for UART communication according to embodiments of the present invention includes: a boot field INIT, a device field DEVID, a register address field REGADDR, a data field DATA, and a checksum field CRC.

[0093] The data structure of the broadcast command is largely the same as that of the write command; that is, the definitions of the INIT field, REGADDR field, DATA field, and CRC field are identical. The only difference is that the device field DEVID in the broadcast command is set to a predetermined value. This device field DEVID does not belong to any of the values ​​in Table 2 and is used to indicate the data written in the broadcast command to the registers of all slave devices.

[0094] Referring to the example in Table 6, the INIT field of the broadcast command has a value of 0x87, indicating that the command type is a broadcast command used to write one byte of data; the DEVID field has a value of 0xBF, indicating that it is used to write to the registers in all slave devices. The subsequent register address field REGADDR, data field DATA, and checksum field CRC indicate that the register address to be written is 0x80, the data to be written is one byte of data: 0x02, the least significant bit checksum CRCL and the most significant bit checksum CRCH are 0xF9 and 0x51, respectively.

[0095] Table 6 Example data structure for broadcast commands INIT DEVID REGADDR DATA CRCL CRCH 0x87 0xBF 0x80 0x02 0xF9 0x51 Figure 6 A state machine used in a communication system according to an embodiment of the present invention is shown. This state machine is the state machine in the communication system for implementing the above-described communication method by a slave device.

[0096] In the communication system described above, all slave devices are initially in an idle state. For example, in the idle state, the transmit ports of all slave devices are at a predetermined level.

[0097] When the master device sends a command, all slave devices receive the command. After the data length of the received command reaches one byte, the first byte of data is used as the bootstrap field INIT. Then, the slave devices compare the bootstrap field INIT with the configuration shown in Table 1 to determine whether it is a valid field.

[0098] If the bootstrap field INIT is not a valid field as shown in Table 1, the device returns an idle state. If the bootstrap field INIT is a valid field, Table 1 is looked up to obtain the command type and data length.

[0099] After the received command data reaches a length of 2 bytes, the second byte is used as the device field DEVID. The slave device then compares the device field DEVID with the configuration shown in Table 2 to obtain the device address DEVADDR and register identifier REGID. This register identifier REGID is used to identify multiple programmable registers or volatile registers in the slave device.

[0100] If the device address DEVADDR in the DEVID field matches the device address of the slave device, the slave device determines itself to be the selected slave device. If the device address DEVADDR in the DEVID field does not match the device address of the slave device, the slave device determines itself to be an unselected slave device.

[0101] Based on the data length indicated by the INIT field in the command, the selected slave device and the unselected slave device each receive the corresponding bytes of data. After receiving all bytes of data, both the selected and unselected slave devices calculate the CRC data according to all fields preceding the CRC field in the command, and then compare the calculated CRC data with the CRC data in the CRC field of the command.

[0102] If the calculated CRC data matches the CRC data in the field, the verification is successful. When a slave device is selected to execute a command, any unselected slave device will set its own transmit port to a high-impedance state during the command execution process to avoid interfering with the transmission of the selected slave device, thereby improving the reliability and stability of data communication.

[0103] If the calculated CRC data does not match the CRC data in the field, it indicates a check error. Selecting a slave device and not selecting a slave device increments the error counter CRC_ERR by 1, then returns to an idle state.

[0104] Figure 7A schematic diagram of a data frame buffer for a UART bus signal in a direct communication system according to an embodiment of the present invention is shown.

[0105] As described above, in a direct communication system, when a master device sends a command to multiple slave devices, all slave devices respond to the command. Among them, the selected slave device executes the command, while the unselected slave device sets its own transmission port to a high-impedance state during the period when the selected slave device executes the command.

[0106] See Figure 7 Taking the read command as an example, if the slave device is not selected, it sets the status of the sending port after receiving the command; if the slave device is selected, it sends local data after executing the command after receiving it.

[0107] In this embodiment, the response action of the unselected slave device precedes that of the selected slave device. After the unselected slave device receives the last byte of the command, an invalid enable signal is generated after a first buffer time Tpadding, setting the state of the transmit port to high impedance. After the selected slave device receives the last byte of the command, local data is transmitted via the transmit port after a first buffer time Tpadding and a second buffer time Tstart.

[0108] Furthermore, in this embodiment, the unselected slave device recovers to the normal state after the selected slave device sends its local data. That is, the recovery action of the unselected slave device is later than the end time of the selected slave device's transmission. After the selected slave device sends the last byte of its local data, the unselected slave device generates a valid enable signal after a third buffer time (Tend), restoring the state of its transmission port to the normal state.

[0109] The first buffer time, Tpadding, is proportional to the byte length and is used to ensure the integrity of all commands received from slave devices. For example, the first buffer time, Tpadding, is equal to N * Tclk, where N represents the byte length and Tclk represents the system clock cycle.

[0110] The second buffer time Tstart and the third buffer time Tend are, for example, half a clock cycle. These are used to ensure that the transmit port of the unselected slave device is in a high-impedance state while the selected slave device is transmitting local data, thus avoiding interference with the transmission of the selected slave device. For example, at a baud rate of 1MHz, the second buffer time Tstart and the third buffer time Tend are each 0.5 microseconds.

[0111] Figure 8 A schematic diagram of a data frame buffer for a CAN bus signal in a hybrid communication system according to an embodiment of the present invention is shown.

[0112] As described above, in a hybrid communication system, the master device is connected to multiple slave devices in sequence via a relay bus and a UART bus. The relay bus not only forwards data transmission between the master device and the slave devices, but also the relay bus transceiver forwards data sent by selected slave devices to the receiving port of unselected slave devices.

[0113] In this embodiment, the response action of the unselected slave device precedes that of the selected slave device. After the unselected slave device receives the last byte of the command, an invalid enable signal is generated after a first buffer time Tpadding, setting the state of the transmit port to high impedance. After the selected slave device receives the last byte of the command, local data is transmitted via the transmit port after a first buffer time Tpadding and a second buffer time Tstart.

[0114] In this embodiment, the local data of the selected slave device is sent to the master device via the UART bus and the CAN bus. Due to the physical layer characteristics of the CAN protocol, the CAN transceiver forwards the local data on the TX line of the UART bus to the RX line of the UART bus. Therefore, an unselected slave device can receive the local data of the selected slave device.

[0115] Furthermore, in this embodiment, the unselected slave device recovers to the normal state after the selected slave device sends its local data. That is, the recovery action of the unselected slave device is later than the end time of the selected slave device's transmission. After the selected slave device sends the last byte of its local data, the unselected slave device generates a valid enable signal after a third buffer time (Tend), restoring the state of its transmission port to the normal state.

[0116] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. For those skilled in the art, the present invention can be modified and varied in various ways. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the present invention should be included within the scope of protection of the present invention.

Claims

1. A communication method based on the UART protocol for data communication between a master device and multiple slave devices, wherein the master device is connected to the multiple slave devices via a UART bus, and the master device and the multiple slave devices each include a transmitting port and a receiving port, the communication method comprising: The selected slave device among the plurality of slave devices executes the command sent by the master device; The unselected slave device among the plurality of slave devices maintains the transmitting port in a high-impedance state during the execution of the command by the selected slave device, and restores the transmitting port to a normal state after the execution of the command by the selected slave device ends.

2. The communication method according to claim 1, wherein, The command includes at least a boot field, a device field, a register address field, and a verification field.

3. The communication method according to claim 2, wherein, The guiding field identifies the command type and data length.

4. The communication method according to claim 2, wherein, The device field includes the device address and register identifier.

5. The communication method according to claim 2, wherein, The verification field includes verification data used for CRC verification.

6. The communication method according to claim 1, wherein, The command includes any one of a broadcast command, a write command, and a read command, and the broadcast command and the write command further include a data field.

7. The communication method according to claim 6, wherein, The device field of the broadcast command is a predetermined value, used to write data from the data field to the plurality of slave devices. The device address of the write command is a selection identifier, used to write data from the data field to the selected slave device among the plurality of slave devices. The device address of the read command is a selection identifier, used to read local data from a selected slave device among the plurality of slave devices.

8. The communication method according to claim 1, wherein, After receiving the last byte of the command, the unselected slave device sets the sending port to a high-impedance state after a first buffer period. The selected slave device executes the command after receiving the last byte of the command, after the first buffer time and the second buffer time.

9. The communication method according to claim 1, wherein, After the selected slave device finishes executing the command, the unselected slave device restores the sending port to normal status after a third buffer period.

10. The communication method according to claim 9, wherein, The command is a read command. The selected slave device executes the command to send local data. After the selected slave device sends the last byte of local data, the execution of the command by the selected slave device ends.

11. The communication method according to claim 9, wherein the command is a write command, the selected slave device executes the command to receive data sent by the master device, and the selected slave device finishes executing the command after receiving the last byte of data.

12. The communication method according to claim 1, wherein, The plurality of slave devices each include a tri-state buffer. The unselected slave device generates an enable signal according to the command to control the data transmission state of the tri-state buffer, thereby controlling the state of the sending port.

13. The communication method according to claim 1, wherein, The master device is directly connected to the plurality of slave devices via a UART bus, and the unselected slave device estimates the end time of the selected slave device's execution of the command based on the data length indicated by the command's boot field.

14. The communication method according to claim 1, wherein, The master device is connected to the plurality of slave devices in sequence via a relay bus and a UART bus. The unselected slave device obtains the end time of the command execution by the selected slave device based on the data length indicated by the command's boot field and the data length of the local data sent by the selected slave device.

15. The communication method according to claim 14, wherein, The relay bus includes any one of the following: CAN bus or LIN bus.

16. The communication method according to claim 14, wherein, A first transceiver is used to forward data between the master device and the relay bus, and a second transceiver is used to forward data between the multiple slave devices and the relay bus.

17. The communication method according to claim 16, wherein, When the selected slave device sends local data to the master device via the TX line of the UART bus, the second transceiver also forwards the local data to the unselected slave device via the RX line of the UART bus.

18. A communication device based on the UART protocol, comprising: The read buffer, connected to the RX line of the UART bus via the receive port, is used to buffer received external commands; A write buffer, connected to the TX line of the UART bus via the transmit port, is used to buffer local data to be transmitted; The UART controller, working in conjunction with the read buffer and the write buffer, receives the commands and sends the local data via the UART bus in an asynchronous data transmission manner. The communication device generates an enable signal according to the command to control the data transmission state of the write buffer, thereby controlling the state of the sending port to be either a normal state or a high-impedance state.

19. The communication device according to claim 18, wherein, The communication device determines whether it is a selected communication device based on the device address indicated by the command, and estimates the end time of the selected communication device executing the command based on the data length indicated by the command. During the execution of the command by the selected communication device, the communication device maintains its transmission port in a high-impedance state, and after the execution of the command by the selected communication device ends, the communication device restores its transmission port to a normal state.

20. The communication device according to claim 18, wherein, The write buffer is a tri-state buffer.

21. A communication system based on the UART protocol, comprising: Main equipment; Multiple devices; The master device is connected to the plurality of slave devices via a UART bus. The plurality of slave devices respectively execute the communication method according to claims 1 to 17.

22. The communication system according to claim 21, wherein, The master device is an electronic controller in the automotive system, and the multiple slave devices are LED matrix controllers in the automotive system. The LED matrix controllers are used to control the LED light sources used as vehicle lights.

23. The communication system according to claim 21, further comprising: A relay bus, through which the master device is connected to the UART bus.

24. The communication system according to claim 23, wherein, The relay bus includes any one of the following: CAN bus or LIN bus.

Citation Information

Patent Citations

  • Home appliance, communication system and communication method of home appliance

    CN108123863A

  • Communication system and communication method for household electrical appliance and household electrical appliance

    CN108134726A

  • Communication method, apparatus and system

    CN109240971A

  • One-to-many UART communication method

    CN115499032A

  • A bus communication system based on UARTs

    CN203180949U