Specific embodiment
Fig. 1 is please referred to, Fig. 1 shows the schematic diagram of the time correction circuit of one embodiment of the invention.Time correction circuit 100
Including frequency eliminator 110, computing circuit 120 and time counter 130.Frequency eliminator 110 receives clock signal FO and frequency elimination value
S, according to frequency elimination value S to generate frequency elimination clock signal FCNT.Time counter 130 couples frequency eliminator 110.Time counter 130
Frequency elimination clock signal FCNT is received, and according to frequency elimination clock signal FCNT to carry out counting action, and uses the generation output time
TOUT.In addition, computing circuit 120 couples frequency eliminator 110 and time counter 130.120 receiving time counter of computing circuit
Time TOUT is exported caused by 130, and receives the system time t* transmitted by external host (i.e. system end), according to output
The time difference of time TOUT and system time t*, to adjust generated frequency elimination value S.
It should also be noted that in the embodiment of the present invention, external host can periodic generation system time t*, and when by system
Between t* be sent to computing circuit 120.Computing circuit 120 can generate in advance frequency elimination value S according to preset value, and when receiving system
Between t* when, according to output time TOUT and system time t* time difference dT, generated frequency elimination value S is adjusted.
That is, the time correction circuit 100 of the embodiment of the present invention will not directly adjust output time TOUT according to system time t*.
By adjusting frequency elimination value S, can make caused by output time TOUT progressive variation occurs, avoid time correction circuit 100 according to
Unnatural bounce is generated according to the time that output time TOUT is shown.
About implementation detail, please synchronize referring to Fig.1 and Fig. 2, wherein Fig. 2 shows the time adjustments of the embodiment of the present invention
Action flow chart.In Fig. 2, in step S210, computing circuit 120 can be initialized, set stable state frequency elimination value S* and
Frequency elimination value S at present, and previous time difference dT (pre) is set equal to 0.In addition, computing circuit 120 is also set in step S210
Init flag INI and stable state flag STDY.In the present embodiment, it in step S210, stable state frequency elimination value S* and removes at present
Frequency value S can be preset as being equal to 60, and init flag INI and stable state flag STDY then can be set as identical logical value 1.
Step S220 starts when updating system time t*, and wherein system time t* can be sent by external electronic device,
And it is received by computing circuit 120.The system time t* of step S220 can be to periodically update movement.Computing circuit 120 simultaneously can be according to
Time difference dT is calculated according to system time t* and output time TOUT.
In step S230, the time difference dT of the judgement output of computing circuit 120 time TOUT and system time t* is
It is no to be equal to previous time difference dT (pre), if time difference dT is equal to previous time difference dT (pre), indicates current and remove
Frequency value S and system end are fully synchronized.In the case, computing circuit 120 can first carry out step S240 and execute step S250 again.?
On the other hand, if time difference dT is not equal to previous time difference dT (pre), indicate that current frequency elimination value S has with system end
Error.In the case, computing circuit 120 can directly execute step S250.
In the present embodiment, stable state frequency elimination value S* is updated to frequency elimination value S by step S240, and makes to remove init flag INI,
Make init flag INI logical value 0.The meaning of this step is that computing circuit 120 has learnt to right-on frequency elimination value
S, and stable state frequency elimination value S* is set it to, and indicate this state by removing init flag INI.
Computing circuit 120 makes previous time difference dT (pre) be equal to time difference dT in step S250.In step S260
In, computing circuit 120 judges whether time difference dT is not equal to 0, if the judging result of step S260 is yes, the expression output time
Still there is error between TOUT and system time t*, computing circuit 120 can remove stable state flag STDY by step S270, make stable state
Flag STDY is equal to logical value 0 to indicate current output time TOUT and have error needs to be adjusted.Later, computing circuit 120
Execute step S280.It is opposite, if the judging result of step S260 be it is no, computing circuit 120 directly executes step S280.
In step S280, computing circuit 120 judges whether stable state flag STDY is logical value 0, and is working as stable state flag
When STDY is logical value 0, by step S290, generated according to stable state frequency elimination value S*, current frequency elimination value S and time difference dT
Frequency elimination value SN is updated, and is set frequency elimination value SN is updated to current frequency elimination value S;Wherein, frequency elimination value SN=(1-A) × S+A is updated
× S*+B × dT, A, B are respectively the first adjustment coefficient and second adjustment coefficient, and the first adjustment coefficient A is less than or equal to 1.This
Outside, second adjustment coefficient B can be set according to the first adjustment coefficient A, for example, second adjustment coefficient B can be with the first adjustment
Coefficient A is inversely proportional, or has other proportionate relationships.
It is worth noting that, the size of the first adjustment coefficient A, second adjustment coefficient B can also patrolling according to init flag INI
Value is collected to set.That is, whether can learn according to computing circuit 120 to right-on frequency elimination value S, and set
It is set to stable state frequency elimination value S* setting the first adjustment coefficient A and second adjustment coefficient B.For example bright, when init flag INI is to patrol
When collecting value 1, the first adjustment coefficient A can be set as 1/2, and second adjustment coefficient B then can be set as 2.When init flag INI is
When logical value 0, the first adjustment coefficient A can be set as 1, and second adjustment coefficient B then can be set as 1.It must be noted that
After stable state flag STDY is removed (=0), when time difference dT is for the first time zero, step S280 still can be because of stable state flag STDY
It is not yet set to 1 (this setting must be to subsequent step S2110) and enters step S290 adjustment and update frequency elimination value SN.If but at this time
Stable state frequency elimination value S* (init flag INI is logical value 0) fully synchronized with system end, and time difference dT is zero, meaning
Adjustment completed.That is, the setting of the first adjustment coefficient A and second adjustment coefficient B must make under this state
It is essentially equal in stable state frequency elimination value S* to update frequency elimination value SN.Accordingly, when stable state frequency elimination value S* is fully synchronized with system end (just
Beginning flag INI is logical value 0), then it no longer needs to update frequency elimination value SN (the first adjustment according to current frequency elimination value S adjustment instantly
1) coefficient A should be, it is only necessary to update frequency elimination value SN with right-on stable state frequency elimination value S* and time difference dT fine tuning.
It should also be noted that in the present embodiment, init flag INI is cleared to logical value 0, be by step S240 come into
Capable.In step S240, computing circuit 120 has learnt to right-on frequency elimination value, and sets it to stable state frequency elimination
Value S*.Therefore, when init flag INI is logical value 0, frequency elimination value SN and stable state frequency elimination value are updated caused by step S290
S* and time difference dT are related, that is, will not be adjusted according to current frequency elimination value S.Opposite, when init flag INI is
When logical value 1, indicate that step S240 is not performed, stable state frequency elimination value S* is not right-on frequency elimination value.Therefore, pass through step
S290, computing circuit 120 can be simultaneously according to not right-on stable state frequency elimination value S*, current frequency elimination value S and time differences
DT updates frequency elimination value SN, and is updated by updating frequency elimination value SN to be directed to current frequency elimination value S.
In addition, step S2100 is judged again for whether time difference dT is equal to 0, if time difference dT is not equal to
0, it is re-execute the steps S220, wakes up process when system update system time t*.Relatively, if time difference dT is equal to
0, after thening follow the steps S2110 to set stable state flag STDY as logical value 1, then it re-execute the steps S220.
Actual computation paradigm is enumerated, herein the implementation detail of the embodiment of the present invention is explained in more detail.Believed with clock pulse
For the frequency of number FO is 37.8 megahertz by 36 megahertz drifts.In period first time, computing circuit 120 is in step
Rapid S210 setting stable state frequency elimination value S* and current frequency elimination value S is all equal to 60, sets previous time difference dT (pre) equal to 0, and
Init flag INI and stable state flag STDY are set as logical value 1.Step S220 receives the system time t* updated, operation electricity
Road 120 simultaneously calculates time difference dT equal to 3.It is not identical based on time difference dT and previous time difference dT (pre), operation electricity
Road 120 does not execute step S240, and directly executes step S230 and set previous time difference dT (pre) equal to time difference dT=
3.Then, in step S260, computing circuit 120 judges that time difference dT is steady to remove not equal to 0, and by step S270
State flag STDY is logical value 0.Then, computing circuit 120 judge in step S280 stable state flag STDY for logical value 0, and
It executes step S290 and updates (1/2) × (60)+(1/2) × (60)+(2) frequency elimination value SN=× (3)=66 to calculate, and will more
New frequency elimination value SN is set to current frequency elimination value S, here, be equal to logic 1 based on init flag INI, the first adjustment coefficient A and the
Two regulation coefficient B can be respectively 1/2,2.Then, step S2100 judges that time difference dT is not equal to 0, and executes step
S220。
It holds and continues above-mentioned explanation, in second time period, based on the movement in period first time, time difference at this time
DT can be equal to 0, and computing circuit 120 can determine whether out previous time difference dT (pre) (=3) not equal to the time in step S230
Difference dT (=0), therefore do not execute step S240 (i.e. current frequency elimination value S and system end be not fully synchronized).Computing circuit 120
It is equal to time difference dT=0 by the new previous time difference dT (pre) of step S250 setting, and passes through step S260, S280,
By judging that stable state flag STDY, Lai Zhihang the step S290 for being maintained equal to logical value 0 updates frequency elimination value SN=(1/ to calculate
2) × (60)+(1/2) × (66)+(2) × (0)=63.Then, it is based on time difference dT=0, computing circuit 120 executes step
S2110 is replied to set stable state flag STDY as logical value 1 and is executed step S220 to wait update system time t* next time
Movement generation.
In the third time cycle of second time period, based on current frequency elimination value S=63 at this time, clock signal FO is
37.8 megahertz.Therefore, by making 37.8 megahertz divided by 63 again divided by 6 × 105(default frequency elimination value), when can make frequency elimination
Arteries and veins signal FCNT is just equal to 1 hertz.That is, frequency elimination value S is fully synchronized with system end at present.In week this third time
It is interim, based on time difference dT (being all equal to 0) equal with previous time difference dT (pre), pass through step S230, computing circuit
120 can remove init flag INI as logical value 0, and stable state frequency elimination value S* is made to be equal to right-on current frequency elimination value S=
63.Also, by step S260, S280, S2110, stable state flag STDY and current frequency elimination value S are not changed, achievable
Export the adjustment movement of time TOUT.
In the present embodiment, every a period of time can be 1 minute, alternatively, designer can be arranged according to actual demand
The length of time in each period, the limitation that do not fix.
By above description it is known that in embodiments of the present invention, when the frequency of clock signal FO morphs, this hair
The time correction circuit 100 of bright embodiment can complete the adjustment movement of output time TOUT by three time cycles.Pass through
Gradual adjustment movement, effectively promotes the smoothness of output time showing, promotes visual comfort level.
It is noted that after the completion of the adjustment of above-mentioned current frequency elimination value S, after regular hour length, if send out again
It the phenomenon that frequency drift of raw clock signal FO, then can be by the motion flow of 2 embodiment of earlier figures, further directed to removing at present
Frequency value S is adjusted, and effectively correction output time TOUT.Relevant movement details is similar in explanation above-mentioned, pardons herein
Seldom repeat.
Referring to figure 3., Fig. 3 shows the schematic diagram of the time correction circuit of another embodiment of the present invention.Time correction circuit
300 include frequency eliminator 310, computing circuit 320 and time counter 330.With previous embodiment the difference is that, frequency eliminator
310 include the frequency eliminating circuit 311 and 312 of coupled in series.Frequency eliminating circuit 311 receive clock signal FO, and according to frequency elimination value S with
Frequency elimination is carried out for clock signal FO to generate clock signal CK1.Frequency eliminating circuit 312 then receives clock signal CK1, and according to pre-
If frequency elimination value BS is to carry out frequency elimination for clock signal CK1 to generate frequency elimination clock signal FCNT.In the present embodiment, frequency elimination electricity
The coupling sequence on road 311,312 can exchange, and default frequency elimination value BS can be changeless numerical value.
In addition, in the present embodiment, computing circuit 320 is coupled to host 340, and can receive periodical hair by host 340
The system time t* sent.
Subsidiary one mentions, and in embodiments of the present invention, the hardware structure of frequency eliminating circuit 311,312 can pass through art technology
Frequency eliminating circuit known to personnel is implemented, and does not limit specifically.In addition, the hardware structure of time counting circuit 330 can lead to
Counting circuit well-known to those skilled in the art is crossed to implement, also without specific limitation.Computing circuit 320 then can be
Has the processor of operational capability.Alternatively, computing circuit 320 can be through hardware description language (Hardware
Description Language, HDL) or any other digital circuit well-known to those skilled in the art design method
It is designed, and can programmed logic gate array (Field Programmable Gate Array, FPGA), multiple by scene
It is miscellaneous can program logic device (Complex Programmable Logic Device, CPLD) or special application integrated circuit
The mode of (Application-specific Integrated Circuit, ASIC) is come the hardware circuit realized, for example, fortune
Calculating circuit 320 can be a state machine (state machine) circuit.
A and Fig. 4 B, Fig. 4 A and Fig. 4 B are shown respectively in the embodiment of the present invention referring to figure 4. below, execute time school
The variable condition schematic diagram of the current frequency elimination value of direct action, stable state frequency elimination value and time difference.In Figure 4 A, believe when clock pulse
Number frequency when changing, frequency elimination value S, stable state frequency elimination value S* can be adjusted according to step shown by Fig. 2 embodiment at present
It is whole, and gradual stabilization after multiple steps.If also, over time, the frequency of clock signal again this change
When, frequency elimination value S, stable state frequency elimination value S* can also be gradual at present stabilization.It is found that passing through frequency elimination value S, stable state frequency elimination value in Fig. 4 B
The gradual stable adjustment movement of S*, the convergence that time difference dT can also be gradual, and at steady state level off to 0.
Referring to figure 5., Fig. 5 shows the flow chart of the time-correcting method of the embodiment of the present invention.Wherein, step S510 is received
Clock signal and frequency elimination value, according to frequency elimination value to generate frequency elimination clock signal;Step S520 according to frequency elimination clock signal with into
Row counting action, and use the generation output time;Step S530 then according to output time and the time difference of system time, comes
Adjust frequency elimination value.
Have explanation in detail about the implementation detail of above-mentioned steps, in the embodiment stated before this invention, with it is following not
It repeats more.
In conclusion frequency elimination value of the present invention by adjusting frequency eliminator, carrys out gradual adjustment time correcting circuit and is produced
The raw output time.In this way, which the display time will not be promoted because there is a phenomenon where unexpected bounces for corrective action by exporting the time
Display smooth degree.
Although the present invention is disclosed as above with embodiment, however, it is not to limit the invention, any technical field
In technical staff, without departing from the spirit and scope of the present invention, when can make a little change and retouching, therefore guarantor of the invention
Subject to shield range ought be defined depending on claim.