Refreshing method of control register and related device

By implementing the periodic register refresh method in the automotive electronic controller, the problem of abnormal driver chip function caused by changes in the control register data is solved, ensuring the stable operation of the automotive functions.

CN119883371APending Publication Date: 2025-04-25BEIJING JINGWEI HIRAIN TECH CO INC
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510045320.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-10
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The data changes in the control register cause abnormal function of the driver chip, which in turn leads to the out of control of the car.

Method used

By implementing the register refresh method when periodic main task is implemented in the microcontroller unit MCU of the electronic controller ECU, the number of executions of the main task is counted, and whether the refresh time is reached is determined based on the preconfigured refresh cycle and the task execution cycle, and the target control register is refreshed.

Benefits of technology

Ensure that the control register data of the driver chip is stable, avoid functional abnormalities, and ensure the normal operation of the car's functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883371A_ABST
    Figure CN119883371A_ABST
Patent Text Reader

Abstract

The invention discloses a control register refreshing method and a related device, and relates to the technical field of automotive electronics, and the method comprises the following steps: when a periodic main task is executed, counting the execution times of the main task from the refreshing time of the last register to the current moment; according to the number of execution times of the main task, a pre-configured register refresh cycle and a pre-configured task execution cycle for the main task, whether register refresh time is reached or not is determined; if the register refreshing time is reached, refreshing a control register corresponding to the target control register identifier; and after the control register corresponding to the target control register identifier is refreshed, updating the target control register identifier into the identifier of the next to-be-refreshed control register. When the data in the control register is changed due to external interference, the data in the control register can be recovered to the original data through the method disclosed by the invention, so that the normal function of the driving chip can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automotive electronic technology, and in particular to a control register refresh method and related devices. Background Art

[0002] In order to meet the needs of various automobile functions, the automobile electronic controller ECU integrates more and more driver chips. Each driver chip has several control registers. The microcontroller unit MCU in the ECU can write data to the control register of the driver chip. Then, the complex driver chip drives the corresponding external load according to the data in its own control register.

[0003] Sometimes, the driver chip is affected by certain factors (such as the external environment), which may cause the data in the control register to change. The change in the data in the control register may cause the driver chip to malfunction, and eventually lead to loss of control of the vehicle's functions. Summary of the invention

[0004] In view of this, the present application provides a control register refresh method and related devices to solve the problem that the data in the control register changes and causes the driver chip to function abnormally, which eventually leads to the loss of control of the vehicle function. The technical solution is as follows:

[0005] In a first aspect, the present application provides a control register refresh method, which is applied to a microcontroller unit MCU in an electronic controller ECU. The control register refresh method comprises:

[0006] Whenever a periodic main task is executed, the number of executions of the main task from the last register refresh time to the current time is counted;

[0007] Determining whether a register refresh time has been reached according to the number of executions of the main task, a preconfigured register refresh cycle, and a task execution cycle preconfigured for the main task;

[0008] If the register refresh time is reached, the control register corresponding to the target control register identifier is refreshed, wherein the target control register identifier is an identifier of a control register to be refreshed of a driver chip in the ECU;

[0009] After completing refreshing of the control register corresponding to the target control register identifier, the target control register identifier is updated to the identifier of the next control register to be refreshed.

[0010] In a possible implementation, determining whether the register refresh time has arrived according to the number of executions of the main task, a preconfigured register refresh cycle, and a task execution cycle preconfigured for the main task includes:

[0011] According to the preconfigured task execution cycle and the preconfigured register refresh cycle, determining the number of times the main task can be executed within the preconfigured register refresh cycle to obtain a target number;

[0012] Determining whether the execution times of the main task reaches the target times;

[0013] If the execution times of the main task reaches the target times, it is determined that the register refresh time has been reached; if the execution times of the main task does not reach the target times, it is determined that the register refresh time has not been reached.

[0014] In a possible implementation, a random access memory RAM of the MCU stores register data corresponding to a plurality of control register identifiers, and the register data corresponding to any control register identifier in the RAM is the data most recently written by the MCU to the control register corresponding to the control register identifier;

[0015] The step of refreshing the control register corresponding to the target control register identifier includes:

[0016] Reading register data corresponding to the target control register identifier from the RAM to obtain first register data;

[0017] Read register data from the control register corresponding to the target control register identifier to obtain second register data;

[0018] Determining whether the first register data is consistent with the second register data;

[0019] If the first register data is inconsistent with the second register data, the first register data is overwritten and written into the control register corresponding to the target control register identifier.

[0020] In a possible implementation, the method for refreshing the control register further includes:

[0021] If the first register data is inconsistent with the second register data, register fault information indicating that a control register corresponding to the target control register identifier has a fault is output.

[0022] In a possible implementation, whenever the periodic main task is executed, the number of executions of the main task from the last register refresh time to the current time is counted, including:

[0023] Whenever a periodic task function for executing a main task is called, a refresh function function set in the periodic task function is used to count the number of calls of the periodic task function from the last register refresh time to the current moment;

[0024] The determining whether the register refresh time has arrived according to the number of executions of the main task, the preconfigured register refresh cycle, and the task execution cycle preconfigured for the main task includes:

[0025] The refresh function is used to determine whether the register refresh time has arrived according to the number of calls of the periodic task function, the preconfigured register refresh cycle, and the function call cycle preconfigured for the periodic task function.

[0026] In a possible implementation manner, refreshing the control register corresponding to the target control register identifier includes:

[0027] Refreshing the control register corresponding to the target control register identifier using the refresh register function set in the periodic task function;

[0028] The step of updating the target control register identifier to the identifier of the next control register to be refreshed includes:

[0029] The target control register identifier is updated to the identifier of the next control register to be refreshed by using the refresh register function.

[0030] A second aspect of the present application provides a control register refresh device, which is applied to a microcontroller unit MCU in an electronic controller ECU, wherein the control register refresh device comprises: a task execution times counting module, a register refresh time determining module, a register refresh module and a register identification updating module;

[0031] The task execution times statistics module is used to count the execution times of the main task from the last register refresh time to the current time whenever a periodic main task is executed;

[0032] The register refresh time determination module is used to determine whether the register refresh time has arrived according to the number of executions of the main task, the preconfigured register refresh cycle, and the task execution cycle preconfigured for the main task;

[0033] The register refresh module is used to refresh the control register corresponding to the target control register identifier when the register refresh time is reached, wherein the target control register identifier is an identifier of a control register to be refreshed of a driver chip in the ECU;

[0034] The register identifier updating module is used to update the target control register identifier to the identifier of the next control register to be refreshed after the register refreshing module completes refreshing the control register corresponding to the target control register identifier.

[0035] The third aspect of the present application provides an electronic controller ECU, including a microcontroller unit MCU and a plurality of driver chips:

[0036] The MCU is used to refresh the control registers of the plurality of driver chips using any one of the control register refresh methods described above.

[0037] The fourth aspect of the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by a microcontroller unit MCU in an electronic controller ECU, the MCU can implement the steps of the control register refresh method described in any one of the above.

[0038] The fifth aspect of the present application provides a computer program product, comprising computer-readable instructions. When the computer-readable instructions are executed on a microcontroller unit MCU in an electronic controller ECU, the MCU implements the steps of any one of the above-mentioned control register refresh methods.

[0039] By means of the above technical scheme, the control register refresh method provided by the present application counts the number of executions of the main task from the last register refresh time to the current moment each time a periodic main task is executed, and determines whether the register refresh time has been reached based on the number of executions of the main task from the last register refresh time to the current moment, the preconfigured register refresh cycle, and the preconfigured task execution cycle for the main task. If the register refresh time has been reached, the control register corresponding to the target control register identifier is refreshed, and after completing the refresh of the control register corresponding to the target control register identifier, the target control register identifier is updated to the identifier of the next control register to be refreshed. The control register refresh method provided in the present application can refresh the control register of the driver chip according to a preconfigured register refresh cycle. When the data in the control register of the driver chip changes due to certain factors, the data in the control register can be restored to the original data through the refresh operation, thereby ensuring the normal function of the driver chip. In addition, the control register refresh method provided in the present application refreshes the control register according to the register refresh cycle configured by the user, and only one control register is refreshed each time. Refreshing the control register according to the register refresh cycle configured by the user allows the user to flexibly configure the register refresh cycle, and only one control register is refreshed each time so that the execution of the main task will not be affected. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the embodiments of the present invention 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, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0041] Figure 1 A flowchart of a method for refreshing a control register provided in an embodiment of the present application;

[0042] Figure 2 A schematic diagram of a driver chip and a control register of the driver chip in an ECU provided in an embodiment of the present application;

[0043] Figure 3 A flow chart of determining whether a register refresh time has been reached according to the number of executions of a main task from the last register refresh time to the current moment, a preconfigured register refresh cycle, and a preconfigured task execution cycle for the main task provided in an embodiment of the present application;

[0044] Figure 4 A schematic diagram of a process for refreshing a control register corresponding to a target control register identifier provided in an embodiment of the present application;

[0045] Figure 5 A schematic diagram of the structure of a refresh device for a control register provided in an embodiment of the present application. DETAILED DESCRIPTION

[0046] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.

[0047] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0048] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0049] The driver chip may be disturbed by certain factors (such as momentary high-voltage static electricity), which may cause changes in the data in the control register. Changes in the data in the control register may cause abnormal functions of the driver chip, and ultimately lead to loss of control of the vehicle functions. In response to the above problem, the inventor of this case thought that it could be solved by refreshing the control register of the driver chip.

[0050] In order to realize the refresh of the control registers of the driver chip, the inventor of this case conducted research. The initial idea was: every 100 times the MCU executes the main task, all the control registers of all the driver chips are refreshed.

[0051] The inventor of this case studied the above idea and found that although the above idea can realize the refresh of the control register and thus ensure the normal function of the driver chip, when refreshing all the control registers of all the driver chips, since the MCU needs to write data to each control register of each driver chip, the MCU communicates with the driver chip more times and the communication time is longer. The more times and the longer the communication time between the MCU and the driver chip will affect the execution of the main task by the MCU.

[0052] In view of the problems existing in the above-mentioned ideas, the inventor of this case continued to conduct research, and finally proposed a control register refresh method with better effect through continuous research. This control register refresh method can not only realize the refresh of the control register, but also will not affect the execution of the main task.

[0053] Next, the control register refresh method provided by the present application is introduced through the following embodiments.

[0054] See also Figure 1 , shows a flow chart of a control register refresh method provided in an embodiment of the present application, the control register refresh method is applied to a microcontroller unit MCU in an electronic controller ECU, and the control register refresh method may include:

[0055] Step S101: Whenever a periodic main task is executed, the number of executions of the main task from the last register refresh time to the current time is counted.

[0056] Among them, the main task is a periodic task, which refers to a task that the MCU needs to execute once every period of time.

[0057] In this embodiment, the MCU executes a main task once at a certain time interval, and refreshes the control register once at a certain time interval. Whenever the MCU executes a main task, the number of executions of the main task from the last register refresh time to the current moment is counted.

[0058] Step S102: determining whether the register refresh time has arrived according to the number of executions of the main task from the last register refresh time to the current moment, the preconfigured register refresh cycle, and the preconfigured task execution cycle for the main task.

[0059] In this embodiment, the task execution cycle and register refresh cycle of the main task can be configured by the user. Usually, the task execution cycle of the main task is short and the register refresh cycle is relatively long. For example, the task execution cycle of the main task can be configured to be 10ms and the register refresh cycle can be configured to be 1000ms.

[0060] Step S103: If the register refresh time is reached, the control register corresponding to the target control register identifier is refreshed.

[0061] The target control register identifier is an identifier of a control register to be refreshed of a driver chip in the ECU, and the target control register identifier can indicate which control register of which driver chip the corresponding control register is.

[0062] The target control register identifier may include a first identifier ID1 and a second identifier ID2, wherein the first identifier ID1 is used to indicate the driver chip to which the corresponding control register belongs, and the second identifier ID2 is used to indicate which control register in the driver chip the corresponding control register belongs to.

[0063] The first identifier ID1 may be the identifier of the driver chip to which the corresponding control register belongs, and the second identifier may be the identifier of the corresponding control register in the driver chip to which it belongs. It should be noted that each driver chip in the ECU has an identifier, and each control register of each driver chip has its identifier in the driver chip to which it belongs. For example, Figure 2As shown, there are M driver chips in the ECU, the first driver chip is identified as 1, the driver chip identified as 1 includes n+1 control registers, the identifications of the n+1 control registers in the driver chip identified as 1 are 0, 1, 2, ..., n respectively, the second driver chip is identified as 2, the driver chip identified as 2 includes n+1 control registers, the identifications of the n+1 control registers in the driver chip identified as 2 are 0, 1, 2, ..., n respectively, and the same applies to other driver chips.

[0064] Exemplarily, if the target control register identifier is (ID1=1, ID2=1), the control register corresponding to the target control register identifier is refreshed, that is, the control register identified as 1 in the driver chip identified as 1 is refreshed.

[0065] It should be noted that before the first refresh, the target control register identifier may be initialized first, for example, the target control register identifier may be initialized to (ID1=1, ID2=0).

[0066] Considering that the MCU and the driver chip communicate frequently and for a long time, which will affect the execution of the main task, in order not to affect the execution of the main task, this embodiment proposes to refresh only one control register each time.

[0067] Step S104: after completing the refreshing of the control register corresponding to the target control register identifier, the target control register identifier is updated to the identifier of the next control register to be refreshed.

[0068] The target control register identifier is updated to the identifier of the next control register to be refreshed, so that when the register refresh time is reached again, the next control register to be refreshed is refreshed.

[0069] Exemplarily, the current target control register is identified as (ID1=1, ID2=0). After completing the refresh of the control register identified as 0 in the driver chip identified as 1, the target control register identifier is updated to (ID1=1, ID2=1), that is, the control register identified as 1 in the driver chip identified as 1 is refreshed next time.

[0070] Exemplarily, the current target control register is identified as (ID1=1, ID2=n). After completing the refresh of the control register identified as n in the driver chip identified as 1, the target control register identifier is updated to (ID1=2, ID2=0), that is, the control register identified as 0 in the driver chip identified as 2 is refreshed next time.

[0071] The control register refresh method provided in the embodiment of the present application counts the number of executions of the main task from the last register refresh time to the current moment each time a periodic main task is executed, and determines whether the register refresh time has been reached based on the number of executions of the main task from the last register refresh time to the current moment, the preconfigured register refresh cycle, and the preconfigured task execution cycle for the main task. If the register refresh time has been reached, the control register corresponding to the target control register identifier is refreshed, and after completing the refresh of the control register corresponding to the target control register identifier, the target control register identifier is updated to the identifier of the next control register to be refreshed. The control register refresh method provided in the embodiment of the present application can refresh the control register of the driver chip according to a preconfigured register refresh cycle. When the data in the control register of the driver chip changes due to certain factors, the data in the control register can be restored to the original data through the refresh operation, thereby ensuring the normal function of the driver chip. In addition, the control register refresh method provided in the embodiment of the present application refreshes the control register according to the register refresh cycle configured by the user, and only one control register is refreshed each time. Refreshing the control register according to the register refresh cycle configured by the user allows the user to flexibly configure the register refresh cycle, and only one control register is refreshed each time so that the execution of the main task will not be affected.

[0072] In another embodiment of the present application, the specific implementation process of "Step S101: whenever a periodic main task is executed, counting the number of executions of the main task from the last register refresh time to the current moment" and "Step S102: determining whether the register refresh time has been reached based on the number of executions of the main task from the last register refresh time to the current moment, the preconfigured register refresh cycle, and the preconfigured task execution cycle for the main task" in the above embodiment is introduced.

[0073] Whenever a periodic main task is executed, the process of counting the number of executions of the main task from the last register refresh time to the current moment may include: whenever a periodic task function for executing the main task is called, the refresh function function set in the periodic task function is used to count the number of calls of the periodic task function from the last register refresh time to the current moment.

[0074] When the ECU executes the main task, it calls the periodic task function used to execute the main task. In order to realize the refresh of the control register, the present application sets a refresh function function in the periodic task function. Based on the refresh function function in the periodic task function, the number of calls to the periodic task function from the last register refresh time to the current moment is counted.

[0075] A static variable RefreshCnt is defined in the refresh function. The initial value of RefreshCnt is 0. Each time the periodic task function is called, the refresh function adds 1 to the value of RefreshCnt. When the register refresh time is reached, the value of RefreshCnt is initialized to 0.

[0076] like Figure 3 As shown, according to the number of executions of the main task from the last register refresh time to the current moment, the preconfigured register refresh cycle, and the preconfigured task execution cycle for the main task, the process of determining whether the register refresh time has been reached may include:

[0077] Step S301: According to the preconfigured task execution cycle and the preconfigured register refresh cycle, the executable times of the main task within the preconfigured register refresh cycle are determined to obtain the target times.

[0078] If the preconfigured task execution period is represented as MAIN_PERIOD and the preconfigured register refresh period is represented as REFRESH_PERIOD, the target number of times can be obtained by calculating REFRESH_PERIOD / MAIN_PERIOD.

[0079] Exemplarily, the preconfigured register refresh cycle is 1000 ms, the preconfigured task execution cycle is 10 ms, and the target number of times=1000 / 10=100.

[0080] Step S302: Determine whether the execution times of the main task from the last register refresh time to the current time has reached the target times.

[0081] This embodiment determines whether the register refresh time has been reached by judging whether the execution times (RefreshCnt) of the main task from the last register refresh time to the current moment has reached the target times (REFRESH_PERIOD / MAIN_PERIOD).

[0082] Step S303a: If the number of executions of the main task from the last register refresh time to the current moment reaches the target number, it is determined that the register refresh time has been reached.

[0083] Step S303b: If the number of executions of the main task from the last register refresh time to the current moment does not reach the target number, it is determined that the register refresh time has not been reached.

[0084] Exemplarily, the target number is 100, and it is determined whether the number of executions of the main task from the last register refresh time to the current moment has reached 100. If the number of executions of the main task from the last register refresh time to the current moment has reached 100, it is determined that the register refresh time has been reached, otherwise, it is determined that the register refresh time has not been reached.

[0085] This embodiment is not limited to determining whether the register refresh time has been reached by judging whether the number of executions (RefreshCnt) of the main task from the last register refresh time to the current moment has reached the target number (REFRESH_PERIOD / MAIN_PERIOD). For example, whether the register refresh time has been reached may also be determined by judging whether the result obtained by multiplying RefreshCnt by MAIN_PERIOD has reached REFRESH_PERIOD.

[0086] The above content mentioned that a refresh function function can be set in the periodic task function. In a possible implementation method, the refresh function function set in the periodic task function can be used to determine whether the register refresh time has been reached based on the number of executions of the main task from the last register refresh time to the current moment (that is, the number of calls to the periodic task function from the last register refresh time to the current moment), the preconfigured register refresh cycle, and the preconfigured task execution cycle for the main task. When determining whether the register refresh time has been reached, the refresh function function can make a determination in the manner of steps S301 to S303 above.

[0087] In another embodiment of the present application, the specific implementation process of "step S103: if the register refresh time is reached, refreshing the control register corresponding to the target control register identifier" in the above embodiment is introduced.

[0088] like Figure 4 As shown, the implementation process of refreshing the control register corresponding to the target control register identifier may include:

[0089] Step S401: Read register data corresponding to a target control register identifier from a random access memory RAM to obtain first register data.

[0090] The RAM of the MCU stores register data corresponding to a number of control register identifiers. The register data corresponding to any control register identifier in the RAM is the latest data written by the MCU to the control register corresponding to the control register identifier.

[0091] It should be noted that when the MCU controls the driver chip, it will write data to the control register of the driver chip. In order to refresh the control register, when the MCU writes data to the control register of the driver chip, it will store the data written into the control register into the RAM for backup. In order to distinguish the data of different control registers, in addition to storing the register data, the RAM also stores the corresponding control register identifier, that is, the MCU's RAM stores register data corresponding to several control register identifiers.

[0092] Step S402: Read register data from the control register corresponding to the target control register identifier to obtain second register data.

[0093] The second register data can be obtained by reading register data from the control register corresponding to the target control register identifier via a communication bus connecting the MCU and the driver chip.

[0094] Step S403: Determine whether the first register data is consistent with the second register data.

[0095] By determining whether the first register data is consistent with the second register data, it can be known whether the data in the control register corresponding to the target control register identifier has changed due to interference from certain factors (such as external environment).

[0096] Step S404: If the first register data is inconsistent with the second register data, the first register data is overwritten and written into the control register corresponding to the target control register identifier.

[0097] If the first register data is inconsistent with the second register data, it means that the data in the control register corresponding to the target control register identifier has changed due to interference from certain factors (such as the external environment). At this time, it is necessary to refresh the control register corresponding to the target control register identifier, and then overwrite the first register data with the control register corresponding to the target control register identifier. In this way, the data in the control register corresponding to the target control register identifier is restored to the original data.

[0098] Optionally, when it is determined that the first register data is inconsistent with the second register data, register fault information indicating that a control register corresponding to the target control register identifier has a fault may be output.

[0099] It should be noted that if the first register data is consistent with the second register data, it means that the data in the control register corresponding to the target control register identifier has not changed. At this time, there is no need to refresh the control register corresponding to the target control register identifier.

[0100] In one possible implementation, a refresh register function may be set in the periodic task function. When the register refresh time is reached, the refresh register function set in the periodic task function may be used to refresh the control register corresponding to the target control register identifier. When refreshing the control register corresponding to the target control register identifier, the refresh register function may refresh in the manner of steps S401 to S404.

[0101] It should be noted that this embodiment is not limited to refreshing the control register corresponding to the target control register identifier in the manner of steps S401 to S404. For example, the register data corresponding to the target control register identifier can also be read from the RAM, and the register data read from the RAM can be directly overwritten and written into the control register corresponding to the target control register identifier.

[0102] After completing the refresh operation on the control register corresponding to the target control register identifier, the target control register identifier (ID1, ID2) may be updated to the identifier of the next control register to be refreshed using the refresh register function.

[0103] The above describes the control register refresh method provided in the embodiment of the present application. The following describes the device corresponding to the control register refresh method.

[0104] See also Figure 5 , Figure 5 A structural diagram of a control register refresh device provided in an embodiment of the present application, the control register refresh device may include: a task execution times counting module 501, a register refresh time determination module 502, a register refresh module 503 and a register identification update module 504.

[0105] The task execution times statistics module 501 is used to count the execution times of the main task from the last register refresh time to the current time whenever a periodic main task is executed.

[0106] The register refresh time determination module 502 is used to determine whether the register refresh time has been reached based on the number of executions of the main task from the last register refresh time to the current moment, the preconfigured register refresh cycle, and the preconfigured task execution cycle for the main task.

[0107] The register refresh module 503 is used to refresh the control register corresponding to the target control register identifier when the register refresh time is reached, wherein the target control register identifier is the identifier of a control register to be refreshed of a driver chip in the ECU.

[0108] The register identifier updating module 504 is used to update the target control register identifier to the identifier of the next control register to be refreshed after the register refreshing module 503 completes refreshing of the control register corresponding to the target control register identifier.

[0109] In a possible implementation, the register refresh time determination module 502 determines whether the register refresh time has been reached according to the number of executions of the main task from the last register refresh time to the current moment, the preconfigured register refresh cycle, and the preconfigured task execution cycle for the main task, and is specifically used to:

[0110] According to the preconfigured task execution cycle and the preconfigured register refresh cycle, determining the number of times the main task can be executed within the preconfigured register refresh cycle to obtain a target number;

[0111] Determining whether the execution times of the main task reaches the target times;

[0112] If the execution times of the main task reaches the target times, it is determined that the register refresh time has been reached; if the execution times of the main task does not reach the target times, it is determined that the register refresh time has not been reached.

[0113] In a possible implementation, register data corresponding to a number of control register identifiers are stored in the random access memory RAM of the MCU, and the register data corresponding to any control register identifier in the RAM is the latest data written by the MCU to the control register corresponding to the control register identifier.

[0114] When refreshing the control register corresponding to the target control register identifier, the register refreshing module 503 is specifically used to:

[0115] Read the register data corresponding to the target control register identifier from the RAM to obtain the first register data;

[0116] Read register data from the control register corresponding to the target control register identifier to obtain second register data;

[0117] Determining whether the first register data is consistent with the second register data;

[0118] If the first register data is inconsistent with the second register data, the first register data is overwritten and written into the control register corresponding to the target control register identifier.

[0119] In a possible implementation, the device for controlling register refresh may further include: a register fault information output module.

[0120] The register fault information output module is used to output register fault information indicating that a control register corresponding to the target control register identifier has a fault when the first register data is inconsistent with the second register data.

[0121] In a possible implementation, the task execution count counting module 501 counts the execution count of the main task from the last register refresh time to the current time whenever a periodic main task is executed, specifically for:

[0122] Whenever the periodic task function for executing the main task is called, the refresh function function set in the periodic task function is used to count the number of calls to the periodic task function from the last register refresh time to the current moment;

[0123] The register refresh time determination module 502 is specifically used to determine whether the register refresh time has arrived according to the number of executions of the main task, the preconfigured register refresh cycle, and the task execution cycle preconfigured for the main task:

[0124] By using the refresh function function set in the periodic task function, it is determined whether the register refresh time has arrived according to the number of calls of the periodic task function, the preconfigured register refresh cycle and the function call cycle preconfigured for the periodic task function.

[0125] In a possible implementation, when refreshing the control register corresponding to the target control register identifier, the register refreshing module 503 is specifically configured to:

[0126] The control register corresponding to the target control register identifier is refreshed using the refresh register function set in the periodic task function.

[0127] The register identification updating module 504, when updating the target control register identification to the identification of the next control register to be refreshed, is specifically used to:

[0128] The target control register identifier is updated to the identifier of the next control register to be refreshed by using the refresh register function set in the periodic task function.

[0129] The control register refresh device provided in the embodiment of the present application counts the number of executions of the main task from the last register refresh time to the current moment each time a periodic main task is executed, and determines whether the register refresh time has been reached based on the number of executions of the main task from the last register refresh time to the current moment, the preconfigured register refresh cycle, and the preconfigured task execution cycle for the main task. If the register refresh time has been reached, the control register corresponding to the target control register identifier is refreshed, and after completing the refresh of the control register corresponding to the target control register identifier, the target control register identifier is updated to the identifier of the next control register to be refreshed. The control register refresh device provided in the embodiment of the present application can refresh the control register of the driver chip according to a preconfigured register refresh cycle. When the data in the control register of the driver chip changes due to certain factors, the data in the control register can be restored to the original data through the refresh operation, thereby ensuring the normal function of the driver chip. In addition, the control register refresh device provided in the embodiment of the present application refreshes the control register according to the register refresh cycle configured by the user, and only one control register is refreshed each time. Refreshing the control register according to the register refresh cycle configured by the user allows the user to flexibly configure the register refresh cycle, and only one control register is refreshed each time so that the execution of the main task will not be affected.

[0130] An embodiment of the present application also provides an electronic controller ECU, which includes a microcontroller unit MCU and several driver chips.

[0131] The MCU is used to refresh the control registers of several driver chips using the control register refresh method provided in the above embodiment.

[0132] An embodiment of the present application also provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by the MCU in the ECU, the MCU can implement the steps of the control register refresh method provided in the above embodiment.

[0133] An embodiment of the present application also provides a computer program product, including computer-readable instructions. When the computer-readable instructions are executed on the MCU in the ECU, the MCU implements the steps of the control register refresh method provided in the above embodiment.

[0134] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.

[0135] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0136] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0137] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

Claims

1. A method for refreshing a control register, characterized in that: The control register refresh method used in a microcontroller unit MCU in an electronic controller ECU includes: Whenever a periodic main task is executed, the number of executions of the main task from the last register refresh time to the current time is counted; Determining whether a register refresh time has been reached according to the number of executions of the main task, a preconfigured register refresh cycle, and a task execution cycle preconfigured for the main task; If the register refresh time is reached, the control register corresponding to the target control register identifier is refreshed, wherein the target control register identifier is an identifier of a control register to be refreshed of a driver chip in the ECU; After completing refreshing of the control register corresponding to the target control register identifier, the target control register identifier is updated to the identifier of the next control register to be refreshed.

2. The method for refreshing a control register according to claim 1, wherein: The determining whether the register refresh time has arrived according to the number of executions of the main task, the preconfigured register refresh cycle, and the task execution cycle preconfigured for the main task includes: According to the preconfigured task execution cycle and the preconfigured register refresh cycle, determining the number of times the main task can be executed within the preconfigured register refresh cycle to obtain a target number; Determining whether the execution times of the main task reaches the target times; If the execution times of the main task reaches the target times, it is determined that the register refresh time has been reached; if the execution times of the main task does not reach the target times, it is determined that the register refresh time has not been reached.

3. The method for refreshing a control register according to claim 1, characterized in that: The random access memory RAM of the MCU stores register data corresponding to a plurality of control register identifiers, and the register data corresponding to any control register identifier in the RAM is the data most recently written by the MCU to the control register corresponding to the control register identifier; The step of refreshing the control register corresponding to the target control register identifier includes: Reading register data corresponding to the target control register identifier from the RAM to obtain first register data; Read register data from the control register corresponding to the target control register identifier to obtain second register data; Determining whether the first register data is consistent with the second register data; If the first register data is inconsistent with the second register data, the first register data is overwritten and written into the control register corresponding to the target control register identifier.

4. The method for refreshing a control register according to claim 3, characterized in that: Also includes: If the first register data is inconsistent with the second register data, register fault information indicating that a control register corresponding to the target control register identifier has a fault is output.

5. The method for refreshing a control register according to claim 1, characterized in that: Whenever the periodic main task is executed, the number of executions of the main task from the last register refresh time to the current time is counted, including: Whenever a periodic task function for executing a main task is called, a refresh function function set in the periodic task function is used to count the number of calls of the periodic task function from the last register refresh time to the current moment; The determining whether the register refresh time has arrived according to the number of executions of the main task, the preconfigured register refresh cycle, and the task execution cycle preconfigured for the main task includes: The refresh function is used to determine whether the register refresh time has arrived according to the number of calls of the periodic task function, the preconfigured register refresh cycle, and the function call cycle preconfigured for the periodic task function.

6. The method for refreshing a control register according to claim 5, characterized in that: The step of refreshing the control register corresponding to the target control register identifier includes: Refreshing the control register corresponding to the target control register identifier using the refresh register function set in the periodic task function; The step of updating the target control register identifier to the identifier of the next control register to be refreshed includes: The target control register identifier is updated to the identifier of the next control register to be refreshed by using the refresh register function.

7. A refreshing device for a control register, characterized in that: The microcontroller unit MCU in the electronic controller ECU is applied, and the control register refresh device comprises: a task execution times counting module, a register refresh time determining module, a register refresh module and a register identification updating module; The task execution times statistics module is used to count the execution times of the main task from the last register refresh time to the current time whenever a periodic main task is executed; The register refresh time determination module is used to determine whether the register refresh time has arrived according to the number of executions of the main task, the preconfigured register refresh cycle, and the task execution cycle preconfigured for the main task; The register refresh module is used to refresh the control register corresponding to the target control register identifier when the register refresh time is reached, wherein the target control register identifier is an identifier of a control register to be refreshed of a driver chip in the ECU; The register identifier updating module is used to update the target control register identifier to the identifier of the next control register to be refreshed after the register refreshing module completes refreshing the control register corresponding to the target control register identifier.

8. An electronic controller ECU, characterized in that: include: Microcontroller unit MCU and several driver chips: The MCU is used to refresh the control registers of the plurality of driver chips using the control register refresh method as described in any one of claims 1 to 6.

9. A computer storage medium, characterized in that The storage medium carries one or more computer programs. When the one or more computer programs are executed by a microcontroller unit MCU in an electronic controller ECU, the MCU can implement the steps of the control register refresh method as described in any one of claims 1 to 6.

10. A computer program product, characterized in that The method comprises computer-readable instructions, and when the computer-readable instructions are executed on a microcontroller unit MCU in an electronic controller ECU, the MCU implements the steps of the control register refresh method as claimed in any one of claims 1 to 6.

Citation Information

Cited By

  • Driving method of off-chip chip and related device

    CN121348895A