Method, apparatus, vehicle, and storage medium for restoring system clock

By reading the RTC time when the MCU wakes up and performing compensation processing, the problem of low clock recovery efficiency of the MCU system caused by RTC time reading exceptions is solved, and fast and accurate system clock recovery is achieved, improving the efficiency of the timing system.

CN117687291BActive Publication Date: 2025-06-10XIAOMI EV TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311553636.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-20
Publication Date
2025-06-10
Estimated Expiration
2043-11-20

AI Technical Summary

Technical Problem

When the vehicle switches from the sleep state to the wake state, the time reading of the real-time clock RTC is abnormal, causing the microcontroller unit MCU system clock to be unable to recover quickly, affecting the efficiency of the timing system.

Method used

The time of the RTC is read when the MCU switches from the sleep state to the wake state. If the read is successful, the system clock of the MCU is restored based on the read time. If the read fails, the state switching compensation time and system time of the MCU are obtained, and the system time at the wake-up time is estimated through the summation operation, which is used to quickly restore the system clock of the MCU.

Benefits of technology

Even if RTC time is lost or read abnormal, the system clock of the MCU can be quickly and accurately restored, improving the time recovery efficiency of the MCU system clock and the efficiency of the timing system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117687291B_ABST
    Figure CN117687291B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method, apparatus, transportation vehicle, and storage medium for restoring a system clock. The specific solution includes: when a microcontroller unit (MCU) switches from a sleep state to a wake state, reading the time of a real-time clock (RTC); in response to successful reading of the RTC time, restoring the system clock of the MCU based on the read RTC time; or, in response to failure to read the RTC time, obtaining a status switching compensation time and a system time of the MCU, and restoring the system clock of the MCU according to the status switching compensation time and the system time, so that the system clock of the MCU can be restored quickly and accurately, improving the time restoration efficiency of the system clock of the MCU and improving the efficiency of the timing system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of time synchronization in a system, and particularly to a method, an apparatus, a vehicle, and a storage medium for restoring a system clock. Background Art

[0002] With the development of intelligent transportation technology, the electronic systems of vehicles have become increasingly complex. The Microcontroller Unit (MCU) is the core of internal operation and processing in the electronic system. When the vehicle is in a sleep state, the clock timing can be maintained by the Real Time Clock (RTC). After the vehicle is awakened, the MCU reads the time of the RTC to restore the hardware system time.

[0003] When the MCU reads the RTC, abnormal situations may occur occasionally, such as the loss of RTC time, abnormal reading of RTC time by the MCU, etc. As a result, the time of the MCU system cannot be restored, and it can only wait to be time-synchronized through other means, such as obtaining a time source like the Network Time Protocol (NTP) or the Global Navigation Satellite System (GNSS) to restore the system clock. However, it takes a long time to obtain time sources such as NTP and GNSS. During this period, the upper-layer applications will not be able to obtain valid time, resulting in low efficiency of the time-synchronization system. Summary of the Invention

[0004] The present disclosure provides a method, an apparatus, a vehicle, and a storage medium for restoring a system clock.

[0005] According to a first aspect of an embodiment of the present disclosure, a method for restoring a system clock is provided, including:

[0006] When the microcontroller unit (MCU) switches from a sleep state to a wake state, reading the time of the real-time clock (RTC);

[0007] In response to successful reading of the RTC time, restoring the system clock of the MCU based on the read RTC time; or,

[0008] In response to failed reading of the RTC time, obtaining the state-switching compensation time and the system time of the MCU, and restoring the system clock of the MCU according to the state-switching compensation time and the system time.

[0009] In some embodiments of the present disclosure, the system time includes at least one of the following:

[0010] The system time corresponding to the sleep moment when the MCU enters the sleep state this time;

[0011] The sleep duration when the MCU is in the sleep state this time.

[0012] In some embodiments of the present disclosure, the method further includes:

[0013] Writing the system time corresponding to the sleep moment when the MCU enters the sleep state this time into the storage unit; the storage unit maintains data without loss when the MCU is in the sleep state.

[0014] In some embodiments of the present disclosure, obtaining the system time corresponding to the sleep moment when the MCU enters the sleep state this time includes:

[0015] Obtaining the system time corresponding to the sleep moment when the MCU enters the sleep state this time from the storage unit.

[0016] In some embodiments of the present disclosure, the method further includes:

[0017] During the sleep of the MCU, controlling the MCU to operate with a minimum system; the minimum system includes an internal soft clock module operating at the software level within the MCU.

[0018] In some embodiments of the present disclosure, obtaining the sleep duration when the MCU is in the sleep state this time includes:

[0019] Obtaining the sleep duration when the MCU is in the sleep state this time from the internal soft clock module.

[0020] In some embodiments of the present disclosure, the state transition compensation time of the MCU is a calibrated value obtained by measuring the required duration of the MCU sample during the process of entering the sleep state from the wake state and / or entering the wake state from the sleep state.

[0021] In some embodiments of the present disclosure, restoring the system clock of the MCU according to the state transition compensation time and the system time includes:

[0022] Performing a summation operation on the state transition compensation time and the system time to obtain a total time;

[0023] Restoring the system clock of the MCU based on the total time.

[0024] According to the second aspect of the embodiments of the present disclosure, there is provided a device for restoring a system clock, including:

[0025] A reading module, configured to read the time of a real-time clock (RTC) when a microcontroller unit (MCU) switches from the sleep state to the wake state;

[0026] A restoring module, configured to, in response to successful reading of the RTC time, restore the system clock of the MCU based on the read RTC time; or,

[0027] The recovery module is further configured to, in response to a failure in reading the time of the RTC, obtain the status switching compensation time of the MCU and the system time, and recover the system clock of the MCU according to the status switching compensation time and the system time.

[0028] In some embodiments of the present disclosure, the device further includes a storage module, configured to write the system time corresponding to the sleep moment when the MCU enters the sleep state this time into a storage unit; the storage unit maintains data without loss when the MCU is in the sleep state.

[0029] In some embodiments of the present disclosure, the device further includes a control module, configured to control the MCU to operate with a minimum system during the sleep of the MCU.

[0030] In some embodiments of the present disclosure, the recovery module includes an acquisition unit and a recovery unit.

[0031] Wherein, the acquisition unit is configured to acquire the status switching compensation time of the MCU and the system time.

[0032] In some embodiments of the present disclosure, the system time acquired by the acquisition unit includes at least one of the following:

[0033] The system time corresponding to the sleep moment when the MCU enters the sleep state this time;

[0034] The sleep duration when the MCU is in the sleep state this time.

[0035] The recovery unit is configured to recover the system clock of the MCU according to the status switching compensation time and the system time.

[0036] In some embodiments of the present disclosure, the acquisition unit is further configured to acquire from the storage unit the system time corresponding to the sleep moment when the MCU enters the sleep state this time.

[0037] In some embodiments of the present disclosure, the acquisition unit is further configured to acquire from the internal soft clock module the sleep duration when the MCU is in the sleep state this time.

[0038] In some embodiments of the present disclosure, the recovery unit is specifically configured to perform a summation operation on the status switching compensation time and the system time to obtain a total time; and recover the system clock of the MCU based on the total time.

[0039] According to a third aspect of the embodiments of the present disclosure, a vehicle is provided, including: a micro control unit (MCU), a real-time clock (RTC), and a storage unit. Wherein, the RTC is communicatively connected to the MCU through a bus; the storage unit is disposed outside the MCU, and the storage unit is configured to store the system time corresponding to the sleep moment when the MCU enters the sleep state; the MCU includes: one or more processors, wherein the MCU is configured to execute the method of the first aspect above.

[0040] According to a fourth aspect of the embodiments of the present disclosure, a storage medium is provided. The storage medium stores instructions, and when the instructions run on a microcontroller unit (MCU), the MCU is caused to execute the method of the first aspect.

[0041] According to a fifth aspect of the embodiments of the present disclosure, a computer program product is provided, including a computer program which can implement the method of the above-mentioned first aspect when being executed by a processor.

[0042] The technical solutions provided by the embodiments of the present disclosure may include the following beneficial effects: When the microcontroller unit (MCU) switches from the sleep state to the wake state, the time of the real-time clock (RTC) is read. In the case where the time of the RTC is successfully read, the read time of the RTC can be directly used to quickly restore the system clock of the MCU. In the case where the time of the RTC is read unsuccessfully, the state transition compensation time and the system time of the MCU can be used to estimate the system time corresponding to the wake-up moment when the MCU switches from the sleep state to the wake state, and the system time corresponding to the wake-up moment is used to truly and accurately quickly restore the system clock of the MCU. Therefore, even in scenarios such as the loss of the RTC time and the abnormality of the MCU reading the RTC time, the system clock of the MCU can be quickly and accurately restored, solving the problems such as the long required time caused by time synchronization through time sources such as NTP and GNSS in the related art, thereby improving the time restoration efficiency of the system clock of the MCU and the efficiency of the time synchronization system.

[0043] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present invention and used together with the specification to explain the principles of the present invention.

[0045] Figure 1 is a flowchart of a method for restoring a system clock according to an embodiment of the present disclosure.

[0046] Figure 2 is a flowchart of another method for restoring a system clock according to an embodiment of the present disclosure.

[0047] Figure 3 is a flowchart of yet another method for restoring a system clock according to an embodiment of the present disclosure.

[0048] Figure 4 is a block diagram of a system for restoring a system clock according to an embodiment of the present disclosure.

[0049] Figure 5 It is a block diagram of a system clock recovery device provided according to an embodiment of the present disclosure.

[0050] Figure 6 It is a block diagram of a vehicle provided according to an embodiment of the present disclosure. Detailed implementation manners

[0051] Here, exemplary embodiments will be described in detail, and examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present invention. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.

[0052] In the description of the present disclosure, unless otherwise specified, " / " means "or". For example, A / B may represent A or B; herein, "and / or" is merely a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone.

[0053] Figure 1 It is a flowchart of a system clock recovery method provided according to an embodiment of the present disclosure. It should be noted that the execution subject of the system clock recovery method provided by the embodiment of the present disclosure can be an MCU. The system clock recovery method can be applied to the system clock recovery device provided by the embodiment of the present disclosure. Exemplarily, the system clock recovery device can be configured on the vehicle provided by the embodiment of the present disclosure.

[0054] As Figure 1 shown, the system clock recovery method includes but is not limited to the following steps:

[0055] In step S101, when the MCU switches from the sleep state to the wake state, read the time of the RTC.

[0056] It should be noted that in some embodiments, the RTC is disposed outside the MCU and can be communicatively connected to the MCU through a bus (for example, a CAN (Controller Area Network) bus) to send the time of the RTC to the MCU. Exemplarily, the MCU is the MCU on a vehicle (such as a vehicle), the RTC is disposed outside the MCU, and the RTC can be communicatively connected to the MCU through the CAN bus. Exemplarily, the MCU can read the time of the RTC through the bus.

[0057] In step S102, determine whether the time of the RTC is successfully read.

[0058] It should be noted that step S102 is optional.

[0059] Optionally, in some embodiments, when the time is obtained from the RTC and the obtained time is not the default value, it is determined that the time reading of the RTC is successful. Exemplarily, the default value can be the default time set at the factory of the device. For example, when the time is obtained from the RTC and the obtained time is not the default time set at the factory of the device, it is determined that the time reading of the RTC is successful.

[0060] Optionally, in some embodiments, when the time cannot be obtained from the RTC or the obtained time is the default value, it is determined that the time reading of the RTC fails.

[0061] In step S103, in response to the successful reading of the RTC time, the system clock of the MCU is restored based on the read RTC time.

[0062] In step S104, in response to the failure of the RTC time reading, the state switching compensation time and the system time of the MCU are obtained, and the system clock of the MCU is restored according to the state switching compensation time and the system time.

[0063] Among them, in some embodiments, the state switching compensation time of the MCU can be obtained by measuring the required duration of the MCU sample during the process of entering the sleep state from the wake state and / or entering the wake state from the sleep state.

[0064] In some embodiments, the system time includes at least one of the following: the system time corresponding to the sleep moment when the MCU enters the sleep state this time; the sleep duration when the MCU is in the sleep state this time.

[0065] In some embodiments, the system time corresponding to the sleep moment when the MCU enters the sleep state this time can be obtained in the following way: when the MCU enters the sleep state, record the system time corresponding to the sleep moment when the MCU enters the sleep state this time.

[0066] In some embodiments, the sleep duration when the MCU is in the sleep state this time can be calculated by the soft clock on the MCU system.

[0067] In an embodiment of the present disclosure, in the case where the time reading of the RTC fails, the system time corresponding to the wake-up time when the MCU switches from the sleep state to the wake-up state can be estimated by using the state transition compensation time of the MCU, the system time corresponding to the sleep time when the MCU enters the sleep state this time, and the sleep duration when the MCU is in the sleep state this time. By using the system time corresponding to this wake-up time, the system clock of the MCU can be quickly restored. Since the system time corresponding to the wake-up time when the MCU switches from the sleep state to the wake-up state is estimated, the system time corresponding to the sleep time when the MCU enters the sleep state this time, the sleep duration when the MCU is in the sleep state this time, and the time when the MCU switches from the wake-up state to the sleep state and from the sleep state to the wake-up state are considered, the estimated system time is more authentic and accurate.

[0068] By implementing the embodiments of the present disclosure, when the microcontroller unit (MCU) switches from the sleep state to the wake-up state, the time of the real-time clock (RTC) is read. In the case where the time reading of the RTC is successful, the system clock of the MCU can be directly restored by using the read time of the RTC. In the case where the time reading of the RTC fails, the system time corresponding to the wake-up time when the MCU switches from the sleep state to the wake-up state can be estimated by using the state transition compensation time of the MCU and the system time, and the system clock of the MCU can be quickly restored truly and accurately by using the system time corresponding to this wake-up time. Therefore, even in scenarios such as the loss of the RTC time and the abnormality of the MCU reading the RTC time, the system clock of the MCU can be quickly and accurately restored, solving the problems such as the long required time caused by time synchronization through time sources such as NTP and GNSS in the related art, thereby improving the time recovery efficiency of the system clock of the MCU and the efficiency of the time synchronization system.

[0069] Figure 2 is a flowchart of another method for restoring the system clock according to an embodiment of the present disclosure. As Figure 2 shown, the method for restoring the system clock includes but is not limited to the following steps:

[0070] In step S201, when the MCU enters the sleep state, the system time corresponding to the sleep time when the MCU enters the sleep state this time is written into the storage unit.

[0071] It should be noted that, in some embodiments, the storage unit may be an external storage unit of the MCU. The storage unit can maintain data without loss when the MCU is in the sleep state.

[0072] In step S202, when the MCU switches from the sleep state to the wake-up state, the time of the RTC is read.

[0073] In an embodiment of the present disclosure, step S202 can be implemented in any one of the various embodiments of the present disclosure. The embodiments of the present disclosure do not limit this and will not elaborate further.

[0074] In step S203, it is determined whether the time of the RTC is successfully read.

[0075] It can be understood that after the time of the RTC is read, the difference between the time of the RTC and the total time can be calculated based on the time of the RTC and the total time; the time of the RTC can be verified based on this difference to determine whether there is an abnormality in the time of the RTC.

[0076] Optionally, in some embodiments, after it is determined that the time of the RTC is successfully read, the state transition compensation time of the MCU, the system time corresponding to the sleep moment when the MCU enters the sleep state this time, and the sleep duration when the MCU is in the sleep state this time are obtained; the total time is determined by performing a summation calculation based on the state transition compensation time, the system time corresponding to the sleep moment, and the sleep duration; the difference calculation is performed based on the read time of the RTC and the total time to determine whether the time of the RTC is successfully read; in response to the successful reading of the time of the RTC, the system clock of the MCU is restored based on the read time of the RTC, or, in response to the failure to read the time of the RTC, the state transition compensation time of the MCU, the system time corresponding to the sleep moment when the MCU enters the sleep state this time, and the sleep duration when the MCU is in the sleep state this time are obtained, and the system clock of the MCU is restored according to the state transition compensation time, the system time corresponding to the sleep moment, and the sleep duration.

[0077] Optionally, in some embodiments, a difference calculation is performed based on the read time of the RTC and the total time to obtain a time difference; when the time difference is less than or equal to a first threshold, it is determined that the time of the RTC is successfully read, or, when the time difference is greater than the first threshold, it is determined that the time of the RTC is read fails.

[0078] In step S204, in response to the successful reading of the time of the RTC, the system clock of the MCU is restored based on the read time of the RTC.

[0079] In step S205, in response to the failure to read the time of the RTC, the system time corresponding to the sleep moment when the MCU enters the sleep state this time is obtained from the storage unit.

[0080] In step S206, the state transition compensation time of the MCU and the sleep duration when the MCU is in the sleep state this time are obtained.

[0081] Optionally, in the case of a failure to read the time of the RTC, the state transition compensation time of the MCU and the duration of the sleep state of the MCU this time can be obtained.

[0082] It should be noted that in some embodiments, steps S205 and S206 can be executed synchronously.

[0083] In step S207, the system clock of the MCU is restored according to the state transition compensation time, the system time corresponding to the sleep moment, and the sleep duration.

[0084] Optionally, in some embodiments, in response to a failure to read the time of the RTC, obtain the state transition compensation time of the MCU, the system time corresponding to the sleep moment when the MCU enters the sleep state this time, and the sleep duration when the MCU is in the sleep state this time; perform a summation operation on the state transition compensation time, the system time corresponding to the sleep moment, and the sleep duration to obtain the total time; based on the total time, restore the system clock of the MCU. Exemplarily, the total time can be calculated by the following formula (1):

[0085] t = t 1 + t 2 + t 3 (1)

[0086] Where, t refers to the total time; t 1 refers to the state transition compensation time of the MCU; t 2 refers to the system time corresponding to the sleep moment when the MCU enters the sleep state this time; t 3 refers to the sleep duration when the MCU is in the sleep state this time.

[0087] Optionally, in some embodiments, the state transition compensation time of the MCU is a calibrated value obtained by measuring the required duration of the MCU sample from the wake state to the sleep state and / or from the sleep state to the wake state.

[0088] Exemplarily, the MCU sample can refer to this MCU (the MCU involved in this article), that is, analyze the historical data of the state transition of this MCU to obtain this calibrated value. Exemplarily, the MCU can analyze the historical data of the state transition of this MCU to obtain the state transition compensation time of this MCU.

[0089] It should be noted that the historical data of state transition may include the required duration in the process of transitioning from the wake state to the sleep state and / or from the sleep state to the wake state. Exemplarily, the historical data of state transition may include the required duration in the process of transitioning from the wake state to the sleep state; or, the historical data of state transition may include the required duration in the process of transitioning from the sleep state to the wake state; or, the historical data of state transition may include the required duration in the process of transitioning from the wake state to the sleep state and the required duration in the process of transitioning from the sleep state to the wake state.

[0090] Exemplarily, the MCU sample may also refer to an MCU with the same model and the same function (or use) as this MCU. For example, the MCUs on the same vehicle model. Exemplarily, based on big data technology, the historical data of state transition of the MCUs on the same vehicle model can be obtained, and by analyzing the historical data of state transition, the calibration value can be obtained.

[0091] By implementing the embodiments of the present disclosure, taking advantage of the characteristic that the storage unit can maintain data without loss when the MCU is in the sleep state, the storage unit is used to record the system time corresponding to the sleep moment when the MCU enters the sleep state this time. In this way, in the case where the time reading of the RTC fails, the system time corresponding to the wake moment when the MCU switches from the sleep state to the wake state can be estimated by using the state transition compensation time of the MCU, the sleep duration when the MCU is in the sleep state this time, and the system time corresponding to the sleep moment when the MCU enters the sleep state this time obtained from the storage unit. By using the system time corresponding to the wake moment, the system clock of the MCU can be quickly restored, which can further improve the authenticity and accuracy of the estimated system time.

[0092] Figure 3 is a flowchart of another method for restoring the system clock according to the embodiments of the present disclosure. As Figure 3 shown, the method for restoring the system clock includes but is not limited to the following steps:

[0093] In step S301, when the MCU enters the sleep state, the system time corresponding to the sleep moment when the MCU enters the sleep state this time is written into the storage unit.

[0094] In the embodiments of the present disclosure, step S301 can be implemented in any one of the various embodiments of the present disclosure. The embodiments of the present disclosure do not make any limitations thereto and will not be elaborated further.

[0095] In step S302, during the sleep period of the MCU, the MCU is controlled to operate with the minimum system.

[0096] Optionally, in some embodiments, the minimum system includes an internal software clock module that runs at the software level within the MCU. Among them, the internal software clock module can calculate the sleep duration of the MCU when it is in the sleep state based on the operating frequency of the processor (e.g., the central processing unit CPU) in the MCU.

[0097] In step S303, when the microcontroller unit MCU switches from the sleep state to the wake state, the time of the real-time clock RTC is read.

[0098] In the embodiments of the present disclosure, step S303 can be implemented in any one of the various embodiments of the present disclosure. The embodiments of the present disclosure do not limit this and will not elaborate further.

[0099] In step S304, it is determined whether the time of the RTC is successfully read.

[0100] In the embodiments of the present disclosure, step S304 can be implemented in any one of the various embodiments of the present disclosure. The embodiments of the present disclosure do not limit this and will not elaborate further.

[0101] In step S305, in response to the successful reading of the time of the RTC, the system clock of the MCU is restored based on the read time of the RTC.

[0102] In step S306, in response to the failure to read the time of the RTC, the sleep duration of the MCU during this sleep state is obtained from the internal software clock module.

[0103] In step S307, the system time corresponding to the sleep moment when the MCU enters the sleep state this time is obtained from the storage unit.

[0104] Optionally, in the case of a failure to read the time of the RTC, the system time corresponding to the sleep moment when the MCU enters the sleep state this time can be obtained from the storage unit.

[0105] In step S308, the state switching compensation time of the MCU is obtained.

[0106] It should be noted that, in some embodiments, steps S306, S307, and S308 can be executed synchronously.

[0107] In step S309, based on the state switching compensation time, the system time corresponding to the sleep moment, and the sleep duration, the system clock of the MCU is restored.

[0108] In the embodiments of the present disclosure, step S309 can be implemented in any one of the various embodiments of the present disclosure. The embodiments of the present disclosure do not limit this and will not elaborate further.

[0109] By implementing the embodiments of the present disclosure, during the sleep period of the MCU, controlling the MCU to operate with a minimum system can reduce power consumption. Additionally, the sleep duration of the MCU in the sleep state is calculated by the internal soft clock module in the minimum system. In this way, in the case of a failure to read the time of the RTC, the sleep duration of the MCU in the sleep state this time is obtained from the internal soft clock module, and the system clock is restored by using the sleep duration in combination with the system time corresponding to the sleep moment when the MCU enters the sleep state this time and the system time corresponding to the sleep moment, which can improve the time recovery speed of the system clock of the MCU, and further improve the accuracy of the restored system time of the MCU and the reliability of the MCU.

[0110] In some embodiments, the MCU can be the MCU on a vehicle. Exemplarily, the vehicle can be a car. When the MCU of the vehicle enters the sleep state, the system time corresponding to the moment when the MCU of the vehicle enters the sleep state this time is written into the storage unit. During the sleep period of the MCU of the vehicle, control the MCU of the vehicle to operate with a minimum system. The minimum system includes an internal soft clock module operating at the software level within the vehicle MCU. The sleep duration of the MCU in the sleep state is calculated by the internal soft clock module based on the operating frequency of the processor in the vehicle MCU. When the MCU of the vehicle switches from the sleep state to the wake state, read the time of the RTC.

[0111] Exemplarily, in the case of a successful reading of the time of the RTC, restore the system clock of the vehicle MCU based on the read time of the RTC.

[0112] Exemplarily, in the case of a failure to read the time of the RTC, obtain the system time corresponding to the sleep moment when the MCU enters the sleep state this time from the storage unit; obtain the sleep duration of the MCU in the sleep state this time from the internal soft clock module; measure the required duration for the MCU sample to enter the sleep state and / or switch from the sleep state to the wake state to obtain the state transition compensation time of the vehicle MCU; perform a summation operation on the state transition compensation time, the system time corresponding to the sleep moment, and the sleep duration to obtain the total time; restore the system clock of the MCU based on the total time.

[0113] Figure 4 is a structural block diagram of a system clock recovery system provided according to the embodiments of the present disclosure. As Figure 4As shown in the figure, the system clock recovery system includes, but is not limited to: MCU 400, RTC 601, and storage unit 602. Among them, MCU 400 includes a processor 401, a system clock 402, and an internal soft clock module 403. The RTC is communicatively connected to the MCU via a bus. The storage unit 602 is disposed outside the MCU 400, and the storage unit 602 is used to store the system time corresponding to the sleep time when the MCU 400 enters the sleep state. For the convenience of understanding the system clock recovery method, according to Figure 4 An example is given for illustration.

[0114] For example, before the MCU 400 enters the sleep state, the MCU 400 writes the system time corresponding to the sleep time of this entry into the storage unit 602. When the MCU 400 is in the sleep state, the data stored in the storage unit 602 will not be lost.

[0115] During the sleep period of the MCU 400, the MCU 400 is controlled to operate with the minimum system. The minimum system includes the internal soft clock module 403 running at the software level within the MCU 400. During the sleep period of the MCU 400, the internal soft clock module 403 can calculate using the operating frequency of the processor 401 in the MCU 400 to obtain the sleep duration when the MCU 400 is in the sleep state this time.

[0116] When the MCU 400 switches from the sleep state to the wake-up state, the time of the RTC 601 is read.

[0117] When the time of the RTC 601 can be obtained and the obtained time of the RTC 601 is not the default value (for example, the default time set at the factory), it is determined that the time reading of the RTC 601 is successful.

[0118] In some embodiments, after obtaining the time of the RTC 601, calculations can be performed based on the time of the RTC 601 and the total time to obtain the time difference between the time of the RTC 601 and the total time; when the time difference is less than or equal to the first threshold, it is determined that the time reading of the RTC 601 is successful.

[0119] In response to the successful reading of the time of the RTC 601, the system clock 402 of the MCU 400 is restored based on the read time of the RTC 601.

[0120] When the time of the RTC 601 cannot be obtained or the obtained time of the RTC 601 is the default value (for example, the default time set at the factory), it is determined that the time reading of the RTC 601 fails.

[0121] In some embodiments, after obtaining the time of RTC 601, it is possible to calculate based on the time of RTC 601 and the total time to obtain the time difference between the time of RTC 601 and the total time; when the time difference is greater than the first threshold, it is determined that the time reading of RTC 601 fails.

[0122] In response to the failure of reading the time of RTC 601, obtain the state switching compensation time of MCU 400, the system time corresponding to the sleep moment when MCU 400 enters the sleep state this time, and the sleep duration when MCU 400 is in the sleep state this time, and restore the system clock 402 of MCU 400 according to the state switching compensation time, the system time corresponding to the sleep moment, and the sleep duration.

[0123] Figure 5 It is a block diagram of a system clock recovery device provided according to an embodiment of the present disclosure. As Figure 5 shown, the system clock recovery device includes but is not limited to a reading module 501 and a recovery module 502.

[0124] Among them, the reading module 501 is used to read the time of the real-time clock RTC when the microcontroller unit MCU switches from the sleep state to the wake state.

[0125] The recovery module 502 is used to restore the system clock of the MCU based on the read time of the RTC in response to the successful reading of the time of the RTC.

[0126] The recovery module 502 is further used to obtain the state switching compensation time and the system time of the MCU in response to the failure of reading the time of the RTC, and restore the system clock of the MCU according to the state switching compensation time and the system time.

[0127] Optionally, in some embodiments, the system clock recovery device further includes a storage module 503. The storage module 503 is used to write the system time corresponding to the sleep moment when the MCU enters the sleep state this time into the storage unit. Among them, the storage unit maintains data without loss when the MCU is in the sleep state.

[0128] Optionally, in some embodiments, the system clock recovery device further includes a control module 504. The control module 504 is used to control the MCU to operate with the minimum system during the sleep of the MCU; the minimum system includes an internal soft clock module running at the software level within the MCU.

[0129] Optionally, in some embodiments, the recovery module 502 includes an acquisition unit and a recovery unit.

[0130] Among them, the acquisition unit is used to obtain the state switching compensation time and the system time of the MCU.

[0131] In some embodiments of the present disclosure, the system time obtained by the acquisition unit includes at least one of the following:

[0132] The system time corresponding to the sleep moment when the MCU enters the sleep state this time;

[0133] The sleep duration when the MCU is in the sleep state this time.

[0134] The restoration unit is used to restore the system clock of the MCU according to the state transition compensation time and the system time.

[0135] Optionally, in some embodiments, the acquisition unit is further configured to obtain from the storage unit the system time corresponding to the sleep moment when the MCU enters the sleep state this time.

[0136] Optionally, in some embodiments, the acquisition unit is further configured to obtain from the internal soft clock module the sleep duration when the MCU is in the sleep state this time.

[0137] Optionally, in some embodiments, the restoration unit is specifically configured to perform a summation operation on the state transition compensation time and the system time to obtain a total time; and based on the total time, restore the system clock of the MCU.

[0138] Regarding the device in the above embodiments, the specific manners in which each module performs operations have been described in detail in the embodiments related to the method, and will not be elaborated herein.

[0139] Figure 6 is a block diagram of a vehicle provided according to an embodiment of the present disclosure. For example, the vehicle may include, but is not limited to, vehicles such as fuel vehicles, new energy vehicles, drones, electric bicycles, and other vehicles. In some embodiments, the vehicle may be a vehicle. As Figure 6 shown, the vehicle includes, but is not limited to: a microcontroller unit MCU400, a real-time clock RTC 601, and a storage unit 602.

[0140] Among them, the RTC 601 is communicatively connected to the microcontroller unit MCU 400 through a bus. The storage unit 602 is disposed outside the microcontroller unit MCU 400, and the storage unit 602 is used to store the system time corresponding to the sleep moment when the microcontroller unit MCU 400 enters the sleep state.

[0141] The microcontroller unit MCU 400 generally controls the overall operation of the vehicle, such as operations related to vehicle body power, driving control, infotainment, intelligent driving, and system clock. The microcontroller unit MCU 400 may include one or more processors (for example, a central processing unit CPU) to execute instructions to complete all or part of the steps of the above method. Figure 6Taking the microcontroller unit MCU 400 including a processor 401 as an example. The microcontroller unit MCU 400 may include one or more modules to facilitate the interaction between the microcontroller unit MCU 400 and other components. For example, the microcontroller unit MCU 400 may include a communication module to facilitate the interaction between the communication component and the microcontroller unit MCU 400.

[0142] The storage unit 602 is configured to store various types of data to support the operation of the vehicle. Examples of such data include instructions for any application or method for operating on the vehicle, system clock information, status switch compensation time information, the sleep duration information when the microcontroller unit MCU 400 is in the sleep state this time, etc. The storage unit 602 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0143] Optionally, the vehicle may further include one or more of the following components: a power component 603, a multimedia component 604, an input / output (I / O) interface 605, a sensor component 606, and a communication component 607.

[0144] The power component 603 provides power for various components of the vehicle. The power component 603 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the vehicle.

[0145] The multimedia component 604 includes a screen that provides an output interface between the vehicle and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can not only sense the boundaries of the touch or swipe actions, but also detect the duration and pressure associated with the touch or swipe operation.

[0146] The I / O interface 605 provides an interface between the microcontroller unit MCU 400 and the peripheral interface module, and the above peripheral interface module can be a keyboard, click wheel, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, and a start button.

[0147] The sensor assembly 606 includes one or more sensors for providing a status assessment of various aspects of the vehicle. For example, the sensor assembly 606 can detect the on / off status of the vehicle. The sensor assembly 606 can also detect a change in the position of the vehicle, the orientation of the vehicle, or acceleration / deceleration, and changes in temperature inside and outside the vehicle. The sensor assembly 606 can include proximity sensors configured to detect the presence of nearby objects without any physical contact. The sensor assembly 606 can also include light sensors, such as CMOS or CCD image sensors, for use in imaging applications. In some embodiments, the sensor assembly 606 can further include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0148] The communication assembly 607 is configured to facilitate communication between the vehicle and other devices in a wired or wireless manner. The vehicle can access a wireless network based on communication standards, such as WiFi, 2G, or 3G, or a combination thereof. In one exemplary embodiment, the communication assembly 607 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication assembly 607 further includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0149] In an exemplary embodiment, the vehicle can be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the system clock recovery method provided by the embodiments of the present disclosure.

[0150] Optionally, in some embodiments, a non-transitory computer-readable storage medium including instructions is also provided, such as a storage unit 602 including instructions, and the above instructions can be executed by a micro control unit (MCU) 400 of the vehicle to complete the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0151] Optionally, in some embodiments, a computer program product is also provided, including a computer program that can implement the system clock recovery method provided by the embodiments of the present disclosure when executed by the micro control unit (MCU) 400.

[0152] Other embodiments of the present invention will be readily apparent to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following the general principles of the invention and including known common general knowledge or conventional technical means in the technical field not disclosed in this disclosure. The specification and examples are only to be considered as exemplary, and the true scope and spirit of the invention are pointed out by the following claims.

[0153] It should be understood that the present invention is not limited to the exact structures already described and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present invention is only limited by the appended claims.

Claims

1. A method for restoring a system clock, characterized in that, comprising: When the microcontroller unit (MCU) switches from the sleep state to the wake state, reading the time of the real-time clock (RTC); When the reading of the RTC time is successful in response, restoring the system clock of the MCU based on the read RTC time; When the reading of the RTC time fails in response, obtaining the state transition compensation time and the system time of the MCU, and restoring the system clock of the MCU according to the state transition compensation time and the system time; The system time includes: The system time corresponding to the sleep moment when the MCU enters the sleep state this time; The sleep duration when the MCU is in the sleep state this time.

2. The method according to claim 1, characterized in that, The method further includes: Writing the system time corresponding to the sleep moment when the MCU enters the sleep state this time into the storage unit; the storage unit maintains data without loss when the MCU is in the sleep state.

3. The method according to claim 2, characterized in that, Obtaining the system time corresponding to the sleep moment when the MCU enters the sleep state this time includes: Obtaining the system time corresponding to the sleep moment when the MCU enters the sleep state this time from the storage unit.

4. The method according to claim 1, characterized in that, The method further includes: During the sleep of the MCU, controlling the MCU to operate with the minimum system; the minimum system includes the internal soft clock module operating at the software level within the MCU.

5. The method according to claim 4, characterized in that, Obtaining the sleep duration when the MCU is in the sleep state this time includes: Obtaining the sleep duration when the MCU is in the sleep state this time from the internal soft clock module.

6. The method according to claim 1, characterized in that, The state transition compensation time of the MCU is a calibrated value obtained by measuring the required duration during the process of the MCU sample entering the sleep state from the wake state and / or entering the wake state from the sleep state.

7. The method according to any one of claims 1-6, characterized in that, Restoring the system clock of the MCU according to the state transition compensation time and the system time includes: Performing a summation operation on the state transition compensation time and the system time to obtain a total time; Restoring the system clock of the MCU based on the total time.

8. A device for restoring a system clock, characterized in that, comprising: A reading module, configured to read the time of the real-time clock (RTC) when the microcontroller unit (MCU) switches from the sleep state to the wake state; A restoring module, configured to restore the system clock of the MCU based on the read RTC time when the reading of the RTC time is successful in response; The restoring module is further configured to obtain the state transition compensation time and the system time of the MCU, and restore the system clock of the MCU according to the state transition compensation time and the system time when the reading of the RTC time fails in response; The system time includes: The system time corresponding to the sleep moment when the MCU enters the sleep state this time; The sleep duration when the MCU is in the sleep state this time.

9. A vehicle, characterized in that, it includes: A micro control unit MCU, a real-time clock RTC and a storage unit, wherein, The RTC is communicatively connected to the MCU through a bus; The storage unit is disposed outside the MCU, and the storage unit is used to store the system time corresponding to the sleep moment when the MCU enters the sleep state; The MCU includes: one or more processors, wherein, the MCU is used to execute the method according to any one of claims 1-7.

10. A storage medium storing instructions, characterized in that, when the instructions run on a micro control unit MCU, the MCU is caused to execute the method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Clock circuit and electronic equipment

    CN115268571A