Microcontroller load rate test method, device and system and vehicle

By inserting task identification and timer functions into the microcontroller source code, the load rate of the MCU is identified and calculated in real time, the problem of the MCU cannot be tested under actual operating conditions in the prior art, and the load rate of the MCU is realized The accurate evaluation and optimization of the vehicle improves the stability and safety of the entire vehicle.

CN119002444APending Publication Date: 2024-11-22BEBEST (SHANGHAI) AUTOMOTIVE ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410947165.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-16
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

The prior art is difficult to test the load rate of the microcontroller after mass production, and it is impossible to accurately evaluate the load rate of the MCU under actual operating conditions, which affects the software development and the operating stability and safety of the entire vehicle.

Method used

By inserting task identifiers and timer functions into the source code of the microcontroller, we can identify the start and end time of the task in real time, and send log data to the upper computer based on the controller's LAN bus protocol, calculate each task and the overall load rate, and realize Accurate test of MCU load rate.

Benefits of technology

It realizes accurate testing of load rates before and after the microcontroller mass production, helps developers to discover problems and optimize software design, improves the operating stability of MCUs and the safety of the entire vehicle, and is suitable for the automotive industry and other fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119002444A_ABST
    Figure CN119002444A_ABST
Patent Text Reader

Abstract

The invention relates to a microcontroller load rate test method, device and system and a vehicle, and is applied to the technical field of microcontrollers, and the method comprises the steps: recognizing a start task identifier and an end task identifier of each task from a source code of a microcontroller in real time; when a starting task identifier of each task is identified, calling a timer function to obtain a starting moment of the task; when an end task identifier of each task is identified, calling a timer function to obtain an end moment of the task; and sending log data including a start task identifier, an end task identifier, a start moment and an end moment of each task to an upper computer based on a controller area network bus protocol, so that the upper computer identifies each task based on the start task identifier and the end task identifier, and determining the load rate of each task and the overall load rate according to the starting time and the ending time. According to the invention, the overall load rate of the microcontroller and the load rate of a single task can be tested in real time before and after mass production of the microcontroller.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of microcontroller technology, and in particular to a microcontroller load rate testing method, device, system and vehicle. Background Art

[0002] In the modern automobile industry, MCU (Microcontroller Unit) is the core control unit, and its performance directly affects the running stability and safety of the whole vehicle. Therefore, in the process of MCU software development, it is very important to calculate the MCU load rate in real time to ensure the reliable operation of the program.

[0003] In the related art, the load rate test is usually carried out by debugging means such as the Jtag (Joint Test Action Group) interface. This method can simulate the vehicle driving situation on a single unit or Hil test bench to test the MCU load rate. However, this method can only simulate the vehicle driving situation on a single unit or Hil (Hardware-in-the-Loop) test bench to test the MCU load rate, and after the microcontroller is mass-produced, its load rate cannot be tested. Most working conditions need to be triggered in the actual situation after the vehicle is running, and the MCU load rate under actual working conditions is more reliable and effective, which is of practical help to software developers in troubleshooting problems. Summary of the invention

[0004] In order to solve the above technical problems, the present application provides a microcontroller load rate testing method, device, system and vehicle.

[0005] According to a first aspect of the present application, a microcontroller load rate testing method is provided, comprising:

[0006] identifying in real time from the source code of the microcontroller the start task identifier and the end task identifier of each task executed by the microcontroller;

[0007] When the start task identifier of each task is identified, a timer function is called to obtain the start time of the task;

[0008] When the end task identifier of each task is identified, the timer function is called to obtain the end time of the task;

[0009] Based on the controller area network bus protocol, log data including the start task identifier, end task identifier, start time and end time of each task is sent to the host computer, so that the host computer can identify each task based on the start task identifier and the end task identifier, and determine the load rate of each task and the overall load rate of the microcontroller according to the start time and the end time.

[0010] Optionally, the sending of log data including a start task identifier, an end task identifier, a start time and an end time of each task to a host computer based on a controller area network bus protocol includes:

[0011] Use the Can_Write function to send log data containing the start task identifier, end task identifier, start time and end time of each task to the host computer.

[0012] Optionally, the accuracy of the time output by the timer function is at the microsecond level.

[0013] According to a second aspect of the present application, a microcontroller load rate testing device is provided, comprising:

[0014] A task identification module is used to identify the start task identification and the end task identification of each task executed by the microcontroller in real time from the source code of the microcontroller;

[0015] A start time determination module is used to call a timer function to obtain the start time of each task when the start task identifier of each task is identified;

[0016] An end time determination module is used to call a timer function to obtain the end time of each task when an end task identifier of each task is identified;

[0017] The log data sending module is used to send log data containing the start task identifier, end task identifier, start time and end time of each task to the host computer based on the controller local area network bus protocol, so that the host computer can identify each task based on the start task identifier and the end task identifier, and determine the load rate of each task and the overall load rate of the microcontroller according to the start time and the end time.

[0018] Optionally, the log data sending module is specifically used to send log data including a start task identifier, an end task identifier, a start time and an end time of each task to a host computer using a Can_Write function.

[0019] Optionally, the accuracy of the time output by the timer function is at the microsecond level.

[0020] According to a third aspect of the present application, there is provided a microcontroller load rate testing system, comprising: a lower computer and an upper computer;

[0021] The lower computer is used to identify the start task identifier and the end task identifier of each task executed by the microcontroller in real time from the source code of the microcontroller; when the start task identifier of each task is identified, the timer function is called to obtain the start time of the task; when the end task identifier of each task is identified, the timer function is called to obtain the end time of the task; based on the controller local area network bus protocol, the log data containing the start task identifier, the end task identifier, the start time and the end time of each task are sent to the upper computer;

[0022] The host computer is used to identify each task based on the start task identifier and the end task identifier, and determine the load rate of each task and the overall load rate of the microcontroller according to the start time and the end time.

[0023] Optionally, the lower computer is specifically used to send log data including a start task identifier, an end task identifier, a start time and an end time of each task to the upper computer using a Can_Write function.

[0024] Optionally, the accuracy of the time output by the timer function is at the microsecond level.

[0025] According to a fourth aspect of the present application, a vehicle is provided, comprising: the device described in the second aspect.

[0026] According to a fifth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method described in the first aspect is implemented.

[0027] According to a sixth aspect of the present application, a computer program product is provided. When the computer program product is run on a computer, the computer is enabled to execute the method described in the first aspect.

[0028] Compared with the prior art, the technical solution provided by the embodiments of the present application has the following advantages:

[0029] By adding a start task identifier and a timer function to the start position of each task in the source code of the microcontroller in advance, and adding an end task identifier and a timer function to the end position, when analyzing the load rate of the microcontroller, the start task identifier and the end task identifier are identified from the source code to accurately locate the start and end positions of each task. In addition, by calling the timer function at the start and end positions of each task, the execution time of each task can be accurately obtained, and then the instantaneous load rate of a single task and the overall load rate of the microcontroller can be obtained. The embodiment of the present application can not only test the load rate of the microcontroller before mass production, but also test the load rate of the microcontroller after mass production, thereby helping developers to find and solve problems. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0031] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0032] Figure 1 A flow chart of a microcontroller load rate testing method in an embodiment of the present application;

[0033] Figure 2 A schematic diagram of the structure of a microcontroller load rate testing device in an embodiment of the present application;

[0034] Figure 3 A structural schematic diagram of a microcontroller load rate testing system in an embodiment of the present application. DETAILED DESCRIPTION

[0035] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0036] In the following description, many specific details are set forth to facilitate a full understanding of the present application, but the present application may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only part of the embodiments of the present application, rather than all of the embodiments.

[0037] The microcontroller load rate testing method of the embodiment of the present application is applied to a lower computer, which includes: MCU, ECU (ectronic Control Unit), and HCU (Hydraulic Control Unit).

[0038] See also Figure 1 , Figure 1 A flow chart of a microcontroller load rate testing method in an embodiment of the present application may include the following steps:

[0039] Step S102 , identifying in real time from the source code of the microcontroller the start task identifier and the end task identifier of each task executed by the microcontroller.

[0040] In an embodiment of the present application, a set of uint32 bits of data can be defined, wherein 4 bytes store a number, 6 numbers store time data (i.e., the start time and the end time), and 2 numbers store the start task identifier and the end task identifier. For example, an array named "timeData" can be defined to store time data, wherein each element represents a time point. An array named "pileID" is defined to store the start task identifier and the end task identifier. The start task identifier and the end task identifier corresponding to each task are unique.

[0041] A start task identifier is inserted into the start position of each task in the source code of the microcontroller in advance, and an end task identifier is inserted into the end position of each task. In this way, the start position and the end position of each task can be accurately located by identifying the start task identifier and the end task identifier in the source code of the microcontroller. In addition, through the built-in long timing counter of the embedded system, the register for obtaining the real-time value of the counter is encapsulated into a timer function, and the timer function is inserted into the start position and the end position of each task.

[0042] Step S104, when the start task identifier of each task is identified, the timer function is called to obtain the start time of the task.

[0043] When the start task identifier of each task is identified, it means that the task is started, and the timer function is called to obtain the start time of the task.

[0044] Step S106, when the end task identifier of each task is identified, the timer function is called to obtain the end time of the task.

[0045] When the end task identifier of each task is identified, it means that the task is completed, and the timer function is called to get the end time of the task. Optionally, the accuracy of the time output by the timer function is at the us level. For example, a counter named "timerCounter" can be used, and the resolution of the counter is 1us. The value of the counter is called at the start and end of each task. In this way, even if the interrupt is a fast-running and difficult-to-capture task, its maximum execution time can be accurately tested.

[0046] Step S108, based on the controller LAN bus protocol, sends log data including the start task identifier, end task identifier, start time and end time of each task to the host computer, so that the host computer can identify each task based on the start task identifier and the end task identifier, and determine the load rate of each task and the overall load rate of the microcontroller according to the start time and the end time.

[0047] CAN (Controller Area Network) bus technology is a communication technology widely used in the automotive field and is widely used in MCU load rate testing. In the embodiment of the present application, the lower computer sends log data including the start task identifier, end task identifier, start time and end time of each task to the upper computer based on the controller area network bus protocol. The CAN communication interface can be adapted to various test environments and has strong adaptability.

[0048] Optionally, the underlying Can_Write function can be used to send log data containing the start task identifier, end task identifier, start time, and end time of each task to the host computer. The parameters related to the Can_Wriite function are mainly the handle and the transmitted data, where the handle can be matched in the Canif configuration file to ensure normal data transmission and reception. For example, a function called "canSend" can be used, the parameters of which include the handle and the data to be sent, where the handle can be matched in the Canif configuration file.

[0049] After receiving the log data, the host computer identifies the specific task according to the start task identifier and end task identifier in the log data, and calculates the execution time of the task according to the start time and end time. The execution time of the same task under different working conditions is usually different. The host computer can receive log data sent by multiple different slave computers. The shortest time, longest time, and average time of the same task can be parsed out by post-processing for analysis by software developers. Software developers can easily analyze the running performance of the software, find performance bottlenecks, and optimize software design.

[0050] The microcontroller load rate test method of the embodiment of the present application can obtain the load rate of the MCU in real time, and can be accurate to the level of 1us, so as to accurately calculate the load rate of a single task or interrupt. It is of great significance to improve the operational stability and safety of the microcontroller, especially in the automotive industry, and can effectively avoid abnormal working conditions such as software stuck due to the excessively high load rate of the MCU, thereby improving the operational stability and safety of the vehicle. The present application can not only test the load rate of the microcontroller before mass production, but also test the load rate of the controller after mass production, so that the performance of the MCU can be more accurately evaluated, thereby improving the quality and reliability of the product. The present application sends data based on the CAN protocol, so the data sending device is replaceable, such as serial port, Ethernet, so that it can be applied not only to the automotive field, but also to other fields that require MCU load rate testing, such as industrial automation field, smart home field, etc.

[0051] It should be noted that although the steps of the method in the present application are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0052] The present application also provides a microcontroller load rate test device, see Figure 2 , the microcontroller load rate testing device 200 comprises:

[0053] The task identification module 202 is used to identify the start task identification and the end task identification of each task executed by the microcontroller in real time from the source code of the microcontroller;

[0054] The start time determination module 204 is used to call the timer function to obtain the start time of each task when the start task identifier of each task is identified;

[0055] The end time determination module 206 is used to call the timer function to obtain the end time of the task when the end task identifier of each task is identified;

[0056] The log data sending module 208 is used to send log data including the start task identifier, end task identifier, start time and end time of each task to the host computer based on the controller LAN bus protocol, so that the host computer can identify each task based on the start task identifier and the end task identifier, and determine the load rate of each task and the overall load rate of the microcontroller according to the start time and the end time.

[0057] Optionally, the log data sending module 208 is specifically used to send log data including the start task identifier, end task identifier, start time and end time of each task to the host computer using the Can_Write function.

[0058] Optionally, the time output by the timer function has an accuracy of microseconds.

[0059] The specific details of each module or unit in the above device have been described in detail in the corresponding method, so they will not be repeated here.

[0060] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0061] The present application also provides a microcontroller load rate testing system. Figure 3 , the microcontroller load rate test system 300 includes: a lower computer 310 and an upper computer 320;

[0062] The lower computer 310 is used to identify the start task identifier and the end task identifier of each task executed by the microcontroller in real time from the source code of the microcontroller; when the start task identifier of each task is identified, the timer function is called to obtain the start time of the task; when the end task identifier of each task is identified, the timer function is called to obtain the end time of the task; based on the controller local area network bus protocol, the log data containing the start task identifier, the end task identifier, the start time and the end time of each task is sent to the upper computer;

[0063] The host computer 320 is used to identify each task based on the start task identifier and the end task identifier, and determine the load rate of each task and the overall load rate of the microcontroller according to the start time and the end time.

[0064] Optionally, the lower computer 310 is specifically used to send log data including a start task identifier, an end task identifier, a start time and an end time of each task to the upper computer by using the Can_Write function.

[0065] Optionally, the time output by the timer function has an accuracy of microseconds.

[0066] An embodiment of the present application also provides a vehicle, comprising the above-mentioned microcontroller load rate testing device.

[0067] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned microcontroller load rate testing method is implemented.

[0068] It should be noted that the computer-readable storage medium shown in the present application may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, radio frequency, etc., or any suitable combination of the above.

[0069] In an embodiment of the present application, a computer program product is also provided. When the computer program product is run on a computer, the computer executes the above-mentioned microcontroller load rate testing method.

[0070] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0071] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A microcontroller load rate testing method, characterized in that: The method comprises: identifying in real time from the source code of the microcontroller the start task identifier and the end task identifier of each task executed by the microcontroller; When the start task identifier of each task is identified, a timer function is called to obtain the start time of the task; When the end task identifier of each task is identified, the timer function is called to obtain the end time of the task; Based on the controller area network bus protocol, log data including the start task identifier, end task identifier, start time and end time of each task is sent to the host computer, so that the host computer can identify each task based on the start task identifier and the end task identifier, and determine the load rate of each task and the overall load rate of the microcontroller according to the start time and the end time.

2. The method according to claim 1, characterized in that: The sending of log data including the start task identifier, end task identifier, start time and end time of each task to the host computer based on the controller area network bus protocol includes: Use the Can_Write function to send log data containing the start task identifier, end task identifier, start time and end time of each task to the host computer.

3. The method according to claim 1, characterized in that The accuracy of the time output by the timer function is at the microsecond level.

4. A microcontroller load rate testing device, characterized in that: The device comprises: A task identification module is used to identify the start task identification and the end task identification of each task executed by the microcontroller in real time from the source code of the microcontroller; A start time determination module is used to call a timer function to obtain the start time of each task when the start task identifier of each task is identified; An end time determination module is used to call a timer function to obtain the end time of each task when an end task identifier of each task is identified; The log data sending module is used to send log data containing the start task identifier, end task identifier, start time and end time of each task to the host computer based on the controller local area network bus protocol, so that the host computer can identify each task based on the start task identifier and the end task identifier, and determine the load rate of each task and the overall load rate of the microcontroller according to the start time and the end time.

5. The device according to claim 4, characterized in that The log data sending module is specifically used to send log data including the start task identifier, end task identifier, start time and end time of each task to the host computer using the Can_Write function.

6. The device according to claim 4, characterized in that The accuracy of the time output by the timer function is at the microsecond level.

7. A microcontroller load rate testing system, characterized in that: include: Lower computer and upper computer; The lower computer is used to identify the start task identifier and the end task identifier of each task executed by the microcontroller in real time from the source code of the microcontroller; When the start task identifier of each task is identified, the timer function is called to obtain the start time of the task; when the end task identifier of each task is identified, the timer function is called to obtain the end time of the task; based on the controller area network bus protocol, log data containing the start task identifier, end task identifier, start time and end time of each task is sent to the host computer; The host computer is used to identify each task based on the start task identifier and the end task identifier, and determine the load rate of each task and the overall load rate of the microcontroller according to the start time and the end time.

8. The system according to claim 7, characterized in that The lower computer is specifically used to send log data including the start task identifier, end task identifier, start time and end time of each task to the upper computer using the Can_Write function.

9. The system according to claim 7, characterized in that The accuracy of the time output by the timer function is at the microsecond level.

10. A vehicle, characterized in that: include: The device according to any one of claims 4 to 6.