CN112114616A - Switching method of real-time clock, electronic equipment and computer storage medium - Google Patents
Switching method of real-time clock, electronic equipment and computer storage medium Download PDFInfo
- Publication number
- CN112114616A CN112114616A CN202010772922.XA CN202010772922A CN112114616A CN 112114616 A CN112114616 A CN 112114616A CN 202010772922 A CN202010772922 A CN 202010772922A CN 112114616 A CN112114616 A CN 112114616A
- Authority
- CN
- China
- Prior art keywords
- real
- time clock
- clock module
- time
- external
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/04—Generating or distributing clock signals or signals derived directly therefrom
- G06F1/14—Time supervision arrangements, e.g. real time clock
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
- Electric Clocks (AREA)
Abstract
The application is applicable to the technical field of electronics, and provides a switching method of a real-time clock and electronic equipment, wherein the method comprises the following steps: when the external real-time clock module is in a normal working state, acquiring an interrupt signal and real-time of the external real-time clock module, taking the real-time of the external real-time clock module as system time of the electronic equipment, and executing preset operation based on the interrupt signal of the external real-time clock module; and when the external real-time clock module is in an abnormal working state, acquiring an interrupt signal and real-time of the internal real-time clock module, taking the real-time of the internal real-time clock module as system time, and executing preset operation based on the interrupt signal of the internal real-time clock module. According to the switching method of the real-time clock, when the external real-time clock module is abnormal, the electronic equipment can take the real-time of the internal real-time clock module as the system time, and executes the preset operation based on the interrupt signal of the module, so that the electronic equipment can work normally.
Description
Technical Field
The present application relates to the field of electronic technologies, and in particular, to a switching method for a real-time clock, an electronic device, and a computer-readable storage medium.
Background
A Real-time Clock (RTC), also called a Clock chip, can provide accurate Real-time and interrupt signals for various electronic devices. Currently, electronic devices may use an external real-time clock and/or an internal self-contained real-time clock to obtain real-time or interrupt signals. The external real-time clock can generally provide relatively accurate real-time for the electronic equipment, but the external real-time clock is easily influenced by the environment and is abnormal; the stability of the internal self-contained real-time clock is good, but the real-time provided by the internal self-contained real-time clock is generally not accurate enough.
In the existing scheme, when the electronic device uses the external real-time clock and its own internal real-time clock at the same time, the electronic device usually uses the real-time provided by the external real-time clock as the system time of the electronic device, and executes the preset operation based on the interrupt signal of the external real-time clock, and the external real-time clock and the internal own real-time clock can be calibrated with each other. However, when the external real-time clock is abnormal, the electronic device cannot acquire the real-time and the interrupt signal, and thus the electronic device cannot work normally.
Disclosure of Invention
The embodiment of the application provides a switching method of a real-time clock, an electronic device and a computer readable storage medium, which can solve the problem that when an external real-time clock of the existing electronic device is abnormal, the electronic device cannot acquire real-time and interrupt signals, and further the electronic device cannot work normally.
In a first aspect, an embodiment of the present application provides a switching method of a real-time clock, which is applied to an electronic device, where the electronic device is provided with an external real-time clock module and an internal real-time clock module, and the switching method includes:
when the working state of the external real-time clock module is a normal state, acquiring an interrupt signal and real-time of the external real-time clock module, determining the real-time of the external real-time clock module as the system time of the electronic equipment, and executing preset operation based on the interrupt signal of the external real-time clock module;
and when the working state of the external real-time clock module is an abnormal state, acquiring an interrupt signal and real-time of the internal real-time clock module, determining the real-time of the internal real-time clock module as the system time, and executing the preset operation based on the interrupt signal of the internal real-time clock module.
Further, after the obtaining of the interrupt signal and the real-time of the internal real-time clock module, the method further includes:
initializing the hardware of the external real-time clock module;
adjusting the real-time of the external real-time clock module according to the real-time of the internal real-time clock module, and adjusting the value of a preset parameter to a preset value; the preset value is an integer greater than 0
Further, after the adjusting the value of the preset parameter to the preset value, the method further includes:
if the interrupt signal of the external real-time clock module is detected, acquiring the interrupt signal and real-time of the external real-time clock module;
and determining the real-time of the external real-time clock module as the system time, and executing the preset operation based on the interrupt signal of the external real-time clock module.
Further, the handover method further includes:
determining the value of a preset parameter according to the times of detecting the interrupt signal of the external real-time clock module and the times of detecting the interrupt signal of the internal real-time clock module; the initial value of the preset parameter is a preset value, and the preset value is an integer greater than 0;
and determining the working state of the external real-time clock module according to the value of the preset parameter.
Further, the determining a value of a preset parameter according to the number of times of detecting the interrupt signal of the external real-time clock module and the number of times of detecting the interrupt signal of the internal real-time clock module includes:
adding 1 to the value of the preset parameter every time an interrupt signal of the external real-time clock module is detected;
and subtracting 1 from the value of the preset parameter once every time an interrupt signal of the internal real-time clock module is detected.
Further, the determining the working state of the external real-time clock module according to the value of the preset parameter includes:
if the value of the preset parameter is 0, determining that the working state of the external real-time clock module is an abnormal state;
and if the value of the preset parameter is greater than 0, determining that the working state of the external real-time clock module is a normal state.
Further, after the obtaining of the interrupt signal and the real-time of the external real-time clock module, the method further includes:
and calibrating the real-time of the internal real-time clock module according to the real-time of the external real-time clock module.
In a second aspect, an embodiment of the present application provides an electronic device, where the electronic device is provided with an external real-time clock module and an internal real-time clock module, and the electronic device includes:
a first obtaining unit, configured to obtain an interrupt signal and real-time of the external real-time clock module when a working state of the external real-time clock module is a normal state, determine the real-time of the external real-time clock module as system time of the electronic device, and perform a preset operation based on the interrupt signal of the external real-time clock module;
and the second acquisition unit is used for acquiring the interrupt signal and the real-time of the internal real-time clock module when the working state of the external real-time clock module is an abnormal state, determining the real-time of the internal real-time clock module as the system time, and executing the preset operation based on the interrupt signal of the internal real-time clock module.
In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the electronic device is provided with an external real-time clock module and an internal real-time clock module, and wherein the processor implements the steps of the handover method according to any of the first aspect when executing the computer program.
In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the steps of the handover method according to any one of the first aspect.
In a fifth aspect, an embodiment of the present application provides a computer program product, which, when run on an electronic device, causes the electronic device to execute the handover method according to any one of the above first aspects.
Compared with the prior art, the embodiment of the application has the advantages that:
according to the switching method of the real-time clock, when the working state of the external real-time clock module is a normal state, the interrupt signal and the real-time of the external real-time clock module are obtained, the real-time of the external real-time clock module is determined as the system time of the electronic equipment, and preset operation is executed based on the interrupt signal of the external real-time clock module; when the working state of the external real-time clock module is an abnormal state, acquiring an interrupt signal and real-time of the internal real-time clock module, determining the real-time of the internal real-time clock module as system time, and executing preset operation based on the interrupt signal of the internal real-time clock module. Therefore, when the external real-time clock module of the electronic device is abnormal, the electronic device can acquire the real-time and the interrupt signal of the internal real-time clock module, determine the real-time of the internal real-time clock module as the system time of the electronic device, and execute preset operation based on the interrupt signal of the internal real-time clock module, so that the electronic device can continuously and stably work normally.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart illustrating an implementation of a method for switching a real-time clock according to an embodiment of the present disclosure;
fig. 2 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
fig. 3 is a flowchart illustrating an implementation of a switching method of a real-time clock according to another embodiment of the present application;
fig. 4 is a flowchart illustrating a specific implementation of S301 in a method for switching a real-time clock according to another embodiment of the present application;
fig. 5 is a flowchart illustrating a specific implementation of S302 in a method for switching a real-time clock according to another embodiment of the present application;
fig. 6 is a flowchart illustrating an implementation of a switching method of a real-time clock according to yet another embodiment of the present application;
fig. 7 is a flowchart illustrating an implementation of a switching method of a real-time clock according to another embodiment of the present application;
fig. 8 is a schematic structural diagram of an electronic device according to another embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to" determining "or" in response to detecting ". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
Referring to fig. 1, fig. 1 is a flowchart illustrating an implementation of a switching method of a real-time clock according to an embodiment of the present disclosure, where the method can be applied to an electronic device. The electronic device may be a desktop computer, a notebook, a palm computer, a cloud-end electronic device, and the like.
Fig. 2 is a schematic structural diagram of an electronic device provided in an embodiment of the present application, and as shown in fig. 2, the electronic device 20 may include: an internal real time clock module 201 and a processor 202, and the electronic device 20 is further provided with an external real time clock module 203. Wherein, the internal real-time clock module 201 and the external real-time clock module 203 are both connected to the processor 202 in communication.
The Processor 202 may be a Central Processing Unit (CPU), and the Processor 202 may also be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), off-the-shelf Programmable Gate arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
In the embodiment of the present application, both the internal real-time clock module 201 and the external real-time clock module 203 can provide real-time and interrupt signals for the electronic device 20. Since the external real-time clock module 203 can provide relatively accurate real-time for the electronic device 20, the electronic device 20 defaults to use the real-time provided by the external real-time clock module 203 as the system time of the electronic device 20, and performs a preset operation based on the interrupt signal of the external real-time clock module 203. The preset operation may be determined according to actual needs, and is not limited herein. For example, the predetermined operation may be that the processor 202 sends a data acquisition instruction to the data collector after detecting the interrupt signal. The data collector can be various sensors.
In practical applications, the external real-time clock module 203 may be a clock module including a clock chip DS1302, and the internal real-time clock module 201 may be a clock module including a Resistance-Capacitance (RC) oscillator, by way of example and not limitation.
It should be noted that, in the embodiment of the present application, the electronic device 20 stores an initial value of a preset parameter in advance, where the initial value may be a preset value. The preset parameter is used to determine whether to switch between the external real-time clock module and the internal real-time clock module, and the value of the preset parameter may be determined according to a preset value, the number of times that the processor 202 detects the interrupt signal of the external real-time clock module 203, and the number of times that the processor 202 detects the interrupt signal of the internal real-time clock module 201. The preset value is an integer greater than 0, and the preset value may be set according to actual needs, and is not limited herein, for example, the preset value may be 3.
In one embodiment of the present application, as shown in FIG. 2, the electronic device 20 may also include a memory 204 coupled to the processor 202. Initial values of preset parameters may be stored in the memory 204.
It is noted that the storage 204 may be an internal storage unit of the electronic device 20 in some embodiments, for example, a hard disk or a memory of the electronic device 20. The memory 204 may also be an external storage device of the electronic device 20 in other embodiments, such as a plug-in hard disk provided on the electronic device 20, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and so on. Further, the memory 204 may also include both internal storage units and external storage devices of the electronic device 20. The memory 204 is used for storing an operating system, an application program, a Boot Loader (Boot Loader), data, and other programs, such as program codes of the computer programs. The memory 204 may also be used to temporarily store data that has been output or is to be output.
In another embodiment of the present application, as shown in FIG. 2, the electronic device 20 may further include a computer program 205 stored in the memory 204 and executable on the at least one processor 202. The processor 202 implements S101 to S103 described below when executing the computer program 205.
The execution subject of the switching method of the real-time clock provided by the embodiment of the present application may be the processor 202. As shown in fig. 1, the switching method of the real-time clock may include steps S101 to S103, which are detailed as follows:
in S101, the operating state of the external real-time clock module is detected.
In practical applications, the processor can detect the interaction state between the external real-time clock module and the electronic device in real time. Wherein, the interaction state between the external real-time clock module and the electronic device may be an interaction state between the external real-time clock module and the processor.
In one embodiment of the present application, the processor may detect the interaction state between the external real time clock module and the processor according to the number of times it detects the interrupt signal of the internal real time clock module and the number of times it detects the interrupt signal of the external real time clock module.
When the processor detects an interrupt signal of the external real-time clock module, it may be determined that the interaction between the processor and the external real-time clock module is normal, that is, the working state of the external real-time clock module is a normal state. When the processor cannot detect the interrupt signal of the external real-time clock module, the interaction abnormity between the processor and the external real-time clock module can be determined, namely the working state of the external real-time clock module is an abnormal state.
In another embodiment of the present application, the processor may specifically determine the operating state of the external real-time clock through S301 to S302 shown in fig. 3, which is detailed as follows:
in S301, determining a value of a preset parameter according to the number of times of detecting the interrupt signal of the external real-time clock module and the number of times of detecting the interrupt signal of the internal real-time clock module; the initial value of the preset parameter is a preset value, and the preset value is an integer greater than 0.
In S302, the working state of the external real-time clock module is determined according to the value of the preset parameter.
In this embodiment, under the condition that the external real-time clock module and the internal real-time clock module both work normally, the external real-time clock module and the internal real-time clock module both generate an interrupt signal at every preset time interval, and therefore, under the condition that the external real-time clock module and the internal real-time clock module both work normally, the processor detects an interrupt signal generated by the external real-time clock module and an interrupt signal generated by the internal real-time clock module at every preset time interval. Based on this, the processor may determine the value of the preset parameter according to the number of times of the detected interrupt signal of the external real time clock module and the number of times of the detected interrupt signal generated by the internal real time clock module. The preset time interval may be set according to actual needs, for example, the preset time interval may be 10 seconds.
In an implementation manner of this embodiment, the processor may specifically determine the values of the preset parameters through S401 to S402 shown in fig. 4, which are detailed as follows:
in S401, every time an interrupt signal of the external real-time clock module is detected, a value of the preset parameter is incremented by 1.
In S402, every time an interrupt signal of the internal real-time clock module is detected, a subtraction operation of 1 is performed on the value of the preset parameter.
In this embodiment, assuming that the initial value of the preset parameter is 3, if the processor detects an interrupt signal of the external real-time clock module, the processor performs an operation of adding 1 to the value of the preset parameter once, and at this time, the value of the preset parameter is changed to 4. If the processor detects an interrupt signal of the internal real-time clock module once again, the processor performs a subtraction operation of 1 on the value of the preset parameter, at this time, the value of the preset parameter is changed to 3, and so on.
When the external real-time clock module is in an abnormal working state, the external real-time clock module cannot generate an interrupt signal, the processor cannot detect the interrupt signal of the external real-time clock module, and only can detect the interrupt signal of the internal real-time clock module, and under the condition, the processor can continuously subtract 1 from the value of the preset parameter.
Based on this, the processor can determine the working state of the external clock module according to S501 and S502 as shown in fig. 5, which is detailed as follows:
in S501, if the value of the preset parameter is 0, it is determined that the working state of the external real-time clock module is an abnormal state.
In this embodiment, with reference to S401 to S402, when the processor detects that the value of the preset parameter is 0, it indicates that the processor has not detected the interrupt signal of the external real-time clock module at intervals of the preset number of preset time intervals, and only detects the interrupt signal of the internal real-time clock module, so that the processor can determine that the working state of the external real-time clock module is an abnormal state.
In S502, if the value of the preset parameter is greater than 0, it is determined that the working state of the external real-time clock module is a normal state.
In this embodiment, with reference to S401 to S402, when the processor detects that the value of the preset parameter is greater than 0, it indicates that the processor can detect not only the interrupt signal of the internal real-time clock module but also the interrupt signal of the external real-time clock module, and therefore, the processor can determine that the working state of the external real-time clock module is a normal state.
In the embodiment of the present application, if the processor detects that the working state of the external real-time clock module is a normal state, S102 is executed; if the processor detects that the operating state of the external real-time clock module is abnormal, S103 is executed.
In S102, when the working state of the external real-time clock module is a normal state, acquiring an interrupt signal and real-time of the external real-time clock module, determining the real-time of the external real-time clock module as system time of the electronic device, and executing a preset operation based on the interrupt signal of the external real-time clock module.
In this embodiment, since the external real-time clock module can provide more accurate real-time for the electronic device than the internal real-time clock module, when the operating state of the external real-time clock module is a normal state, the processor can acquire the interrupt signal and the real-time of the external real-time clock module, determine the real-time of the external real-time clock module as the system time of the electronic device, and execute a preset operation based on the interrupt signal of the external real-time clock module.
In another embodiment of the present application, after acquiring the interrupt signal and the real-time of the external real-time clock module, the processor may calibrate the real-time of the internal real-time clock module according to the real-time of the external real-time clock module, so as to reduce a time difference between the real-time of the external real-time clock module and the real-time of the internal real-time clock module, and improve an accuracy of the real-time of the internal real-time clock module.
In S103, when the working state of the external real-time clock module is an abnormal state, acquiring an interrupt signal and real-time of the internal real-time clock module, determining the real-time of the internal real-time clock module as the system time, and executing the preset operation based on the interrupt signal of the internal real-time clock module.
In the embodiment of the present application, since the working state of the external real-time clock module is an abnormal state, at this time, the external real-time clock module cannot generate an interrupt signal and real-time, and the processor cannot detect the interrupt signal of the external real-time clock module. Based on this, in the embodiment of the present application, when the processor detects that the working state of the external real-time clock module is an abnormal state, the processor may obtain the interrupt signal and the real-time of the internal real-time clock module, determine the real-time of the internal real-time clock module as the system time of the processor, and execute the preset operation based on the interrupt signal of the internal real-time clock module.
As can be seen from the above, according to the switching method of the real-time clock provided in the embodiment of the present application, when the working state of the external real-time clock module is a normal state, the interrupt signal and the real-time of the external real-time clock module are obtained, the real-time of the external real-time clock module is determined as the system time of the electronic device, and the preset operation is executed based on the interrupt signal of the external real-time clock module; when the working state of the external real-time clock module is an abnormal state, acquiring an interrupt signal and real-time of the internal real-time clock module, determining the real-time of the internal real-time clock module as system time, and executing preset operation based on the interrupt signal of the internal real-time clock module. Therefore, when the external real-time clock module of the electronic device is abnormal, the electronic device can acquire the real-time and the interrupt signal of the internal real-time clock module, determine the real-time of the internal real-time clock module as the system time of the electronic device, and execute preset operation based on the interrupt signal of the internal real-time clock module, so that the electronic device can continuously and stably work normally.
Referring to fig. 6, fig. 6 is a flowchart illustrating an implementation of a switching method of a real-time clock according to still another embodiment of the present application. With respect to the embodiment corresponding to fig. 1, the switching method provided in this embodiment may further include S601 to S602 shown in fig. 6 after S102, which is detailed as follows:
in S601, an initialization operation is performed on the hardware of the external real-time clock module.
In this embodiment, in order to enable the external real-time clock module to recover as soon as possible and provide the interrupt signal and the real-time of the external real-time clock module for the processor, the processor may perform an initialization operation on hardware of the external real-time clock module after acquiring the interrupt signal and the real-time of the internal real-time clock module, so that each hardware configuration of the external real-time clock module is recovered to a default state. For example, the clock chip DS1302 of the external real time clock module may be initialized.
In S602, adjusting the real-time of the external real-time clock module according to the real-time of the internal real-time clock module, and adjusting a value of a preset parameter to a preset value; the preset value is an integer greater than 0.
In this embodiment, the processor performs an initialization operation on the hardware of the external real-time clock module and also performs an initialization operation on the software of the external real-time clock module, so that both the hardware and the software configuration of the external real-time clock module can be restored to default states, and the external real-time clock module can run normally, that is, the working state of the external real-time clock module is a normal state.
Specifically, the initializing operation of the software of the external real-time clock module by the processor may include: the processor adjusts the value of the preset parameter to a preset value.
In another embodiment of the present application, after the processor initializes the software and hardware of the external real-time clock module, the working state of the external real-time clock module can be recovered to a normal state, and the external real-time clock module can continue to generate the interrupt signal. Therefore, after adjusting the value of the preset parameter to the preset value, the processor may further determine whether an interrupt signal of the external real-time clock module is detected. After executing S601 to S602, the processor detects an interrupt signal of the external real-time clock module, and then executes S701 to S702 shown in fig. 7. After executing the above S601 to S602, if the processor does not detect the interrupt signal of the external real-time clock module, which indicates that the working state of the external real-time clock module is still in an abnormal state, the processor continues to acquire the interrupt signal and the real-time clock of the internal real-time clock module, determines the real-time of the internal real-time clock module as the system time of the electronic device, and executes a preset operation based on the interrupt signal of the internal real-time clock module.
As shown in fig. 7, in S701, if the interrupt signal of the external real-time clock module is detected, the interrupt signal and the real-time of the external real-time clock module are acquired.
In this embodiment, when the processor detects the interrupt signal of the external real-time clock module, it indicates that the interaction between the external real-time clock module and the electronic device is normal, that is, the working state of the external real-time clock module is a normal state, so that the processor can obtain the interrupt signal and the real-time of the external real-time clock module.
In S702, the real-time of the external real-time clock module is determined as the system time, and the preset operation is performed based on the interrupt signal of the external real-time clock module.
In this embodiment, since the real-time of the external real-time clock module is more accurate than the real-time of the internal real-time clock, the processor may determine the real-time of the external real-time clock module as the system time of the electronic device, and execute the preset operation based on the interrupt signal of the external real-time clock module.
It can be seen from the above that, according to the switching method of the real-time clock provided in the embodiment of the present application, it can be detected whether the external real-time clock module has recovered to normal or not while the internal real-time clock module provides the interrupt signal and the real-time, so that when the external real-time clock module recovers to a normal working state, the electronic device can obtain the interrupt signal and the real-time of the external real-time clock module, thereby obtaining more accurate real-time.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Fig. 8 shows a block diagram of an electronic device according to an embodiment of the present application, which corresponds to the switching method of a real-time clock described in the foregoing embodiment, and only shows portions related to the embodiment of the present application for convenience of description. Referring to fig. 8, the electronic device 800 includes: a first acquisition unit 81 and a second acquisition unit 82. Wherein:
the first obtaining unit 81 is configured to obtain an interrupt signal and a real-time of the external real-time clock module when the working state of the external real-time clock module is a normal state, determine the real-time of the external real-time clock module as a system time of the electronic device, and execute a preset operation based on the interrupt signal of the external real-time clock module.
The second obtaining unit 82 is configured to obtain an interrupt signal and a real-time of the internal real-time clock module when the working state of the external real-time clock module is an abnormal state, determine the real-time of the internal real-time clock module as the system time, and execute the preset operation based on the interrupt signal of the internal real-time clock module.
In one embodiment of the present application, the electronic device further comprises: an initialization unit and an adjustment unit. Wherein:
the initialization unit is used for initializing the hardware of the external real-time clock module.
The adjusting unit is used for adjusting the real-time of the external real-time clock module according to the real-time of the internal real-time clock module and adjusting the value of a preset parameter to a preset value; the preset value is an integer greater than 0.
In one embodiment of the present application, the electronic device further comprises: a third acquisition unit and a determination unit. Wherein:
the third obtaining unit is used for obtaining the interrupt signal and the real-time of the external real-time clock module if the interrupt signal of the external real-time clock module is detected.
The determining unit is used for determining the real-time of the external real-time clock module as the system time, and executing the preset operation based on the interrupt signal of the external real-time clock module.
In one embodiment of the present application, the electronic device further comprises: a counting unit and a working state determining unit. Wherein:
the counting unit is used for determining the value of a preset parameter according to the times of detecting the interrupt signal of the external real-time clock module and the times of detecting the interrupt signal of the internal real-time clock module; the initial value of the preset parameter is a preset value, and the preset value is an integer greater than 0.
And the working state determining unit is used for determining the working state of the external real-time clock module according to the value of the preset parameter.
In an embodiment of the application, the counting unit is specifically configured to: adding 1 to the value of the preset parameter every time an interrupt signal of the external real-time clock module is detected; and subtracting 1 from the value of the preset parameter once every time an interrupt signal of the internal real-time clock module is detected.
In an embodiment of the present application, the operating state determining unit is specifically configured to: if the value of the preset parameter is 0, determining that the working state of the external real-time clock module is an abnormal state; and if the value of the preset parameter is greater than 0, determining that the working state of the external real-time clock module is a normal state.
In one embodiment of the present application, the electronic device further comprises: and a calibration unit.
The calibration unit is used for calibrating the real-time of the internal real-time clock module according to the real-time of the external real-time clock module.
It should be noted that the units described above may be disposed in the processor 202 shown in fig. 2. For the information interaction, execution process, and other contents between the above units, the specific functions and technical effects of the embodiments of the method of the present application are based on the same concept, and thus reference may be made to the above embodiments of the method, which is not described herein again.
As can be seen from the above, according to the electronic device provided by the application, when the working state of the external real-time clock module is a normal state, the interrupt signal and the real-time of the external real-time clock module are acquired, the real-time of the external real-time clock module is determined as the system time of the electronic device, and the preset operation is executed based on the interrupt signal of the external real-time clock module; when the working state of the external real-time clock module is an abnormal state, acquiring an interrupt signal and real-time of the internal real-time clock module, determining the real-time of the internal real-time clock module as system time, and executing preset operation based on the interrupt signal of the internal real-time clock module. Therefore, when the external real-time clock module of the electronic device is abnormal, the electronic device can acquire the real-time and the interrupt signal of the internal real-time clock module, determine the real-time of the internal real-time clock module as the system time of the electronic device, and execute preset operation based on the interrupt signal of the internal real-time clock module, so that the electronic device can continuously and stably work normally.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
An embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the steps in any of the foregoing method embodiments for switching a real-time clock may be implemented.
The embodiment of the present application provides a computer program product, which, when running on an electronic device, enables the electronic device to implement the steps in any of the above embodiments of the switching method for the real-time clock when executed.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium and can implement the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code to a photographing apparatus/electronic device, a recording medium, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), an electrical carrier signal, a telecommunications signal, and a software distribution medium. Such as a usb-disk, a removable hard disk, a magnetic or optical disk, etc. In certain jurisdictions, computer-readable media may not be an electrical carrier signal or a telecommunications signal in accordance with legislative and patent practice.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed switching method of the real-time clock and the electronic device may be implemented in other ways. For example, the above-described embodiments of the electronic device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.
Claims (10)
1. A switching method of a real-time clock is applied to electronic equipment and is characterized in that the electronic equipment is provided with an external real-time clock module and an internal real-time clock module, and the switching method comprises the following steps:
when the working state of the external real-time clock module is a normal state, acquiring an interrupt signal and real-time of the external real-time clock module, determining the real-time of the external real-time clock module as the system time of the electronic equipment, and executing preset operation based on the interrupt signal of the external real-time clock module;
and when the working state of the external real-time clock module is an abnormal state, acquiring an interrupt signal and real-time of the internal real-time clock module, determining the real-time of the internal real-time clock module as the system time, and executing the preset operation based on the interrupt signal of the internal real-time clock module.
2. The switching method according to claim 1, wherein after acquiring the interrupt signal and the real time of the internal real time clock module, further comprising:
initializing the hardware of the external real-time clock module;
adjusting the real-time of the external real-time clock module according to the real-time of the internal real-time clock module, and adjusting the value of a preset parameter to a preset value; the preset value is an integer greater than 0.
3. The handover method according to claim 2, wherein after adjusting the value of the preset parameter to the preset value, the method further comprises:
if the interrupt signal of the external real-time clock module is detected, acquiring the interrupt signal and real-time of the external real-time clock module;
and determining the real-time of the external real-time clock module as the system time, and executing the preset operation based on the interrupt signal of the external real-time clock module.
4. The handover method according to claim 1, further comprising:
determining the value of a preset parameter according to the times of detecting the interrupt signal of the external real-time clock module and the times of detecting the interrupt signal of the internal real-time clock module; the initial value of the preset parameter is a preset value, and the preset value is an integer greater than 0;
and determining the working state of the external real-time clock module according to the value of the preset parameter.
5. The switching method according to claim 4, wherein the determining the value of the preset parameter according to the number of times of detecting the interrupt signal of the external real-time clock module and the number of times of detecting the interrupt signal of the internal real-time clock module comprises:
adding 1 to the value of the preset parameter every time an interrupt signal of the external real-time clock module is detected;
and subtracting 1 from the value of the preset parameter once every time an interrupt signal of the internal real-time clock module is detected.
6. The switching method according to claim 4, wherein said determining the operating state of the external real-time clock module according to the value of the preset parameter comprises:
if the value of the preset parameter is 0, determining that the working state of the external real-time clock module is an abnormal state;
and if the value of the preset parameter is greater than 0, determining that the working state of the external real-time clock module is a normal state.
7. The switching method according to any one of claims 1 to 6, wherein after acquiring the interrupt signal and the real time of the external real time clock module, the method further comprises:
and calibrating the real-time of the internal real-time clock module according to the real-time of the external real-time clock module.
8. An electronic device, characterized in that the electronic device is provided with an external real time clock module and an internal real time clock module, the electronic device comprising:
a first obtaining unit, configured to obtain an interrupt signal and real-time of the external real-time clock module when a working state of the external real-time clock module is a normal state, determine the real-time of the external real-time clock module as system time of the electronic device, and perform a preset operation based on the interrupt signal of the external real-time clock module;
and the second acquisition unit is used for acquiring the interrupt signal and the real-time of the internal real-time clock module when the working state of the external real-time clock module is an abnormal state, determining the real-time of the internal real-time clock module as the system time, and executing the preset operation based on the interrupt signal of the internal real-time clock module.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the electronic device is provided with an external real time clock module and an internal real time clock module, the processor implementing the method according to any of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010772922.XA CN112114616B (en) | 2020-08-04 | 2020-08-04 | Switching method of real-time clock, electronic equipment and computer storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010772922.XA CN112114616B (en) | 2020-08-04 | 2020-08-04 | Switching method of real-time clock, electronic equipment and computer storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112114616A true CN112114616A (en) | 2020-12-22 |
CN112114616B CN112114616B (en) | 2022-10-25 |
Family
ID=73799156
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010772922.XA Active CN112114616B (en) | 2020-08-04 | 2020-08-04 | Switching method of real-time clock, electronic equipment and computer storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112114616B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113448381A (en) * | 2021-05-28 | 2021-09-28 | 山东英信计算机技术有限公司 | CPLD working clock keeping method, system, storage medium and device |
CN113757932A (en) * | 2021-08-27 | 2021-12-07 | Tcl空调器(中山)有限公司 | Air conditioner communication fault processing method and device, computer equipment and storage medium |
Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1870509A (en) * | 2005-05-25 | 2006-11-29 | 中兴通讯股份有限公司南京分公司 | Method and device for raising protection stability of multi-section when clock plate switchover |
CN101090341A (en) * | 2007-08-10 | 2007-12-19 | 中控科技集团有限公司 | Method and system for network clock synchronous |
CN101324931A (en) * | 2007-06-12 | 2008-12-17 | 株式会社瑞萨科技 | Processing device and clock control method |
CN104410400A (en) * | 2014-09-26 | 2015-03-11 | 惠州市亿能电子有限公司 | Real-time clock synchronization circuit of battery management system and method thereof |
CN106066817A (en) * | 2016-05-30 | 2016-11-02 | 珠海市微半导体有限公司 | clock monitoring circuit and method thereof |
CN106154824A (en) * | 2016-08-19 | 2016-11-23 | 北京航天自动控制研究所 | A kind of spaceborne clock redundant system and method |
CN205750769U (en) * | 2016-05-30 | 2016-11-30 | 珠海市一微半导体有限公司 | Clock monitoring circuit |
CN106569921A (en) * | 2016-10-17 | 2017-04-19 | 国家电网公司 | Metering core clock processing method and apparatus for dual-core intelligent electric energy meter |
CN108089631A (en) * | 2017-12-11 | 2018-05-29 | 深圳市博巨兴实业发展有限公司 | A kind of clock circuit for detecting for microcontroller chip |
CN109117309A (en) * | 2018-07-27 | 2019-01-01 | 努比亚技术有限公司 | Mobile terminal restarts localization method, mobile terminal and computer readable storage medium |
CN110690894A (en) * | 2019-09-20 | 2020-01-14 | 上海励驰半导体有限公司 | Clock failure safety protection method and circuit |
-
2020
- 2020-08-04 CN CN202010772922.XA patent/CN112114616B/en active Active
Patent Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1870509A (en) * | 2005-05-25 | 2006-11-29 | 中兴通讯股份有限公司南京分公司 | Method and device for raising protection stability of multi-section when clock plate switchover |
CN101324931A (en) * | 2007-06-12 | 2008-12-17 | 株式会社瑞萨科技 | Processing device and clock control method |
CN101090341A (en) * | 2007-08-10 | 2007-12-19 | 中控科技集团有限公司 | Method and system for network clock synchronous |
CN104410400A (en) * | 2014-09-26 | 2015-03-11 | 惠州市亿能电子有限公司 | Real-time clock synchronization circuit of battery management system and method thereof |
CN106066817A (en) * | 2016-05-30 | 2016-11-02 | 珠海市微半导体有限公司 | clock monitoring circuit and method thereof |
CN205750769U (en) * | 2016-05-30 | 2016-11-30 | 珠海市一微半导体有限公司 | Clock monitoring circuit |
CN106154824A (en) * | 2016-08-19 | 2016-11-23 | 北京航天自动控制研究所 | A kind of spaceborne clock redundant system and method |
CN106569921A (en) * | 2016-10-17 | 2017-04-19 | 国家电网公司 | Metering core clock processing method and apparatus for dual-core intelligent electric energy meter |
CN108089631A (en) * | 2017-12-11 | 2018-05-29 | 深圳市博巨兴实业发展有限公司 | A kind of clock circuit for detecting for microcontroller chip |
CN109117309A (en) * | 2018-07-27 | 2019-01-01 | 努比亚技术有限公司 | Mobile terminal restarts localization method, mobile terminal and computer readable storage medium |
CN110690894A (en) * | 2019-09-20 | 2020-01-14 | 上海励驰半导体有限公司 | Clock failure safety protection method and circuit |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113448381A (en) * | 2021-05-28 | 2021-09-28 | 山东英信计算机技术有限公司 | CPLD working clock keeping method, system, storage medium and device |
CN113757932A (en) * | 2021-08-27 | 2021-12-07 | Tcl空调器(中山)有限公司 | Air conditioner communication fault processing method and device, computer equipment and storage medium |
CN113757932B (en) * | 2021-08-27 | 2022-12-13 | Tcl空调器(中山)有限公司 | Air conditioner communication fault processing method and device, computer equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN112114616B (en) | 2022-10-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111797293B (en) | Data adjustment method, device, terminal equipment and storage medium | |
CN112114616B (en) | Switching method of real-time clock, electronic equipment and computer storage medium | |
CN111161259B (en) | Method and device for detecting whether image is tampered or not and electronic equipment | |
CN111585682A (en) | Sensor time synchronization method and device and terminal equipment | |
CN111211929A (en) | Fault positioning method, fault positioning device, control equipment and intelligent equipment | |
US9400734B2 (en) | Apparatuses and methods for generating event codes including event source | |
CN109005002A (en) | Sensing data processing unit, sensing system and the method for determining reduced parameter in the scope of the sensing system | |
CN111130510A (en) | Method and device for outputting pulse per second signal | |
EP3883190B1 (en) | Detection device, detection method, and detection program | |
US12045970B2 (en) | Method for detecting defects in product and computer device | |
CN108922478B (en) | Backlight brightness adjusting method and system and display device | |
US10773728B2 (en) | Signal processing system and signal processing method for sensors of vehicle | |
CN111046392A (en) | BIOS (basic input output System) credibility measuring method and device and terminal equipment | |
EP4184367A1 (en) | Integrity measurement method and integrity measurement device | |
CN115603849B (en) | Multi-sensor trigger control method, device, equipment and storage medium | |
US11055165B2 (en) | Shadow memory checking | |
CN115278431B (en) | State determination method and device, electronic equipment and readable storage medium | |
US8612660B2 (en) | Interrupt latency measurement | |
US7080282B2 (en) | Method for determining an operating voltage of floating point error detection | |
EP3480608B1 (en) | Method and system for measuring power-on reset time | |
CN115235531B (en) | Sensor correction method and device, terminal equipment and storage medium | |
CN112463125B (en) | Timing method and equipment of virtual timer | |
US20050182579A1 (en) | Sensor signal debouncing | |
CN116755514A (en) | Standby method for notebook computer and notebook computer | |
CN116030101A (en) | Map calibration method and device based on canvas and terminal equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |