CN109283967A - A kind of micro-control unit MCU clock correcting method and relevant device - Google Patents

A kind of micro-control unit MCU clock correcting method and relevant device Download PDF

Info

Publication number
CN109283967A
CN109283967A CN201811384477.9A CN201811384477A CN109283967A CN 109283967 A CN109283967 A CN 109283967A CN 201811384477 A CN201811384477 A CN 201811384477A CN 109283967 A CN109283967 A CN 109283967A
Authority
CN
China
Prior art keywords
clock
value
frequency
mcu
mcu clock
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
Application number
CN201811384477.9A
Other languages
Chinese (zh)
Other versions
CN109283967B (en
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 CHIPSBANK TECHNOLOGY Co Ltd
Original Assignee
SHENZHEN CHIPSBANK TECHNOLOGY 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 CHIPSBANK TECHNOLOGY Co Ltd filed Critical SHENZHEN CHIPSBANK TECHNOLOGY Co Ltd
Priority to CN201811384477.9A priority Critical patent/CN109283967B/en
Publication of CN109283967A publication Critical patent/CN109283967A/en
Application granted granted Critical
Publication of CN109283967B publication Critical patent/CN109283967B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/04Generating or distributing clock signals or signals derived directly therefrom
    • G06F1/08Clock generators with changeable or programmable clock frequency
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/04Generating or distributing clock signals or signals derived directly therefrom
    • G06F1/14Time 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 embodiment of the present application provides a kind of micro-control unit MCU clock correcting method and relevant device, for improving the precision and stability of MCU clock.The embodiment of the present application method includes: to determine target time section using a reference source clock;The counting number in the target time section is calculated using the frequency of MCU clock, is denoted as the first numerical value;The counting number in the target time section is calculated using the frequency of a reference source clock, is denoted as second value;The frequency of the MCU clock is adjusted according to first numerical value and the second value.Therefore, the frequency of the MCU clock is adjusted by first numerical value and the second value, i.e., MCU clock is calibrated using the reference clock that a reference source clock is used as calibration MCU clock, the precision and stability of MCU clock can be improved.

Description

A kind of micro-control unit MCU clock correcting method and relevant device
Technical field
This application involves electronic information fields more particularly to a kind of micro-control unit MCU clock correcting method and correlation to set It is standby.
Background technique
Micro-control unit (Microcontroller Unit;MCU), also known as one chip microcomputer or single-chip microcontroller are The frequency of central processing unit and specification are done appropriate reduction, and by memory, counter, USB, A/D conversion, UART, PLC, DMA etc. Perimeter interface or even LCD driving circuit all integrate the computer for forming chip-scale on a single chip, are different applied fields Various combination control is done in conjunction.
In MCU, clock is important a composition part, is the equal of the heart of MCU, the precision of clock can be direct Influence function and the stability etc. of product.Such as: when MCU and other equipment carry out UART communication, the precision of clock can be direct Influence the correct transmitting-receiving of communication data.
However, the internal clocking that actual conditions are MCU can generate certain temperature drift with the variation of environment temperature, temperature drift Cause the error of clock that may be up to ± 20% even more greatly, when this error precision generated by temperature drift is far beyond MCU The permitted normal range (NR) of clock error causes product function to occur abnormal.
Apply for content
The embodiment of the present application provides a kind of micro-control unit MCU clock correcting method and relevant device, for improving MCU The precision and stability of clock.
The embodiment of the present application first aspect provides a kind of micro-control unit MCU clock correcting method, comprising:
Target time section is determined using a reference source clock;
The counting number in the target time section is calculated using the frequency of MCU clock, is denoted as the first numerical value;
The counting number in the target time section is calculated using the frequency of a reference source clock, is denoted as the second number Value;
The frequency of the MCU clock is adjusted according to first numerical value and the second value.
Optionally, the frequency for adjusting the MCU clock according to first numerical value and the second value includes:
If first numerical value is greater than the second value, the frequency of the MCU clock is reduced;
If first numerical value is less than the second value, increase the frequency of the MCU clock.
Optionally, the frequency using MCU clock calculates the counting number in the target time section, is denoted as first Numerical value specifically includes:
Obtain the maximum value and minimum value in the register effective range of the MCU clock;
Intermediate value is determined using dichotomy according to the maximum value and minimum value;
The register is set according to the intermediate value, obtains the frequency of the MCU clock;
The counting number in the target time section is calculated using the frequency of MCU clock, is denoted as the first numerical value.
Optionally, the frequency for adjusting the MCU clock according to first numerical value and the second value is specifically wrapped It includes:
Obtain calibration cycle and calibration error;
In the calibration cycle, it is described to judge whether the numerical error of first numerical value and the second value meets Standard error;
If it is not, the register of the MCU clock is then adjusted, to adjust the frequency of the MCU clock.
The embodiment of the present application second aspect provides a kind of micro-control unit MCU clock alignment system, comprising:
Determination unit, for determining target time section using a reference source clock;
First computing unit, for using the frequency of MCU clock to calculate the counting number in the target time section, note For the first numerical value;
Second computing unit, for using the frequency of a reference source clock to calculate the counting in the target time section Number is denoted as second value;
Adjustment unit, for adjusting the frequency of the MCU clock according to first numerical value and the second value.
Optionally, the adjustment unit is specifically used for:
If first numerical value is greater than the second value, the frequency of the MCU clock is reduced;
If first numerical value is less than the second value, increase the frequency of the MCU clock.
Optionally, first computing unit is specifically used for:
Obtain the maximum value and minimum value in the register effective range of the MCU clock;
Intermediate value is determined using dichotomy according to the maximum value and minimum value;
The register is set according to the intermediate value, obtains the frequency of the MCU clock;
The counting number in the target time section is calculated using the frequency of MCU clock, is denoted as the first numerical value.
Optionally, second computing unit is specifically used for:
Obtain calibration cycle and calibration error;
In the calibration cycle, it is described to judge whether the numerical error of first numerical value and the second value meets Standard error;
If it is not, the register of the MCU clock is then adjusted, to adjust the frequency of the MCU clock.
The embodiment of the present application third aspect provides a kind of computer installation, comprising:
Processor, memory, input-output equipment and bus;
The processor, memory, input-output equipment are connected with the bus respectively;
The processor is for executing method as in the foregoing embodiment.
The embodiment of the present application fourth aspect provides a kind of computer readable storage medium, is stored thereon with computer journey Sequence, it is characterised in that: realize when the computer program is executed by processor such as any one of previous embodiment the method Step.
As can be seen from the above technical solutions, the embodiment of the present application has the advantage that in the present embodiment, utilizes a reference source Clock determines target time section;The counting number in the target time section is calculated using the frequency of MCU clock, is denoted as first Numerical value;The counting number in the target time section is calculated using the frequency of a reference source clock, is denoted as second value;Root The frequency of the MCU clock is adjusted according to first numerical value and the second value.Therefore, by first numerical value and described Second value adjusts the frequency of the MCU clock, i.e., the reference clock pair of calibration MCU clock is used as using a reference source clock MCU clock is calibrated, and the precision and stability of MCU clock can be improved.
Detailed description of the invention
Fig. 1 is an a kind of schematic diagram of micro-control unit MCU clock correcting method embodiment in the embodiment of the present application;
Fig. 2 is a kind of another schematic diagram of micro-control unit MCU clock correcting method embodiment in the embodiment of the present application;
Fig. 3 is a kind of another schematic diagram of micro-control unit MCU clock correcting method embodiment in the embodiment of the present application;
Fig. 4 is a kind of another schematic diagram of micro-control unit MCU clock correcting method embodiment in the embodiment of the present application;
Fig. 5 is an a kind of schematic diagram of micro-control unit MCU clock alignment system embodiment in the embodiment of the present application;
Fig. 6 is an a kind of schematic diagram of computer installation embodiment in the embodiment of the present application.
Specific embodiment
The embodiment of the present application provides a kind of micro-control unit MCU clock correcting method and relevant device, for improving MCU The precision and stability of clock.
In order to make those skilled in the art more fully understand application scheme, below in conjunction in the embodiment of the present application Attached drawing, the technical scheme in the embodiment of the application is clearly and completely described, it is clear that described embodiment is only The embodiment of the application a part, instead of all the embodiments.Based on the embodiment in the application, ordinary skill people Member's every other embodiment obtained without making creative work, all should belong to the model of the application protection It encloses.
The description and claims of this application and term " first ", " second ", " third ", " in above-mentioned attached drawing Four " etc. be to be used to distinguish similar objects, without being used to describe a particular order or precedence order.It should be understood that using in this way Data be interchangeable under appropriate circumstances, so that the embodiments described herein can be in addition to illustrating herein or describing Sequence other than appearance is implemented.In addition, term " includes " and " having " and their any deformation, it is intended that covering is non-exclusive Include, for example, the process, method, system, product or equipment for containing a series of steps or units are not necessarily limited to clearly arrange Those of out step or unit, but may include be not clearly listed or it is solid for these process, methods, product or equipment The other step or units having.
In order to make it easy to understand, the detailed process in the embodiment of the present application is described below, referring to Fig. 1, the application A kind of one embodiment of micro-control unit MCU clock correcting method includes: in embodiment
101, target time section is determined using a reference source clock;
, can be by terminal device in the present embodiment, such as use the end product of MCU, or use computer, server Etc. executing subject of the terminals connection MCU as the embodiment of the present application, execution determine target time section using a reference source clock.
A reference source clock is intended for the reference clock of calibration MCU internal clocking, therefore a reference source clock has to completely Sufficient following two requirement: the temperature drift under precision height, full operating temperature is small.The reference clock can be external real-time clock (RTC, Real_Time Clock) (such as 32.768khz or 100khz etc.), it is also possible to the low-speed clock inside MCU (if in MCU When there are precision height and temperature drift small low-speed clock in portion).Specifically, using clock reference source clock as the clock of timer T0 One correct time section of timing is carried out as target time section (10ms, 100ms or 1s or other time) in source.
102, the counting number in the target time section is calculated using the frequency of MCU clock, is denoted as the first numerical value;
In the present embodiment, terminal calculates the counting number in the target time section using the frequency of MCU clock, is denoted as First numerical value.
Specifically, select MCU clock as the clock source of timer T1, to facilitate in statistics a period of time T1 to current The counting number of MCU clock counts, in a step 102 in the timer T0 timed period timer T1 in current MCU The counting number curCntVal of portion's clock, is denoted as the first numerical value.
103, the counting number in the target time section is calculated using the frequency of a reference source clock, is denoted as second Numerical value;
In the present embodiment, terminal calculates the counting in the target time section using the frequency of a reference source clock Number, is denoted as second value.
Specifically, in a reference source clock timer T0 timed period, use of the MCU timer T1 to MCU clock The counting number VREFCNTVAL of the frequency of a reference source clock, is denoted as second value.
104, the frequency of the MCU clock is adjusted according to first numerical value and the second value.
In the present embodiment, when terminal is adjusted MCU with specific reference to the numerical values recited relationship of the first numerical value and second value The frequency of clock.
Specifically, the frequency of MCU clock can be adjusted by the clock triming register of MCU.Wherein, It is vertical to compare current MCU clock frequency count value the first numerical value curCntVal and MCU clock object frequency count second The size of VREFCNTVAL, to determine the adjustment direction of clock triming register.
In the present embodiment, target time section is determined using a reference source clock;It is calculated using the frequency of MCU clock in the mesh The counting number in the period is marked, the first numerical value is denoted as;It is calculated using the frequency of a reference source clock in the object time Counting number in section, is denoted as second value;The frequency of the MCU clock is adjusted according to first numerical value and the second value Rate.Therefore, the frequency of the MCU clock is adjusted by first numerical value and the second value, that is, uses a reference source clock The reference clock for being used as calibration MCU clock calibrates MCU clock, and the precision and stability of MCU clock can be improved.
In the embodiment of the present application, step 104 adjusts the MCU clock according to first numerical value and the second value There are many modes of frequency, specifically can be according to the numerical relation between the first numerical value and second value come when carrying out MCU The adjustment of clock frequency.Below referring to Fig. 2, based on embodiment described in Fig. 1, when a kind of micro-control unit MCU of the embodiment of the present application In another embodiment of clock calibration method, step 104 be can specifically include:
If 201, first numerical value is greater than the second value, the frequency of the MCU clock is reduced;
In the present embodiment, if terminal determines that the first numerical value is greater than second value, illustrate current MCU clock frequency ratio benchmark The target frequency of source clock greatly, will need at this time to reduce the value of (or increase) clock triming register to reduce in current MCU Portion's clock frequency.
If 202, first numerical value is less than the second value, increase the frequency of the MCU clock.
In the present embodiment, if terminal determines that the first numerical value is less than second value, illustrate current MCU clock frequency ratio benchmark The target frequency of source clock wants small, needs to increase the value of (or reduction) clock triming register at this time to improve in current MCU Portion's clock frequency.
In addition, in the present embodiment, if the first numerical value is equal to second value, illustrating current MCU internal clock frequencies etc. In the target frequency of a reference source clock, the value of corresponding clock triming register is a reference source clock object frequency at this time Corresponding triming value, does not need to change.
In the embodiment of the present application, since day and night temperature is big, very big etc. factors objective reality of the north and south region temperature difference, and produce The power-on time point of product with power on region be it is uncertain, therefore environment temperature of the MCU when just powering on be it is uncertain, exactly Environment temperature is uncertain so that MCU internal clocking temperature drift is not known yet when powering on when due to powering on, in fact it could happen that when just powering on The very big situation of MCU internal clocking temperature drift;Therefore the present invention when MCU is powered on by using " dichotomy " mechanism come in MCU Portion's clock is calibrated, and MCU internal clocking quickly can be calibrated to target frequency, and " dichotomy can with " be utilized to obtain With the optimal matching frequency point of target frequency.Below referring to Fig. 3, based on embodiment described in Fig. 1 or Fig. 2, the embodiment of the present application one In another embodiment of kind micro-control unit MCU clock correcting method, step 102 be can specifically include:
301, the maximum value and minimum value in the register effective range of the MCU clock are obtained;
In the present embodiment, terminal obtains the maximum value and minimum value in the register effective range of the MCU clock.
Specifically, the acquisition process in this step can be acquired by way of receiving third party's terminal and sending, It can be acquired by inquiring the datasheet of MCU, can also be that other way acquires, herein without limitation.To look into For the datasheet for asking MCU, it can determine that the valid value range of the clock triming register of the MCU is [a, b], wherein A is the minimum value of clock triming register virtual value, and b is the maximum value of clock triming register virtual value.
302, intermediate value is determined using dichotomy according to the maximum value and minimum value;
In the present embodiment, terminal determines intermediate value using dichotomy according to the maximum value and minimum value.
303, the register is arranged according to the intermediate value, obtains the frequency of the MCU clock;
In the present embodiment, the register is arranged according to the intermediate value in terminal, obtains the frequency of the MCU clock.
304, the counting number in the target time section is calculated using the frequency of MCU clock, is denoted as the first numerical value.
In the present embodiment, the counting number in the target time section is calculated using the frequency of MCU clock, is denoted as first Numerical value.
Specifically, the process of step 302-- step 304 can recycle execution, i.e., found out most using the mode of dichotomy Excellent solution.Firstly, setting 3 variables minTrim, midTrim, maxTrim;Wherein minTrim=a, maxTrim=b, MidTrim=(maxTrim+minTrim)/2=(a+b)/2;By the clock Triming register of the value write-in MCU of midTrim In, it then substitutes into Fig. 1 embodiment or Fig. 2 embodiment, by calibration, obtains counting of the timer T1 to current MCU clock Number curCntVal;Compare the size of the counting number VREFCNTVAL of curCntVal and a reference source clock object frequency simultaneously; If curCntVal > VREFCNTVAL, then illustrate that the target frequency of current MCU internal clock frequencies ratio MCU internal clocking is wanted Greatly, it needs to update the range of clock Triming register as follows: minTrim=a, maxTrim=midTrim=(a+b)/ 2, midTrim=(maxTrim+minTrim)/2=(a+ (a+b)/2)/2;If curCntVal < VREFCNTVAL then illustrates The target frequency of current MCU internal clock frequencies ratio MCU internal clocking is small, needs the range of clock Triming register It updates as follows: minTrim=midTrim=(a+b)/2, maxTrim=b, midTrim=(maxTrim+minTrim)/2= ((a+b)/2+b)/2;After the value for having redefined minTrim, midTrim, maxTrim, by midTrim value write clock In Triming register, the movement of step 101 in embodiment described in Fig. 1 to step 104 is repeated again, until meeting item Until part midTrim-minTrim=maxTrim-midTrim=1, then illustrate that " dichotomy " clock alignment mechanism has been completed, Meanwhile clock frequency corresponding to the value midTrim of final clock Triming register is just closest to a reference source clock Target frequency.
In the present embodiment, when using " dichotomy " alignment mechanism, the period described in step 101 can be periodically smaller, It is ms grades (such as 10ms, 15ms etc.) general, therefore the school to MCU clock can be completed in the very short time when MCU is powered on Quasi- movement powers on the delay very little of rear function to MCU (usually can only be delayed 100ms or so).
In the embodiment of the present application, in the course of work of MCU after the power-up, operating ambient temperature can be over time (for example diurnal temperature is different) or load change and change, but the variation of this temperature is typically all gradual change type, corresponding Temperature drift caused by MCU internal clocking is also gradual change, MCU internal clock frequencies will not be made to mutate, but can make MCU internal clock frequencies generate cumulative errors effect with temperature gradients, such as calibrate not in time, may result in very big mistake Poor result occurs, therefore in the MCU course of work, it is also necessary to calibration actions are timed to its internal clocking, and it is unsuitable at this time It is calibrated using " dichotomy " and (clock of MCU just at work can be made to generate biggish fluctuation), it should use " linear approximation The mode of method " fine tuning calibrates MCU internal clock frequencies.Below referring to Fig. 4, based on embodiment described in Fig. 1, Fig. 2 or Fig. 3, In a kind of another embodiment of micro-control unit MCU clock correcting method of the embodiment of the present application, step 103 specifically be can wrap It includes:
401, calibration cycle and calibration error are obtained;
In the present embodiment, terminal obtains calibration cycle and calibration error.
Specifically, the acquisition process in this step can be acquired by way of receiving third party's terminal and sending, Signal acquisition can be received by the input-output equipment of terminal to obtain, can also be that other way acquires, do not do herein It limits.
In addition, for calibration cycle, due in the MCU course of work, the variation of temperature is usually gradual change and slower, Therefore 1min or 10min even more long time period too frequently need not be typically chosen to the calibration cycle of MCU internal clock frequencies Just carry out primary calibration, specific calibration cycle is also related with variation speed of the MCU internal clock frequencies to temperature, if temperature Internal clock frequencies are influenced greatly, then calibration cycle will be arranged shorter, if temperature is small on internal clock frequencies influence, calibrate Period, settable length was a little.For calibration error, the difference of actual clock frequency and benchmark source clock frequency after referring to calibration. Typically, since there are the factors such as the adjusting step sizes of counting error, MCU clock frequency itself to make the clock after calibration Frequency can not necessarily be equal to benchmark source clock frequency, and in this case, MCU internal clock frequencies fluctuate back and forth in order to prevent, answer This sets calibration error in a certain range (such as ± 1% or ± 2% etc.), as long as the clock frequency error after calibration is being permitted Perhaps within calibration error, then it is assumed that calibrate successfully.
402, in the calibration cycle, judge whether the numerical error of first numerical value and the second value meets The standard error;
In the present embodiment, in the calibration cycle that step 401 is determined, first numerical value and second number are judged Whether the numerical error of value meets the standard error that step 401 is determined, if so, 404 are thened follow the steps, if it is not, then executing Step 403.
403, if it is not, then adjusting the register of the MCU clock, to adjust the frequency of the MCU clock.
In the present embodiment, when terminal determination, in the calibration cycle that step 401 is determined, first numerical value is judged When being unsatisfactory for the standard error that step 401 is determined with the numerical error of the second value, then the MCU clock is adjusted Register, to adjust the frequency of the MCU clock.
404, if so, executing other operations.
In the present embodiment, when terminal determination, in the calibration cycle that step 401 is determined, first numerical value is judged When meeting the standard error that step 401 is determined with the numerical error of the second value, then terminal executes other operations, example As continued to execute step 401-404 circulation execution in calibration cycle, it is also possible to not execute movement, can also be other behaviour Make, herein without limitation.
Specifically, in step 403 to step 404, the example to execute, being embodied below by one can be integrated Son is introduced.Similar to the Regulation mechanism in embodiment described in Fig. 1 to Fig. 3, when obtaining MCU timer T1 to current MCU The counting number curCntVal of clock, while comparing the counting number of the target frequency of curCntVal and a reference source clock The size of VREFCNTVAL.By calibration error percentage identified in step 401 (△ is 1% or 2% etc.), correspondence is calculated Counting error △ CNTVAL=VREFCNTVAL* △;If (curCntVal-VREFCNTVAL) > △ CNTVAL, then illustrate Current MCU clock frequency is bigger than normal, needs the value -1 of clock Triming register;(if VREFCNTVAL-curCntVal) > △ CNTVAL then illustrates that current MCU clock frequency is bigger than normal, needs the value+1 of clock Triming register;If | CurCntVal-VREFCNTVAL | < △ CNTVAL then illustrates current MCU clock frequency in the permitted model of target clock frequency In enclosing, without adjusting the value of clock Triming register.After this, it after having updated clock Triming register value, repeats Step 401 is executed to step 404, until shutdown terminates.
The embodiment of the present application is described from the angle of method above, below from the angle of virtual bench to the application Embodiment is described, referring to Fig. 5, in the embodiment of the present application, an a kind of reality of micro-control unit MCU clock alignment system Applying example includes:
Determination unit 501, for determining target time section using a reference source clock;
First computing unit 502, for using the frequency of MCU clock to calculate the counting in the target time section Number, is denoted as the first numerical value;
Second computing unit 503, for using the frequency of a reference source clock to calculate in the target time section Number is counted, second value is denoted as;
Adjustment unit 504, for adjusting the frequency of the MCU clock according to first numerical value and the second value.
In the present embodiment, determination unit 501, for determining target time section using a reference source clock;First computing unit 502, for using the frequency of MCU clock to calculate the counting number in the target time section, it is denoted as the first numerical value;Second meter Unit 503 is calculated, for using the frequency of a reference source clock to calculate counting number in the target time section, is denoted as the Two numerical value;Adjustment unit 504, for adjusting the frequency of the MCU clock according to first numerical value and the second value.Cause This, the frequency of the MCU clock is adjusted by first numerical value and the second value, i.e., is used to make using a reference source clock MCU clock is calibrated to calibrate the reference clock of MCU clock, the precision and stability of MCU clock can be improved.
As a preferred embodiment, adjustment unit 504 is specifically used for:
If first numerical value is greater than the second value, the frequency of the MCU clock is reduced;
If first numerical value is less than the second value, increase the frequency of the MCU clock.
As a preferred embodiment, the first computing unit 502 is specifically used for:
Obtain the maximum value and minimum value in the register effective range of the MCU clock;
Intermediate value is determined using dichotomy according to the maximum value and minimum value;
The register is set according to the intermediate value, obtains the frequency of the MCU clock;
The counting number in the target time section is calculated using the frequency of MCU clock, is denoted as the first numerical value.
As a preferred embodiment, the second computing unit 503 is specifically used for:
Obtain calibration cycle and calibration error;
In the calibration cycle, it is described to judge whether the numerical error of first numerical value and the second value meets Standard error;
If it is not, the register of the MCU clock is then adjusted, to adjust the frequency of the MCU clock.
Micro-control unit MCU clock alignment system a kind of in the embodiment of the present application is carried out from modular device above Description, below hardware device the computer installation in the embodiment of the present application is described, referring to Fig. 6, the embodiment of the present application One specific embodiment of middle computer installation includes:
The device 600 can generate bigger difference because configuration or performance are different, may include one or more Central processing unit (central processing units, CPU) 601 (for example, one or more processors) and storage Device 605 is stored with one or more application program or data in the memory 605.
Wherein, memory 605 can be volatile storage or persistent storage.The program for being stored in memory 605 can wrap One or more modules are included, each module may include to the series of instructions operation in server.Further, in Central processor 601 can be set to communicate with memory 605, and a series of fingers in memory 605 are executed on intelligent terminal 600 Enable operation.
The device 600 can also include one or more power supplys 602, one or more wired or wireless networks Interface 603, one or more input/output interfaces 604, and/or, one or more operating systems, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM etc..
Processor 601 is specifically used for executing following steps:
Target time section is determined using a reference source clock;
The counting number in the target time section is calculated using the frequency of MCU clock, is denoted as the first numerical value;
The counting number in the target time section is calculated using the frequency of a reference source clock, is denoted as the second number Value;
The frequency of the MCU clock is adjusted according to first numerical value and the second value.
It is described that the MCU clock is adjusted according to first numerical value and the second value as a preferred embodiment Frequency includes:
If first numerical value is greater than the second value, the frequency of the MCU clock is reduced;
If first numerical value is less than the second value, increase the frequency of the MCU clock.
As a preferred embodiment, the frequency using MCU clock calculates the counting in the target time section Number, is denoted as the first numerical value and specifically includes:
Obtain the maximum value and minimum value in the register effective range of the MCU clock;
Intermediate value is determined using dichotomy according to the maximum value and minimum value;
The register is set according to the intermediate value, obtains the frequency of the MCU clock;
The counting number in the target time section is calculated using the frequency of MCU clock, is denoted as the first numerical value.
It is described that the MCU clock is adjusted according to first numerical value and the second value as a preferred embodiment Frequency specifically includes:
Obtain calibration cycle and calibration error;
In the calibration cycle, it is described to judge whether the numerical error of first numerical value and the second value meets Standard error;
If it is not, the register of the MCU clock is then adjusted, to adjust the frequency of the MCU clock.
It is understood that the size of the serial number of above steps is not meant in the various embodiments of the application Execution sequence it is successive, the execution of each step sequence should be determined by its function and internal logic, without coping with the embodiment of the present application Implementation process constitute any restriction.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description, The specific work process of device and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In several embodiments provided herein, it should be understood that disclosed system, device and method can be with It realizes by another way.For example, the apparatus embodiments described above are merely exemplary, for example, the unit It divides, only a kind of logical function partition, there may be another division manner in actual implementation, such as multiple units or components It can be combined or can be integrated into another system, or some features can be ignored or not executed.Another point, it is shown or The mutual coupling, direct-coupling or communication connection discussed can be through some interfaces, the indirect coupling of device or unit It closes or communicates to connect, can be electrical property, mechanical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme 's.
It, can also be in addition, each functional unit in each embodiment of the application can integrate in one processing unit It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list Member both can take the form of hardware realization, can also realize in the form of software functional units.
If the integrated unit is realized in the form of SFU software functional unit and sells or use as independent product When, it can store in a computer readable storage medium.Based on this understanding, the technical solution of the application is substantially The all or part of the part that contributes to existing technology or the technical solution can be in the form of software products in other words It embodies, which is stored in a storage medium, including some instructions are used so that a computer Equipment (can be personal computer, server or the network equipment etc.) executes the complete of each embodiment the method for the application Portion or part steps.And storage medium above-mentioned includes: USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic or disk etc. are various can store journey The medium of sequence code.
The above, above embodiments are only to illustrate the technical solution of the application, rather than its limitations;Although referring to before Embodiment is stated the application is described in detail, those skilled in the art should understand that: it still can be to preceding Technical solution documented by each embodiment is stated to modify or equivalent replacement of some of the technical features;And these It modifies or replaces, the spirit and scope of each embodiment technical solution of the application that it does not separate the essence of the corresponding technical solution.

Claims (10)

1. a kind of micro-control unit MCU clock correcting method characterized by comprising
Target time section is determined using a reference source clock;
The counting number in the target time section is calculated using the frequency of MCU clock, is denoted as the first numerical value;
The counting number in the target time section is calculated using the frequency of a reference source clock, is denoted as second value;
The frequency of the MCU clock is adjusted according to first numerical value and the second value.
2. the method according to claim 1, wherein described according to first numerical value and the second value tune The frequency of the whole MCU clock includes:
If first numerical value is greater than the second value, the frequency of the MCU clock is reduced;
If first numerical value is less than the second value, increase the frequency of the MCU clock.
3. method according to claim 1 or 2, which is characterized in that the frequency using MCU clock is calculated in the mesh The counting number in the period is marked, the first numerical value is denoted as and specifically includes:
Obtain the maximum value and minimum value in the register effective range of the MCU clock;
Intermediate value is determined using dichotomy according to the maximum value and minimum value;
The register is set according to the intermediate value, obtains the frequency of the MCU clock;
The counting number in the target time section is calculated using the frequency of MCU clock, is denoted as the first numerical value.
4. method according to claim 1 or 2, which is characterized in that described to be counted according to first numerical value with described second The frequency that value adjusts the MCU clock specifically includes:
Obtain calibration cycle and calibration error;
In the calibration cycle, judge whether the numerical error of first numerical value and the second value meets the standard Error;
If it is not, the register of the MCU clock is then adjusted, to adjust the frequency of the MCU clock.
5. a kind of micro-control unit MCU clock alignment system characterized by comprising
Determination unit, for determining target time section using a reference source clock;
First computing unit is denoted as for using the frequency of MCU clock to calculate counting number in the target time section One numerical value;
Second computing unit, for using the frequency of a reference source clock to calculate the counting in the target time section Number, is denoted as second value;
Adjustment unit, for adjusting the frequency of the MCU clock according to first numerical value and the second value.
6. system according to claim 5, which is characterized in that the adjustment unit is specifically used for:
If first numerical value is greater than the second value, the frequency of the MCU clock is reduced;
If first numerical value is less than the second value, increase the frequency of the MCU clock.
7. method according to claim 5 or 6, which is characterized in that first computing unit is specifically used for:
Obtain the maximum value and minimum value in the register effective range of the MCU clock;
Intermediate value is determined using dichotomy according to the maximum value and minimum value;
The register is set according to the intermediate value, obtains the frequency of the MCU clock;
The counting number in the target time section is calculated using the frequency of MCU clock, is denoted as the first numerical value.
8. method according to claim 5 or 6, which is characterized in that second computing unit is specifically used for:
Obtain calibration cycle and calibration error;
In the calibration cycle, judge whether the numerical error of first numerical value and the second value meets the standard Error;
If it is not, the register of the MCU clock is then adjusted, to adjust the frequency of the MCU clock.
9. a kind of computer installation characterized by comprising
Processor, memory, input-output equipment and bus;
The processor, memory, input-output equipment are connected with the bus respectively;
The processor is for executing such as the described in any item methods of Claims 1-4.
10. a kind of computer readable storage medium, is stored thereon with computer program, it is characterised in that: the computer program It realizes when being executed by processor such as the step of any one of claims 1 to 4 the method.
CN201811384477.9A 2018-11-20 2018-11-20 MCU clock calibration method and related equipment Active CN109283967B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811384477.9A CN109283967B (en) 2018-11-20 2018-11-20 MCU clock calibration method and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811384477.9A CN109283967B (en) 2018-11-20 2018-11-20 MCU clock calibration method and related equipment

Publications (2)

Publication Number Publication Date
CN109283967A true CN109283967A (en) 2019-01-29
CN109283967B CN109283967B (en) 2021-11-02

Family

ID=65176118

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811384477.9A Active CN109283967B (en) 2018-11-20 2018-11-20 MCU clock calibration method and related equipment

Country Status (1)

Country Link
CN (1) CN109283967B (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110174922A (en) * 2019-04-15 2019-08-27 合肥格易集成电路有限公司 A kind of calibration method and device of HSI clock frequency
CN111726190A (en) * 2020-06-18 2020-09-29 四川艾贝斯科技发展有限公司 System time calibration method for street lamp control system
CN111736570A (en) * 2020-06-02 2020-10-02 中国电子产品可靠性与环境试验研究所((工业和信息化部电子第五研究所)(中国赛宝实验室)) Controller clock frequency detection method and device, computer equipment and storage medium
CN113009899A (en) * 2019-12-20 2021-06-22 金卡智能集团股份有限公司 RTC (real time clock) calibration method for high-precision timing of metering instrument
CN113260129A (en) * 2021-07-06 2021-08-13 珠海市杰理科技股份有限公司 Synchronous flashing light control method, device, system and storage medium
CN113377155A (en) * 2021-06-08 2021-09-10 深圳市汇顶科技股份有限公司 Clock calibration method and device and electronic equipment
CN114138056A (en) * 2021-11-04 2022-03-04 珠海格力节能环保制冷技术研究中心有限公司 Display terminal clock calibration method and device and display terminal
CN114298075A (en) * 2021-12-30 2022-04-08 江苏集萃智能集成电路设计技术研究所有限公司 Ultrahigh frequency national standard reader baseband decoding method based on MCU
CN114397939A (en) * 2022-01-20 2022-04-26 无锡驰翔创新科技有限公司 Chip clock frequency trimming method, burning method and burner
CN116185128A (en) * 2023-03-06 2023-05-30 珠海极海半导体有限公司 MCU chip internal clock calibration method and circuit
CN117539323A (en) * 2023-11-14 2024-02-09 深圳市航顺芯片技术研发有限公司 MCU internal clock calibration method, system and chip based on ATE equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101552606A (en) * 2009-04-29 2009-10-07 西安理工大学 Intelligent self-calibration chip based on chip internal clock crystal oscillator and self-calibration method
CN103955257A (en) * 2014-03-27 2014-07-30 美的集团股份有限公司 Method and device for calibrating system clocks of single chip microcomputers, and air conditioner control system
CN108023589A (en) * 2016-11-03 2018-05-11 深圳市中兴微电子技术有限公司 A kind of transmitting frequency calibration method and circuit

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101552606A (en) * 2009-04-29 2009-10-07 西安理工大学 Intelligent self-calibration chip based on chip internal clock crystal oscillator and self-calibration method
CN103955257A (en) * 2014-03-27 2014-07-30 美的集团股份有限公司 Method and device for calibrating system clocks of single chip microcomputers, and air conditioner control system
CN108023589A (en) * 2016-11-03 2018-05-11 深圳市中兴微电子技术有限公司 A kind of transmitting frequency calibration method and circuit

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110174922A (en) * 2019-04-15 2019-08-27 合肥格易集成电路有限公司 A kind of calibration method and device of HSI clock frequency
CN113009899A (en) * 2019-12-20 2021-06-22 金卡智能集团股份有限公司 RTC (real time clock) calibration method for high-precision timing of metering instrument
CN111736570A (en) * 2020-06-02 2020-10-02 中国电子产品可靠性与环境试验研究所((工业和信息化部电子第五研究所)(中国赛宝实验室)) Controller clock frequency detection method and device, computer equipment and storage medium
CN111726190A (en) * 2020-06-18 2020-09-29 四川艾贝斯科技发展有限公司 System time calibration method for street lamp control system
CN113377155A (en) * 2021-06-08 2021-09-10 深圳市汇顶科技股份有限公司 Clock calibration method and device and electronic equipment
CN113260129B (en) * 2021-07-06 2021-11-12 珠海市杰理科技股份有限公司 Synchronous flashing light control method, device, system and storage medium
CN113260129A (en) * 2021-07-06 2021-08-13 珠海市杰理科技股份有限公司 Synchronous flashing light control method, device, system and storage medium
CN114138056A (en) * 2021-11-04 2022-03-04 珠海格力节能环保制冷技术研究中心有限公司 Display terminal clock calibration method and device and display terminal
CN114138056B (en) * 2021-11-04 2024-05-17 珠海格力节能环保制冷技术研究中心有限公司 Display terminal clock calibration method and device and display terminal
CN114298075A (en) * 2021-12-30 2022-04-08 江苏集萃智能集成电路设计技术研究所有限公司 Ultrahigh frequency national standard reader baseband decoding method based on MCU
CN114298075B (en) * 2021-12-30 2024-02-06 江苏集萃智能集成电路设计技术研究所有限公司 MCU-based ultrahigh frequency national standard reader baseband decoding method
CN114397939A (en) * 2022-01-20 2022-04-26 无锡驰翔创新科技有限公司 Chip clock frequency trimming method, burning method and burner
CN116185128A (en) * 2023-03-06 2023-05-30 珠海极海半导体有限公司 MCU chip internal clock calibration method and circuit
CN116185128B (en) * 2023-03-06 2024-05-17 珠海极海半导体有限公司 MCU chip internal clock calibration method and circuit
CN117539323A (en) * 2023-11-14 2024-02-09 深圳市航顺芯片技术研发有限公司 MCU internal clock calibration method, system and chip based on ATE equipment

Also Published As

Publication number Publication date
CN109283967B (en) 2021-11-02

Similar Documents

Publication Publication Date Title
CN109283967A (en) A kind of micro-control unit MCU clock correcting method and relevant device
US10042383B2 (en) Navigation system and mouse device
CN109067394B (en) On-chip clock calibration device and calibration method
CN109257507B (en) Method for adjusting screen brightness, mobile terminal and storage medium
CN104679098A (en) Automatic calibration circuit for clock frequency of microcontroller
CN103078697B (en) A kind of distributed clock synchronization method
CN110138402A (en) A kind of control method, device and the mobile terminal of mobile terminal output power
CN109347938B (en) Traffic monitoring method, telephone watch, mobile terminal and server
CN103955257A (en) Method and device for calibrating system clocks of single chip microcomputers, and air conditioner control system
US20200313663A1 (en) Frequency demultiplication adjustment method of pll
CN101151584B (en) Timer circuit, mobile communication terminal using the same, and electronic device using the same
US20040012415A1 (en) Circuit for correcting deviation in oscillating frequency
CN112014749B (en) Method, device, chip and storage medium for determining battery display electric quantity
US5546363A (en) Clock apparatus for forming time information for use in computer system
CN115566296B (en) Battery power display method, electronic device, program product and medium
CN109799872A (en) Improve the method, apparatus and electronic equipment of low-res real-time clock waking-up precision
CN106940665B (en) Time correction control method and system based on mobile terminal and mobile terminal
US8731042B2 (en) Generating pulse width modulated signals
CN111865306B (en) Real-time clock time-base frequency divider and real-time clock adjusting method
CN112601329A (en) Lamplight brightness control method and related equipment thereof
CN109154796B (en) Time updating method, device and movable platform
US10411717B2 (en) Device and method for multiple reference system timer
US9170602B1 (en) Calibrating a high-speed clock signal generated using a processor internal to the electronic authentication device without using a crystal oscillator
CN113552921B (en) System time synchronization method and system for software and hardware interlocking and electronic equipment
CN109413725B (en) Method, device and equipment for prolonging service life of battery of low-power-consumption Internet of things 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