CN112419628A - RTC (real time clock) calibration method and device, computer readable medium and POS (point of sale) machine - Google Patents

RTC (real time clock) calibration method and device, computer readable medium and POS (point of sale) machine Download PDF

Info

Publication number
CN112419628A
CN112419628A CN202011313090.1A CN202011313090A CN112419628A CN 112419628 A CN112419628 A CN 112419628A CN 202011313090 A CN202011313090 A CN 202011313090A CN 112419628 A CN112419628 A CN 112419628A
Authority
CN
China
Prior art keywords
tempfreq
freq
rtc
clock
lowfreq
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.)
Pending
Application number
CN202011313090.1A
Other languages
Chinese (zh)
Inventor
江沣
孙晓朋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Jiecheng Technology Service Co ltd
Original Assignee
Shenzhen Jiecheng Technology Service Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Shenzhen Jiecheng Technology Service Co ltd filed Critical Shenzhen Jiecheng Technology Service Co ltd
Priority to CN202011313090.1A priority Critical patent/CN112419628A/en
Publication of CN112419628A publication Critical patent/CN112419628A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G07CHECKING-DEVICES
    • G07GREGISTERING THE RECEIPT OF CASH, VALUABLES, OR TOKENS
    • G07G1/00Cash registers
    • G07G1/12Cash registers electronically operated

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Electric Clocks (AREA)

Abstract

The invention provides an RTC (real time clock) calibration method which is applied to a POS (point of sale) machine and is characterized in that the POS machine comprises a detection clock and an internal LSI (large scale integration) clock, the frequency of the detection clock is MainCPUFreq, the theoretical frequency of the internal LSI clock is 32768Hz, and a detection parameter is set to freq, so that the accuracy of an RTC module can be ensured on the premise of not using an external crystal oscillator, the error of the internal low-frequency clock of a security chip can be avoided, and the cost can be reduced without using an external calibration module.

Description

RTC (real time clock) calibration method and device, computer readable medium and POS (point of sale) machine
Technical Field
The invention relates to the technical field of clock calibration, in particular to a method and a device for RTC calibration, a computer readable medium and a POS machine.
Background
The RTC module plays an unachievable role in that the POS product needs to record strictly and accurately every consumption record that occurs during personal use and merchant use. When the conventional product uses the RTC module, because the error of the internal low-frequency clock of the security chip is large, in order to solve the problem, an external crystal oscillator is usually used to avoid the error, but the cost of the product is also increased, so that an RTC calibration method capable of ensuring the accuracy of the RTC module on the premise of not using the external crystal oscillator is required.
Disclosure of Invention
The invention provides an RTC calibration method, an RTC calibration device, a computer readable medium and a POS machine, and aims to solve the technical problems mentioned in the background technology.
The invention firstly provides an RTC calibration method, which is applied to a POS machine, wherein the POS machine comprises a detection clock and an internal LSI clock, the frequency of the detection clock is MainCPUFreq, the theoretical frequency of the internal LSI clock is 32768Hz, and a detection parameter is set to freq, the RTC calibration method comprises the following steps:
s100, initializing freq to 32768, and resetting the state of an initialization trigger;
s200, acquiring a measured frequency TempFreq of an LSI clock (MainCPUFreq/(a +1)), and comparing the TempFreq with the freq, wherein a is the number of clocks used by the internal LSI clock in 1/32768S;
s300, when TempFreq is larger than freq, the freq is freq +1, and the step S200 is returned;
s400, when TempFreq is less than freq, freq-1 is equal to freq-1, and the step S200 is returned;
s500, when TempFreq is freq, setting the state of the trigger;
s600: outputting TempFreq;
s700: comparing TempFreq with 32768Hz, when TempFreq is less than 32768, executing step S800, and when TempFreq is more than 32768, executing step S900;
s800: the RTC count value per second needs to be increased (TempFreq-32768);
s900: the RTC count per second needs to be decreased (32768-TempFreq).
Further, setting a detection parameter freq ═ Lowfreq, Highfreq, and when Lowfreq ═ Highfreq ═ 32768, freq ═ Lowfreq ═ Highfreq; when Lowfreq < 32768, freq ═ Lowfreq; when the Highfreq is more than 32768, the freq is Highfreq; when Lowfreq is less than 32768 and Highfreq is more than 32768, an error reporting instruction is issued; the method further comprises the following steps:
when TempFreq is greater than freq, Highfreq is ═ Highfreq +1, and the process returns to step S200;
when TempFreq is less than freq, Lowfreq is equal to Lowfreq-1, and the process returns to step S200.
Further, the method further comprises:
and acquiring TempFreq values at least twice, and calculating to obtain an average value.
The invention also provides an RTC calibration device, which is applied to a POS machine, wherein the POS machine comprises a detection clock and an internal LSI clock, the frequency of the detection clock is MainCPUFreq, the theoretical frequency of the internal LSI clock is 32768Hz, and a detection parameter is set to freq, the device comprises:
the initialization module is used for initializing freq 32768 and resetting the state of the trigger;
a first comparison module, configured to obtain a measured frequency TempFreq of an LSI clock (MainCPUFreq/(a +1)), and compare the magnitudes of TempFreq and freq, where a is the number of clocks used by the detection clock in 1/32768 s;
a first execution module, configured to, when TempFreq > freq, return to compare TempFreq and freq sizes, where freq is freq + 1;
the second execution module is used for returning to compare the sizes of TempFreq and freq when TempFreq is less than freq and freq-1;
the third execution module is used for setting the state of the trigger when TempFreq is freq;
the output module is used for outputting TempFreq;
the second comparison module is used for comparing TempFreq with 32768Hz, when TempFreq is less than 32768, the step S800 is executed, and when TempFreq is more than 32768, the step S900 is executed;
the first calibration module is used for enabling the RTC count value per second to be increased (TempFreq-32768);
and a second calibration module for decreasing the count value of the RTC per second (32768-TempFreq).
The present invention also provides a computer readable medium having a computer program stored thereon, wherein the program when executed is configured to implement the RTC calibration method described above.
The invention also provides a POS machine, comprising:
one or more processors;
a storage device for storing one or more programs that, when executed by the one or more processors, cause the one or more processors to implement the RTC calibration method described above.
The RTC calibration method provided by the invention can ensure the accuracy of the RTC module on the premise of not using an external crystal oscillator, can avoid reducing the low-frequency clock error in the security chip, and can reduce the cost without using an external calibration module.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
Fig. 1 is a flowchart illustrating steps of an RTC calibration method according to an embodiment of the invention.
FIG. 2 is a block diagram of an RTC calibration apparatus according to an embodiment of the present invention.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are illustrative only and should not be construed as limiting the invention.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, or operations, but do not preclude the presence or addition of one or more other features, integers, steps, operations, or groups thereof.
It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
It will be appreciated by those skilled in the art that the terms "application," "application program," "application software," and the like, as used herein, are intended to refer to a computer software product electronically-adapted to be electronically-constructed, from a collection of computer instructions and associated data resources, in accordance with the principles of the present invention. Unless otherwise specified, such nomenclature is not itself limited by the programming language class, level, or operating system or platform upon which it depends. Of course, such concepts are not limited to any type of terminal.
It should be understood by those skilled in the art that the user interface and the display interface referred to in the present invention generally refer to a display interface capable of being used to send the control instruction to the intelligent terminal, and for example, may be an option (or a button, added by the application program, the same applies hereinafter) in a setup page of an Android/IOS/Windows Phone system, an option in a notification bar or an interaction page called from a desktop, or an option in a page constructed by an active component of the application program.
Referring to fig. 1, the present invention first provides an RTC calibration method applied to a POS machine, where the POS machine includes a detection clock and an internal LSI clock, the frequency of the detection clock is MainCPUFreq, the theoretical frequency of the internal LSI clock is 32768Hz, and a detection parameter is set to freq. When the ready state of the detection module is in a reset (clear 0) state, the number a of clocks used by the detection clock in 1/32768s and the actual measurement frequency TempFreq of the LSI clock cannot be read, and only detection comparison can be carried out; when the flip-flop is in the set (set 1) state, the number of clocks a used by the detection clock at 1/32768s and the actual measurement frequency TempFreq of the LSI clock can be read.
The RTC calibration method comprises the following steps:
and S100, initializing freq to 32768, and resetting the state of the initialization trigger.
Initialization freq is 32768, that is, freq is initially set to the theoretical frequency of the internal LSI clock. And the state reset of the initialization trigger is set, so that the TempFreq output before the verification is not finished is avoided.
S200, acquiring the actual measurement frequency TempFreq of the LSI clock (MainCPUFreq/(a +1)), and comparing the TempFreq with the freq, wherein a is the number of clocks used by the internal LSI clock in 1/32768S.
S300, when TempFreq is larger than freq, freq is freq +1, and the step S200 is returned to.
S400, when TempFreq is less than freq, freq-1 is equal to freq-1, and the step S200 is returned to.
And S500, when TempFreq is freq, setting the state of the trigger.
S600: and outputting TempFreq.
In this embodiment, after the state of the flip-flop is set, the TempFreq value is allowed to be output, and the TempFreq value obtained after verification corresponds to the actual measurement frequency of the internal LSI clock.
S700: comparing TempFreq and 32768Hz, when TempFreq < 32768, step S800 is performed, and when TempFreq > 32768, step S900 is performed.
S800: the RTC count per second needs to be incremented (TempFreq-32768).
S900: the RTC count per second needs to be decreased (32768-TempFreq).
In the embodiment, TempFreq is compared with a theoretical value of 32768Hz, when TempFreq is larger than the theoretical value, the result shows that the RTC clock is slow when the crystal oscillator frequency is high, and the count value of the RTC per second needs to be increased (TempFreq-32768); when TempFreq is smaller than the theoretical value, the crystal oscillator frequency is low, the RTC clock is fast, and the count value of the RTC per second needs to be reduced (32768-TempFreq).
Further, in one embodiment of the present invention, the detection parameter freq is set to (Lowfreq, Highfreq), and when Lowfreq is 32768, freq is set to Lowfreq; when Lowfreq < 32768, freq ═ Lowfreq; when the Highfreq is more than 32768, the freq is Highfreq; when Lowfreq < 32768 and Highfreq > 32768, an error notification instruction is issued.
The method further comprises the following steps:
when TempFreq > freq, Highfreq ═ Highfreq +1, return to step S200.
When TempFreq is less than freq, Lowfreq is equal to Lowfreq-1, and the process returns to step S200.
In the embodiment, two comparison parameters are set as representatives of freq, when TempFreq is greater than freq, high-frequency alarm is generated, and the corresponding value of HighFreq is accumulated and added by 1; when TempFreq is less than freq, low-frequency alarm is generated, the corresponding Lowfreq value is cumulatively reduced by 1, and in the theoretical application, only the Lowfreq or Highfreq value is changed in one calibration process, namely the freq is always reduced or increased until no alarm is generated; however, if the dead cycle occurs, which causes TempFreq > freq and TempFreq < freq in one calibration (i.e. both Lowfreq and Highfreq values change), an abnormal error is reported and then the calibration is withdrawn.
Further, in an embodiment of the present invention, the method further includes:
and acquiring TempFreq values at least twice, and calculating to obtain an average value.
In this embodiment, the average value is obtained by obtaining multiple TempFreq values, and then the average value is compared with 32768Hz, so that the RTC calibration is more accurate.
The invention also provides an RTC calibration device 100 applied to a POS machine, the device storing a plurality of instructions, the instructions being suitable for being loaded by a processor and executing an RTC calibration method, the RTC calibration device including:
and S100, initializing freq to 32768, and resetting the state of the initialization trigger.
S200, acquiring the actual measurement frequency TempFreq of the LSI clock (MainCPUFreq/(a +1)), and comparing the TempFreq with the freq, wherein a is the number of clocks used by the internal LSI clock in 1/32768S.
S300, when TempFreq is larger than freq, freq is freq +1, and the step S200 is returned to.
S400, when TempFreq is less than freq, freq-1 is equal to freq-1, and the step S200 is returned to.
And S500, when TempFreq is freq, setting the state of the trigger.
S600: and outputting TempFreq.
S700: comparing TempFreq and 32768Hz, when TempFreq < 32768, step S800 is performed, and when TempFreq > 32768, step S900 is performed.
S800: the RTC count per second needs to be incremented (TempFreq-32768).
S900: the RTC count per second needs to be decreased (32768-TempFreq).
For convenience of description, the RTC calibration apparatus is split into functional module architectures, as shown in fig. 2, including:
the initialization module 10 is configured to initialize freq 32768, and initialize the state reset of the flip-flop;
a first comparison module 20, configured to obtain a measured frequency TempFreq of an LSI clock (MainCPUFreq/(a +1)), and compare the magnitudes of TempFreq and freq, where a is the number of clocks used by the detection clock in 1/32768 s;
a first execution module 30, configured to, when TempFreq > freq, return to compare TempFreq and freq sizes, if freq + 1;
a second execution module 40, configured to, when TempFreq < freq, return to compare TempFreq and freq sizes, if freq-1;
a third execution module 50, configured to set the state of the flip-flop when TempFreq is freq;
an output module 60 for outputting TempFreq;
the second comparison module 70 is used for comparing TempFreq with 32768Hz, when TempFreq is less than 32768, the step S800 is executed, and when TempFreq is more than 32768, the step S900 is executed;
a first calibration module 80 for the RTC count per second to be incremented (TempFreq-32768);
the second calibration module 90, for RTC count per second needs to be decremented (32768-TempFreq).
The present invention also provides a computer readable medium having a computer program stored thereon, wherein the program when executed is configured to implement the RTC calibration method described above.
The invention also provides a POS machine, comprising:
one or more processors;
a storage device for storing one or more programs that, when executed by the one or more processors, cause the one or more processors to implement the RTC calibration method described above.
The RTC calibration method provided by the invention can ensure the accuracy of the RTC module on the premise of not using an external crystal oscillator, can avoid reducing the low-frequency clock error in the security chip, and can reduce the cost without using an external calibration module.
Throughout the description and claims of this application, the words "comprise/comprises" and the words "have/includes" and variations of these are used to specify the presence of stated features, values, steps or components but do not preclude the presence or addition of one or more other features, values, steps, components or groups thereof.
Some features of the invention, which are, for clarity, described in the context of separate embodiments, may also be provided in combination in a single embodiment. Conversely, certain features of the invention, which are, for brevity, described in the context of a single embodiment, may also be provided separately or in any suitable combination in different embodiments.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.

Claims (6)

1. An RTC calibration method is applied to a POS machine, and is characterized in that the POS machine comprises a detection clock and an internal LSI clock, the frequency of the detection clock is MainCPUFreq, the theoretical frequency of the internal LSI clock is 32768Hz, and a detection parameter is set to freq, the RTC calibration method comprises the following steps:
s100, initializing freq to 32768, and resetting the state of an initialization trigger;
s200, acquiring an actual measurement frequency TempFreq of the LSI clock (MainCPUFreq/(a +1)), and comparing the sizes of TempFreq and freq, wherein a is the number of clocks used by the internal LSI clock in 1/32768S, and TempFreq is a positive integer;
s300, when TempFreq is larger than freq, the freq is freq +1, and the step S200 is returned;
s400, when TempFreq is less than freq, freq-1 is equal to freq-1, and the step S200 is returned;
s500, when TempFreq is freq, setting the state of the trigger;
s600: outputting TempFreq;
s700: comparing TempFreq with 32768Hz, when TempFreq is less than 32768, executing step S800, and when TempFreq is more than 32768, executing step S900;
s800: the RTC count value per second needs to be increased (TempFreq-32768);
s900: the RTC count per second needs to be decreased (32768-TempFreq).
2. The RTC calibration method according to claim 1, wherein the detection parameter freq is set to (Lowfreq, Highfreq), and when Lowfreq is 32768, freq is set to Lowfreq; when Lowfreq < 32768, freq ═ Lowfreq; when the Highfreq is more than 32768, the freq is Highfreq; when Lowfreq is less than 32768 and Highfreq is more than 32768, an error reporting instruction is issued; the method further comprises the following steps:
when TempFreq is greater than freq, Highfreq is ═ Highfreq +1, and the process returns to step S200;
when TempFreq is less than freq, Lowfreq is equal to Lowfreq-1, and the process returns to step S200.
3. The RTC calibration method of claim 1, further comprising:
and acquiring TempFreq values at least twice, and calculating to obtain an average value.
4. An RTC calibration device applied to a POS machine, wherein the POS machine comprises a detection clock and an internal LSI clock, the frequency of the detection clock is MainCPUFreq, the theoretical frequency of the internal LSI clock is 32768Hz, and a detection parameter is set to freq, the device comprises:
the initialization module is used for initializing freq 32768 and resetting the state of the trigger;
a first comparison module, configured to obtain a measured frequency TempFreq of an LSI clock (MainCPUFreq/(a +1)), and compare the magnitudes of TempFreq and freq, where a is the number of clocks used by the detection clock in 1/32768 s;
a first execution module, configured to, when TempFreq > freq, return to compare TempFreq and freq sizes, where freq is freq + 1;
the second execution module is used for returning to compare the sizes of TempFreq and freq when TempFreq is less than freq and freq-1;
the third execution module is used for setting the state of the trigger when TempFreq is freq;
the output module is used for outputting TempFreq;
the second comparison module is used for comparing TempFreq with 32768Hz, when TempFreq is less than 32768, the step S800 is executed, and when TempFreq is more than 32768, the step S900 is executed;
the first calibration module is used for enabling the RTC count value per second to be increased (TempFreq-32768);
and a second calibration module for decreasing the count value of the RTC per second (32768-TempFreq).
5. A computer readable medium having stored thereon a computer program, characterized in that said program, when processed and executed, implements the RTC calibration method of any of claims 1-3.
6. A POS machine, comprising:
one or more processors;
storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the RTC calibration method of any one of claims 1-3.
CN202011313090.1A 2020-11-20 2020-11-20 RTC (real time clock) calibration method and device, computer readable medium and POS (point of sale) machine Pending CN112419628A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011313090.1A CN112419628A (en) 2020-11-20 2020-11-20 RTC (real time clock) calibration method and device, computer readable medium and POS (point of sale) machine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011313090.1A CN112419628A (en) 2020-11-20 2020-11-20 RTC (real time clock) calibration method and device, computer readable medium and POS (point of sale) machine

Publications (1)

Publication Number Publication Date
CN112419628A true CN112419628A (en) 2021-02-26

Family

ID=74777641

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011313090.1A Pending CN112419628A (en) 2020-11-20 2020-11-20 RTC (real time clock) calibration method and device, computer readable medium and POS (point of sale) machine

Country Status (1)

Country Link
CN (1) CN112419628A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090228735A1 (en) * 2008-03-07 2009-09-10 Panasonic Corporation Information processing apparatus and elapsed time measuring method
CN204065907U (en) * 2014-07-21 2014-12-31 深圳市芯海科技有限公司 A kind of MCU chip frequency-dividing clock means for correcting
CN110308762A (en) * 2019-06-21 2019-10-08 广芯微电子(广州)股份有限公司 A kind of clock frequency calibration method of chip interior clock source
CN110968148A (en) * 2018-09-28 2020-04-07 珠海格力电器股份有限公司 Timing calibration method and device and timer
CN111026232A (en) * 2019-11-08 2020-04-17 深圳市汇顶科技股份有限公司 Clock calibration method, chip and electronic equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090228735A1 (en) * 2008-03-07 2009-09-10 Panasonic Corporation Information processing apparatus and elapsed time measuring method
CN204065907U (en) * 2014-07-21 2014-12-31 深圳市芯海科技有限公司 A kind of MCU chip frequency-dividing clock means for correcting
CN110968148A (en) * 2018-09-28 2020-04-07 珠海格力电器股份有限公司 Timing calibration method and device and timer
CN110308762A (en) * 2019-06-21 2019-10-08 广芯微电子(广州)股份有限公司 A kind of clock frequency calibration method of chip interior clock source
CN111026232A (en) * 2019-11-08 2020-04-17 深圳市汇顶科技股份有限公司 Clock calibration method, chip and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
PAUL SANNA,等: "《Visual Basic for Applications 5 开发使用手册》", 31 December 1997, 机械工业出版社 *

Similar Documents

Publication Publication Date Title
US5715438A (en) System and method for providing time base adjustment
US5964846A (en) System and method for mapping processor clock values in a multiprocessor system
CN111104421A (en) Data query method and device based on data interface standard configuration
CN111428462A (en) Communication protocol template construction method and terminal equipment
US5875320A (en) System and method for synchronizing plural processor clocks in a multiprocessor system
US8401828B1 (en) Methods and systems for analog object fetch in mixed-signal simulation
CN110515822A (en) Interrupt response time test method, device, equipment and storage medium
WO2023151339A1 (en) Method and system for high-accuracy measurement of interrupt duration of embedded system, and medium
US20220188221A1 (en) Regression testing method and regression testing apparatus
CN112732427B (en) Data processing method, system and related device based on Redis cluster
CN110580220A (en) method for measuring execution time of code segment and terminal equipment
CN112419628A (en) RTC (real time clock) calibration method and device, computer readable medium and POS (point of sale) machine
CN112114616B (en) Switching method of real-time clock, electronic equipment and computer storage medium
CN109684213A (en) A kind of test method, device and storage medium
CN109254904A (en) A kind of database pressure surveys method, apparatus and electronic equipment
CN112181853A (en) Program debugging method, device and system
CN109408035B (en) Flow configuration method, storage medium and server of business system
CN110837537A (en) Order data synchronization method and device, computer readable storage medium and server
CN113032232B (en) Correlation method, correlation device and equipment for performance detection of equipment
CN113407350B (en) Instruction processing device, processor, chip, computing equipment and corresponding method
CN103677846A (en) SQLite database development kit and development method thereof
US11287453B2 (en) Method and system for measuring power-on reset time
CN112908400A (en) Method, device and equipment for testing double-rate synchronous dynamic random access memory
US10430313B2 (en) System for correlation of operating system and hardware trace events
CN115563015B (en) Code heat statistics method, device, equipment and storage medium

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210226