RTC calibration circuit and calibration method of smoke detector MCU

By designing an RTC calibration circuit including frequency error detection and compensation control in the smoke detector MCU, the problems of frequency deviation-temperature curve consistency and temperature sensor accuracy of the RTC calibration circuit in the prior art are solved, and high-precision RTC timing correction and reliability improvement are achieved.

CN111897202BActive Publication Date: 2025-03-11SHENZHEN PENGXIN DATA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010953858.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-11
Publication Date
2025-03-11
Estimated Expiration
2040-09-11

AI Technical Summary

Technical Problem

The RTC calibration circuit of the existing smoke detector MCU has problems of frequency deviation-temperature curve consistency and temperature sensor accuracy, and cannot effectively solve the impact of crystal aging rate on RTC timing accuracy.

Method used

An RTC calibration circuit including a frequency error detection sub-circuit, a frequency error compensation control sub-circuit, an RTC timing sub-circuit, a 15-bit asynchronous frequency divider and a periodic interrupt controller is designed. By detecting the interval time of timing errors on the online time, the frequency compensation value that needs to be adjusted is obtained, and frequency compensation is performed to correct the RTC timing accuracy problem.

Benefits of technology

High-precision correction of RTC timing accuracy is achieved, reducing the frequency offset-temperature curve measurement cost and non-volatile memory space requirements, and improving calibration accuracy and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111897202B_ABST
    Figure CN111897202B_ABST
Patent Text Reader

Abstract

The present invention discloses an RTC calibration circuit and calibration method of a smoke detector MCU. The RTC calibration circuit of the smoke detector MCU includes: a frequency error detection subcircuit, a frequency error compensation control subcircuit, an RTC timing subcircuit, a 15-bit asynchronous frequency divider and a periodic interrupt controller; the frequency error detection subcircuit is electrically connected to the frequency error compensation control subcircuit, the frequency error compensation control subcircuit is electrically connected to the 15-bit asynchronous frequency divider, the 15-bit asynchronous frequency divider is electrically connected to the periodic interrupt controller and the RTC timing subcircuit respectively, and the periodic interrupt controller is electrically connected to the RTC timing subcircuit. The present invention can cooperate with the smoke detector MCU to timely correct the RTC timing accuracy problem caused by temperature or crystal oscillator inherent error when the host computer is online, which can save the cost of frequency deviation-temperature curve measurement and save non-volatile memory space, and has high calibration accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of clock calibration, and in particular to an RTC calibration circuit and a calibration method for an MCU of a smoke detector. Background Art

[0002] As the instruction manual Figure 2 As shown, the traditional real-time clock RTC circuit calibration scheme generally integrates a temperature sensor on the MCU chip and writes the frequency deviation-temperature curve function of the RTC crystal oscillator into the non-volatile memory. The MCU chip needs to turn on the temperature sensor regularly to detect the temperature of the crystal oscillator, and calculate the frequency deviation at the corresponding temperature according to the frequency deviation-temperature curve, and then correct the frequency offset error back through the correction circuit. This method has the following disadvantages: 1) The temperature compensation method faces the problem of consistency of the crystal oscillator frequency deviation-temperature curve and the problem of the influence of temperature sensor accuracy. 2) Due to the annual aging rate of the crystal itself, according to the data provided by the crystal manufacturer, the maximum aging rate of the crystal in the first year is ±3PPM, and about ±1PPM every year thereafter. The influence of this annual aging rate exists in the positive and negative range and cannot be solved in production calibration. Therefore, inventing a highly reliable RTC calibration circuit for smoke detector MCU has become a problem that needs to be solved urgently by technicians in this field. Summary of the invention

[0003] The technical problem to be solved by the present invention is to provide an RTC calibration circuit and calibration method for a smoke detector MCU in view of the above-mentioned defects of the prior art.

[0004] In a first aspect, the present invention discloses an RTC calibration circuit and calibration method of a smoke detector MCU. The RTC calibration circuit of the smoke detector MCU includes: a frequency error detection subcircuit, a frequency error compensation control subcircuit, an RTC timing subcircuit, a 15-bit asynchronous frequency divider and a periodic interrupt controller; the frequency error detection subcircuit is electrically connected to the frequency error compensation control subcircuit, the frequency error compensation control subcircuit is electrically connected to the 15-bit asynchronous frequency divider, the 15-bit asynchronous frequency divider is electrically connected to the periodic interrupt controller and the RTC timing subcircuit respectively, and the periodic interrupt controller is electrically connected to the RTC timing subcircuit.

[0005] Preferably, the frequency error detection subcircuit includes a deviation timer unit and a deviation lookup table hardware unit; the deviation timer unit is electrically connected to the smoke detector MCU and the deviation lookup table hardware unit respectively, and the deviation lookup table hardware unit is electrically connected to the frequency error compensation control subcircuit.

[0006] Preferably, the frequency error compensation control subcircuit includes a compensation parameter storage unit and an error compensation processing unit; the compensation parameter storage unit is electrically connected to the deviation lookup table hardware unit and the error compensation processing unit, and the error compensation processing unit is electrically connected to the 15-bit asynchronous divider.

[0007] Preferably, the RTC timing subcircuit includes an APB bus interface, a second timing unit, a minute timing unit, an hour timing unit, a day timing unit, a week timing unit, a month timing unit, a year timing unit, a periodic interrupt control unit and an alarm interrupt controller; the second timing unit, the minute timing unit, the hour timing unit, the day timing unit, the week timing unit, the month timing unit and the year timing unit are electrically connected to the APB bus interface and the periodic interrupt controller, respectively, and the minute timing unit, the hour timing unit and the week timing unit are electrically connected to the alarm interrupt controller, respectively.

[0008] In a second aspect, the present invention further discloses a calibration method, including the RTC calibration circuit of the smoke detector MCU according to the first aspect, the calibration method comprising:

[0009] Get the first interval time that produces the timing error;

[0010] Acquire a first frequency compensation value that needs to be adjusted according to the first interval time;

[0011] Performing a first calibration according to the first frequency compensation value;

[0012] Comparing the calibration result of the first calibration with a preset ideal accuracy;

[0013] If the preset ideal accuracy is not reached, obtaining a second interval time that generates a timing error;

[0014] Acquire a second frequency compensation value that needs to be adjusted according to the second interval time;

[0015] A second calibration is performed according to the second compensation value.

[0016] Preferably, the real-time clock of the smoke detector MCU uses a 32.768KHz crystal oscillator clock for counting.

[0017] Preferably, obtaining the first frequency compensation value to be adjusted according to the first interval time includes:

[0018] Obtaining the time point a when the first time calibration command is received, and taking the time point a as the starting point of the first interval time;

[0019] Counting in hours from the starting point a, the timing number of the deviation timer unit is increased by 1 each time a time calibration command is received;

[0020] If the RTC timing subcircuit detects a timing error of 1S at the time point b when the Nth time calibration command is obtained, the time point b is used as the end point of the first interval time;

[0021] Obtaining a difference c between the time point b and the time point a, and obtaining a compensation target value PPM according to the difference c; wherein the difference c is rounded;

[0022] The first frequency compensation value CR corresponding to the compensation target value PPM is obtained according to the preset corresponding relationship.

[0023] Preferably, the formula of the preset corresponding relationship is:

[0024]

[0025] Wherein, the target compensation value represents the frequency error that needs to be compensated per unit time; 15 It is the conversion unit of the 15-bit asynchronous frequency divider to generate a 1S timing pulse under the crystal clock of 32.768KHz, and 0001.00000B is the zero point adjustment number of the CR value.

[0026] Preferably, performing a first calibration according to the first frequency compensation value includes:

[0027] Get the first compensation unit per second under the crystal oscillator clock of 32.768KHz;

[0028] Expand the compensation period of the 32.768KHz crystal oscillator clock by 32 times;

[0029] Obtain a second compensation unit for compensation per second after expanding the compensation period by 32 times according to the first compensation unit;

[0030] Dividing the first frequency compensation value CR into an integer part and a decimal part;

[0031] The integer part and the decimal part are calibrated for the first time in sequence according to the second compensation unit.

[0032] Preferably, the obtaining of the difference c between the time point b and the time point a, and obtaining the compensation target value PPM according to the difference c comprises:

[0033]

[0034] The RTC calibration circuit of a smoke detector MCU disclosed in the present invention has the following beneficial effects. The RTC calibration circuit of the smoke detector MCU includes a frequency error detection subcircuit, a frequency error compensation control subcircuit, an RTC timing subcircuit, a 15-bit asynchronous frequency divider and a periodic interrupt controller; the frequency error detection subcircuit is electrically connected to the frequency error compensation control subcircuit, the frequency error compensation control subcircuit is electrically connected to the 15-bit asynchronous frequency divider, the 15-bit asynchronous frequency divider is electrically connected to the periodic interrupt controller and the RTC timing subcircuit respectively, and the periodic interrupt controller is electrically connected to the RTC timing subcircuit. The frequency error detection subcircuit is used to detect the interval time of the timing error generated according to the online time of the host computer, the frequency error compensation control subcircuit is used to obtain the frequency compensation value that needs to be adjusted according to the interval time, the 15-bit asynchronous frequency divider is used to generate a timing pulse and cooperate with the frequency error compensation control subcircuit to perform frequency compensation, the periodic interrupt controller is used to generate an interrupt signal to the smoke detector MCU, and the smoke detector MCU performs interrupt service control on the RTC timing subcircuit. Therefore, the present invention can cooperate with the host computer of the smoke detector MCU to timely correct the RTC timing accuracy problem caused by temperature or crystal oscillator inherent error, etc., which can save the cost of frequency deviation-temperature curve measurement and non-volatile memory space, and has high calibration accuracy and reliability. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the present invention will be further described below in conjunction with the accompanying drawings and embodiments. The drawings described below are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work:

[0036] Figure 1 1 is a circuit block diagram of an RTC calibration circuit of a smoke detector MCU according to a preferred embodiment of the present invention;

[0037] Figure 2 It is a structural block diagram of a smoke detector of a preferred embodiment of the present invention;

[0038] Figure 3 It is a frequency deviation-temperature curve function diagram of the RTC crystal oscillator of the RTC calibration circuit of the smoke detector MCU in the preferred embodiment of the present invention;

[0039] Figure 4 It is a circuit block diagram of an RTC calibration circuit of a smoke detector MCU according to another preferred embodiment of the present invention;

[0040] Figure 5 It is a timing diagram of RTC timing deviation of the RTC calibration method of the smoke detector MCU in a preferred embodiment of the present invention;

[0041] Figure 6 It is a flow chart of the RTC calibration method of the smoke detector MCU in a preferred embodiment of the present invention;

[0042] Figure 7 It is a flow chart of the RTC calibration method of the smoke detector MCU in a preferred embodiment of the present invention, which obtains the first frequency compensation value that needs to be adjusted according to the first interval time;

[0043] Figure 8 It is a flow chart of the first calibration according to the first frequency compensation value in the RTC calibration method of the smoke detector MCU in a preferred embodiment of the present invention. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the following will be described clearly and completely in combination with the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are partial embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the protection scope of the present invention.

[0045] The preferred embodiment of the present invention is as follows Figure 1 As shown, it includes a frequency error detection subcircuit 1, a frequency error compensation control subcircuit 2, an RTC timing subcircuit 3, a 15-bit asynchronous frequency divider 4 and a periodic interrupt controller 5; the frequency error detection subcircuit 1 is electrically connected to the frequency error compensation control subcircuit 2, the frequency error compensation control subcircuit 3 is electrically connected to the 15-bit asynchronous frequency divider 4, the 15-bit asynchronous frequency divider 4 is electrically connected to the periodic interrupt controller 5 and the RTC timing subcircuit 3 respectively, and the periodic interrupt controller 5 is electrically connected to the RTC timing subcircuit 3. The frequency error detection subcircuit 1 is used to detect the interval time of the timing error generated according to the online time of the host computer, the frequency error compensation control subcircuit 2 is used to obtain the frequency compensation value that needs to be adjusted according to the interval time, the 15-bit asynchronous frequency divider 4 is used to generate a timing pulse and cooperate with the frequency error compensation control subcircuit 2 to perform frequency compensation, and the periodic interrupt controller 5 is used to generate an interrupt signal to the smoke detector MCU, and the smoke detector MCU performs interrupt service control on the RTC timing subcircuit 3. Therefore, the present invention can cooperate with the host computer of the smoke detector MCU to timely correct the RTC timing accuracy problem caused by temperature or crystal oscillator inherent error, etc., which can save the cost of frequency deviation-temperature curve measurement and non-volatile memory space, and has high calibration accuracy and reliability.

[0046] Preferably, see Figure 2, the smoke detector system includes an online host computer and a smoke detector, and the online host computer and the smoke detector are connected to each other through a communication line; the smoke detector includes an MCU, a communication port, a 32.758K crystal, an alarm output port and other peripheral components; the communication port, the crystal and the alarm output port are all electrically connected to the MCU. In this embodiment, the MCU receives the first time calibration command, and the MCU receives the online time of the host computer through the communication port. The frequency error detection subcircuit 1 in the RTC calibration circuit first detects the interval time of the 1S timing error, and then calculates the frequency compensation value that needs to be adjusted. After the frequency error compensation control subcircuit 2 performs frequency compensation, it performs a second detection of the interval time of the 1S timing error, and further corrects the frequency compensation value until the timing accuracy of the RTC timing subcircuit 3 reaches the preset ideal accuracy value.

[0047] Preferably, the frequency error detection subcircuit 1 includes a deviation timer unit and a deviation lookup table hardware unit; the deviation timer unit is electrically connected to the smoke detector MCU and the deviation lookup table hardware unit respectively, and the deviation lookup table hardware unit is electrically connected to the frequency error compensation control subcircuit.

[0048] Preferably, in this embodiment, the MCU software needs to cooperate with the online host computer to complete the frequency compensation value detection. At the start of the operation phase, if the smoke detector MCU receives the first time calibration command after a period of stable operation, it will update the RTC clock and record the calibration time as the starting point of the time interval. At this time, the clock error is 0. During the time interval period when no 1S timing error is generated, if the system time calibration command is received, the smoke detector MCU does not update the RTC internal time. Until it is detected that the MCU internal RTC clock and the online clock generate a 1S timing error, this time point is the end point of the previous stage of the calibration and also the starting point of the next calibration. At this time, the hardware circuit calculates the duration of the time interval that generates the 1S timing error, and obtains the target compensation value corresponding to the time interval, and gives it to the frequency error compensation control subcircuit to perform the frequency error compensation in the next stage, and update the RTC timing time.

[0049] Specifically, the deviation timer unit is measured in hours. When the smoke detector MCU receives the first time calibration command, the deviation timer unit is enabled and turned on. The system updates the RTC clock and records the calibration time as the starting point of the time interval. At this time, the clock error is 0. At the timing moment of the buffer of the RTC timing subcircuit 3, if the system does not detect that the RTC timing subcircuit 3 generates a 1S timing error after the next time calibration command, the deviation timer automatically operates (x+1). Among them, the timing error generated by the time interval (x+1) is less than 1S. Until the system detects that the RTC timing subcircuit 3 generates a 1S timing error after the next time calibration command, the deviation count value of the deviation timer unit is passed to the deviation hardware lookup table unit to obtain the corresponding frequency compensation value. At the same time, the deviation timer unit is cleared to continue to detect the timing of the time interval of the 1S timing error in the next stage. In this embodiment, the deviation hardware lookup table unit uses the value of the deviation timer when the + / -1S timing error is generated as an index, and the circuit hardware calculates the frequency compensation value through a preset corresponding relationship and gives it to the frequency error compensation control subcircuit.

[0050] Preferably, the frequency error compensation control subcircuit 2 includes a compensation parameter register unit and an error compensation processing unit; the compensation parameter register unit is electrically connected to the deviation lookup table hardware unit and the error compensation processing unit, and the error compensation processing unit is electrically connected to the 15-bit asynchronous frequency divider. In this embodiment, the compensation parameter register unit is used to register and obtain the frequency compensation value of the deviation lookup table hardware unit, and the error compensation processing unit is used to perform frequency adjustment according to the frequency compensation value.

[0051] Preferably, see Figure 2 The RTC timing subcircuit includes an APB bus interface, a second timing unit, a minute timing unit, an hour timing unit, a day timing unit, a week timing unit, a month timing unit, a year timing unit, a periodic interrupt control unit and an alarm interrupt controller; the second timing unit, the minute timing unit, the hour timing unit, the day timing unit, the week timing unit, the month timing unit and the year timing unit are electrically connected to the APB bus interface and the periodic interrupt controller respectively, and the minute timing unit, the hour timing unit and the week timing unit are electrically connected to the alarm interrupt controller respectively.

[0052] In another preferred embodiment, see Figure 4 The frequency error detection subcircuit 1 can be implemented by the software part of the smoke detector MCU or by the software part of the online host computer, and can also achieve the function of online error detection.

[0053] Embodiment 2

[0054] The present invention also discloses a calibration method, please refer to Figure 5 , including the RTC calibration circuit of the smoke detector MCU according to the first aspect, the calibration method includes:

[0055] S1, obtaining the first interval time that generates the timing error;

[0056] S2. Acquire a first frequency compensation value to be adjusted according to the first interval time;

[0057] S21, obtaining the time point a when the first time calibration command is received, and taking the time point a as the starting point of the first interval time;

[0058] S22, starting from the starting point a and counting in hours, each time a time calibration command is received, the timing number of the deviation timer unit is increased by 1;

[0059] S23, if the RTC timing subcircuit detects a timing error of 1S at the time point b when the Nth time calibration command is obtained, then the time point b is used as the end point of the first interval time;

[0060] S24, obtaining a difference c between the time point b and the time point a, and obtaining a compensation target value PPM according to the difference c; wherein the difference c is rounded;

[0061] Preferably, the obtaining of the difference c between the time point b and the time point a, and obtaining the compensation target value PPM according to the difference c comprises:

[0062]

[0063] Specifically, in this embodiment, the real-time clock of the smoke detector MCU of the present invention uses a 32.768KHz crystal oscillator clock for counting. The time point a of receiving the first time calibration command is obtained from the 32.768KHz crystal oscillator clock, and the time point a is used as the starting point of the first interval time; starting from the starting point a, the time count of the deviation timer unit is increased by 1 for each time a time calibration command is received; at the time point b of obtaining the Nth time calibration command, the RTC timing subcircuit detects a timing error of 1S, and the time point b is used as the end point of the first interval time at a timing error of 1S. The inherent deviation of the 32.768KHz crystal oscillator clock is 20PPM, and the temperature deviation is 80PPM, so the initial deviation = 20PPM + 80PPM = 100PPM. The timing error of 1S produces an error of about 100PPM = 1 / 10000S, and the accumulated 1S timing error takes a long time T1 = 1 / 100PPM = 10000S ~ = 2.78 hours. The online host computer takes 1 hour as the time interval of the time calibration command, and takes 2.78 hours = 3 hours as the first interval time of the cumulative 1S timing error, wherein 3 hours = 3*60*60 = 10800S, 10800S produces a 1S deviation, then the target compensation value = 1 / 10800*10 to the sixth power = 92.59PPM. It means that the digital circuit finds the target compensation value of 3 hours in a lookup table (hours as the unit) as 92.59PPM, and converts the target compensation value 92.59PPM into the corresponding first frequency compensation value CR according to the preset corresponding relationship, and performs the first calibration.

[0064] S25. Obtain a first frequency compensation value CR corresponding to the compensation target value PPM according to a preset corresponding relationship.

[0065] Preferably, obtaining the first frequency compensation value to be adjusted according to the first interval time includes:

[0066] Preferably, the formula of the preset corresponding relationship is:

[0067]

[0068] Wherein, the target compensation value represents the frequency error that needs to be compensated per unit time; 15 It is the conversion unit of the 15-bit asynchronous frequency divider to generate 1S timing pulse under the crystal oscillator clock of 32.768KHz. In this embodiment, the target compensation value PPM represents the frequency error that needs to be compensated within the 1S timing error, and in fact, the target compensation value PPM = (actual oscillation frequency - target frequency) / target frequency * 10 to the sixth power. It can be understood that, by substituting into the formula, is the number of clock cycles to be compensated. In this embodiment, 0001.00000B is the zero point adjustment number of the CR value, which is used to improve the accuracy of the calculation. After obtaining the number of clock cycles to be compensated, it is converted into a two's complement of a four-digit integer + a five-digit decimal that can be recognized by the frequency error compensation control circuit, and the compensable range is -272.6Pppm: +212.6ppm. The frequency error compensation control circuit compensates the corresponding number of clock cycles according to the two's complement of a four-digit integer + a five-digit decimal.

[0069] S3, performing a first calibration according to the first frequency compensation value;

[0070] Preferably, performing a first calibration according to the first frequency compensation value includes:

[0071] S31, obtaining a first compensation unit compensated per second under a crystal oscillator clock of 32.768KHz;

[0072] S32, expand the compensation period of the 32.768KHz crystal oscillator clock by 32 times;

[0073] S33, obtaining a second compensation unit for compensation per second after expanding the compensation period by 32 times according to the first compensation unit;

[0074] Preferably, the real-time clock of the smoke detector MCU uses a 32.768KHz crystal oscillator clock for counting.

[0075] Preferably, in this embodiment, since the real-time clock uses a 32.768KHz crystal oscillator clock for counting, if the accuracy per second is compensated, the error compensation can only be performed based on an integer cycle of 32.768KHz. The first compensation unit for compensation per second under the 32.768KHz crystal oscillator clock is (1 / 32768)*10 6 =30.5PPM, which cannot meet the high-precision requirements. The present invention expands the compensation period of the 32.768KHz crystal oscillator clock by 32 times, that is, according to the first compensation unit, the second compensation unit for compensation per second is obtained after the compensation period is expanded by 32 times, that is, 30.5PPM / 32=0.96PPM. Therefore, the minimum compensation unit of the present invention under the 32.768KHz crystal oscillator clock is 0.96PPM, that is, it takes 1 / 0.96PPM~=290 hours to generate a 1s error, with high compensation accuracy, accuracy and reliability.

[0076] S34, dividing the first frequency compensation value CR into an integer part and a decimal part;

[0077] S35. Perform a first calibration on the integer part and the decimal part in sequence according to the second compensation unit.

[0078] Preferably, the first frequency compensation value CR of the present invention is expressed in binary. For example, if the target compensation value in the preset corresponding relationship is -11.29 PPM, then the CR value substituted into the preset corresponding relationship is:

[0079]

[0080] Then, frequency error compensation is performed in the frequency error compensation control subcircuit according to the CR value expressed in binary. In a 32.768KHz crystal oscillator clock, the resonant frequency is 32768, that is, the unit time S=32768 clock cycles. The present invention expands the compensation period of the 32.768KHz crystal oscillator clock by 32 times, so the compensation period of the present invention is 32S=32*32768 clock cycles. The first frequency compensation value CR is divided into an integer part and a decimal part. The integer part and the decimal part are calibrated for the first time in turn according to the second compensation unit. That is, if the integer part is 1, then every second period of the 32S compensation period is compensated; if the integer part is 0 and the decimal part is 1, then the 0S-31S period of the 32S compensation period is selectively compensated according to the value of the decimal.

[0081] For example, when CR=0001.0000, CR=0001.0000 is the compensation zero point, and no compensation operation is required;

[0082] When CR=0001.0001, after subtracting the compensation zero point, CR=0000.0001, the integer part is 0, and the decimal part is 1, then 1 clock cycle is compensated in the first second cycle of the 32S compensation cycle, and the first second cycle is compensated to 32769 clock cycles, and the second to the thirty-second seconds are still 32768 clock cycles;

[0083] When CR=0001.0010, after subtracting the compensation zero point, CR=0000.0010, the integer part is 0, and the decimal part is 2. Then, 1 clock cycle is compensated in the first second cycle and the second second cycle of the 32S compensation cycle respectively. The first second cycle and the second second cycle are 32769 clock cycles after compensation respectively, and the third to the thirty-second seconds are still 32768 clock cycles;

[0084] When CR=0010.0010, after subtracting the compensation zero point, CR=0001.0010, the integer part is 1, and the decimal part is 2. First, 1 clock cycle is compensated for each second period of the 32S compensation period, and then 1 clock cycle is compensated for the first second period and the second second period of the 32S compensation period respectively. After compensation, the first second period and the second second period are 32770 clock cycles, and the third second period to the thirty-second second period are 32769 clock cycles.

[0085] When CR=0011.0010, after subtracting the compensation zero point, CR=0010.0010, the integer part is 2, and the decimal part is 2. First, 2 clock cycles are compensated for each second period of the 32S compensation period, and then 2 clock cycles are compensated for the first second period and the second second period of the 32S compensation period respectively. After compensation, the first second period and the second second period are 32772 clock cycles, and the third second period to the thirty-second second period are 32770 clock cycles.

[0086] S4, comparing the calibration result of the first calibration with a preset ideal accuracy;

[0087] S5. If the preset ideal accuracy is not reached, obtaining a second interval time that generates a timing error;

[0088] S6. Obtaining a second frequency compensation value that needs to be adjusted according to the second interval time;

[0089] S7. Perform a second calibration according to the second compensation value.

[0090] Preferably, in this embodiment, if the preset ideal accuracy is not achieved after the first calibration, the second interval time for generating the timing error is obtained for the second calibration. The duration of the 1S deviation generated in the second calibration T2 time period of the 32.768KHz crystal oscillator clock is 200 hours, and the target compensation value corresponding to 200 hours is found to be 1.45PPM through the lookup table, and the target compensation value 1.45PPM is converted into the corresponding first frequency compensation value CR according to the preset corresponding relationship, and the second calibration is performed according to the first frequency compensation value CR. The frequency error compensation control circuit of this embodiment can realize 0.96ppm high-precision clock error compensation, and it takes 1 / 0.96ppm~=290 hours to generate a 1s error. Therefore, until the duration of the 1S deviation is greater than 290 hours, there is no need to calculate a new error compensation value, until the stage error compensation duration caused by ambient temperature or external factors is less than 289 hours, then the error compensation value of the next calibration stage is recalculated. Therefore, the compensation accuracy of the present invention is high.

[0091] In summary, the RTC calibration circuit of the smoke detector MCU provided by the present invention includes the frequency error detection subcircuit 1 for detecting the interval time of the timing error according to the online time of the host computer, the frequency error compensation control subcircuit 2 for obtaining the frequency compensation value to be adjusted according to the interval time, the 15-bit asynchronous frequency divider 4 for generating timing pulses and cooperating with the frequency error compensation control subcircuit 2 for frequency compensation, the periodic interrupt controller 5 for generating an interrupt signal to the smoke detector MCU, and the smoke detector MCU performs interrupt service control on the RTC timing subcircuit 3. Therefore, the present invention calculates based on an accurate algorithm and cooperates with the online time of the host computer of the smoke detector MCU to timely correct the RTC timing accuracy problem caused by temperature or crystal oscillator inherent error, etc., which can save the cost of measuring the frequency deviation-temperature curve and save the non-volatile memory space, and has high calibration accuracy and high reliability.

[0092] The RTC calibration circuit of the smoke detector MCU provided by the present invention is described in detail above. The principle and implementation mode of the present invention are described in this article by using specific examples. The description of the above embodiments is only used to help understand the method and core idea of ​​the present invention. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation mode and application scope. In summary, the content of this specification is only the implementation mode of the present invention, and does not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the content of the present invention specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present invention. It should not be understood as a limitation of the present invention.

Claims

1. An RTC calibration circuit for a smoke detector MCU, characterized in that: It includes a frequency error detection subcircuit, a frequency error compensation control subcircuit, an RTC timing subcircuit, a 15-bit asynchronous frequency divider and a periodic interrupt controller; the frequency error detection subcircuit is electrically connected to the frequency error compensation control subcircuit, the frequency error compensation control subcircuit is electrically connected to the 15-bit asynchronous frequency divider, the 15-bit asynchronous frequency divider is electrically connected to the periodic interrupt controller and the RTC timing subcircuit respectively, and the periodic interrupt controller is electrically connected to the RTC timing subcircuit; the circuit also includes a deviation timer unit and a deviation lookup table hardware unit; the deviation timer unit is electrically connected to the smoke detector MCU and the deviation lookup table hardware unit respectively, and the deviation lookup table hardware unit is electrically connected to the frequency error compensation control subcircuit; the frequency error compensation control subcircuit includes compensation parameters The RTC timing subcircuit comprises an APB bus interface, a second timing unit, a minute timing unit, an hour timing unit, a day timing unit, a week timing unit, a month timing unit, a year timing unit, a periodic interrupt control unit and an alarm interrupt controller; the second timing unit, the minute timing unit, the hour timing unit, the day timing unit, the week timing unit, the month timing unit and the year timing unit are electrically connected to the APB bus interface and the periodic interrupt controller, and the minute timing unit, the hour timing unit and the week timing unit are electrically connected to the alarm interrupt controller.

2. A method for calibrating the RTC of a smoke detector MCU, according to the RTC calibration circuit of the smoke detector MCU of claim 1, characterized in that: The calibration method comprises: Get the first interval time that produces the timing error; Acquire a first frequency compensation value that needs to be adjusted according to the first interval time; Performing a first calibration according to the first frequency compensation value; Comparing the calibration result of the first calibration with a preset ideal accuracy; If the preset ideal accuracy is not reached, obtaining a second interval time that generates a timing error; Obtaining a second frequency compensation value that needs to be adjusted according to the second interval time; A second calibration is performed according to the second frequency compensation value.

3. The RTC calibration method of the smoke detector MCU according to claim 2, characterized in that: The real-time clock of the smoke detector MCU uses a 32.768KHz crystal clock for counting.

4. The RTC calibration method of the smoke detector MCU according to claim 3, characterized in that: The step of obtaining the first frequency compensation value to be adjusted according to the first interval time includes: Obtaining the time point a when the first time calibration command is received, and taking the time point a as the starting point of the first interval time; Starting from the time point a, the counting is performed in hours, and the timing number of the deviation timer unit is increased by 1 each time a time calibration command is received; If the RTC timing subcircuit detects a timing error of 1S at the time point b when the Nth time calibration command is obtained, the time point b is used as the end point of the first interval time; Obtaining a difference c between the time point b and the time point a, and obtaining a compensation target value PPM according to the difference c; wherein the difference c is rounded; The first frequency compensation value CR corresponding to the compensation target value PPM is obtained according to the preset corresponding relationship.

5. The RTC calibration method of the smoke detector MCU according to claim 4, characterized in that: The formula of the preset corresponding relationship is: Wherein, the target compensation value represents the frequency error that needs to be compensated per unit time; It is the conversion unit of the 15-bit asynchronous frequency divider to generate a 1S timing pulse under the crystal clock of 32.768KHz, and 0001.00000B is the zero point adjustment number of the CR value.

6. The RTC calibration method of the smoke detector MCU according to claim 5, characterized in that: The performing a first calibration according to the first frequency compensation value comprises: Get the first compensation unit per second at the 32.768KHz crystal clock; Expand the compensation period of the 32.768KHz crystal oscillator clock by 32 times; Obtain a second compensation unit for compensation per second after expanding the compensation period by 32 times according to the first compensation unit; Dividing the first frequency compensation value CR into an integer part and a decimal part; The integer part and the decimal part are calibrated for the first time in sequence according to the second compensation unit.

7. The RTC calibration method of the smoke detector MCU according to claim 6, characterized in that: The obtaining of the difference c between the time point b and the time point a, and obtaining the compensation target value PPM according to the difference c comprises: 。

Citation Information

Patent Citations

  • RTC calibration circuit of smoke detector MCU

    CN212364801U