A method, system and electronic device for matching CAN network baud rate

By sending the low pulse width of the preset time in the CAN network and calculating the bit width of the target network, the problem of automatic baud rate matching in the CAN network is solved, and fast automatic matching without the preset table is achieved, suitable for unknown baud rate The scenario simplifies the matching process.

CN115277296BActive Publication Date: 2024-11-12WUHAN SOUTH SAGITTARIUS INTEGRATION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210910018.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-29
Publication Date
2024-11-12
Estimated Expiration
2042-07-29

AI Technical Summary

Technical Problem

The prior art has shortcomings in automatic baud rate matching of CAN networks, especially when the target network baud rate is unknown or not in the preset configuration table, it cannot be matched effectively, resulting in communication problems.

Method used

The target ECU controller sends a preset low pulse width to the target CAN network, obtains the first and second low pulse widths, uses these pulse widths to calculate the bit width of the target network, and calculates the baud rate, and configures to match. The baud rate of the device is automatically matched.

Benefits of technology

It can quickly and automatically match the baud rate of the target CAN network without presetting the baud rate table in advance. It is suitable for networks that do not actively send any messages. The method is simple, efficient and easy to apply. The matching time does not depend on the target CAN network node. Number and message.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115277296B_ABST
    Figure CN115277296B_ABST
Patent Text Reader

Abstract

A method for CAN network baud rate matching includes: S100 target ECU controller sends a low pulse width P of a preset time that can generate a bus bit filling error to the target CAN network; S200. Obtain the first low pulse width P0 and the second low pulse width P1 that appear on the target CAN network; S300 when the first low pulse width P0 is equal to the length of the low pulse width P sent, execute S400; S400. Obtain the baud rate of the target network by the second pulse width length P1 and the constant N; S500. Configure the obtained baud rate as the baud rate of the current target network, and configure it to the current CAN baud rate node device to be matched; S600. The current CAN baud rate node device to be matched sends a data frame of specified content to the target CAN network; S700. If the current CAN baud rate node device to be matched successfully sends a data frame to the target CAN network, the target CAN network baud rate is successfully matched. The present invention solves the problem of reducing communication caused by baud rate mismatch, and is suitable for CAN network device scenarios where the baud rate is unknown and no message is sent out.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of vehicle networking, and in particular to a method, system and electronic equipment for matching the baud rate of a CAN network. Background Art

[0002] In addition to being widely used for information exchange between various ECU controllers in vehicles, CAN local area network controllers are also widely used in vehicle diagnostic interfaces. Diagnostic interfaces are usually equipped during the vehicle manufacturing stage and are used to communicate with external diagnostic equipment when a vehicle fails or needs to be repaired.

[0003] For some vehicle diagnostic interfaces, the diagnostic request device (also called the client) is usually required to send a request first, and the diagnostic controller (also called the server) responds to the request. When the client does not send a request, the server does not send any message to the diagnostic interface. For different models and different diagnostic interfaces, the CAN interface baud rate is often different. At present, there are two main ways to automatically adapt the baud rate. One is to preset a baud rate configuration table, traverse the baud rates in the configuration table in turn, and match the baud rate of the target network by judging whether the message is sent to the bus successfully. This method has a disadvantage. If the baud rate of the target network is not in the preset configuration table, this adaptation method is invalid; the other baud rate adaptation method is that there are complete data frames in the network that are periodically transmitted, and the baud rate is matched by measuring the minimum bit width that appears in the data frame. This method also has a disadvantage. The premise of this implementation method is that there must be data frames on the network that are normally transmitted. Therefore, a general CAN baud rate automatic matching method is urgently needed. Reduce communication problems caused by baud rate mismatch. It is particularly suitable for CAN network device scenarios where the baud rate is unknown and no messages are sent out. Summary of the invention

[0004] In view of the above problems, the present invention is proposed to provide a method, system and electronic device for CAN network baud rate matching that overcomes the above problems or at least partially solves the above problems.

[0005] In order to solve the above technical problems, the embodiments of the present application disclose the following technical solutions:

[0006] A method for matching the baud rate of a CAN network, comprising:

[0007] S100 The target ECU controller sends a low pulse width P of a preset time capable of generating a bus bit stuffing error to the target CAN network;

[0008] S200. Obtain the first low pulse width P0 and the second low pulse width P1 appearing on the target CAN network;

[0009] S300. Determine and select the first low pulse width P0. When the first low pulse width P0 is equal to the length of the transmitted low pulse width P, execute S400;

[0010] S400. Obtain the bit width of the target network through the second pulse width length P1 and the constant N, and calculate the baud rate of the target network based on this bit width;

[0011] S500. The calculated baud rate is configured as the baud rate of the current target network, and the current CAN baud rate node device to be matched is configured;

[0012] S600. The current CAN baud rate node device to be matched sends a data frame of specified content to the target CAN network;

[0013] S700. If the current CAN baud rate node device to be matched successfully sends a data frame to the target CAN network, the target CAN network baud rate is successfully matched, otherwise jump to step S100 and start again.

[0014] Further, in S100, the target ECU controller sends a low pulse width of a preset time to the target CAN network. The specific method includes: first determine whether the sending pin TXD of the CAN controller supports the PWM function. If the sending pin TXD of the CAN controller supports the PWM function, the CAN module output pin TXD can be directly set to the PWM output pin. If the sending pin TXD of the CAN controller does not support the PWM function, the GPIO pin supporting PWM on the ECU and the TXD of the CAN controller can be physically short-circuited together; set the PWM module output mode selection to single output mode, the output level is low and effective, the idle level is high, and the low pulse width is set to P to enable PWM output.

[0015] Further, in S200, the first low pulse width P0 and the second low pulse width P1 appearing on the target CAN network are obtained through the input capture function module, wherein the input capture function module has the function of automatically recording the count value corresponding to the moment when the current capture time occurs and generating a capture interrupt when the expected edge signal arrives.

[0016] Furthermore, the work of the input capture function module includes: first, determining whether the receiving pin RXD of the CAN controller supports the input double edge capture function; if the receiving pin RXD of the CAN controller supports the input double edge capture function, directly configuring the RXD of the CAN controller as the input capture function; if the receiving pin RXD of the CAN controller does not support the input capture function, the GPIO pin on the ECU controller that supports the double edge input capture function and the RXD of the CAN controller can be physically short-circuited together; each time an input capture interrupt is generated, the current capture edge moment is recorded and the edge count value is updated.

[0017] Furthermore, the operation of the input capture function module also includes: when the input capture interrupt edge count value is equal to 4, turning off the input capture function and clearing the capture edge count value, setting the first edge moment count value of the input capture module to T0, the second edge moment count value to T1, the third edge moment count value to T2, and the fourth edge moment count value to T3, setting the clock frequency of the input capture module to f, then the first low pulse width P0 of the input capture = (T1-T0) / f, and the second low pulse width P1 = (T3-T2) / f.

[0018] Furthermore, in S400, the bit width of the target network is obtained by the second pulse width length P1 and the constant N, and the baud rate of the target network is calculated based on the bit width, wherein the target network bit width w=P1 / N, and the baud rate of the target network baud=1 / w.

[0019] Furthermore, since the active error identification field is 6 to 12 times the target network bit width, the constant N can be one of 6, 7, 8, 9, 10, 11, and 12.

[0020] Further, in S500, the calculated baud rate is configured as the baud rate of the current target network, specifically including: configuring the calculated baud rate value as the baud rate of the CAN node of the device to be matched, and configuring RXD and TXD as CAN controller peripheral pins for CAN data receiving and sending functions, and enabling CAN data sending completion interrupt.

[0021] The present invention also discloses a CAN network baud rate matching system, comprising: a PWM module, an input capture module, an edge counting module, a data processing module and a CAN controller module; wherein

[0022] PWM module, used for the target ECU controller to send a low pulse width P of a preset time to the target CAN network;

[0023] An input capture module is used to obtain a first low pulse width P0 and a second low pulse width P1 appearing on a target CAN network;

[0024] Edge counting module: used to record the number of input capture edges;

[0025] Data processing module: used to obtain the bit width of the target network through the second pulse width length P1 and the constant N, and calculate the baud rate of the target network based on this bit width

[0026] CAN controller module: used to send the specified message and identify whether the target baud rate adaptation is successful or not by generating a sending completion interrupt.

[0027] On the other hand, the present invention also discloses an electronic device for CAN network baud rate matching, comprising:

[0028] a memory for storing instructions executable by a processor;

[0029] A processor configured to execute the instructions to implement the method according to any one of claims 1 to 8.

[0030] The beneficial effects of the above technical solution provided by the embodiment of the present invention include at least:

[0031] The present invention discloses a method for matching the baud rate of a CAN network, comprising: a target ECU controller sends a low pulse width P of a preset time capable of generating a bus bit filling error to a target CAN network; obtaining a first low pulse width P0 and a second low pulse width P1 appearing on the target CAN network; judging and selecting the first low pulse width P0, and executing S400 when the first low pulse width P0 is equal to the length P of the sent low pulse width; obtaining the bit width of the target network by using the second pulse width length P1 and a constant N, and calculating the baud rate of the target network with the bit width; configuring the calculated baud rate as the baud rate of the current target network, and configuring the current CAN baud rate node device to be matched;

[0032] The current CAN baud rate node device to be matched sends a data frame of specified content to the target CAN network; if the current CAN baud rate node device to be matched successfully sends the data frame to the target CAN network, the baud rate of the target CAN network is successfully matched. The present invention can quickly and automatically match the baud rate of the target CAN network without presetting the baud rate table in advance, without manual intervention, and is particularly suitable for networks that do not actively send any CAN messages. The matching time does not depend on the number of nodes and messages of the target CAN network, and the implementation method is simple, efficient and easy to apply.

[0033] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:

[0035] Figure 1 This is a flow chart of a method for matching CAN network baud rates in Embodiment 1 of the present invention;

[0036] Figure 2 This is a structural diagram of a CAN network baud rate matching system in Example 1 of the present invention. DETAILED DESCRIPTION

[0037] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0038] In order to solve the problems existing in the prior art, an embodiment of the present invention provides a method, system and electronic device for matching the baud rate of a CAN network.

[0039] Example 1

[0040] This embodiment discloses a method for matching the baud rate of a CAN network. Figure 1 ,include:

[0041] S100 The target ECU controller sends a low pulse width P of a preset time that can generate a bus bit filling error to the target CAN network; in S100 of this embodiment, the target ECU controller sends a low pulse width of a preset time to the target CAN network. The specific method includes: first determine whether the sending pin TXD of the CAN controller supports the PWM function. If the sending pin TXD of the CAN controller supports the PWM function, the output pin TXD of the CAN module can be directly set as the PWM output pin. If the sending pin TXD of the CAN controller does not support the PWM function, the GPIO pin supporting PWM on the ECU and the TXD of the CAN controller can be physically short-circuited together; set the PWM module output mode selection to single output mode, the output level is low and effective, the idle level is high, and the low pulse width is set to P to enable PWM output. Specifically, the preset pulse width can be selected as 5us, and the baud rate range that can be matched is 200Kbps-1Mbps. If a lower baud rate needs to be matched, the preset pulse width time of the PWM module output can be appropriately extended.

[0042] S200. Obtain the first low pulse width P0 and the second low pulse width P1 that appear on the target CAN network. The first low pulse width is actually the low pulse sent by the PWM module and returned to the RXD of the CAN module through the CAN transceiver, and the second low pulse width is the active error identification field of the active error frame sent by other device nodes on the bus after the error frame is filled in place; in this embodiment S200, the first low pulse width P0 and the second low pulse width P1 that appear on the target CAN network are obtained through the input capture function module, wherein the input capture function module has the function of automatically recording the count value corresponding to the moment when the current capture time occurs and generating a capture interrupt when the expected edge signal arrives.

[0043] Specifically, the work of the input capture function module includes: first determine whether the receiving pin RXD of the CAN controller supports the input double edge capture function. If the receiving pin RXD of the CAN controller supports the input double edge capture function, directly configure the RXD of the CAN controller as the input capture function. If the receiving pin RXD of the CAN controller does not support the input capture function, the GPIO pin on the ECU controller that supports the double edge input capture function and the RXD of the CAN controller can be physically short-circuited together. Each time an input capture interrupt is generated, the current capture edge moment is recorded and the edge count value is updated.

[0044] In some preferred embodiments, the operation of the input capture function module also includes: when the input capture interrupt edge count value is equal to 4, turning off the input capture function and clearing the capture edge count value, setting the first edge moment count value of the input capture module to T0, the second edge moment count value to T1, the third edge moment count value to T2, and the fourth edge moment count value to T3, setting the clock frequency of the input capture module to f, then the first low pulse width P0 of the input capture = (T1-T0) / f, and the second low pulse width P1 = (T3-T2) / f.

[0045] S300. Determine and select the first low pulse width P0. When the first low pulse width P0 is equal to the length of the low pulse width P to be sent, execute S400. When the first low pulse width P0 is not equal to the length of the low pulse width P to be sent, re-execute S100.

[0046] S400. Obtain the bit width of the target network through the second pulse width length P1 and the constant N, and calculate the baud rate of the target network based on this bit width;

[0047] In this embodiment, the bit width of the target network is obtained by the second pulse width length P1 and the constant N, and the baud rate of the target network is calculated based on the bit width, wherein the bit width w of the target network is P1 / N, and the baud rate baud of the target network is 1 / w. Since the dominant level duration of the error frame can be 6 to 12 bit time lengths, the value of N can be one of 6, 7, 8, 9, 10, 11, and 12.

[0048] S500. Configure the calculated baud rate as the baud rate of the current target network, and configure the current CAN baud rate node device to be matched; specifically, configure the calculated baud rate as the baud rate of the current target network, specifically including: configuring the calculated baud rate value as the baud rate of the CAN node of the device to be matched, and configuring RXD and TXD as CAN controller peripheral pins for CAN data receiving and sending functions, and enabling CAN data sending completion interrupt.

[0049] S600. The current CAN baud rate node device to be matched sends a data frame of specified content to the target CAN network;

[0050] S700. If the current CAN baud rate node device to be matched successfully sends a data frame to the target CAN network, the target CAN network baud rate is successfully matched, otherwise jump to step S100 and start again.

[0051] Specifically, after the configuration of S500 is completed, a data frame of any content is actively sent to the CAN network under test through the CAN interface. If a CAN data sending completion interrupt is generated, the current baud rate and the CAN baud rate of the target network are matched, otherwise N should be taken as an integer less than or equal to 12, the baud rate is reconfigured and data sending begins. If all N values ​​have been taken and still cannot be matched successfully, exit the current CAN module configuration and jump to step S100 again.

[0052] This embodiment also discloses a CAN network baud rate matching system, such as Figure 2 , including: PWM module, input capture module, edge counting module, data processing module and CAN controller module;

[0053] PWM module, used for the target ECU controller to send a low pulse width P of a preset time to the target CAN network;

[0054] An input capture module is used to obtain a first low pulse width P0 and a second low pulse width P1 appearing on a target CAN network;

[0055] Edge counting module: used to record the number of input capture edges;

[0056] Data processing module: used to obtain the bit width of the target network through the second pulse width length P1 and the constant N, and calculate the baud rate of the target network based on this bit width

[0057] CAN controller module: used to send the specified message and identify whether the target baud rate adaptation is successful or not by generating a send interrupt.

[0058] Among them, the specific working methods of the PWM module, input capture module, edge counting module, data processing module and CAN controller module are described in detail in a method for matching the baud rate of a CAN network, and will not be repeated here.

[0059] The present embodiment discloses a method for CAN network baud rate matching, including: a target ECU controller sends a low pulse width P of a preset time to a target CAN network; obtains a first low pulse width P0 and a second low pulse width P1 that appear on the target CAN network; judges and selects the first low pulse width P0, and when the first low pulse width P0 is equal to the length of the low pulse width P, executes S400; obtains the bit width of the target network by the second pulse width length P1 and a constant N, and calculates the baud rate of the target network with this bit width; configures the calculated baud rate as the baud rate of the current target network, and configures the current CAN baud rate node device to be matched; the current CAN baud rate node device to be matched sends a data frame of a specified content to the target CAN network; if the current CAN baud rate node device to be matched successfully sends a data frame to the target CAN network, the target CAN network baud rate is successfully matched. The present invention can quickly and automatically match the baud rate of the target CAN network without presetting the baud rate table in advance, without manual intervention, and is particularly suitable for networks that do not actively send any CAN messages, and the matching time does not depend on the number of nodes and messages of the target CAN network, and the implementation method is simple, efficient and easy to apply.

[0060] Example 2

[0061] This embodiment further discloses an electronic device, which is characterized by comprising:

[0062] a memory for storing instructions executable by a processor;

[0063] A processor is configured to execute the instructions to implement the method described in embodiment 1.

[0064] It should be understood that the specific order or hierarchy of steps in the disclosed process is an example of an exemplary method. Based on design preferences, it should be understood that the specific order or hierarchy of steps in the process can be rearranged without departing from the scope of protection of the present disclosure. The attached method claims present the elements of the various steps in an exemplary order and are not intended to be limited to the specific order or hierarchy described.

[0065] In the above detailed description, various features are grouped together in a single embodiment to simplify the disclosure. This method of disclosure should not be interpreted as reflecting an intention that the embodiments of the claimed subject matter require more features than are clearly stated in each claim. On the contrary, as reflected in the appended claims, the invention is in a state of having less than all the features of the disclosed individual embodiments. Therefore, the appended claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.

[0066] Those skilled in the art will also appreciate that the various illustrative logic blocks, modules, circuits, and algorithmic steps described in conjunction with the embodiments herein can all be implemented as electronic hardware, computer software, or a combination thereof. In order to clearly illustrate the interchangeability between hardware and software, various illustrative components, blocks, modules, circuits, and steps are generally described above around their functions. Whether such functions are implemented as hardware or software depends on specific applications and the design constraints imposed on the entire system. A skilled person can implement the described functions in an alternative manner for each specific application, but such implementation decisions should not be interpreted as departing from the scope of protection of the present disclosure.

[0067] The steps of the method or algorithm described in conjunction with the embodiments herein may be directly embodied as hardware, a software module executed by a processor, or a combination thereof. The software module may be located in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a mobile disk, a CD-ROM, or any other form of storage medium well known in the art. An exemplary storage medium is connected to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Of course, the storage medium may also be an integral part of the processor. The processor and the storage medium may be located in an ASIC. The ASIC may be located in a user terminal. Of course, the processor and the storage medium may also be present in a user terminal as discrete components.

[0068] For software implementation, the techniques described in this application can be implemented with modules (e.g., procedures, functions, etc.) that perform the functions described in this application. These software codes can be stored in a memory unit and executed by a processor. The memory unit can be implemented within the processor or outside the processor. In the latter case, it is coupled to the processor in a communication manner via various means, which are well known in the art.

[0069] The above description includes examples of one or more embodiments. Of course, it is impossible to describe all possible combinations of components or methods for the purpose of describing the above embodiments, but it should be recognized by those skilled in the art that the various embodiments may be further combined and arranged. Therefore, the embodiments described herein are intended to cover all such changes, modifications and variations that fall within the scope of protection of the appended claims. In addition, with respect to the term "comprising" used in the specification or claims, the word is covered in a manner similar to the term "including", just as "including," is explained as a transitional word in the claims. In addition, any term "or" used in the specification of the claims is intended to mean "non-exclusive or".

Claims

1. A method for CAN network baud rate matching, It is characterized in that include: S100. The target ECU controller sends a low pulse width P of a preset time capable of generating a bus bit stuffing error to the target CAN network; The specific method includes: firstly judging whether the sending pin TXD of the CAN controller supports the PWM function; if the sending pin TXD of the CAN controller supports the PWM function, directly setting the output pin TXD of the CAN module as the PWM output pin; if the sending pin TXD of the CAN controller does not support the PWM function, physically short-circuiting the GPIO pin supporting PWM on the ECU and the TXD of the CAN controller; setting the output mode of the PWM module to the single output mode, the output level is low effective, the idle level is high, and the low pulse width is set to P to enable PWM output; S200. Obtain the first low pulse width P0 and the second low pulse width P1 that appear on the target CAN network; in S200, the first low pulse width P0 and the second low pulse width P1 that appear on the target CAN network are obtained through the input capture module, wherein the input capture module has the function of automatically recording the count value corresponding to the moment when the expected edge signal arrives and generating a capture interrupt; the working method of the input capture module includes: firstly determining whether the receiving pin RXD of the CAN controller supports the input double edge capture function; if the receiving pin RXD of the CAN controller supports the input double edge capture function, directly configuring the RXD of the CAN controller as the input capture function; if the receiving pin RXD of the CAN controller D does not support the input capture function. The GPIO pin on the ECU controller that supports the dual-edge input capture function and the RXD of the CAN controller are physically short-circuited together. Each time an input capture interrupt is generated, the current capture edge time is recorded and the edge count value is updated; when the input capture interrupt edge count value is equal to 4, the input capture function is turned off and the capture edge count value is cleared. The first edge time count value of the input capture module is set to T0, the second edge time count value is set to T1, the third edge time count value is set to T2, and the fourth edge time count value is set to T3. The clock frequency of the input capture module is set to f, then the first low pulse width P0 of the input capture is (T1-T0) / f, and the second low pulse width P1 is (T3-T2) / f; S300. Determine and select the first low pulse width P0. When the first low pulse width P0 is equal to the length of the transmitted low pulse width P, execute S400; S400. Obtain the bit width of the target network through the second pulse width length P1 and the constant N, and calculate the baud rate of the target network based on this bit width; S500. The calculated baud rate is configured as the baud rate of the current target network and configured to the current CAN baud rate node device to be matched; S600. The current CAN baud rate node device to be matched sends a data frame of specified content to the target CAN network; S700. If the current CAN baud rate node device to be matched successfully sends a data frame to the target CAN network, the target CAN network baud rate is successfully matched, otherwise jump to step S100 and start again.

2. A method for CAN network baud rate matching as claimed in claim 1, It is characterized in that In S400, the bit width of the target network is obtained by the second pulse width length P1 and the constant N, and the baud rate of the target network is calculated based on the bit width, wherein the bit width w of the target network is P1 / N, and the baud rate of the target network is baud=1 / w.

3. A method for CAN network baud rate matching as claimed in claim 2, It is characterized in that The constant N is one of 6, 7, 8, 9, 10, 11, and 12.

4. A method for matching CAN network baud rate as claimed in claim 1, It is characterized in that In S500, the calculated baud rate is configured as the baud rate of the current target network, specifically including: configuring the calculated baud rate value as the baud rate of the CAN node of the device to be matched, configuring RXD and TXD as CAN controller peripheral pins for CAN data receiving and sending functions, and enabling CAN data sending completion interrupt.

5. A CAN network baud rate matching system, It is characterized in that include: PWM module, input capture module, edge counting module, data processing module and CAN controller module; in PWM module, the target ECU controller sends a low pulse width P of a preset time that can generate a bus bit filling error to the target CAN network; the specific method includes: firstly judging whether the sending pin TXD of the CAN controller supports the PWM function, if the sending pin TXD of the CAN controller supports the PWM function, directly setting the output pin TXD of the CAN module as the PWM output pin, if the sending pin TXD of the CAN controller does not support the PWM function, physically shorting the GPIO pin supporting PWM on the ECU and the TXD of the CAN controller together; setting the PWM module output mode selection to single output mode, the output level is low effective, the idle level is high, and the low pulse width is set to P to enable PWM output; The input capture module is used to obtain the first low pulse width P0 and the second low pulse width P1 appearing on the target CAN network; the first low pulse width P0 and the second low pulse width P1 appearing on the target CAN network are obtained through the input capture module, wherein the input capture module has the function of automatically recording the count value corresponding to the moment when the expected edge signal arrives and generating a capture interrupt; the work of the input capture module includes: firstly judging whether the receiving pin RXD of the CAN controller supports the input double edge capture function; if the receiving pin RXD of the CAN controller supports the input double edge capture function, directly configuring the RXD of the CAN controller as the input capture function; if the receiving pin RXD of the CAN controller does not support the input double edge capture function, directly configuring the RXD of the CAN controller as the input capture function; Support input capture function, physically short-circuit the GPIO pin supporting the dual-edge input capture function on the ECU controller and the RXD of the CAN controller together, and record the current capture edge time and update the edge count value each time an input capture interrupt is generated; when the edge count value of the input capture interrupt is equal to 4, turn off the input capture function and clear the capture edge count value, set the first edge time count value of the input capture module to T0, the second edge time count value to T1, the third edge time count value to T2, and the fourth edge time count value to T3, set the clock frequency of the input capture module to f, then the first low pulse width P0 of the input capture is (T1-T0) / f, and the second low pulse width P1 is (T3-T2) / f; Edge counting module: used to record the number of input capture edges, judge and select the first low pulse width P0, and execute the data processing module when the first low pulse width P0 is equal to the sending low pulse width length P; Data processing module: used to obtain the bit width of the target network through the second pulse width length P1 and the constant N, and calculate the baud rate of the target network based on the bit width; CAN controller module: used to send the specified message and identify whether the target baud rate adaptation is successful or not by generating a sending completion interrupt.

6. An electronic device for CAN network baud rate matching, It is characterized in that include a memory for storing instructions to be executed by the processor; A processor configured to execute the instructions to implement the method according to any one of claims 1 to 4.