SPI communication fault diagnosis method, SPI communication device, and storage medium
By sending communication diagnosis instructions and obtaining fault diagnosis data in the SPI communication system, the problem of low fault diagnosis coverage in the SPI communication system is solved, high coverage and high reliability communication is achieved, and is suitable for applications that do not have CRC verification capabilities. equipment, reducing costs.
Patent Information
- Application Number
- PCT/CN2024/078573
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-28
- Filing Date
- 2024-02-26
- Publication Date
- 2024-09-06
AI Technical Summary
In the existing SPI communication system, many peripherals, power management chips, sensors and other equipment lack CRC verification capabilities, resulting in low SPI communication fault diagnosis coverage and insufficient communication reliability. Especially in safety-related products, it is difficult to meet functional safety requirements.
By sending communication diagnosis instructions between the master device and the slave device, fault diagnosis data is obtained, communication fault information is determined, fault diagnosis of SPI communication is realized, fault diagnosis coverage and communication reliability are improved, without the need to configure a hardware CRC controller or software CRC check to reduce costs.
Fault diagnosis can be performed at each SPI communication stage, improving the fault diagnosis coverage and reliability of SPI communication. It is suitable for SPI communication interfaces without CRC verification capabilities, reducing costs, and can diagnose permanent and transient faults at the same time.
Smart Images

Figure CN2024078573_06092024_PF_FP
Abstract
Description
SPI communication fault diagnosis method, SPI communication device and storage medium
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on February 28, 2023, with application number 202310230236.3 and entitled “Diagnostic Method for SPI Communication Failure and SPI Communication Device and Storage Medium,” the entire contents of which are incorporated by reference into this application. Technical Field
[0003] The present application relates to the field of communication technology, and in particular to a method for diagnosing SPI (Serial Peripheral Interface) communication failure, an SPI communication device, and a computer-readable storage medium. Background Art
[0004] As embedded systems increasingly demand more reliable communications, especially for safety-related products, a high level of fault diagnosis coverage is required to meet functional safety requirements. For SPI communication, a small number of chips can achieve high diagnostic coverage through CRC (Cyclic Redundancy Check) verification. This is typically achieved by integrating CRC verification hardware circuitry within the chip or by implementing CRC verification through software programming. However, adding hardware circuitry leads to increased costs, and software programming methods are generally only feasible for master control chips. Therefore, most peripherals, power management chips, dedicated driver chips, or slave devices such as sensors do not have the ability to perform CRC verification, and either have no communication verification or only simple parity checking.
[0005] Therefore, how to improve the fault diagnosis coverage of this type of SPI communication to improve communication reliability has become an urgent problem to be solved.
[0006] Summary of the Invention
[0007] The present application aims to solve at least one of the technical problems existing in the prior art. To this end, the first object of the present application is to propose a method for diagnosing SPI communication faults, which can improve the fault diagnosis coverage of SPI communication and enhance communication reliability.
[0008] The second objective of this application is to provide another method for diagnosing SPI communication failures.
[0009] The third object of this application is to provide another method for diagnosing SPI communication failures.
[0010] The fourth objective of this application is to provide an SPI master device.
[0011] A fifth objective of this application is to provide a computer-readable storage medium.
[0012] In order to achieve the above-mentioned purpose, the method for diagnosing SPI communication faults in the first aspect embodiment of the present application is used for a master device, and the method includes: sending a communication diagnostic instruction corresponding to the communication status to the slave device based on the communication status between the master device and the slave device; obtaining fault diagnosis data associated with the slave device; and determining communication fault information between the master device and the slave device based on the fault diagnosis data.
[0013] According to the method for diagnosing SPI communication faults in an embodiment of the present application, a corresponding communication diagnostic instruction is sent to the slave device according to the communication status between the master and slave devices, and communication fault information between the master and slave devices is diagnosed according to the fault diagnostic data associated with the slave device. Fault diagnosis can be performed at each SPI communication stage, thereby improving fault diagnosis coverage and communication reliability. There is no need to configure a hardware CRC controller or software CRC check on the SPI communication device, and the cost is low.
[0014] In some embodiments, the communication status includes a status where no communication data transmission is performed between the master device and the slave device for more than a preset time, a status where the master device sends communication data to the slave device, and a status where the master device receives communication data sent by the slave device.
[0015] In some embodiments, based on the communication status between the master device and the slave device, a communication diagnostic instruction corresponding to the communication status is sent to the slave device, including: if no communication data transmission is performed between the master device and the slave device for more than a preset time, the master device sends a read instruction to the slave device to read the characteristic identification value of the slave device according to the fault diagnosis cycle, so as to obtain the characteristic identification value fed back by the slave device as fault diagnosis data.
[0016] In some embodiments, the characteristic identification value of the slave device includes a configuration value or a preset identification value of the slave device.
[0017] In some embodiments, based on the communication status between the master device and the slave device, a communication diagnostic instruction corresponding to the communication status is sent to the slave device, including: when the master device sends communication data to the slave device, a communication diagnostic instruction corresponding to the communication status is sent to the slave device, and the communication diagnostic instruction is used to obtain readback verification information corresponding to the communication data.
[0018] In some embodiments, obtaining fault diagnostic data associated with the slave device includes: when the master device obtains the readback verification information, using the readback verification information as the fault diagnostic data; and when the master device fails to obtain the readback verification information, obtaining the working status information of the component acted upon by the slave device as the fault diagnostic data.
[0019] In some embodiments, based on the fault diagnosis data, the communication fault information between the master device and the slave device is determined, including: comparing the fault diagnosis data with a target value; if the fault diagnosis data is inconsistent with the target value, determining that there is a communication fault between the master device and the slave device; and if the fault diagnosis data is consistent with the target value, determining that the communication between the master device and the slave device is normal.
[0020] In some embodiments, based on the communication status between the master device and the slave device, a communication diagnostic instruction corresponding to the communication status is sent to the slave device, including: when the master device receives the target data sent by the slave device, a communication diagnostic instruction corresponding to the communication status is sent to the slave device, and the communication diagnostic instruction is used to use the same target data obtained multiple times as the fault diagnosis data.
[0021] In some embodiments, based on the fault diagnosis data, the communication fault information between the master device and the slave device is determined, including: if the same target data of the slave device read multiple times are inconsistent, it is determined that there is a communication failure between the master device and the slave device; if the same target data of the slave device read multiple times are consistent, it is determined that the communication between the master device and the slave device is normal.
[0022] In some embodiments, if the fault diagnosis data is not obtained within a preset communication time, it is determined that there is a communication failure between the master device and the slave device.
[0023] In some embodiments, determining the communication fault information between the master device and the slave device includes: recording the number of times the communication fault between the master device and the slave device is diagnosed; if the number reaches a fault number threshold, determining that there is a communication fault between the master device and the slave device.
[0024] A second aspect embodiment of the present application proposes a method for diagnosing an SPI communication fault, which is applied to a slave device, including: receiving a communication diagnostic instruction sent by a master device, wherein the communication diagnostic instruction corresponds to the communication status between the master device and the slave device; and the slave device feeds back fault diagnostic data to the master device according to the communication diagnostic instruction, so that the master device determines the communication fault information between the slave device and the master device based on the fault diagnostic data.
[0025] According to the SPI communication fault diagnosis method of the embodiment of the present application, the slave device feeds back fault diagnosis data to the master device according to the communication diagnosis instruction sent by the master device based on the communication status of the master-slave device, so that the master device performs communication fault diagnosis between the master and slave devices. Communication fault diagnosis can be performed under different communication states, thereby improving fault diagnosis coverage and improving the reliability of communication between the master and slave devices.
[0026] In some embodiments, the communication status includes a status where no communication data transmission is performed between the master device and the slave device for more than a preset time, a status where the master device sends communication data to the slave device, and a status where the master device receives communication data sent by the slave device.
[0027] In some embodiments, the slave device feeds back fault diagnosis data to the master device according to the communication diagnostic instruction, including at least one of the following: feeding back the characteristic identification value of the slave device to the master device; feeding back readback verification information corresponding to the communication data sent by the master device to the master device; and feeding back the same target data to the master device multiple times.
[0028] In some embodiments, the characteristic identification value of the slave device includes a configuration value or a preset identification value of the slave device.
[0029] In a third aspect, an embodiment of the present application proposes a method for diagnosing an SPI communication fault, comprising: a master device sending a communication diagnostic instruction corresponding to the communication status to a slave device based on the communication status between the master device and the slave device; the slave device feeding back fault diagnostic data to the master device based on the communication diagnostic instruction; and the master device determining communication fault information between the master device and the slave device based on the fault diagnostic data.
[0030] According to the SPI communication fault diagnosis method of the embodiment of the present application, the master device feeds back fault diagnosis data to the master device based on the communication diagnosis instruction sent based on the communication status of the master and slave devices, and the slave device feeds back the associated fault diagnosis data. The master device performs communication fault diagnosis on the master and slave devices. Communication fault diagnosis can be performed under different communication states, thereby improving fault diagnosis coverage and improving the reliability of communication between the master and slave devices.
[0031] In order to achieve the above-mentioned purpose, the SPI communication device of the second embodiment of the present application includes: a processor; and a memory communicatively connected to the processor; the memory stores a computer program executable by the processor, and when the processor executes the computer program, the SPI communication fault diagnosis method is implemented.
[0032] According to the SPI communication device of the embodiment of the present application, the SPI communication fault diagnosis method of the above embodiment is executed by a processor, a communication diagnosis instruction is sent to the slave device based on the communication status of the master and slave devices, and fault diagnosis is performed according to the fault diagnosis data. Fault diagnosis can be performed at each SPI communication stage, and the fault diagnosis coverage rate is high, which improves the communication reliability. In addition, the SPI communication device, such as the SPI master device, or various slave devices that perform SPI communication with the SPI master device, does not need to add a hardware CRC controller or software CRC check, and the cost is low.
[0033] The third aspect of the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the method for diagnosing SPI communication failure when executed.
[0034] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become obvious from the description below, or will be learned through practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0036] FIG1 is a flow chart of a method for diagnosing an SPI communication failure according to an embodiment of the present application;
[0037] FIG2 is a flow chart of a process for diagnosing a permanent SPI communication fault according to an embodiment of the present application;
[0038] FIG3 is a flow chart of a diagnostic process for an SPI communication transient fault according to an embodiment of the present application;
[0039] FIG4 is a flow chart of a method for diagnosing an SPI communication failure according to an embodiment of the present application;
[0040] FIG5 is a flow chart of a method for diagnosing an SPI communication failure according to an embodiment of the present application;
[0041] FIG6 is a block diagram of an SPI communication device according to an embodiment of the present application. DETAILED DESCRIPTION
[0042] The following describes in detail embodiments of the present application, and the embodiments described with reference to the accompanying drawings are exemplary.
[0043] Fault diagnosis coverage is a mandatory indicator of functional safety standards. If SPI communication is safety-related, it must meet the corresponding diagnostic coverage requirements. To address the low fault diagnosis coverage and reliability issues of SPI communication without CRC verification capabilities, the present invention proposes a new SPI communication fault diagnosis method that can diagnose permanent and transient SPI communication faults, improve fault diagnosis coverage, and enhance the safety and reliability of SPI communication.
[0044] The following describes a method for diagnosing an SPI communication fault according to an embodiment of the first aspect of the present application with reference to FIG1 to FIG5 .
[0045] SPI is a master-slave synchronous serial communication interface specification used for short-distance communication. It is widely used for communication between master and slave devices in embedded systems. In embodiments, the master device includes, for example, a main control chip, and the slave devices include, for example, peripherals, power management chips, dedicated driver chips, and sensors. The method for diagnosing SPI communication faults in the embodiments of the present application can be applied to SPI communication interfaces that do not have CRC verification capabilities.
[0046] Figure 1 is a flow chart of a method for diagnosing an SPI communication fault according to an embodiment of the present application. As shown in Figure 1 , the method of the embodiment of the present application includes the following steps S1-S3, and the method can be used on the master device side.
[0047] S1, according to the communication status between the master device and the slave device, sending a communication diagnostic instruction corresponding to the communication status to the slave device.
[0048] Among them, in some embodiments, the communication status between the master device and the slave device may include but is not limited to a state in which no communication data transmission is performed between the master device and the slave device for more than a preset time, a state in which the master device sends communication data to the slave device, and a state in which the master device receives communication data sent by the slave device.
[0049] That is, in an embodiment of the present application, considering the state in which the master device sends data to the slave device, receives data fed back by the slave device, and the state in which the master and slave devices time out and do not send or receive data, communication diagnostic instructions are sent to the slave device in a targeted manner, and different feedback information related to the slave device can be obtained for different communication states, so that the communication status diagnosis between the master and slave devices can be performed at different communication stages.
[0050] In an embodiment, sending an SPI communication diagnostic instruction can be the master device actively sending SPI communication data, based on which the slave device can respond and feed back SPI data; or when performing fault diagnosis, the master device actively sends a read instruction, such as reading target data or reading status detection data of a detection device of the slave device.
[0051] S2, obtaining fault diagnosis data associated with the slave device.
[0052] In an embodiment, the fault diagnostic data associated with a slave device may include relevant information directly fed back by the slave device in response to a communication diagnostic instruction, or it may include operating status detection information from other modules in response to a communication diagnostic instruction sent by the master device. For example, if communication between the master and slave devices times out and no communication occurs, there may be a fault between the master and slave devices, and the master device may not be able to receive the data directly fed back by the corresponding slave device. In this case, the operating detection information of the external device can serve as the fault diagnostic data associated with the slave device. It is understood that the external device is linked to the operation of the slave device.
[0053] S3, determining communication fault information between the master device and the slave device according to the fault diagnosis data.
[0054] Specifically, in SPI fault diagnosis mode, the master device can send a communication diagnostic instruction corresponding to the communication status of the master-slave device to the slave device to obtain fault diagnostic data associated with the corresponding slave device. This fault diagnostic data is identifiable data. By performing timeout detection on the identifiable data associated with the slave device and comparing the identifiable data of the slave device with a target value, a permanent fault between the master and slave devices can be diagnosed. In this case, the fault diagnostic data may be empty or contain a preset fault code. Permanent faults may include SPI communication faults such as a master device transmission failure, a slave device feedback failure, or an inability to transmit or receive data between the master and slave devices or abnormal data transmission and reception.
[0055] Alternatively, when SPI communication is performed between the master device and the slave device, the master device can send a communication diagnostic instruction to the slave device to obtain fault diagnostic data associated with the corresponding slave device, and then diagnose a transient communication fault between the master device and the slave device based on whether the fault diagnostic data associated with the slave device is obtained and whether the obtained fault diagnostic data associated with the slave device is consistent with the target value and a communication timeout detection is performed, wherein the transient communication fault may include a fault when the master and slave devices perform conventional SPI communication.
[0056] In the embodiment, at each SPI communication stage, the master device can read the corresponding slave device side SPI communication data, and then diagnose whether there is an SPI communication fault between the master and slave devices based on the read data, with high fault diagnosis coverage.
[0057] According to the method for diagnosing SPI communication faults in an embodiment of the present application, by sending corresponding communication diagnostic instructions to the slave device according to the communication status between the master and slave devices, and diagnosing communication fault information between the master device and the slave device according to the fault diagnosis data associated with the slave device, fault diagnosis can be performed at each SPI communication stage, such as diagnosing permanent faults or transient faults, with high fault diagnosis coverage, no need to configure the SPI communication device with a hardware CRC controller or software CRC check, and low cost.
[0058] In the example, when the master and slave devices can send and receive SPI communication data normally, the fault diagnosis data associated with the slave device can be compared with the target value. If it is determined that the fault diagnosis data is inconsistent with the target value, it is determined that there is an SPI communication fault between the master device and the slave device; or, if it is determined that the fault diagnosis data is consistent with the target value, it is determined that the SPI communication between the master device and the slave device is normal.
[0059] In other embodiments, communication timeout diagnosis can also be performed to record the SPI communication data sending and receiving time of the master and slave devices. If the SPI communication data obtained on the slave device side exceeds the preset SPI communication time, it is empty, that is, the master and slave devices cannot send and receive data normally. For example, the data sent by the master device cannot reach the slave device, or the data fed back by the slave device cannot reach the master device, then it is determined that there is an SPI communication failure between the master device and the slave device.
[0060] In an embodiment of the present application, the SPI communication fault diagnosis method of the present application can diagnose both permanent SPI communication faults during data transmission and reception between master and slave devices, and transient SPI communication faults during transient communication between master and slave devices. Specifically, permanent SPI communication faults can be diagnosed based on test mode verification methods and timeout detection; and transient SPI communication faults can be diagnosed using methods such as information redundancy, information readback, and timeout detection. This achieves high diagnostic coverage for SPI communication faults without requiring additional hardware or costs.
[0061] In some embodiments, fault diagnostic data associated with a slave device includes a characteristic identification value fed back by the slave device. As the name implies, the characteristic identification value fed back by the slave device can be used to identify the configuration or inherent data of the slave device and the slave device from which the data originated. If the characteristic identification value fed back by the slave device is obtained, it is assumed that the SPI communication between the master and slave devices is smooth and there is no permanent fault.
[0062] Furthermore, in some embodiments, the characteristic identification value fed back by the slave device may include a configuration value or a preset identification value of the slave device. The preset identification value may be a characteristic value of the slave device known to the master device. Specifically, the configuration value or known characteristic value of the slave device is obtained and used to perform communication timeout detection or compare the value with a target value to diagnose whether a permanent fault exists between the master and slave devices.
[0063] In an embodiment, if no communication data transmission is performed between the master device and the slave device for more than a preset time, the master device sends a read instruction to the slave device to read the characteristic identification value of the slave device according to the fault diagnosis cycle to obtain the characteristic identification value fed back by the slave device as fault diagnosis data.
[0064] Specifically, the characteristic identification value of the slave device is compared with the target identification value of the slave device to obtain a first comparison result, and communication fault information between the master device and the slave device is diagnosed based on the first comparison result. For example, if it is determined that the slave device identification value is inconsistent with the target identification value of the slave device, that is, the master device reads an incorrect return value, then there is a permanent SPI communication fault between the master device and the slave device. Alternatively, if it is determined that the slave device identification value is consistent with the target identification value of the slave device, then the SPI communication between the master device and the slave device is normal.
[0065] In some embodiments, communication timeout detection can also be performed based on fault diagnosis data associated with the slave device. If the slave device identification value obtained after the first communication duration is empty, that is, if the fault diagnosis data associated with the slave device, such as the identification value, is not obtained after the first communication duration, it is determined that there is a permanent SPI communication fault between the master device and the slave device. For example, it is believed that the communication diagnosis instruction sent by the master device did not reach the slave device, that is, the master device transmission fault; or the slave device characteristic identification value fed back by the slave device did not reach the master device, that is, the slave device transmission fault; or both the master and slave devices have data transmission and reception faults, etc.
[0066] For example, common SPI slave devices such as peripherals, power management chips, sensors, and dedicated drivers typically require configuration by the master device during power-up initialization. These devices often have fixed values, such as specific product numbers, operating modes, and default parameters. Therefore, periodic fault diagnosis for permanent SPI communication failures can be achieved by having the master device read the slave device's configuration values or characteristic values, such as the known values mentioned above, at regular intervals and compare them with target values. If the comparison results are inconsistent, a fault is confirmed.
[0067] During implementation, the fault diagnosis cycle can be set based on the product's functional fault detection interval requirements. The fault diagnosis function is called within each diagnostic cycle. Communication timeout detection can be added during data reception to cover faults such as communication device loss, message loss, and unacceptable message delays.
[0068] FIG2 is a flow chart of a process for diagnosing a permanent fault in SPI communication according to an embodiment of the present application. As shown in FIG2 , the process includes the following steps S101 - S105 .
[0069] S101, after entering the fault diagnosis function, the SPI communication master device reads the configuration value or known value of the slave device.
[0070] S102, performing communication timeout detection during data reading, if the communication times out, proceeding to step S105, if the communication does not time out, proceeding to step S103.
[0071] S103, compare the readback value with the target value. If the readback value is consistent with the target value, go to step S104, otherwise go to step S105.
[0072] S104, verification passed.
[0073] S105, fault handling procedure.
[0074] The above is an embodiment of diagnosing a permanent SPI communication fault between a master and a slave device according to an embodiment of the present application. In other embodiments, the method of the embodiment of the present application can also diagnose a transient SPI communication fault between a master and a slave device, that is, perform fault diagnosis during the SPI communication process between the master and the slave device.
[0075] In some embodiments, for transient SPI communication faults, i.e., transient faults during real-time system communication, different processing can be performed for data transmission and reception. When an SPI master device sends SPI data to a slave device, a corresponding diagnostic solution can be selected based on whether the transmitted data can be read back or confirmed by the slave device.
[0076] Specifically, when the master device sends communication data to the slave device, it sends a communication diagnostic instruction corresponding to the communication status to the slave device. The communication diagnostic instruction is used to obtain readback verification information corresponding to the communication data. In other words, if the transmitted data can use data readback or status flags as feedback, when the master device obtains the readback verification information, it uses the readback verification information as fault diagnosis data and compares the readback data or status value with the target value. If they match the target value, the verification passes.
[0077] Specifically, the system obtains readback verification information from the slave device corresponding to a communication diagnostic instruction sent by the master device, such as a status flag value reported by the slave device in response to the SPI data sent by the master device. If the readback verification value is determined to be consistent with a readback verification target value, the SPI communication between the master and slave devices is normal. Alternatively, if the readback verification value is determined to be inconsistent with the readback verification target value, a transient SPI communication fault has occurred between the master and slave devices, meaning that the slave device has reported a fault in response to the SPI data currently being sent by the master device.
[0078] In some embodiments, communication timeout detection can also be performed. For example, if the readback verification value obtained after the second communication time period is empty, that is, the readback verification value of the slave device is not obtained after the second communication time period, it is determined that there is an SPI communication transient fault between the master device and the slave device.
[0079] Alternatively, in other embodiments, if the sent data cannot be read back to determine whether the communication is abnormal, other diagnostic mechanisms outside the communication loop can be considered to cover the communication failure based on the impact of the transmitted data on the working status, output, etc. of the slave device.
[0080] That is, when the master device fails to obtain the readback verification information, it obtains the working status information of the component affected by the slave device as fault diagnosis data.
[0081] Specifically, the working status detection value of the component acted on by the slave device is obtained, the working status detection value is compared with the target value, and if it is determined that the working status detection value is consistent with the working status target value, it is determined that the SPI communication between the master device and the slave device is normal; or, if it is determined that the working status detection value is inconsistent with the working status target value, it is determined that there is a transient SPI communication fault between the master device and the slave device.
[0082] For example, in SPI communication between an MCU and a MOSFET driver chip, faults caused by control instructions sent by the MCU via SPI can be covered by detecting the conduction status of the MOSFET. If the operating status / output of the slave device is detected to be inconsistent with expectations, a fault is triggered.
[0083] In other embodiments, when the master device receives target data sent by the slave device, it sends a communication diagnostic instruction corresponding to the communication status to the slave device, and the communication diagnostic instruction is used to obtain the same target data multiple times as fault diagnosis data.
[0084] Specifically, when the master device is not sending SPI data to the slave device, during transient fault diagnosis, the target data can be actively acquired. For example, multiple identical target data values can be obtained from the slave device. By reading the data multiple times and comparing the data, transient faults during communication can be identified. For example, if the identical target data read from the slave device multiple times are inconsistent, a communication fault between the master and slave devices is determined. If the identical target data read from the slave device multiple times are consistent, communication between the master and slave devices is determined to be normal.
[0085] In an embodiment, based on the requirements of the fault tolerance time interval and the fluctuation cycle and regularity of the data to be read, the method of reading data multiple times can be selected to read at a fixed cycle, and the data read in multiple consecutive cycles can be formed into an array for comparison, or the data read multiple times in a row can be compared. When the data read multiple times are consistent, the verification passes. When the data read multiple times are inconsistent, a fault is triggered. Specifically, when reading data multiple times in a fixed cycle, the data read in multiple consecutive cycles can be formed into an array for comparison. When the data forming the array are consistent, the verification passes. When the data forming the array are inconsistent, a fault is detected.
[0086] In an embodiment, communication timeout detection can also be performed. For example, if the same target data value of the slave device obtained after exceeding the third communication time is empty, that is, the target data value is not obtained after exceeding the third communication time, it is determined that there is an SPI communication transient fault between the master device and the slave device, and fault processing is performed.
[0087] In an embodiment of the present application, the master device sends a communication diagnostic instruction corresponding to the communication status of the master-slave device to the slave device. If no fault diagnostic data is obtained after the preset communication time, it is determined that there is a communication fault between the master device and the slave device.
[0088] Furthermore, a fault-tolerance mechanism can be implemented for SPI communication fault diagnosis. For example, the number of communication faults between the master and slave devices can be recorded. If the number reaches a preset fault threshold, a communication fault between the master and slave devices is determined. Otherwise, if the number does not reach the preset fault threshold, the fault can be ignored.
[0089] Specifically, the timeout detection and data verification described above can be tailored to the specific product application, allowing for a certain number of fault tolerances. That is, if a timeout or data error is detected, it can be ignored. When the number of consecutive errors reaches a set threshold, a fault is triggered and the fault handling procedure begins.
[0090] FIG3 is a flow chart of a method for diagnosing a transient fault in SPI communication according to an embodiment of the present application. As shown in FIG3 , the method specifically includes:
[0091] S201, determining whether the current operation is data sending or data reading.
[0092] S202: The master device performs a sending operation.
[0093] S203 , determining which fault detection mechanism to use based on whether the data sent by the master device can be verified by reading back the configuration value or status value from the slave device.
[0094] S204: Read back the configuration value or status value from the slave device.
[0095] S205: Execute communication timeout detection.
[0096] S206: Determine whether the read-back configuration value or status value is consistent with the target value.
[0097] S207, verification passed.
[0098] S208: Execute the fault handling procedure.
[0099] S209 is a fault diagnosis mechanism outside the communication loop.
[0100] S210: Determine whether a fault is detected through an external diagnostic mechanism.
[0101] S211, the master device reads the same target data value multiple times in succession.
[0102] S212, determining whether the data read multiple times are consistent.
[0103] As shown in Figure 3, transient SPI communication faults are diagnosed by information readback and timeout detection, or by using reference external monitoring measures. Transient data reception faults are diagnosed by information redundancy. Overall, this approach achieves high diagnostic coverage for transient SPI communication faults.
[0104] The second embodiment of the present application further proposes a method for diagnosing SPI communication failures, which can be applied to slave devices.
[0105] FIG4 is a flow chart of a method for diagnosing an SPI communication fault according to an embodiment of the present application. As shown in FIG4 , the method specifically includes:
[0106] S41, receiving a communication diagnostic instruction sent by the master device, wherein the communication diagnostic instruction corresponds to the communication status between the master device and the slave device.
[0107] In some embodiments, the communication status may include but is not limited to the state where no communication data transmission is performed between the master device and the slave device for more than a preset time, the state where the master device sends communication data to the slave device, and the state where the master device receives communication data sent by the slave device.
[0108] S42 , the slave device feeds back fault diagnosis data to the master device according to the communication diagnosis instruction, so that the master device determines communication fault information between the slave device and the master device according to the fault diagnosis data.
[0109] In some embodiments, the slave device feeds back fault diagnosis data to the master device according to the communication diagnostic instruction, including at least one of the following: feeding back the characteristic identification value of the slave device to the master device; feeding back the readback verification information of the communication data sent by the corresponding master device to the master device; feeding back the same target data to the master device multiple times.
[0110] In an embodiment, the characteristic identification value of the slave device may include a configuration value or a preset identification value of the slave device, and the master device may perform fault diagnosis through the characteristic identification value.
[0111] That is, for different communication states between the master and slave devices, the slave device can respond to the communication diagnostic instructions of the master device and feedback fault diagnosis information corresponding to the current communication state, so that fault diagnosis can be covered in each communication stage, thereby improving the fault diagnosis coverage rate.
[0112] According to the SPI communication fault diagnosis method of the embodiment of the present application, the slave device feeds back fault diagnosis data to the master device according to the communication diagnosis instruction sent by the master device based on the communication status of the master-slave device, so that the master device performs communication fault diagnosis between the master and slave devices. Communication fault diagnosis can be performed under different communication states, thereby improving fault diagnosis coverage and improving the reliability of communication between the master and slave devices.
[0113] The third embodiment of the present application further proposes a method for diagnosing SPI communication failures. The method performs diagnosis based on the communication status between master and slave devices. The method can be used in a system including master-slave device communication.
[0114] FIG5 is a flow chart of a method for diagnosing an SPI communication fault according to an embodiment of the present application, as shown in FIG5 , comprising the following steps;
[0115] S51, the master device sends a communication diagnostic instruction corresponding to the communication status to the slave device according to the communication status between the master device and the slave device.
[0116] S52, the slave device feeds back fault diagnosis data to the master device according to the communication diagnosis instruction.
[0117] S53: The master device determines communication fault information between the master device and the slave device based on the fault diagnosis data.
[0118] The communication status may include but is not limited to the state where no communication data transmission is performed between the master device and the slave device for more than a preset time, the state where the master device sends communication data to the slave device, and the state where the master device receives communication data sent by the slave device.
[0119] According to the SPI communication fault diagnosis method of the embodiment of the present application, the master device sends a communication diagnostic instruction based on the communication status of the master and slave devices, the slave device feeds back associated fault diagnosis data, and the master device performs communication fault diagnosis on the master and slave devices, thereby achieving communication fault diagnosis in different communication states, improving fault diagnosis coverage, and improving the reliability of communication between the master and slave devices.
[0120] Based on the method for diagnosing SPI communication failures in the above embodiment, a fourth embodiment of the present application proposes an SPI master device.
[0121] FIG6 is a block diagram of an SPI communication device according to one embodiment of the present application. As shown in FIG6 , SPI communication device 100 includes a processor 101 and a memory 102. SPI communication device 100 can be a master device or a slave device, and the master device communicates with one or more slave devices, for example, via SPI, such as between a main control chip of a system or device and peripherals, a power management chip, a dedicated driver chip, or a sensor.
[0122] Among them, the memory 102 is communicatively connected to the processor 101, and the memory 102 stores a computer program that can be executed by the processor 101. When the processor 101 executes the computer program, the diagnostic method for the SPI communication fault of the above embodiment can be implemented. The specific implementation process of the diagnostic method can refer to the description of the above embodiment and will not be repeated here.
[0123] According to the SPI communication device 100 of the embodiment of the present application, the SPI communication fault diagnosis method of the above embodiment is executed by the processor 101. According to the communication status between the master device and the slave device, a communication diagnostic instruction corresponding to the communication status is sent to the slave device; fault diagnosis data associated with the slave device is obtained, and communication fault information between the master device and the slave device is determined based on the fault diagnosis data. Fault diagnosis, such as diagnosis of permanent faults or transient faults, can be performed at each SPI communication stage. SPI communication devices, such as an SPI master device, or various slave devices that perform SPI communication with the SPI master device, do not need to add a hardware CRC controller or software CRC check, thereby reducing costs and increasing fault diagnosis coverage.
[0124] Based on the diagnostic method of SPI communication failure in the above embodiment, the fifth embodiment of the present application further proposes a computer-readable storage medium on which a computer program is stored. When the computer program is executed, the diagnostic method of SPI communication failure in the above embodiment can be implemented.
[0125] Among them, the computer-readable storage medium can be the aforementioned storage medium, for example, it can be a non-transitory storage medium, including: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes, or it can be a transient storage medium.
[0126] Throughout this specification, reference to terms such as "one embodiment," "some embodiments," "illustrative embodiments," "example," "specific example," or "some examples" means that a specific feature, structure, material, or characteristic described in conjunction with the embodiment or example is included in at least one embodiment or example of the present application. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example.
[0127] Although the embodiments of the present application have been shown and described, those skilled in the art will appreciate that various changes, modifications, substitutions, and variations may be made to the embodiments without departing from the principles and intent of the present application, and that the scope of the present application is defined by the claims and their equivalents.
Claims
1. A method for diagnosing SPI communication failures, applied to a master device, It is characterized in that include: According to the communication status between the master device and the slave device, a communication diagnosis instruction corresponding to the communication status is sent to the slave device (S1); acquiring fault diagnosis data associated with the slave device (S2); and According to the fault diagnosis data, communication fault information between the master device and the slave device is determined (S3).
2. The method for diagnosing a SPI communication failure according to claim 1, It is characterized in that The communication status includes a status where no communication data transmission is performed between the master device and the slave device for more than a preset time period, a status where the master device sends communication data to the slave device, and a status where the master device receives communication data sent by the slave device.
3. The method for diagnosing a SPI communication failure according to claim 1 or 2, It is characterized in that According to the communication state between the master device and the slave device, a communication diagnosis instruction (S1) corresponding to the communication state is sent to the slave device, comprising: If the master device and the slave device do not communicate or transmit data for more than a preset period of time, the master device sends a read instruction to the slave device to read the characteristic identification value of the slave device according to the fault diagnosis cycle, so as to obtain the characteristic identification value fed back by the slave device as fault diagnosis data.
4. The method for diagnosing a SPI communication failure according to claim 3, It is characterized in that The characteristic identification value of the slave device includes a configuration value or a preset identification value of the slave device.
5. A method for diagnosing a SPI communication failure according to any one of claims 1 to 4, It is characterized in that According to the communication state between the master device and the slave device, a communication diagnosis instruction (S1) corresponding to the communication state is sent to the slave device, comprising: When the master device sends communication data to the slave device, a communication diagnostic instruction corresponding to the communication state is sent to the slave device, where the communication diagnostic instruction is used to obtain readback verification information corresponding to the communication data.
6. The method for diagnosing a SPI communication failure according to claim 5, It is characterized in that Acquiring fault diagnosis data associated with the slave device (S2), comprising: When the master device obtains the read-back verification information, using the read-back verification information as the fault diagnosis data; and When the master device fails to obtain the read-back verification information, the working state information of the component acted upon by the slave device is obtained as the fault diagnosis data.
7. A method for diagnosing a SPI communication failure according to any one of claims 1 to 6, It is characterized in that Determining communication fault information between the master device and the slave device according to the fault diagnosis data (S3), comprising: comparing the fault diagnosis data with a target value; If the fault diagnosis data is inconsistent with the target value, determining that there is a communication failure between the master device and the slave device; and If the fault diagnosis data is consistent with the target value, it is determined that the communication between the master device and the slave device is normal.
8. A method for diagnosing a SPI communication failure according to any one of claims 1 to 4, It is characterized in that According to the communication state between the master device and the slave device, a communication diagnosis instruction (S1) corresponding to the communication state is sent to the slave device, comprising: When the master device receives the target data sent by the slave device, it sends a communication diagnostic instruction corresponding to the communication state to the slave device, wherein the communication diagnostic instruction is used to use the same target data obtained multiple times as the fault diagnosis data.
9. The method for diagnosing a SPI communication failure according to claim 8, It is characterized in that Determining communication fault information between the master device and the slave device according to the fault diagnosis data (S3), comprising: If the same target data of the slave device read multiple times are inconsistent, it is determined that there is a communication failure between the master device and the slave device; If the same target data of the slave device read multiple times is consistent, it is determined that the communication between the master device and the slave device is normal.
10. A method for diagnosing a SPI communication failure according to any one of claims 1 to 6 or 8 or 9, It is characterized in that The diagnostic method further comprises: If the fault diagnosis data is not obtained within the preset communication time, it is determined that there is a communication failure between the master device and the slave device.
11. The method for diagnosing a SPI communication failure according to claim 10, It is characterized in that Determining communication failure information between the master device and the slave device (S3), comprising: Recording the number of times a communication failure is diagnosed between the master device and the slave device; and If the number reaches the failure number threshold, it is determined that there is a communication failure between the master device and the slave device.
12. A method for diagnosing SPI communication failures, applied to slave devices, It is characterized in that include: Receiving a communication diagnostic instruction sent by a master device, wherein the communication diagnostic instruction corresponds to a communication state between the master device and a slave device (S41); and The slave device feeds back fault diagnosis data to the master device according to the communication diagnosis instruction, so that the master device determines communication fault information between the slave device and the master device according to the fault diagnosis data (S42).
13. The method for diagnosing a SPI communication failure according to claim 12, It is characterized in that The communication status includes a status where no communication data transmission is performed between the master device and the slave device for more than a preset time period, a status where the master device sends communication data to the slave device, and a status where the master device receives communication data sent by the slave device.
14. The method for diagnosing SPI communication failure according to claim 12 or 13, It is characterized in that The slave device feeds back fault diagnosis data to the master device according to the communication diagnosis instruction (S42), including at least one of the following: Feedback the feature identification value of the slave device to the master device; Feedback to the master device readback verification information corresponding to the communication data sent by the master device; and The same target data is fed back to the master device multiple times.
15. The method for diagnosing SPI communication failure according to claim 14, It is characterized in that The characteristic identification value of the slave device includes a configuration value or a preset identification value of the slave device.
16. A method for diagnosing SPI communication failure. It is characterized in that include: The master device sends a communication diagnosis instruction corresponding to the communication status to the slave device according to the communication status between the master device and the slave device (S51); The slave device feeds back fault diagnosis data to the master device according to the communication diagnosis instruction (S52); and The master device determines communication fault information between the master device and the slave device according to the fault diagnosis data (S53).
17. An SPI communication device (100), It is characterized in that include: Processor (101); and A memory (102) communicatively connected to the processor (101); The memory (102) stores a computer program executable by the processor (101), and when the processor (101) executes the computer program, the method for diagnosing a SPI communication fault according to any one of claims 1 to 11 or the method for diagnosing a SPI communication fault according to any one of claims 12 to 15 is implemented.
18. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed, the method for diagnosing a SPI communication failure according to any one of claims 1 to 11 or the method for diagnosing a SPI communication failure according to any one of claims 12 to 15 is implemented.
Citation Information
Patent Citations
Detection method and device for communication link
CN107332726A
Fault diagnosis method, electronic equipment and storage medium
CN113765608A
Fault diagnosis method, device and equipment and computer readable storage medium
CN114338464A
Fault diagnosis method, management device, and program
JP2015220547A
Serial interface with improved diagnostic coverage
US20210374022A1
