CN117978785A - MCU and SOC communication method based on SPI communication protocol and protocol construction method - Google Patents

MCU and SOC communication method based on SPI communication protocol and protocol construction method Download PDF

Info

Publication number
CN117978785A
CN117978785A CN202410024917.9A CN202410024917A CN117978785A CN 117978785 A CN117978785 A CN 117978785A CN 202410024917 A CN202410024917 A CN 202410024917A CN 117978785 A CN117978785 A CN 117978785A
Authority
CN
China
Prior art keywords
soc
mcu
data
communication protocol
spi communication
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410024917.9A
Other languages
Chinese (zh)
Inventor
徐雷
刘朝阳
马业轩
张明炀
迟桐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Faw Beijing Software Technology Co ltd
FAW Group Corp
Original Assignee
Faw Beijing Software Technology Co ltd
FAW Group Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Faw Beijing Software Technology Co ltd, FAW Group Corp filed Critical Faw Beijing Software Technology Co ltd
Priority to CN202410024917.9A priority Critical patent/CN117978785A/en
Publication of CN117978785A publication Critical patent/CN117978785A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/1066Session management
    • H04L65/1101Session protocols
    • H04L65/1104Session initiation protocol [SIP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session
    • H04L67/145Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Business, Economics & Management (AREA)
  • General Business, Economics & Management (AREA)
  • Multimedia (AREA)
  • Communication Control (AREA)

Abstract

The application discloses an MCU and SOC communication method based on SPI communication protocol and a protocol construction method. The MCU and SOC communication method based on the SPI communication protocol comprises the following steps: an SPI communication system data path based on an SPI communication protocol is established between the MCU end and the SOC end; and the SOC end generate data according to the SPI communication protocol and mutually send the data. The communication mode adopted by the MCU and SOC communication method based on the SPI communication protocol is SPI communication, the SPI protocol supports a full duplex communication mode, and the communication method based on the SPI communication protocol has the characteristics of simplicity in communication, high transmission rate and the like.

Description

MCU and SOC communication method based on SPI communication protocol and protocol construction method
Technical Field
The application relates to the technical field of SPI communication of automobiles, in particular to an MCU and SOC communication method based on an SPI communication protocol and an SPI communication protocol construction method.
Background
The automobile instrument system mostly adopts an MCU+SOC architecture, wherein the MCU side is responsible for receiving the CAN signal and the hard wire signal and judging the display result at the same time, and the SOC side receives the result of the MCU side and displays the result. Therefore, ensuring the accuracy, reliability and high efficiency of MCU and SOC data transmission is a key ring for ensuring the normal display of the instrument.
In the traditional instrument communication mode, UART and I2C are adopted, the maximum of UART communication data frames supports 9 bits of data, the transmission speed is slower, and in serial communication, additional information bits such as a start bit, a check bit, a stop bit and the like are needed for bit transmission of one character. These additional information bits are not the valid information itself, and belong to additional communication overhead. Meanwhile, the I2C also has the characteristic of low transmission rate.
It is therefore desirable to have a solution that solves or at least alleviates the above-mentioned drawbacks of the prior art.
Disclosure of Invention
The invention aims to provide an MCU and SOC communication method based on SPI communication protocol to at least solve one technical problem.
In one aspect of the present invention, there is provided an MCU and SOC communication method based on an SPI communication protocol, the MCU and SOC communication method based on an SPI communication protocol including:
an SPI communication system data path based on an SPI communication protocol is established between the MCU end and the SOC end;
and the SOC end generate data according to the SPI communication protocol and mutually send the data.
Optionally, the data includes a heartbeat packet, and when the data is the heartbeat packet and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:
the SOC end generates and sends a heartbeat packet to the MCU end based on the SPI communication protocol period, wherein the heartbeat packet comprises LiveCounter fields, and the heartbeat packet is in a single sending mode;
and the MCU end acquires the heartbeat packet and informs the watchdog of the MCU end to update.
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:
And triggering the SOC to restart through EcuM when the MCU end does not receive the effective heartbeat packet within the preset time.
Optionally, the data includes a periodic packet, and when the data is the periodic packet and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:
The MCU end periodically generates a periodic message to be sent according to the operation period, wherein the periodic message comprises LiveCounter fields and a checksum field;
the MCU end sends a periodic message to the SOC end;
And the SOC end receives the periodic message and checks LiveCounter fields and checksum fields in the periodic message, and if the check is successful, the SOC end distributes data.
Optionally, when the data is a periodic packet and is uplink data, the MCU and SOC communication method based on the SPI communication protocol further includes:
and the SOC end receives the periodic message and checks LiveCounter fields and a checksum field in the periodic message, and if LiveCounter fields fail to check or are overtime, the SOC communication process is restarted.
Optionally, when the data is a periodic packet and is uplink data, the method for communicating the MCU and the SOC based on the SPI communication protocol includes:
And the SOC end receives the periodic message and checks LiveCounter fields and checksum fields in the periodic message, and if the checksum is abnormal, the message data is discarded.
Optionally, the data includes an event type message, and when the data is the event type message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:
The method comprises the steps that an MCU end generates an event type message to be sent, wherein the event type message comprises LiveCounter fields and a checksum field;
the MCU end sends an event type message to be sent to the SOC end;
and the SOC receives the event type message, checks LiveCounter fields and checksum fields in the event type message, and distributes data if the check is successful.
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:
And the SOC end receives the event type message and checks LiveCounter fields and checksum fields in the event type message, and if the checksum fields fail to check, the NACK data is recorded and inserted into a linked list to be sent.
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:
and the SOC end receives the event type message and checks LiveCounter fields and checksum fields in the event type message, and if LiveCounter fields fail to check, the record is abnormal.
The application also provides an SPI communication protocol construction method, which is used 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, and the SPI communication protocol construction method comprises the following steps:
Setting an interface, an application layer, a session layer, a transmission layer, a data link layer and a driving layer;
Defining a protocol format;
The state machine is designed.
Advantageous effects
The communication mode adopted by the MCU and SOC communication method based on the SPI communication protocol is SPI communication, the SPI protocol supports a full duplex communication mode, and the communication method based on the SPI communication protocol has the characteristics of simplicity in communication, high transmission rate and the like.
Drawings
Fig. 1 is a flowchart of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 2 is a schematic diagram of an uplink path establishment flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 3 is a schematic diagram of an abnormal flow of uplink path establishment of the MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.
Fig. 4 is a flowchart illustrating a normal uplink heartbeat packet transmission procedure of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 5 is a flow chart of an uplink heartbeat packet flow (abnormal) situation of the MCU and SOC communication method based on the SPI communication protocol according to an embodiment of the present application.
Fig. 6 is a schematic diagram of an uplink periodic packet generation flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 7 is a schematic diagram of an uplink periodic packet transmission flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 8 is a schematic diagram of an uplink periodic message triggering flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 9 is a schematic diagram of an abnormal flow of an uplink periodic message checksum of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 10 is an abnormal flow diagram of an uplink periodic message LiveCounter of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 11 is a schematic diagram of an abnormal flow of an uplink periodic message TimeOut of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 12 is a schematic diagram of an uplink periodic message SOC end distribution flow of an MCU and SOC communication method based on an SPI communication protocol in an embodiment of the present application.
Fig. 13 is a schematic diagram of an uplink event type message generation flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 14 is a schematic diagram of an uplink event type message sending flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 15 is a schematic diagram of an abnormal flow of an uplink event message checksum of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 16 is an abnormal flow diagram of an uplink event message LiveCounter of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 17 is a schematic diagram of an abnormal flow of uplink event type message timeout in the communication method of the MCU and the SOC based on the SPI communication protocol in an embodiment of the present application.
Fig. 18 is a schematic diagram of an uplink event message SOC end distribution flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 19 is a schematic diagram of an uplink ACK data flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 20 is a schematic diagram of an uplink NACK data flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 21 is a schematic diagram of a periodic packet downstream data generation flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 22 is a schematic diagram of a periodic packet downstream data transmission flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 23 is a schematic diagram of a periodic packet downstream data checksum exception flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 24 is a schematic diagram of an abnormal flow of a downlink data periodic message LiveCounter of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 25 is a schematic diagram of a downlink data event type message generation flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 26 is a schematic diagram of a downlink data event type message sending process of the MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.
Fig. 27 is a schematic diagram of an abnormal flow of a downlink data event type message checksum of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 28 is a schematic diagram of an abnormal flow of a downlink data event message LiveCounter of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 29 is a schematic diagram of an abnormal flow of a downlink data event type message timeout in an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 30 is a schematic diagram of a downlink data ACK transmission flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 31 is a schematic diagram of a downlink data NACK transmission flow of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 32 is a schematic diagram of an MCU data transmission flow of an MCU-to-SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 33 is a schematic diagram of an MCU data receiving flow according to an MCU-to-SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
Fig. 34 is a schematic diagram of MCU and SOC data transmission according to an embodiment of the present application.
Fig. 35 is a schematic diagram of protocol format definition in an embodiment of the present application.
FIG. 36 is a schematic diagram of a state machine design in accordance with one embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application become more apparent, the technical solutions in the embodiments of the present application will be described in more detail below with reference to the accompanying drawings in the embodiments of the present application. In the drawings, the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The described embodiments are some, but not all, embodiments of the application. The embodiments described below by referring to the drawings are illustrative and intended to explain the present application and should not be construed as limiting the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application. Embodiments of the present application will be described in detail below with reference to the accompanying drawings.
Fig. 1 is a flowchart of an MCU and SOC communication method based on an SPI communication protocol according to an embodiment of the present application.
The MCU and SOC communication method based on the SPI communication protocol shown in FIG. 1 comprises the following steps:
an SPI communication system data path based on an SPI communication protocol is established between the MCU end and the SOC end;
and the SOC end generate data according to the SPI communication protocol and mutually send the data.
The communication mode adopted by the MCU and SOC communication method based on the SPI communication protocol is SPI communication, the SPI protocol supports a full duplex communication mode, and the communication method based on the SPI communication protocol has the characteristics of simplicity in communication, high transmission rate and the like.
In this embodiment, the data includes a heartbeat packet, and when the data is the heartbeat packet, the method for communicating the MCU and the SOC based on the SPI communication protocol includes:
The SOC end generates and sends a heartbeat packet to the MCU end based on the SPI communication protocol period, wherein the heartbeat packet comprises LiveCounter (counter) fields, and the heartbeat packet is in a single sending mode;
and the MCU end acquires the heartbeat packet and informs the watchdog of the MCU end to update.
In this embodiment, when the data is a heartbeat packet, the method for communicating the MCU and the SOC based on the SPI communication protocol further includes:
When the MCU end does not receive the effective heartbeat packet within the preset time, the SOC restart is triggered through EcuM (state management).
In this embodiment, the data includes a periodic packet, and when the data is a periodic packet, the MCU and SOC communication method based on the SPI communication protocol includes:
The MCU end periodically generates a periodic message to be transmitted according to the operation period, wherein the periodic message comprises LiveCounter fields and a checksum field;
the MCU end sends a periodic message to the SOC end;
And the SOC end receives the periodic message and checks LiveCounter fields and checksum fields in the periodic message, and if the check is successful, the SOC end distributes data.
In this embodiment, when the data is a periodic packet, the MCU and SOC communication method based on the SPI communication protocol further includes:
and the SOC end receives the periodic message and checks LiveCounter fields and a checksum field in the periodic message, and if LiveCounter fields fail to check or are overtime, the SOC communication process is restarted.
In this embodiment, when the data is a periodic packet, the method for communicating the MCU and the SOC based on the SPI communication protocol includes:
And the SOC end receives the periodic message and checks LiveCounter fields and checksum fields in the periodic message, and if the checksum is abnormal, the message data is discarded.
In this embodiment, the data includes an event type message, and when the data is an event type message, the MCU and SOC communication method based on the SPI communication protocol includes:
The method comprises the steps that an MCU end generates an event type message to be sent, wherein the event type message comprises LiveCounter fields and a checksum field;
the MCU end sends an event type message to be sent to the SOC end;
and the SOC receives the event type message, checks LiveCounter fields and checksum fields in the event type message, and distributes data if the check is successful.
In this embodiment, when the data is an event type message, the method for communicating the MCU and the SOC based on the SPI communication protocol includes:
And the SOC end receives the event type message and checks LiveCounter fields and a checksum field in the event type message, and if the checksum field fails to check, the NACK (non-response) data is recorded and inserted into a chain table to be sent.
In this embodiment, when the data is an event type message, the method for communicating the MCU and the SOC based on the SPI communication protocol includes:
and the SOC end receives the event type message and checks LiveCounter fields and checksum fields in the event type message, and if LiveCounter fields fail to check, the record is abnormal.
The application also provides an SPI communication protocol construction method, which is used 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, and the SPI communication protocol construction method comprises the following steps:
Setting an interface, an application layer, a session layer, a transmission layer, a data link layer and a driving layer;
Defining a protocol format;
The state machine is designed.
The application is described in further detail below by way of examples, which should not be construed as limiting the application in any way.
Referring to FIG. 34, in this embodiment, the MCU communicates with the SOC A-CORE via an SPI communication system, and the MCU communicates with the M-CORE using a UART.
Referring to fig. 35, fig. 35 is a diagram illustrating an SPI communication protocol according to the present application.
In this embodiment, the SPI communication protocol of the present application needs to set an interface, an application layer, a session layer, a transport layer, a data link layer, and a driver layer.
See table 1 below:
Referring to fig. 35, the SPI communication protocol of the present application requires protocol format definition, and the specific definition is shown in fig. 35.
In this embodiment, the protocol format is specifically described as follows:
in this embodiment, the SPI communication protocol of the present application requires a state machine design, and the specific design is shown in fig. 36.
In the present embodiment, each state in the state machine shown in fig. 36 is described as follows:
State transition description:
The communication protocol designed by the application ensures the stability of data transmission through a timeout retransmission mechanism and a response detection mechanism, different processes are set among all levels to ensure the stable and reliable transmission of the data, and the communication method designed based on the protocol meets the real-time requirement through the verification of actual vehicle type projects, can ensure the stable transmission of the data between the MCU and the SOC without errors, can realize continuous operation for one month without downtime, and meets the technical requirements on stability and accuracy.
In this embodiment, the communication method of the MCU and the SOC based on the SPI communication protocol includes:
an SPI communication system data path based on an SPI communication protocol is established between the MCU end and the SOC end;
and the SOC end generate data according to the SPI communication protocol and mutually send the data.
In this embodiment, the data sent from the MCU side to the SOC a side is referred to as uplink data, and the data sent from the SOC a side to the MCU side is referred to as downlink data.
In this embodiment, firstly, an SPI communication system data path based on an SPI communication protocol needs to be established between the MCU end and the SOC end.
In this embodiment, the communication system data path establishment flow: communication interaction is established, the communication interaction is initiated after the SOC end service is started, the MCU end responds to the handshake message to be in a single-sending mode, communication mechanisms such as ACK (acknowledgement)/NACK, liveCounter/CheckSum and the like are not needed to be carried out, the handshake phase message is triggered once by the MCU every 10ms, and message content acquisition is carried out again when no handshake acknowledgement exists or the messages are not matched.
For convenience of description, the following description will be made from the MCU side and the SOC side, respectively.
Specifically, referring to fig. 2, the description is made in terms of the MCU:
MCU_ VEHICLELNTERFACE (communication protocol interface of MCU) of MCU end starts and waits for SOC end to start at first, after receiving GPIO (chip IO pin interface) notice that the SOC end sent, start communication mode, obtain A-Core of SOC end periodically, judge whether obtain handshake message, if yes, send handshake response message to A-Core of SOC end, obtain the message that the SOC end sent, judge whether the message obtained is handshake completion message, if yes, judge handshake completion, enter the normal communication state.
Referring to fig. 2, described in terms of SOC end:
After the start of the SOC end is finished, the GPIO notification is sent to the MCU end and handshake starts, the SOC end sends a handshake message to the MCU end, acquires a handshake response message sent by the MCU end, judges whether the handshake response message is a handshake response, and if yes, sends a handshake completion message and enters a normal communication state.
It can be understood that the situation of abnormal uplink channel establishment may occur in some cases, at this time, the SOC service is started, timing is started, 5s cannot complete the handshake, service restart is required to be performed, handshake is restarted, the MCU side, timing is started after task start, 10s cannot complete the handshake, and SOC communication service restart is required to be performed, and handshake is restarted.
Referring to fig. 3, the description is made on the MCU side:
the MCU end sets a timer to judge whether handshake is completed within a preset time (for example, 10 seconds), if not, the GPIO informs the SOC end to restart the communication service.
Referring to fig. 3, described in SOC end:
And setting a timer at the SOC end, judging whether handshake is completed within a preset time (for example, 5 seconds), and restarting the communication service if not.
In this embodiment, the data of the present application includes heartbeat packet data.
In the case of heartbeat packet data, the application is specifically as follows:
After communication interaction is established, the SOC end service sends a heartbeat packet in a fixed period (1 s), the heartbeat packet needs to contain LiveCounter fields (0-0 xF), and the heartbeat packet is in a single-sending mode and does not need to be ensured by communication mechanisms such as ACK/NACK, liveCounter/CheckSum and the like. Heartbeat packet LiveCounter errors do not require error logging and restarting at the link layer.
Referring to fig. 4, in this embodiment, the MCU side is described as follows:
and when the MCU_ VEHICLELNTERFACE is in a normal communication state, providing a common communication state for the watchdog of the MCU, starting a communication mode, periodically acquiring the A-Core data of the SOC, judging whether the acquired A-Core data are heartbeat packets, if so, informing the watchdog of the MCU, and resetting a timer by the watchdog of the MCU.
Referring to fig. 5, in the present embodiment, description is made in terms of SOC end:
the A-Core of the SOC sends the normal communication status to the watchdog of the A-Core.
When the watchdog of the A-Core of the SOC sends a heartbeat message, the A-Core of the SOC updates LiveCounter fields in the heartbeat packet and sends the fields to the MCU.
Referring to fig. 5 (only the differences from fig. 4 are described in the description), in this embodiment, if the flow of heartbeat packets of the SPI communication system is abnormal, for example, when the MCU side 30s does not receive a valid heartbeat packet (no communication, or LiveCounter has no change), the SOC side is triggered to restart by EcuM.
In this embodiment, when the data is a periodic packet and is uplink data, each modules of the MCUs call the SPI communication system interface to update the data of the periodic packet, the periodic packet is a static fixed size buffer, and the interface is covered and filled after call, so that it is not necessary to determine whether the old data is sent to complete the data change determination in the interface, the interface call count management needs to include a data change field, and the interface call Counter field needs to be included in the periodic packet protocol, so as to confirm the call relationship between the APP and the system.
Referring to fig. 6, the description is made on the MCU side:
MCU_modules (MCU module scheduling) periodically packs data and invokes a data update interface according to the running period;
MCU VEHICLELNTERFACE updates the interface call number counter, judges whether the data is the same as the last time, if not, sets the data change flg as TRUE, and updates the periodic message data buff and the management data.
In this embodiment, the periodic message is issued (statically designed) in a fixed period according to a designed transmission period, and two attributes of an initial transmission time and a periodic transmission time are required for the periodic message, and when the periodic message is transmitted for the first time, the initial transmission time is used as an identifier for judging whether the transmission period is reached, and after the transmission is once, the heavy load is the periodic transmission time for quick transmission of the periodic message when the periodic message is started. Through static design, when two or more than two periodic messages meet the issuing requirement at the same time, the messages are not sent according to the message ID arbitration sending sequence, and when the link layer sends the next scheduling, SPI drives the inside, when sending, mirror image of the issuing buffer (DI when data copy) is needed, and the data buffer is ensured not to be updated in the data transmission process.
Referring to fig. 7, in this embodiment, the MCU side is described as follows:
After the MCU VEHICLELNTERFACE establishes communication with the SOC, traversing the periodic message to determine whether the periodic message reaches a transmission period, if so, updating a checksum field in the data, transmitting the tidied data (the periodic message) to an A_Core of the SOC, and updating the transmission time and the transmission state.
Referring to fig. 7, in the present embodiment, description is made in terms of SOC end:
After the SOC end acquires the periodic message, data verification is carried out, and if the verification is successful, the periodic data is reset in a timing way and the first data distribution is carried out.
In this embodiment, the SPI communication system uplink data transmission flow (periodic message event trigger): the periodic message is allowed to be set to be a periodic event type aiming at the periodic message with larger period, and after the event is triggered, the periodic message is treated as a period in the next transmission period, and the periodic timing is carried out again after the transmission is completed.
Referring to fig. 8, the contents of fig. 8 are the combination of fig. 7 and fig. 6.
Referring to FIG. 9, in the present embodiment, when the checksum is abnormal, the message data is discarded
In this embodiment, when LiveCounter is abnormal, the communication process of the SOC end is restarted.
Specifically, see fig. 10 (only the LiveCounter determination at the SOC end is described).
The SOC end determines LiveCounter whether there is a change, if not, determines LiveCounter whether there is no change record more than 5 times, if yes, restarts.
The SOC end determines LiveCounter whether there is a change, if yes, determines whether the change is less than 3 times, if no, records LiveCounter are abnormal, repeats this determination, and if records LiveCounter are abnormal more than 5 times, restarts.
The SOC end determines LiveCounter whether there is a change, if yes, determines whether the change is less than 3 times, if yes, determines LiveCounter that there is no abnormality, and the data is valid.
Referring to fig. 11, in the present embodiment, when a TimeOut anomaly occurs, a restart is performed.
Referring to fig. 12 (only the portions different from fig. 8 are described), in this embodiment, at the time of first data distribution, VEHICLELNTERFACE of the a_core of the SOC end is distributed to Modules of the a_core of the SOC end through an inter-process communication mechanism.
In this embodiment, the data of the present application includes event type messages, and when the data is event type messages and is uplink data, after communication interaction is established, each module invokes a data update interface according to the need, and performs linked list management according to the attribute of each event message.
Referring to fig. 13, in this embodiment, modules at the MCU end call the data update interface according to the service logic. And VEHICLELNTERFACE at the MCU end updates an interface calling number counter to judge whether to allow coverage of the unsent data, if so, searching the same ID event message in the data link list to be sent, and if so, updating the same ID event message in the link list and updating the data link list to be sent.
Referring to fig. 14, in this embodiment, the uplink data transmission flow (event type packet) of the communication system is specifically as follows:
Taking the MCU end as an example:
after VEHICLELNTERFACE handshakes at the MCU end are completed, the fixed period is detected, the to-be-transmitted linked list is searched, whether data are to be transmitted or not is judged, if yes, liveCounter fields and checksum fields in the to-be-transmitted data are updated, the tidied data (namely event type messages) are transmitted to the SOC, and the message ID is put into the transmitted to-be-verified linked list.
Taking the SOC end as an example:
And the SOC end checks the LiveCounter field and the checksum field, and if the check is successful, the second data distribution is performed.
Referring to fig. 15 (only the differences from fig. 14 are described), in this embodiment, if the event message checksum is abnormal, the checksum abnormal record NACK data is inserted into the linked list to be transmitted.
Referring to fig. 16 (only the differences from fig. 14 are described), in this embodiment, if the event message LiveCounter is abnormal, the SOC end determines LiveCounter whether there is a change, if not, determines LiveCounter whether there is no change record more than 5 times, and if yes, restarts.
The SOC end determines LiveCounter whether there is a change, if yes, determines whether the change is less than 3 times, if no, records LiveCounter are abnormal, repeats this determination, and if records LiveCounter are abnormal more than 5 times, restarts.
The SOC end determines LiveCounter whether there is a change, if yes, determines whether the change is less than 3 times, if yes, determines LiveCounter that there is no abnormality, and the data is valid.
Referring to fig. 17, in the present embodiment, when an ACK/NACK timeout abnormality occurs, a restart is performed.
Referring to fig. 18, in this embodiment, the SPI communication system distributes data to other module flows (event type messages) in the uplink data a-CORE.
Referring to fig. 18, in the present embodiment, at the time of the second data distribution, VEHICLELNTERFACE of the a_core of the SOC end is distributed to Modules of the a_core of the SOC end through an inter-process communication mechanism.
Referring to fig. 19, in the present embodiment, the SPI communication system uplink data transmission flow (ACK) is specifically as follows:
Taking the MCU end as an example:
acquiring a message type transmitted by an SOC (system on chip) end;
And judging whether an ACK response exists, if so, traversing the verification linked list to find out the element with the same ID, and clearing the element from the linked list.
Referring to fig. 20, in the present embodiment, a communication system uplink data transmission flow (NACK) is specifically as follows:
Taking the MCU end as an example:
and acquiring the message type transmitted by the SOC, judging whether NACK response is acquired, if so, traversing the band verification linked list to find out the elements with the same ID and updating the retry times, if the retry times are more than 3 times, restarting communication, and if the retry times are not more than 3 times, clearing the elements from the linked list and adding the elements to the linked list to be transmitted.
Referring to fig. 21 to 30, in this embodiment, the above-mentioned periodic packet and event packet simultaneously include the processes of sending and distributing downlink data, and the sending process is substantially the same as that of uplink data, except that the sender and the receiver are opposite to the uplink data, for example, when the periodic packet is on uplink data, the SOC end needs to do something on the MCU end when the downlink data is sent, and when the uplink data is sent, the MCU end does something on the SOC end is sent on the downlink data, and please refer to fig. 21 to 32 for details.
Referring to fig. 32, in this embodiment, the method further includes a MCU data transmission SOC, specifically as follows:
Prior to the message transmission, a Checksum Livecounter needs to be added to the packet. Wherein Livecounter uses 4 bits, each Group uses independent Livecounter numbers, 0 is invalid, 1-15 are valid, and the numbers start from 1 and are recycled.
The 16bit is used by Checksum and the algorithm is a standard algorithm.
In addition, the data needs to be repeatedly transmitted in 10ms periods, and each new period is updated Livecounter.
Referring to fig. 33, in this embodiment, the method further includes MCU data reception, specifically as follows: the data to be transmitted through the SPI/UART is processed and received in an interrupt mode, and the data is carried from the DMA to the system content. The message processing thread needs to process the data with a period of 10 ms.
The application designs and realizes a complete communication protocol, ensures the stability of data transmission by formulating a data priority mechanism, a timeout retransmission mechanism and a response detection mechanism, sets different processes among various levels for ensuring the stable and reliable transmission of data, meets the real-time requirement based on the communication method designed by the protocol through the verification of actual vehicle type project, can ensure the stable transmission of data between MCU and SOC without error, and can realize continuous operation for one month without downtime, and the stability and the accuracy meet the technical requirement.
The application designs and realizes a communication message format which comprises a data head, a message ID, a message type, a group ID, a message communication count, a trigger count, a data length and a data packet CRC8 checking algorithm.
The application defines the responsibilities and functions of each level through level division, so that each level has no interference with each other, and stable data transmission is achieved.
The application ensures the stability and reliability of data transmission by formulating a data priority mechanism, a timeout retransmission mechanism and a response detection mechanism. So as to prevent the problems of error display and the like of the instrument caused by data transmission errors.
Furthermore, it is evident that the word "comprising" does not exclude other elements or steps. A plurality of units, modules or means recited in the apparatus claims can also be implemented by means of software or hardware by means of one unit or total means.
While the invention has been described in detail in the foregoing general description and with reference to specific embodiments thereof, it will be apparent to one skilled in the art that modifications and improvements can be made thereto. Accordingly, such modifications or improvements may be made without departing from the spirit of the invention and are intended to be within the scope of the invention as claimed.

Claims (10)

1. The MCU and SOC communication method based on the SPI communication protocol is characterized by comprising the following steps of:
an SPI communication system data path based on an SPI communication protocol is established between the MCU end and the SOC end;
and the SOC end generate data according to the SPI communication protocol and mutually send the data.
2. The SPI communication protocol-based MCU and SOC communication method of claim 1, wherein the data includes a heartbeat packet, and when the data is a heartbeat packet and is uplink data, the SPI communication protocol-based MCU and SOC communication method includes:
the SOC end generates and sends a heartbeat packet to the MCU end based on the SPI communication protocol period, wherein the heartbeat packet comprises LiveCounter fields, and the heartbeat packet is in a single sending mode;
and the MCU end acquires the heartbeat packet and informs the watchdog of the MCU end to update.
3. The SPI communication protocol-based MCU and SOC communication method of claim 2, wherein when the data is a heartbeat packet and is uplink data, the SPI communication protocol-based MCU and SOC communication method further comprises:
And triggering the SOC to restart through EcuM when the MCU end does not receive the effective heartbeat packet within the preset time.
4. The method for communicating with an MCU and an SOC based on an SPI communication protocol according to claim 3, wherein the data includes a periodic message, and when the data is a periodic message and is uplink data, the method for communicating with an MCU and an SOC based on an SPI communication protocol includes:
The MCU end periodically generates a periodic message to be sent according to the operation period, wherein the periodic message comprises LiveCounter fields and a checksum field;
the MCU end sends a periodic message to the SOC end;
And the SOC end receives the periodic message and checks LiveCounter fields and checksum fields in the periodic message, and if the check is successful, the SOC end distributes data.
5. The method for communicating with an MCU and an SOC based on an SPI communication protocol according to claim 4, wherein when the data is a periodic message and is uplink data, the method for communicating with an MCU and an SOC based on an SPI communication protocol further comprises:
and the SOC end receives the periodic message and checks LiveCounter fields and a checksum field in the periodic message, and if LiveCounter fields fail to check or are overtime, the SOC communication process is restarted.
6. The method for communicating with an MCU and an SOC based on an SPI communication protocol according to claim 5, wherein when the data is a periodic message and is uplink data, the method for communicating with an MCU and an SOC based on an SPI communication protocol comprises:
And the SOC end receives the periodic message and checks LiveCounter fields and checksum fields in the periodic message, and if the checksum is abnormal, the message data is discarded.
7. The method for communicating with an MCU and an SOC based on an SPI communication protocol according to claim 6, wherein the data includes an event type message, and when the data is an event type message and is uplink data, the method for communicating with an MCU and an SOC based on an SPI communication protocol includes:
The method comprises the steps that an MCU end generates an event type message to be sent, wherein the event type message comprises LiveCounter fields and a checksum field;
the MCU end sends an event type message to be sent to the SOC end;
and the SOC receives the event type message, checks LiveCounter fields and checksum fields in the event type message, and distributes data if the check is successful.
8. The method for communicating with an MCU and an SOC based on an SPI communication protocol according to claim 7, wherein when the data is an event type message and is uplink data, the method for communicating with an MCU and an SOC based on an SPI communication protocol comprises:
And the SOC end receives the event type message and checks LiveCounter fields and checksum fields in the event type message, and if the checksum fields fail to check, the NACK data is recorded and inserted into a linked list to be sent.
9. The method for communicating with an MCU and an SOC based on an SPI communication protocol according to claim 8, wherein when the data is an event type message and is uplink data, the method for communicating with an MCU and an SOC based on an SPI communication protocol comprises:
and the SOC end receives the event type message and checks LiveCounter fields and checksum fields in the event type message, and if LiveCounter fields fail to check, the record is abnormal.
10. A method for constructing an SPI communication protocol for use in the MCU and SOC communication method based on the SPI communication protocol according to any one of claims 1 to 9, the method comprising:
Setting an interface, an application layer, a session layer, a transmission layer, a data link layer and a driving layer;
Defining a protocol format;
The state machine is designed.
CN202410024917.9A 2024-01-08 2024-01-08 MCU and SOC communication method based on SPI communication protocol and protocol construction method Pending CN117978785A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410024917.9A CN117978785A (en) 2024-01-08 2024-01-08 MCU and SOC communication method based on SPI communication protocol and protocol construction method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410024917.9A CN117978785A (en) 2024-01-08 2024-01-08 MCU and SOC communication method based on SPI communication protocol and protocol construction method

Publications (1)

Publication Number Publication Date
CN117978785A true CN117978785A (en) 2024-05-03

Family

ID=90850788

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410024917.9A Pending CN117978785A (en) 2024-01-08 2024-01-08 MCU and SOC communication method based on SPI communication protocol and protocol construction method

Country Status (1)

Country Link
CN (1) CN117978785A (en)

Similar Documents

Publication Publication Date Title
EP0374134B1 (en) Local area network for digital data processing system
US4975904A (en) Local area network for digital data processing system including timer-regulated message transfer arrangement
US4823122A (en) Local area network for digital data processing system
US5754754A (en) Transmission order based selective repeat data transmission error recovery system and method
US4975905A (en) Message transmission control arrangement for node in local area network
US5432798A (en) Data communication method and system
US10348616B2 (en) Packet transmission method and apparatus, and interconnect interface
JP2002542662A (en) Flexible radio link control protocol
JPH1079097A (en) Mobile object communication method
CN113986501B (en) Real-time database API (application program interface) interrupt-free calling method, system, storage medium and server
JPH09160858A (en) Data resending method and server
CN101087171A (en) A method and system of transmission control of wireless link
EP1580916A2 (en) System and method for transmitting units of messages in a mobile communication system
CN117978785A (en) MCU and SOC communication method based on SPI communication protocol and protocol construction method
CN115328840A (en) System and method for dual-interface self-adaptive data communication between master MCU and slave MCU
JPS6072351A (en) Method for supervising operating condition of packet communication system
JPH114259A (en) Virtual connection communication equipment and communication method
US20230112796A1 (en) Method and apparatus of reporting automatic repeat request status in a communication system
CN116743324B (en) Data transmission method, device, receiving end, storage medium, system and server
CN114158067B (en) Method and device for data transmission in private network
JP3217397B2 (en) Data transmission method of communication control device
JPH05334104A (en) Data control device in datagram type inter-multiprocessor socket communication
JP2004260562A (en) Method and device for transmitting and receiving packet
JPH0830523A (en) Method for communicating on-line message
JPH09326782A (en) Serial communication method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination