MCU and SOC communication method based on SPI communication protocol, and protocol construction method
By adopting the SPI communication protocol in the automotive instrument system, designing a full-duplex communication method and formulating a timeout retransmission mechanism and a response detection mechanism, the problem of low UART and I2C transmission rates is solved, and the efficiency and reliability of data transmission is achieved, and the real-time requirements of the instrument system are met.
Patent Information
- Application Number
- PCT/CN2024/111110
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-01-08
- Filing Date
- 2024-08-09
- Publication Date
- 2025-07-17
AI Technical Summary
In existing automotive instrument systems, the transmission rate of UART and I2C communication methods is low, resulting in low data transmission efficiency and cannot meet the real-time requirements of instrument display.
The SPI communication protocol is adopted to design a full-duplex communication method, and a timeout retransmission mechanism and response detection mechanism are formulated within the protocol to ensure the stability and reliability of data transmission.
It realizes the efficiency and reliability of data transmission, ensures the normal display of the automotive instrument system, and uses the SPI communication protocol to stabilize data transmission between the MCU and the SOC, meets the real-time requirements, and does not crash after continuous operation for one month.
Smart Images

Figure CN2024111110_17072025_PF_FP_ABST
Abstract
Description
A communication method between MCU and SOC based on SPI communication protocol and protocol construction method Technical Field
[0001] The present application relates to the field of automotive SPI communication technology, and in particular to a method for communicating between an MCU and a SOC based on the SPI communication protocol and a method for constructing the SPI communication protocol. Background Art
[0002] Automotive instrument cluster systems often utilize an MCU + SOC architecture. The MCU receives CAN and hard-wired signals and determines the display results, while the SOC receives the results from the MCU and displays them. Therefore, ensuring the accuracy, reliability, and efficiency of data transmission between the MCU and SOC is crucial for ensuring proper instrument display.
[0003] Traditional instrument communication methods mostly use UART and I2C. UART communication data frames support a maximum of 9 bits of data, resulting in slow transmission speeds. In serial communication, sending a single character requires additional information bits, such as start, parity, and stop bits. These additional information bits are not valid information and constitute additional communication overhead. I2C also has a relatively low transmission rate.
[0004] Therefore, it is hoped that there will be a technical solution to solve or at least alleviate the above-mentioned deficiencies in the prior art.
[0005] Summary of the Invention
[0006] The object of the present invention is to provide a communication method between MCU and SOC based on the SPI communication protocol to at least solve one of the above technical problems.
[0007] One aspect of the present invention provides a method for communicating between an MCU and a SOC based on the SPI communication protocol, the method comprising:
[0008] The MCU and SOC establish an SPI communication system data path based on the SPI communication protocol;
[0009] The SOC end and the SOC end generate data according to the SPI communication protocol and send the data to each other.
[0010] Optionally, the data includes a heartbeat packet. When the data is a heartbeat packet and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:
[0011] The SOC generates and sends heartbeat packets to the MCU periodically based on the SPI communication protocol. The heartbeat packets include a LiveCounter field and the heartbeat message is sent in single mode.
[0012] The MCU side obtains the heartbeat packet and notifies the watchdog on the MCU side to update.
[0013] Optionally, when the data is a heartbeat packet and is uplink data, the MCU and SOC communication method based on the SPI communication protocol further includes:
[0014] When the MCU does not receive a valid heartbeat packet within the preset time, the SOC restart is triggered through EcuM.
[0015] Optionally, the data includes a periodic message. When the data is a periodic message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:
[0016] The MCU generates a periodic message to be sent according to the operation cycle, and the periodic message includes a LiveCounter field and a checksum field;
[0017] The MCU sends periodic messages to the SOC.
[0018] The SOC end receives the periodic message and verifies the LiveCounter field and the checksum field in the periodic message. If the verification is successful, the SOC end distributes the data.
[0019] Optionally, when the data is a periodic message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol further includes:
[0020] The SOC receives the periodic message and verifies the LiveCounter field and the checksum field in the periodic message. If the LiveCounter field verification fails or times out, the SOC communication process is restarted.
[0021] Optionally, when the data is a periodic message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:
[0022] The SOC receives the periodic message and checks the LiveCounter field and the checksum field in the periodic message. If the checksum is abnormal, the message data is discarded.
[0023] Optionally, the data includes an event-type message. When the data is an event-type message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:
[0024] The MCU generates an event message to be sent, which includes a LiveCounter field and a checksum field.
[0025] The MCU sends the event message to be sent to the SOC;
[0026] The SOC receives the event message and verifies the LiveCounter field and the checksum field in the event message. If the verification is successful, the SOC distributes the data.
[0027] Optionally, when the data is an event-type message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:
[0028] The SOC receives the event message and verifies the LiveCounter field and the checksum field in the event message. If the checksum field verification fails, the NACK data is recorded and inserted into the to-be-sent linked list.
[0029] Optionally, when the data is an event-type message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:
[0030] The SOC receives the event message and verifies the LiveCounter field and the checksum field in the event message. If the LiveCounter field verification fails, an exception is recorded.
[0031] The present application also provides an SPI communication protocol construction method for constructing an SPI communication protocol, wherein the SPI communication protocol is used for the MCU and SOC communication method based on the SPI communication protocol as described above, and the SPI communication protocol construction method includes:
[0032] Set up the interface, application layer, session layer, transport layer, data link layer, and driver layer;
[0033] Define the protocol format;
[0034] Design a state machine. Beneficial effects
[0035] The communication method adopted by the MCU and SOC communication method based on the SPI communication protocol of this application is SPI communication. The SPI protocol supports full-duplex communication and has the characteristics of simple communication and fast transmission rate. This application is based on the SPI communication method, designs the communication protocol within the protocol, and formulates a timeout retransmission mechanism and a response detection mechanism to ensure stable and reliable data transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] FIG1 is a flow chart of a method for communicating between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.
[0037] FIG2 is a schematic diagram of an uplink path establishment process of a communication method between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.
[0038] FIG3 is a schematic diagram of an abnormal flow of establishing an uplink path in a communication method between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.
[0039] FIG4 is a flow chart of a normal uplink heartbeat packet transmission process of the MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.
[0040] FIG5 is a flow chart of an uplink heartbeat packet process (abnormal) of a communication method between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.
[0041] FIG6 is a schematic diagram of an uplink periodic message generation process of a method for communicating between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.
[0042] FIG7 is a schematic diagram of an uplink periodic message sending process of a communication method between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.
[0043] FIG8 is a schematic diagram of an uplink periodic message triggering process of an MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.
[0044] FIG9 is a schematic diagram of an abnormal process of an uplink periodic message checksum in a method for communicating between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.
[0045] FIG10 is a schematic diagram of an abnormal LiveCounter process of an uplink periodic message in a method for communicating between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.
[0046] FIG11 is a schematic diagram of a TimeOut exception process of an uplink periodic message in a method for communicating between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.
[0047] FIG12 is a schematic diagram of the SOC-side distribution process of the uplink periodic message of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0048] FIG13 is a schematic diagram of the uplink event message generation process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0049] FIG14 is a schematic diagram of the uplink event message sending process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0050] FIG15 is a schematic diagram of an abnormal flow of an uplink event message checksum in a method for communicating between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.
[0051] FIG16 is a schematic diagram of an abnormal flow of an uplink event-type message LiveCounter in a method for communicating between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.
[0052] FIG17 is a schematic diagram of an abnormal flow of an uplink event-type message timeout in a method for communicating between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.
[0053] FIG18 is a schematic diagram of the SOC-side distribution process of the uplink event message of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0054] FIG19 is a schematic diagram of an uplink ACK data flow of an MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.
[0055] FIG20 is a schematic diagram of an uplink NACK data flow of an MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.
[0056] FIG21 is a schematic diagram of a process for generating periodic message downlink data in a method for communicating between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.
[0057] Figure 22 is a schematic diagram of the periodic message downlink data sending process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0058] Figure 23 is a schematic diagram of the abnormal process of the periodic message downlink data checksum of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0059] Figure 24 is a schematic diagram of the LiveCounter exception process of the downlink data periodic message of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0060] Figure 25 is a schematic diagram of the downlink data event message generation process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0061] Figure 26 is a schematic diagram of the downlink data event message sending process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0062] Figure 27 is a schematic diagram of the downlink data event message checksum exception process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0063] FIG28 is a schematic diagram of the LiveCounter exception flow of the downlink data event message of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0064] Figure 29 is a schematic diagram of the downlink data event type message timeout exception process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0065] Figure 30 is a schematic diagram of the downlink data ACK sending process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0066] Figure 31 is a schematic diagram of the downlink data NACK sending process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0067] Figure 32 is a schematic diagram of the MCU data sending process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0068] Figure 33 is a schematic diagram of the MCU data receiving process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.
[0069] FIG34 is a schematic diagram of data transmission between MCU and SOC in one embodiment of the present application.
[0070] Figure 35 is a schematic diagram of the protocol format definition in one embodiment of the present application.
[0071] Figure 36 is a schematic diagram of the state machine design in one embodiment of the present application. DETAILED DESCRIPTION
[0072] In order to make the purpose, technical solutions and advantages of the implementation of this application clearer, the technical solutions in the embodiments of this application will be described in more detail below in conjunction with the drawings in the embodiments of this application. In the drawings, the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions. The described embodiments are part of the embodiments of this application, not all of the embodiments. The embodiments described below with reference to the drawings are exemplary and are intended to be used to explain this application, and should not be understood as limitations on this application. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. The embodiments of this application are described in detail below in conjunction with the drawings.
[0073] FIG1 is a flow chart of a method for communicating between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.
[0074] The MCU and SOC communication method based on the SPI communication protocol as shown in Figure 1 includes:
[0075] The MCU and SOC establish an SPI communication system data path based on the SPI communication protocol;
[0076] The SOC end and the SOC end generate data according to the SPI communication protocol and send the data to each other.
[0077] The communication method adopted by the MCU and SOC communication method based on the SPI communication protocol of this application is SPI communication. The SPI protocol supports full-duplex communication and has the characteristics of simple communication and fast transmission rate. This application is based on the SPI communication method, designs the communication protocol within the protocol, and formulates a timeout retransmission mechanism and a response detection mechanism to ensure stable and reliable data transmission.
[0078] In this embodiment, the data includes a heartbeat packet. When the data is a heartbeat packet, the MCU and SOC communication method based on the SPI communication protocol includes:
[0079] The SOC generates and sends heartbeat packets to the MCU periodically based on the SPI communication protocol. The heartbeat packets include a LiveCounter field, and the heartbeat message is sent in single mode.
[0080] The MCU side obtains the heartbeat packet and notifies the watchdog on the MCU side to update.
[0081] In this embodiment, when the data is a heartbeat packet, the MCU and SOC communication method based on the SPI communication protocol further includes:
[0082] When the MCU does not receive a valid heartbeat packet within the preset time, the SOC restart is triggered through EcuM (state management).
[0083] In this embodiment, the data includes periodic messages. When the data is a periodic message, the MCU and SOC communication method based on the SPI communication protocol includes:
[0084] The MCU generates a periodic message to be sent according to the operation cycle, and the periodic message includes a LiveCounter field and a checksum field;
[0085] The MCU sends periodic messages to the SOC.
[0086] The SOC end receives the periodic message and verifies the LiveCounter field and the checksum field in the periodic message. If the verification is successful, the SOC end distributes the data.
[0087] In this embodiment, when the data is a periodic message, the MCU and SOC communication method based on the SPI communication protocol further includes:
[0088] The SOC receives the periodic message and verifies the LiveCounter field and the checksum field in the periodic message. If the LiveCounter field verification fails or times out, the SOC communication process is restarted.
[0089] In this embodiment, when the data is a periodic message, the MCU and SOC communication method based on the SPI communication protocol includes:
[0090] The SOC receives the periodic message and checks the LiveCounter field and the checksum field in the periodic message. If the checksum is abnormal, the message data is discarded.
[0091] In this embodiment, the data includes an event-type message. When the data is an event-type message, the MCU and SOC communication method based on the SPI communication protocol includes:
[0092] The MCU generates an event message to be sent, which includes a LiveCounter field and a checksum field.
[0093] The MCU sends the event message to be sent to the SOC;
[0094] The SOC receives the event message and verifies the LiveCounter field and the checksum field in the event message. If the verification is successful, the SOC distributes the data.
[0095] In this embodiment, when the data is an event-type message, the MCU and SOC communication method based on the SPI communication protocol includes:
[0096] The SOC receives the event message and verifies the LiveCounter field and the checksum field in the event message. If the checksum field verification fails, NACK (no response) data is recorded and inserted into the to-be-sent linked list.
[0097] In this embodiment, when the data is an event-type message, the MCU and SOC communication method based on the SPI communication protocol includes:
[0098] The SOC receives the event message and verifies the LiveCounter field and the checksum field in the event message. If the LiveCounter field verification fails, an exception is recorded.
[0099] The present application also provides an SPI communication protocol construction method for constructing an SPI communication protocol, wherein the SPI communication protocol is used for the MCU and SOC communication method based on the SPI communication protocol as described above, and the SPI communication protocol construction method includes:
[0100] Set up the interface, application layer, session layer, transport layer, data link layer, and driver layer;
[0101] Define the protocol format;
[0102] Design a state machine.
[0103] The present application is further described in detail below by way of examples. It should be understood that the examples do not constitute any limitation to the present application.
[0104] 34 , in this embodiment, the MCU and the SOC A-core communicate via the SPI communication system, and the MCU and the M-CORE communicate via UART.
[0105] See Figure 35, which is a use case diagram of the SPI communication protocol of the present application.
[0106] In this embodiment, the SPI communication protocol of the present application requires the setting of an interface, an application layer, a session layer, a transport layer, a data link layer, and a driver layer.
[0107] See Table 1 below:
[0108] Referring to FIG35 , the SPI communication protocol of the present application requires protocol format definition, and the specific definition is shown in FIG35 .
[0109] In this embodiment, the protocol format is specifically described as follows:
[0110] In this embodiment, the SPI communication protocol of this application requires a state machine design. For the specific design, see Figure 36.
[0111] In this embodiment, each state in the state machine shown in FIG36 is described as follows:
[0112] State transition description:
[0113] The communication protocol designed in this application ensures the stability of data transmission through a timeout retransmission mechanism and a response detection mechanism. To ensure stable and reliable data transmission, different processes are set between various levels. After verification by actual vehicle project, the communication method designed based on this protocol meets the real-time requirements and can ensure stable and error-free data transmission between the MCU and SOC. It can actually run continuously for one month without downtime, and its stability and accuracy meet the technical requirements.
[0114] In this embodiment, the MCU and SOC communication method based on the SPI communication protocol of the present application includes:
[0115] The MCU and SOC establish an SPI communication system data path based on the SPI communication protocol;
[0116] The SOC end and the SOC end generate data according to the SPI communication protocol and send the data to each other.
[0117] In this embodiment, data sent from the MCU end to the SOC A end is called uplink data, and data sent from the SOC A end to the MCU end is called downlink data.
[0118] In this embodiment, it is first necessary to establish an SPI communication system data path based on the SPI communication protocol between the MCU end and the SOC end.
[0119] In this embodiment, the communication system data path establishment process: communication interaction is established, which is initiated after the SOC-side service is started. The MCU-side responds to the handshake message in a single-sending mode, and does not require ACK (response) / NACK. LiveCounter / CheckSum and other communication mechanisms ensure that the handshake phase message is triggered by the MCU every 10ms. If there is no handshake response or the message does not match during the period, the message content is obtained again.
[0120] For the convenience of description, the following description will be made from the MCU side and the SOC side respectively.
[0121] Specifically, see Figure 2, which describes the MCU side:
[0122] The MCU_VehicleInterface (communication protocol interface on the MCU side) on the MCU side starts first and waits for the SOC side to start. After receiving the GPIO (chip IO pin interface) notification sent by the SOC side, it starts the communication mode, periodically obtains the A-Core on the SOC side, and determines whether a handshake message is obtained. If so, it sends a handshake response message to the A-Core on the SOC side, obtains the message sent by the SOC side, and determines whether the obtained message is a handshake completion message. If so, it determines that the handshake is completed and enters the normal communication state.
[0123] Refer to Figure 2, which describes the SOC side:
[0124] After the SOC is started, it sends a GPIO notification to the MCU and starts handshaking. The SOC sends a handshake message to the MCU, obtains the handshake response message sent by the MCU, and determines whether it is a handshake response. If so, it sends a handshake completion message and enters the normal communication state.
[0125] It is understandable that sometimes there may be abnormalities in the establishment of the uplink channel. At this time, the SOC service is started and the timing begins. If the handshake cannot be completed within 5 seconds, the service needs to be restarted and the handshake needs to be reinitiated. On the MCU side, the timing starts after the task is started. If the handshake cannot be completed within 10 seconds, the SOC communication service needs to be restarted and the handshake needs to be reinitiated.
[0126] See Figure 3, which describes the MCU side:
[0127] The MCU sets a timer to determine whether the handshake is completed within a preset time (e.g., 10 seconds). If not, the GPIO notifies the SOC to restart the communication service.
[0128] See Figure 3, which describes the SOC side:
[0129] The SOC sets a timer to determine whether the handshake is completed within a preset time (eg, 5 seconds). If not, the communication service is restarted.
[0130] In this embodiment, the data of the present application includes heartbeat packet data.
[0131] When it is heartbeat packet data, this application is as follows:
[0132] After communication is established, the SOC service sends heartbeat packets at a fixed interval (1s). Heartbeat packets must contain a LiveCounter field (0-0xF). Heartbeat messages are sent in single-transmission mode and do not require ACK / NACK, LiveCounter / CheckSum, or other communication mechanisms. LiveCounter errors in heartbeat packets do not require the link layer to log errors or restart.
[0133] Referring to FIG4 , in this embodiment, the MCU side is used for description:
[0134] When MCU_VehicleInterface is in normal communication state, it provides the communication state to the MCU watchdog and starts the communication mode. It periodically obtains the A-Core data of the SOC and determines whether the obtained A-Core data is a heartbeat packet. If so, it notifies the MCU watchdog and the MCU watchdog resets the timer.
[0135] Referring to FIG5 , in this embodiment, the SOC side is described as follows:
[0136] The A-Core of the SOC sends the normal communication status to the watchdog of the A-Core.
[0137] When the watchdog of the SOC's A-Core triggers the heartbeat message to be sent, the SOC's A-Core updates the LiveCounter field in the heartbeat packet and sends it to the MCU.
[0138] Referring to Figure 5 (when describing, only the differences from Figure 4 are described), in this embodiment, if the SPI communication system heartbeat packet process (abnormal), for example, the MCU end does not receive a valid heartbeat packet for 30s (no communication, or LiveCounter does not change), the SOC end is triggered to restart through EcuM.
[0139] In this embodiment, when the data is a periodic message and is uplink data, each MCU module calls the SPI communication system interface to update the periodic message data. The periodic message is a static fixed-size buffer, which is overwritten and filled after the interface is called. There is no need to determine whether the old data has been sent. The interface needs to implement data change judgment and interface call count management. The periodic message protocol needs to include a data change field and an interface call Counter field to confirm the calling relationship between the APP and this system.
[0140] See Figure 6, which describes the MCU side:
[0141] MCU_Modules (MCU module scheduling) periodically packages data and calls the data update interface according to the operating cycle;
[0142] MCU_VehicleInterface updates the interface call count counter and determines whether the data is the same as the last time. If not, it sets the data change flg to TRUE and updates the periodic message data buff and management data.
[0143] In this embodiment, periodic messages are periodically published according to a designed transmission cycle (static design). Periodic messages require two attributes: an initial transmission time and a periodic transmission time. During the first transmission, the initial transmission time is used as an indicator to determine whether the transmission cycle has been reached. After one transmission, it is reloaded to the periodic transmission time for rapid transmission of periodic messages at startup. Through static design, the transmission time intervals of each periodic message are averaged. When two or more periodic messages meet the issuance requirements at the same time, the transmission order is arbitrated based on the message ID. Unsent messages await the next scheduled transmission by the link layer. Internally, the SPI driver mirrors the release buffer (DI during data copying) during transmission to ensure that the data buffer is not updated during data transmission.
[0144] Referring to FIG7 , in this embodiment, the MCU side is used for description:
[0145] After establishing communication with the SOC, the MCU_VehicleInterface traverses the periodic message to confirm whether the sending cycle has been reached. If so, the checksum field in the data is updated, and the sorted data (periodic message) is sent to the A_Core of the SOC and the sending time and status are updated.
[0146] Referring to FIG7 , in this embodiment, the SOC side is used for description:
[0147] After the SOC obtains the periodic message, it performs data verification. If the verification is successful, the periodic data timing is reset and the first data distribution is performed.
[0148] In this embodiment, the SPI communication system uplink data transmission process (periodic message event triggering): periodic messages, for periodic messages with a larger period, are allowed to be set as periodic event types. After the event is triggered, it is treated as a cycle in the next transmission cycle, and the cycle timing is restarted after the transmission is completed.
[0149] See Figure 8. The content in Figure 8 is a combination of Figure 7 and Figure 6.
[0150] Referring to FIG9 , in this embodiment, when the checksum is abnormal, the message data is discarded.
[0151] In this embodiment, when LiveCounter is abnormal, the communication process on the SOC side is restarted.
[0152] Specifically, see FIG10 (only LiveCounter determination on the SOC side is described).
[0153] The SOC determines whether the LiveCounter has changed. If not, it determines whether the LiveCounter has no change record for more than 5 times. If so, it restarts.
[0154] The SOC determines whether the LiveCounter has changed. If so, it determines whether the change is less than 3 times. If not, it records the LiveCounter exception and repeats this judgment. If the LiveCounter exception is recorded more than 5 times, it restarts.
[0155] The SOC determines whether the LiveCounter has changed. If so, it determines whether the change is less than 3 times. If so, it determines that there is no abnormality in the LiveCounter and the data is valid.
[0156] Referring to FIG. 11 , in this embodiment, when a TimeOut exception occurs, a restart is performed.
[0157] Referring to FIG. 12 (only describing the parts different from FIG. 8 ), in this embodiment, when the SOC side performs the first data distribution, the VehicleInterface of the A_Core of the SOC side is distributed to the Modules of the A_Core of the SOC side through the inter-process communication mechanism.
[0158] In this embodiment, the data of this application includes event-type messages. When the data is an event-type message and is uplink data, after the communication interaction is established, each module calls the data update interface as needed and performs linked list management according to the attributes of each event message.
[0159] Referring to Figure 13, in this embodiment, the MCU-side modules call the data update interface according to the business logic. The MCU-side vehicle interface updates the interface call count counter to determine whether to overwrite unsent data. If so, it searches the pending data list for an event message with the same ID. If it determines that an event message with the same ID is pending, it updates the event message with the same ID in the list and updates the pending data list.
[0160] Referring to FIG14 , in this embodiment, the communication system uplink data transmission process (event-type message) is as follows:
[0161] Take the MCU side as an example:
[0162] After the VehicleInterface handshake on the MCU side is completed, it performs periodic detection and searches the to-be-sent linked list to determine whether there is data to be sent. If so, it updates the LiveCounter field and checksum field in the to-be-sent data, sends the sorted data (i.e., event-type message) to the SOC, and puts the message ID into the sent to-be-verified linked list.
[0163] Take the SOC side as an example:
[0164] The SOC verifies the LiveCounter field and the checksum field. If the verification is successful, the second data distribution is performed.
[0165] Referring to FIG. 15 (only describing the difference from FIG. 14 ), in this embodiment, if the checksum of the event-type message is abnormal, the checksum abnormality record NACK data is inserted into the to-be-sent linked list.
[0166] Refer to Figure 16 (only the differences from Figure 14 are described). In this embodiment, if the event-type message LiveCounter is abnormal, the SOC end determines whether the LiveCounter has changed. If not, it determines whether the LiveCounter has no change record for more than 5 times. If so, it restarts.
[0167] The SOC determines whether the LiveCounter has changed. If so, it determines whether the change is less than 3 times. If not, it records the LiveCounter exception and repeats this judgment. If the LiveCounter exception is recorded more than 5 times, it restarts.
[0168] The SOC determines whether the LiveCounter has changed. If so, it determines whether the change is less than 3 times. If so, it determines that there is no abnormality in the LiveCounter and the data is valid.
[0169] Referring to FIG. 17 , in this embodiment, when an ACK / NACK timeout exception occurs, a restart is performed.
[0170] 18 , in this embodiment, the SPI communication system uplink data A-CORE distributes data to other module processes (event-type messages).
[0171] 18 , in this embodiment, when the SOC side performs the second data distribution, the VehicleInterface of the A_Core of the SOC side is distributed to the Modules of the A_Core of the SOC side through the inter-process communication mechanism.
[0172] 19 , in this embodiment, the uplink data transmission process (ACK) of the SPI communication system is as follows:
[0173] Take the MCU side as an example:
[0174] Get the message type transmitted by the SOC end;
[0175] Determine whether there is an ACK response. If so, traverse the verification linked list to find the element with the same ID and remove the element from the linked list.
[0176] 20 , in this embodiment, the communication system uplink data transmission process (NACK) is as follows:
[0177] Take the MCU side as an example:
[0178] Get the message type transmitted by the SOC and determine whether a NACK response is obtained. If so, traverse the verification linked list to find the element with the same ID and update the retry count. If the retry count exceeds 3 times, restart the communication. If the retry count does not exceed 3 times, clear the element from the linked list and append it to the to-be-sent linked list.
[0179] Referring to Figures 21 to 30, in this embodiment, the above-mentioned periodic messages and event-type messages also include processes such as the sending and distribution of downlink data. The sending process is generally the same as that of uplink data, except that the sender and receiver are opposite to those of uplink data. For example, when the periodic message is uplink data, what the SOC side needs to do is done by the MCU side in downlink data, and what the MCU side does in uplink data is done by the SOC side in downlink data. For details, please refer to Figures 21 to 32.
[0180] Referring to FIG32 , in this embodiment, an MCU data transmission SOC is also included, specifically as follows:
[0181] Before sending a message, the checksum and livecounter must be added to the packet. Livecounter uses 4 bits, and each group uses a separate livecounter number. 0 is invalid, and 1 to 15 are valid. The numbering starts at 1 and is used in a circular manner.
[0182] The checksum uses 16 bits and the algorithm is the standard algorithm.
[0183] In addition, data needs to be sent repeatedly in a period of 10ms, and the Livecounter needs to be updated in each new period.
[0184] Referring to Figure 33, this embodiment also includes MCU data reception. Specifically, for data to be sent via SPI / UART, the received data is processed using an interrupt, and the data is moved from DMA to the system content. The message processing thread needs to process the data in a 10ms cycle.
[0185] This application designs and implements a complete communication protocol, which ensures the stability of data transmission by formulating a data priority mechanism, a timeout retransmission mechanism, and a response detection mechanism. In order to ensure stable and reliable data transmission, different processes are set between various levels. After verification by actual vehicle project, the communication method designed based on this protocol meets the real-time requirements and can ensure the stable transmission of data between MCU and SOC without errors. It can actually run continuously for one month without downtime, and its stability and accuracy meet the technical requirements.
[0186] This application designs and implements a communication message format, which includes a data header, message ID, message type, group ID, message communication count, trigger count, data length, and data packet CRC8 check algorithm.
[0187] This application clarifies the responsibilities and functions of each level through hierarchical division, so that each level can perform its duties without interfering with each other, so as to achieve stable data transmission.
[0188] This application ensures the stability and reliability of data transmission by establishing a data priority mechanism, a timeout retransmission mechanism, and a response detection mechanism to prevent problems such as instrument erroneous display caused by data transmission errors.
[0189] In addition, it is obvious that the word "comprising" does not exclude other units or steps. Multiple units, modules or devices recited in the device claims can also be implemented by one unit or the entire device through software or hardware.
[0190] Although the present invention has been described in detail above using general descriptions and specific embodiments, it will be apparent to those skilled in the art that modifications and improvements may be made based on the present invention. Therefore, such modifications and improvements, which do not depart from the spirit of the present invention, are intended to be within the scope of protection claimed herein.
Claims
1. A communication method between an MCU and an SOC based on the SPI communication protocol, characterized in that, The MCU and SOC communication method based on the SPI communication protocol includes: Establish a data path for the SPI communication system based on the SPI communication protocol between the MCU side and the SOC side; The SOC side and the SOC side generate data according to the SPI communication protocol and send data to each other.
2. The MCU and SOC communication method based on the SPI communication protocol according to claim 1, characterized in that, The data includes heartbeat packets. When the data is a heartbeat packet and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes: The SOC side generates and sends a heartbeat packet to the MCU side at a fixed period based on the SPI communication protocol. Among them, the heartbeat packet includes a LiveCounter field, and the heartbeat message is in a single-send mode; The MCU side obtains the heartbeat packet and notifies the watchdog of the MCU side to be updated.
3. The MCU and SOC communication method based on the SPI communication protocol according to claim 2, characterized in that, When the data is a heartbeat packet and is uplink data, the MCU and SOC communication method based on the SPI communication protocol further includes: When the MCU side does not receive a valid heartbeat packet within a preset time, trigger the SOC to restart through EcuM.
4. The MCU and SOC communication method based on the SPI communication protocol according to claim 3, characterized in that, The data includes periodic messages. When the data is a periodic message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes: The MCU side generates a periodic message to be sent periodically according to the running period. The periodic message includes a LiveCounter field and a checksum field; The MCU side sends the periodic message to the SOC side; The SOC side receives the periodic message and verifies the LiveCounter field and the checksum field in the periodic message. If the verification is successful, the SOC side performs data distribution.
5. The MCU and SOC communication method based on the SPI communication protocol according to claim 4, characterized in that, When the data is a periodic message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol further includes: The SOC side receives the periodic message and verifies the LiveCounter field and the checksum field in the periodic message. If the LiveCounter field verification fails or times out, restart the SOC communication process.
6. The MCU and SOC communication method based on the SPI communication protocol according to claim 5, characterized in that, When the data is a periodic message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes: The SOC side receives the periodic message and verifies the LiveCounter field and the checksum field in the periodic message. If the checksum is abnormal, discard the message data.
7. The MCU and SOC communication method based on the SPI communication protocol according to claim 6, characterized in that, The data includes event messages. When the data is an event message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes: The MCU side generates an event message to be sent. The event message includes a LiveCounter field and a checksum field; The MCU side sends the event message to be sent to the SOC side; The SOC side receives the event message and verifies the LiveCounter field and the checksum field in the event message. If the verification is successful, the SOC side performs data distribution.
8. The MCU and SOC communication method based on the SPI communication protocol according to claim 7, wherein, When the data is an event - type message and is uplink data, the communication method between the MCU and the SOC based on the SPI communication protocol includes: The SOC end receives the event - type message and verifies the LiveCounter field and the checksum field in the event - type message. If the checksum field verification fails, record the NACK data and insert it into the linked list to be sent.
9. The method for the MCU and the SOC to communicate based on the SPI communication protocol according to claim 8, wherein, When the data is an event - type message and is uplink data, the communication method between the MCU and the SOC based on the SPI communication protocol includes: The SOC end receives the event - type message and verifies the LiveCounter field and the checksum field in the event - type message. If the LiveCounter field verification fails, record the abnormality.
10. A method for constructing an SPI communication protocol, characterized in that, For constructing the SPI communication protocol, the SPI communication protocol is used for the communication method between the MCU and the SOC based on the SPI communication protocol as described in any one of claims 1 to 9. The method for constructing the SPI communication protocol includes: Set up the interface, application layer, session layer, transport layer, data link layer, and driver layer; Define the protocol format; Design the state machine.
Citation Information
Patent Citations
Data communication method and device, electronic equipment and storage medium
CN114640703A
Efficient and reliable communication method between double SOC
CN115801041A
MCU and SOC communication method based on SPI communication protocol and protocol construction method
CN117978785A
Apparatus and method for converting protocol by type of data and vehicle system
US20190132424A1