JPH1020052A - Time correction method and device therefor - Google Patents

Time correction method and device therefor

Info

Publication number
JPH1020052A
JPH1020052A JP17127596A JP17127596A JPH1020052A JP H1020052 A JPH1020052 A JP H1020052A JP 17127596 A JP17127596 A JP 17127596A JP 17127596 A JP17127596 A JP 17127596A JP H1020052 A JPH1020052 A JP H1020052A
Authority
JP
Japan
Prior art keywords
time
interrupt
count number
timer
count
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP17127596A
Other languages
Japanese (ja)
Inventor
Kyoichi Nagaoka
恭一 永岡
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.)
Yazaki Corp
Original Assignee
Yazaki Corp
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 Yazaki Corp filed Critical Yazaki Corp
Priority to JP17127596A priority Critical patent/JPH1020052A/en
Publication of JPH1020052A publication Critical patent/JPH1020052A/en
Pending legal-status Critical Current

Links

Landscapes

  • Electric Clocks (AREA)
  • Measuring Frequencies, Analyzing Spectra (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide a time correction device correcting a time error generated when basic oscillation frequency generated in a basic oscillator is divided by means of a frequency divider. SOLUTION: A reference count unit 35 divides a unit time by a clock cycle of a signal outputted from a frequency divider 31 to a timer 33 so as to find a reference count number. A timer interruption count unit 37 divides a timer 33 interrupting time set in the timer 33 by the clock cycle so as to find an interruption count number and sequently adds the interruption count number every time when timer 33 interruption is generated. An error correcting unit 43 subtracts the reference count number from the addition interruption count number if the provided addition interruption count number exceeds the reference count number, and the excessive count number is used as an initial value of the addition interruption count number in generation of the following timer 33 interruption, and consequently, a time error can be corrected.

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は、マイクロコンピュ
ータなどの情報処理装置に使用される基本発振器で発振
した基本発振周波数を分周器で分周した際に発生する時
刻誤差を補正する時刻誤差補正方法及びその装置に関す
る。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a time error correction for correcting a time error generated when a basic oscillation frequency oscillated by a basic oscillator used in an information processing apparatus such as a microcomputer is divided by a frequency divider. A method and an apparatus therefor.

【0002】[0002]

【従来の技術】マイクロコンピュータなどの情報処理装
置においては、水晶発振器で発振した基本発振周波数を
分周器で分周し、この分周されたクロック信号を用いて
マイクロコンピュータ内の各部のタイミングを図ってい
る。例えば、分周されたクロック信号をタイマカウンタ
に供給し、タイマ割込みにより時刻を計数している。
2. Description of the Related Art In an information processing apparatus such as a microcomputer, the fundamental oscillation frequency oscillated by a crystal oscillator is divided by a frequency divider, and the timing of each section in the microcomputer is calculated using the divided clock signal. I'm trying. For example, the frequency-divided clock signal is supplied to a timer counter, and the time is counted by a timer interrupt.

【0003】図4に従来のこの種の時刻計数方法を示
す。まず、前記分周された信号のクロック周期を決定
し、さらに、タイマカウンタによるタイマ割込み時間を
決定する(ステップS101)。
FIG. 4 shows a conventional time counting method of this kind. First, the clock cycle of the frequency-divided signal is determined, and further, the timer interrupt time by the timer counter is determined (step S101).

【0004】次に、タイマ割込みがあるかどうかが判定
され(ステップS103)、タイマ割込みがあった場合
には、タイマカウンタはカウント値に1を加算する(ス
テップS105)。
Next, it is determined whether there is a timer interrupt (step S103). If there is a timer interrupt, the timer counter adds 1 to the count value (step S105).

【0005】そして、タイマカウンタは、図5に示すよ
うに、1秒間において、クロック周期aをもつ分周され
たクロック信号のクロック数を計数していく。さらに、
1秒が経過したかどうかが判定される(ステップS10
7)。
As shown in FIG. 5, the timer counter counts the number of clocks of the divided clock signal having the clock cycle a in one second. further,
It is determined whether one second has elapsed (step S10).
7).

【0006】1秒が経過した時に、タイマカウンタをク
リアする(ステップS109)。さらに、秒数カウンタ
はカウント値を1だけインクリメントする(ステップS
111)。
When one second has elapsed, the timer counter is cleared (step S109). Further, the second counter increments the count value by 1 (step S).
111).

【0007】そして、秒数カウンタのカウント値が60
(1分間)かどうかが判定され(ステップS113)、
秒数カウンタのカウント値が60でない場合には、ステ
ップS103の処理に戻る。
The count value of the second counter is 60
(1 minute) (step S113).
If the count value of the second counter is not 60, the process returns to step S103.

【0008】さらに、秒数カウンタのカウント値が60
となった場合には、その他の処理、例えば、分数カウン
タのカウントなどの処理が終了かどうかが判定される
(ステップS115)。
Further, the count value of the second counter is 60
When it is determined whether or not other processing, for example, processing such as counting by a fraction counter, is completed (step S115).

【0009】[0009]

【発明が解決しようとする課題】しかしながら、水晶発
振器で発振した基本発振周波数を分周器で分周し、この
分周されたクロック信号に時刻誤差が発生する場合があ
る。
However, the basic oscillation frequency oscillated by the crystal oscillator is divided by the frequency divider, and a time error may occur in the divided clock signal.

【0010】例えば、図5に示すように、1秒経過時に
は、タイマカウンタはn個のクロック周期aをカウント
したことになる。すなわち、n個のクロック周期aの時
間は1秒よりも大きく、斜線部分で示す部分が時刻誤差
となる。
For example, as shown in FIG. 5, when one second has elapsed, the timer counter has counted n clock periods a. That is, the time of the n clock periods a is longer than 1 second, and the portion indicated by the hatched portion is a time error.

【0011】この時刻誤差は補正されていないため、タ
イマカウンタが2秒以上、n個のクロック周期aをカウ
ントしていくと、前記時刻誤差が時間とともに、累積さ
れていく。このため、時計の精度が低下するという問題
があった。
Since this time error is not corrected, when the timer counter counts n clock periods a for 2 seconds or more, the time error is accumulated with time. For this reason, there has been a problem that the accuracy of the timepiece is reduced.

【0012】本発明の目的は、基準クロック信号を分周
した分周信号に時刻誤差がある場合にその時刻誤差を補
正して、時計の精度を向上することのできる時刻誤差補
正方法及びその装置を提供する。
SUMMARY OF THE INVENTION An object of the present invention is to provide a time error correction method and apparatus for correcting a time error in a frequency-divided signal obtained by dividing a reference clock signal, thereby improving the accuracy of a clock. I will provide a.

【0013】[0013]

【課題を解決するための手段】本発明は、前記課題を解
決するために以下の手段を採用した。請求項1の発明
は、基本発振器で発振した基本発振周波数を分周器で分
周した際に発生する時刻誤差を補正する時刻補正装置に
おいて、分周器からタイマに出力される信号のクロック
周期で単位時間を除算することにより基準カウント数を
求める基準カウント部と、タイマに設定されたタイマ割
込み時間を前記クロック周期で除算することにより割込
みカウント数を求め、タイマ割込み発生毎に割込みカウ
ント数を順次加算するタイマ割込みカウント部と、得ら
れた加算割込みカウント数が基準カウント数を超えた場
合に加算割込みカウント数から基準カウント数を減算し
剰余カウント数を次回のタイマ割込み発生時における加
算割込みカウント数の初期値とすることで時刻誤差を補
正する誤差補正部とを備えることを要旨とする。
The present invention employs the following means in order to solve the above-mentioned problems. According to a first aspect of the present invention, there is provided a time correction apparatus for correcting a time error generated when a basic oscillation frequency oscillated by a basic oscillator is divided by a frequency divider, wherein a clock cycle of a signal output from the frequency divider to a timer is provided. And a reference count unit for obtaining a reference count number by dividing the unit time, and an interrupt count number is obtained by dividing the timer interrupt time set for the timer by the clock cycle. A timer interrupt counting unit that sequentially adds, and when the obtained added interrupt count exceeds the reference count, the reference count is subtracted from the added interrupt count and the remaining count is added when the next timer interrupt occurs. The gist is to provide an error correction unit for correcting a time error by setting the initial value of the number.

【0014】この発明によれば、基準カウント部が、分
周器からタイマに出力される信号のクロック周期で単位
時間を除算することにより基準カウント数を求め、タイ
マ割込みカウント部が、タイマに設定されたタイマ割込
み時間を前記クロック周期で除算することにより割込み
カウント数を求めタイマ割込み発生毎に割込みカウント
数を順次加算する。
According to the present invention, the reference count section obtains the reference count number by dividing the unit time by the clock cycle of a signal output from the frequency divider to the timer, and the timer interrupt count section sets the timer count. By dividing the timer interrupt time thus obtained by the clock cycle, an interrupt count is obtained, and the interrupt count is sequentially added every time a timer interrupt occurs.

【0015】そして、誤差補正部は、得られた加算割込
みカウント数が基準カウント数を超えた場合に加算割込
みカウント数から基準カウント数を減算し剰余カウント
数を次回のタイマ割込み発生時における加算割込みカウ
ント数の初期値とすることで時刻誤差を補正する。
The error correction section subtracts the reference count number from the added interrupt count number when the obtained added interrupt count number exceeds the reference count number, and adds the remainder count number to the additional interrupt count at the next occurrence of the timer interrupt. The time error is corrected by setting the initial value of the count number.

【0016】すなわち、基本発振器で発振した基本発振
周波数が分周器によって時刻誤差が発生しても、誤差補
正部によって分周信号の時刻誤差が補正されているか
ら、時計の精度を向上できる。
That is, even if a time error occurs in the basic oscillation frequency oscillated by the basic oscillator due to the frequency divider, the time error of the frequency-divided signal is corrected by the error correction unit, so that the accuracy of the timepiece can be improved.

【0017】請求項2の発明は、前記タイマ割込みカウ
ント部による割込みカウント数の加算処理及び前記誤差
補正部による時刻誤差の補正処理を繰り返し行なうこと
を要旨とする。
The gist of the present invention is to repeat the addition of the interrupt count by the timer interrupt counting section and the time error correction by the error correction section.

【0018】この発明によれば、タイマ割込みカウント
部による割込みカウント数の加算処理及び前記誤差補正
部による時刻誤差の補正処理を繰り返し行なうので、時
間の経過とともに累積される時刻誤差が補正される。
According to the present invention, the addition processing of the interrupt count by the timer interrupt counting section and the correction processing of the time error by the error correction section are repeated, so that the time error accumulated with the passage of time is corrected.

【0019】請求項3の発明は、基本発振器で発振した
基本発振周波数を分周器で分周した際に発生する時刻誤
差を補正する時刻補正方法において、分周器からタイマ
に出力される信号のクロック周期で単位時間を除算する
ことにより基準カウント数を求める第1のステップと、
タイマに設定されたタイマ割込み時間を前記クロック周
期で除算することにより割込みカウント数を求める第2
のステップと、タイマ割込み発生毎に割込みカウント数
を順次加算する第3のステップと、得られた加算割込み
カウント数が基準カウント数を超えた場合に加算割込み
カウント数から基準カウント数を減算し剰余カウント数
を次回のタイマ割込み発生時における加算割込みカウン
ト数の初期値とすることで時刻誤差を補正する第4のス
テップとを含むことを要旨とする。
According to a third aspect of the present invention, there is provided a time correction method for correcting a time error generated when a basic oscillator frequency oscillated by a basic oscillator is frequency-divided by a frequency divider, wherein a signal output from the frequency divider to a timer is provided. A first step of obtaining a reference count number by dividing the unit time by the clock cycle of
A second method for calculating the interrupt count number by dividing the timer interrupt time set in the timer by the clock cycle.
And a third step of sequentially adding the interrupt count number each time a timer interrupt occurs, and, when the obtained additional interrupt count number exceeds the reference count number, subtracting the reference count number from the additional interrupt count number to obtain a remainder. And a fourth step of correcting the time error by setting the count number as an initial value of the added interrupt count number when a next timer interrupt occurs.

【0020】この発明によれば、第1のステップで、分
周器からタイマに出力される信号のクロック周期で単位
時間を除算することにより基準カウント数を求め、第2
のステップで、タイマに設定されたタイマ割込み時間を
前記クロック周期で除算することにより割込みカウント
数を求める。
According to the present invention, in the first step, the reference count is obtained by dividing the unit time by the clock cycle of the signal output from the frequency divider to the timer.
In the step (1), an interrupt count is obtained by dividing the timer interrupt time set in the timer by the clock cycle.

【0021】第3のステップで、タイマ割込み発生毎に
割込みカウント数を順次加算し、第4のステップで、得
られた加算割込みカウント数が基準カウント数を超えた
場合に加算割込みカウント数から基準カウント数を減算
し剰余カウント数を次回のタイマ割込み発生時における
加算割込みカウント数の初期値とすることで時刻誤差を
補正する。
In a third step, the interrupt count number is sequentially added each time a timer interrupt occurs. In a fourth step, when the obtained additional interrupt count number exceeds the reference count number, the reference value is calculated from the added interrupt count number. The time error is corrected by subtracting the count number and setting the remainder count number as the initial value of the added interrupt count number when the next timer interrupt occurs.

【0022】すなわち、基本発振器で発振した基本発振
周波数が分周器によって時刻誤差が発生しても、分周信
号の時刻誤差が補正されるから時計の精度を向上でき
る。
That is, even if a time error occurs in the basic oscillation frequency oscillated by the basic oscillator due to the frequency divider, the time error of the frequency-divided signal is corrected, so that the accuracy of the timepiece can be improved.

【0023】請求項4の発明は、前記第3のステップの
割込みカウント数の加算処理及び第4のステップの時刻
誤差の補正処理を繰り返し行なうことを要旨とする。
The gist of the present invention is that the addition of the interrupt count in the third step and the correction of the time error in the fourth step are repeatedly performed.

【0024】この発明によれば、第3のステップの割込
みカウント数の加算処理及び第4のステップの時刻誤差
の補正処理を繰り返し行なうので、時間の経過とともに
累積される時刻誤差が補正される。
According to the present invention, the addition of the interrupt count in the third step and the correction of the time error in the fourth step are repeatedly performed, so that the time error accumulated with the passage of time is corrected.

【0025】[0025]

【発明の実施の形態】以下、本発明の時刻補正方法及び
その装置を説明する。図1に本発明の時刻補正装置の実
施の形態の構成図を示す。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Hereinafter, a time correction method and device according to the present invention will be described. FIG. 1 shows a configuration diagram of an embodiment of the time correction device of the present invention.

【0026】図1に示す時刻補正装置は、例えば、マイ
クロコンピュータなどの情報処理装置に設けられ、基本
発振器で発振した基本発振周波数を分周器で分周した際
に発生する時刻誤差を補正するものである。
The time correction device shown in FIG. 1 is provided in, for example, an information processing device such as a microcomputer, and corrects a time error generated when the basic oscillation frequency oscillated by the basic oscillator is divided by the frequency divider. Things.

【0027】時刻補正装置は、基本発振器である水晶発
振器1、水晶発振器1に接続される中央処理装置(CP
U)3、CPU3に接続される表示器ドライバIC(集
積回路)5、これに接続される表示器7とから構成され
る。
The time correction device includes a crystal oscillator 1 as a basic oscillator and a central processing unit (CP) connected to the crystal oscillator 1.
U) 3, a display driver IC (integrated circuit) 5 connected to the CPU 3, and a display 7 connected thereto.

【0028】水晶発振器1は、一方の端子にコンデンサ
13を接続し他方の端子にコンデンサ15を接続し、基
本発振周波数を持つ基本クロック信号を発振する水晶振
動子11からなる。
The crystal oscillator 1 includes a crystal resonator 11 having one terminal connected to a capacitor 13 and the other terminal connected to a capacitor 15, and oscillating a basic clock signal having a basic oscillation frequency.

【0029】CPU3は、分周器31、タイマ33、基
準カウント部35、タイマ割込みカウント部37、メモ
リ39、カウント数比較部41、誤差補正部43、秒数
カウンタ45を有する。
The CPU 3 has a frequency divider 31, a timer 33, a reference count unit 35, a timer interrupt count unit 37, a memory 39, a count number comparison unit 41, an error correction unit 43, and a second counter 45.

【0030】分周器31は、水晶発振器1で発振した基
本発振周波数を持つ基本クロック信号を分周して分周信
号をタイマ33及び基準カウント部35に出力する。
The frequency divider 31 divides the frequency of the basic clock signal having the basic oscillating frequency oscillated by the crystal oscillator 1 and outputs a frequency-divided signal to the timer 33 and the reference count unit 35.

【0031】タイマ33はタイマ割込み時間を設定し、
タイマ割込み時間に達した時にタイマ割込みを発生す
る。
The timer 33 sets a timer interrupt time,
Generates a timer interrupt when the timer interrupt time is reached.

【0032】基準カウント部35は、分周器31から出
力される分周信号を入力し分周信号のクロック周期で単
位時間を除算することにより基準カウント数を求める。
The reference count section 35 receives the frequency-divided signal output from the frequency divider 31 and divides the unit time by the clock cycle of the frequency-divided signal to obtain a reference count.

【0033】タイマ割込みカウント部37は、タイマ3
3からのタイマ割込み時間と分周器31からの分周信号
を入力し、タイマ割込み時間を前記クロック周期で除算
することにより割込みカウント数を求め、その割込みカ
ウント数をメモリ39のワークエリアに記憶する。
The timer interrupt counting section 37 is provided for the timer 3
3 and the divided signal from the frequency divider 31 are input, the timer interrupt time is divided by the clock cycle to obtain the interrupt count, and the interrupt count is stored in the work area of the memory 39. I do.

【0034】また、タイマ割込みカウント部37は、タ
イマ割込み発生毎にメモリ39に記憶された割込みカウ
ント数を今回の割込みカウント数に加算して、加算割込
みカウント数をメモリ39に記憶することで、加算割込
みカウント数を順次加算していく。
The timer interrupt counting section 37 adds the interrupt count stored in the memory 39 to the current interrupt count every time a timer interrupt occurs, and stores the added interrupt count in the memory 39. The addition interrupt count number is sequentially added.

【0035】カウント数比較部41は、基準カウント部
35からの基準カウント数とメモリ39からの加算割込
みカウント数とを比較する。
The count comparing section 41 compares the reference count from the reference counting section 35 with the added interrupt count from the memory 39.

【0036】誤差補正部43は、カウント数比較部41
の出力に基づき、得られた加算割込みカウント数が基準
カウント数を超えた場合に、1秒経過したものとして、
秒数カウンタ45のカウント値に1を加算する。
The error correction unit 43 includes a count number comparison unit 41
If the obtained additional interrupt count exceeds the reference count based on the output of
One is added to the count value of the seconds counter 45.

【0037】誤差補正部43は、得られた加算割込みカ
ウント数が基準カウント数を超えた場合に、加算割込み
カウント数から基準カウント数を減算し、剰余カウント
数を次回のタイマ割込み発生時における加算割込みカウ
ント数の初期値としてメモリ39に出力することで時刻
誤差を補正する。
When the obtained added interrupt count exceeds the reference count, the error corrector 43 subtracts the reference count from the added interrupt count, and adds the remainder count when the next timer interrupt occurs. The time error is corrected by outputting to the memory 39 as the initial value of the interrupt count number.

【0038】また、前記タイマ割込みカウント部37に
よる割込みカウント数の加算処理、カウント数比較部4
1のカウント数の比較処理及び前記誤差補正部43によ
る時刻誤差の補正処理は、複数回繰り返し行なわれる。
The timer interrupt counting section 37 adds the interrupt count number, and the count comparing section 4
The process of comparing the count number of 1 and the process of correcting the time error by the error correction unit 43 are repeatedly performed a plurality of times.

【0039】表示器ドライバIC5は、表示器7を駆動
するもので、表示器7は、表示器ドライバIC5を介し
て秒数カウンタ45からの秒数情報を表示する。
The display driver IC 5 drives the display 7, and the display 7 displays the second information from the second counter 45 via the display driver IC 5.

【0040】次に、このように構成された本発明の時刻
補正方法及びその装置の動作を図1の構成図、図2に示
すフローチャート、図3に示すタイミングチャートを参
照して説明する。
Next, the operation of the time correction method and the apparatus according to the present invention thus configured will be described with reference to the block diagram of FIG. 1, the flowchart shown in FIG. 2, and the timing chart shown in FIG.

【0041】まず、分周器31は、水晶発振器1で発振
した基本発振周波数をもつ基本クロック信号を分周して
分周信号をタイマ33及び基準カウント部35に出力す
る。この場合、タイマ33に供給される分周信号のクロ
ック周期が基本発振周波数の分周比から決定される(ス
テップS11)。
First, the frequency divider 31 divides the frequency of the basic clock signal having the basic oscillation frequency oscillated by the crystal oscillator 1 and outputs the frequency-divided signal to the timer 33 and the reference count unit 35. In this case, the clock cycle of the frequency-divided signal supplied to the timer 33 is determined from the frequency division ratio of the basic oscillation frequency (step S11).

【0042】次に、基準カウント部35は、分周器31
から出力される分周信号を入力し分周信号の前記クロッ
ク周期で1秒(単位時間)を除算することにより基準カ
ウント数を求める(ステップS13)。
Next, the reference counting section 35 is provided with the frequency divider 31.
A reference count is obtained by inputting the frequency-divided signal output from the CPU and dividing one second (unit time) by the clock cycle of the frequency-divided signal (step S13).

【0043】すなわち、タイマ33に供給される分周信
号のクロック周期から何クロックをカウントすれば、1
秒になるかを求め、そのカウント値を前記基準カウント
数とする。
That is, if the number of clocks counted from the clock cycle of the frequency-divided signal supplied to the timer 33,
Seconds are determined, and the count value is used as the reference count number.

【0044】そして、タイマ割込みカウント部37は、
タイマ33からのタイマ割込み時間と分周器31からの
分周信号を入力し、タイマ33で設定されたタイマ割込
み時間を前記クロック周期で除算することにより割込み
カウント数を求める(ステップS15)。
The timer interrupt counting section 37
The timer interrupt time from the timer 33 and the frequency-divided signal from the frequency divider 31 are input, and the timer interrupt time set by the timer 33 is divided by the clock cycle to obtain an interrupt count (step S15).

【0045】次に、タイマ33によるタイマ割込みがあ
ったかどうかが判定される(ステップS17)。
Next, it is determined whether or not there has been a timer interrupt by the timer 33 (step S17).

【0046】タイマ割込みがあった場合には、タイマ割
込みカウント部37は、その割込みカウント数をメモリ
39のワークエリアに記憶する(ステップS19)。
When there is a timer interrupt, the timer interrupt counting section 37 stores the count of the interrupt in the work area of the memory 39 (step S19).

【0047】カウント数比較部41は、基準カウント部
35からの基準カウント数とメモリ39からの割込みカ
ウント数とを比較する(ステップS21)。
The count number comparing section 41 compares the reference count number from the reference counting section 35 with the interrupt count number from the memory 39 (step S21).

【0048】図3に示すように、割込みカウント数K2
は、基準カウント数K1よりも小さいので、ステップS
15の処理に戻る。そして、タイマ割込みカウント部3
7は、タイマ割込み発生毎に、メモリ39に記憶された
割込みカウント数を今回の割込みカウント数に加算し
て、加算割込みカウント数をメモリ39に記憶すること
で、加算割込みカウント数を順次加算していく。
As shown in FIG. 3, the interrupt count K2
Is smaller than the reference count K1, so that step S
It returns to the process of 15. Then, the timer interrupt counting unit 3
7 adds the interrupt count number stored in the memory 39 to the current interrupt count number each time a timer interrupt occurs and stores the added interrupt count number in the memory 39, thereby sequentially adding the added interrupt count number. To go.

【0049】そして、図3に示すように、誤差補正部4
3は、メモリ39からの加算割込みカウント数(4つの
K2の和)が基準カウント数K1を超えた場合に、加算
割込みカウント数から基準カウント数を減算する。
Then, as shown in FIG.
Reference numeral 3 indicates that the reference count is subtracted from the added interrupt count when the added interrupt count from the memory 39 (the sum of four K2) exceeds the reference count K1.

【0050】さらに、誤差補正部43は、剰余カウント
数△K21を次回のタイマ割込み発生時における加算割
込みカウント数の初期値としてメモリ39に記憶させる
ことで時刻誤差(剰余カウント数△K21)を補正する
(ステップS23)。
Further, the error correction unit 43 corrects the time error (remainder count △ K21) by storing the remainder count △ K21 in the memory 39 as the initial value of the additional interrupt count at the time of the next timer interrupt. (Step S23).

【0051】すなわち、メモリ39に記憶された加算割
込みカウント数は剰余カウント数△K21に書き換えら
れる。
That is, the added interrupt count stored in the memory 39 is rewritten to the remainder count △ K21.

【0052】また、誤差補正部43は、得られた加算割
込みカウント数が基準カウント数を超えた場合に、1秒
経過したものとして、秒数カウンタ45のカウント値に
1を加算する(ステップS25)。
When the obtained additional interrupt count exceeds the reference count, the error corrector 43 determines that one second has elapsed and adds 1 to the count of the second counter 45 (step S25). ).

【0053】さらに、秒数カウンタ45のカウント値が
60になったどうかが判定され(ステップS27)、秒
数カウンタ45のカウント値が60になっていない場合
には、ステップS17の処理に戻る。
Further, it is determined whether or not the count value of the seconds counter 45 has reached 60 (step S27). If the count value of the seconds counter 45 has not reached 60, the process returns to step S17.

【0054】そして、2秒目のステップS17からステ
ップS27の処理が行なわれる。この場合、タイマ割込
みが発生すると、タイマ割込みカウント部37は、メモ
リ39に記憶された剰余カウント数△K21を今回の割
込みカウント数に加算して、加算割込みカウント数をメ
モリ39に記憶することで、加算割込みカウント数を順
次加算していく。
Then, the processing from step S17 to step S27 in the second second is performed. In this case, when a timer interrupt occurs, the timer interrupt counting section 37 adds the remainder count number △ K21 stored in the memory 39 to the current interrupt count number, and stores the added interrupt count number in the memory 39. , The addition interrupt count number is sequentially added.

【0055】そして、図3に示すように、誤差補正部4
3は、メモリ39からの加算割込みカウント数(4つの
K2の和)が基準カウント数K1を超えた場合に、加算
割込みカウント数から基準カウント数を減算する。
Then, as shown in FIG.
Reference numeral 3 indicates that the reference count is subtracted from the added interrupt count when the added interrupt count from the memory 39 (the sum of four K2) exceeds the reference count K1.

【0056】さらに、誤差補正部43は、剰余カウント
数△K22を次回のタイマ割込み発生時における加算割
込みカウント数の初期値としてメモリ39に記憶させる
ことで時刻誤差(剰余カウント数△K22)を補正す
る。
Further, the error correction unit 43 corrects the time error (remainder count △ K22) by storing the remainder count △ K22 in the memory 39 as an initial value of the additional interrupt count at the time of the next timer interrupt. I do.

【0057】このような時刻誤差の補正処理を複数回繰
り返し行ない、秒数カウンタ45が60になった場合に
は、次に処理を終了するかどうかが判定される(ステッ
プS29)。
When such a time error correction process is repeated a plurality of times, and the number of seconds counter 45 reaches 60, it is determined whether or not to end the process (step S29).

【0058】このように、本発明の時刻補正方法及びそ
の装置の実施の形態によれば、水晶発振器1で発振した
基本発振周波数が分周器31によって時刻誤差が発生し
ても、誤差補正部43によって分周信号の時刻誤差が補
正されているから、時計の精度を向上できる。
As described above, according to the embodiment of the time correction method and apparatus of the present invention, even if the basic oscillation frequency oscillated by the crystal oscillator 1 causes a time error by the frequency divider 31, the error correction unit 43 corrects the time error of the frequency-divided signal, so that the accuracy of the clock can be improved.

【0059】また、タイマ割込みカウント部37による
割込みカウント数の加算処理及び前記誤差補正部43に
よる時刻誤差の補正処理を繰り返し行なうので、時間の
経過とともに累積される時刻誤差が1秒毎に補正され、
その効果は大である。
Further, since the addition processing of the interrupt count number by the timer interrupt counting section 37 and the correction processing of the time error by the error correction section 43 are repeatedly performed, the time error accumulated with the passage of time is corrected every second. ,
The effect is great.

【0060】なお、本発明は、前記実施の形態に限定さ
れるものではない。実施の形態では、図2に示すフロー
チャートにおいて、ステップS13の基準カウント数の
算出処理を行なった後に、ステップS15のタイマ割込
みカウント数の算出処理を行なった。
The present invention is not limited to the above embodiment. In the embodiment, in the flowchart shown in FIG. 2, after performing the reference count calculation process in step S13, the timer interrupt count calculation process in step S15 is performed.

【0061】例えば、実施の形態の処理とは、逆に、タ
イマ割込みカウント数の算出処理を行なった後に、基準
カウント数の算出処理を行なうようにしてもよい。
For example, in contrast to the processing of the embodiment, the calculation processing of the reference count number may be performed after the calculation processing of the timer interrupt count number is performed.

【0062】[0062]

【発明の効果】本発明によれば、基準カウント部が、分
周器からタイマに出力される信号のクロック周期で単位
時間を除算することにより基準カウント数を求め、タイ
マ割込みカウント部が、タイマに設定されたタイマ割込
み時間を前記クロック周期で除算することにより割込み
カウント数を求めタイマ割込み発生毎に割込みカウント
数を順次加算する。
According to the present invention, the reference count unit obtains the reference count number by dividing the unit time by the clock cycle of the signal output from the frequency divider to the timer, and the timer interrupt count unit determines By dividing the timer interrupt time set in (1) by the clock cycle, an interrupt count number is obtained, and the interrupt count number is sequentially added every time a timer interrupt occurs.

【0063】誤差補正部は、得られた加算割込みカウン
ト数が基準カウント数を超えた場合に加算割込みカウン
ト数から基準カウント数を減算し剰余カウント数を次回
のタイマ割込み発生時における加算割込みカウント数の
初期値とすることで時刻誤差を補正する。
The error correction unit subtracts the reference count number from the added interrupt count number when the obtained added interrupt count number exceeds the reference count number, and calculates the remainder count number when the next timer interrupt occurs. The time error is corrected by setting the initial value of.

【0064】すなわち、基本発振器で発振した基本発振
周波数が分周器によって時刻誤差が発生しても、誤差補
正部によって分周信号の時刻誤差が補正されているか
ら、時計の精度を向上できる。
That is, even if a time error occurs in the basic oscillation frequency oscillated by the basic oscillator due to the frequency divider, the time error of the frequency-divided signal is corrected by the error correction unit, so that the accuracy of the timepiece can be improved.

【0065】また、タイマ割込みカウント部による割込
みカウント数の加算処理及び前記誤差補正部による時刻
誤差の補正処理を繰り返し行なうので、時間の経過とと
もに累積される時刻誤差が補正される。
Further, since the addition processing of the interrupt count number by the timer interrupt counting section and the correction processing of the time error by the error correction section are repeated, the time error accumulated with the passage of time is corrected.

【0066】さらに、第1のステップで、分周器からタ
イマに出力される信号のクロック周期で単位時間を除算
することにより基準カウント数を求め、第2のステップ
で、タイマに設定されたタイマ割込み時間を前記クロッ
ク周期で除算することにより割込みカウント数を求め
る。
Further, in a first step, a reference count is obtained by dividing a unit time by a clock cycle of a signal output from the frequency divider to the timer, and in a second step, the timer set in the timer is set. An interrupt count is obtained by dividing the interrupt time by the clock cycle.

【0067】第3のステップで、タイマ割込み発生毎に
割込みカウント数を順次加算し、第4のステップで、得
られた加算割込みカウント数が基準カウント数を超えた
場合に加算割込みカウント数から基準カウント数を減算
し剰余カウント数を次回のタイマ割込み発生時における
加算割込みカウント数の初期値とすることで時刻誤差を
補正する。
In the third step, the count value of the interrupt is sequentially incremented each time a timer interrupt occurs. In the fourth step, when the obtained count value of the interrupt count exceeds the reference count value, the count value of the interrupt count value is added to the reference value. The time error is corrected by subtracting the count number and setting the remainder count number as the initial value of the added interrupt count number when the next timer interrupt occurs.

【0068】すなわち、基本発振器で発振した基本発振
周波数が分周器によって時刻誤差が発生しても、分周信
号の時刻誤差が補正されるから時計の精度を向上でき
る。
That is, even if a time error occurs in the basic oscillation frequency oscillated by the basic oscillator due to the frequency divider, the time error of the divided signal is corrected, so that the accuracy of the timepiece can be improved.

【0069】また、第3のステップの割込みカウント数
の加算処理及び第4のステップの時刻誤差の補正処理を
繰り返し行なうので、時間の経過とともに累積される時
刻誤差が補正される。
The addition of the interrupt count in the third step and the correction of the time error in the fourth step are repeatedly performed, so that the time error accumulated with the passage of time is corrected.

【図面の簡単な説明】[Brief description of the drawings]

【図1】本発明の時刻補正装置の実施の形態を示す構成
図である。
FIG. 1 is a configuration diagram showing an embodiment of a time correction device of the present invention.

【図2】本発明の時刻補正方法を示すフローチャートで
ある。
FIG. 2 is a flowchart illustrating a time correction method according to the present invention.

【図3】本発明の時刻補正装置の動作を説明するための
タイミングチャートである。
FIG. 3 is a timing chart for explaining the operation of the time correction device of the present invention.

【図4】従来の時刻計数方法を示すフローチャートであ
る。
FIG. 4 is a flowchart showing a conventional time counting method.

【図5】従来の時刻計数方法を説明するためのタイミン
グチャートである。
FIG. 5 is a timing chart for explaining a conventional time counting method.

【符号の説明】[Explanation of symbols]

1 水晶発振器 3 CPU 5 表示器ドライバIC 7 表示器 11 水晶振動子 13,15 コンデンサ 31 分周器 33 タイマ 35 基準カウント数算出部 37 タイマ割込みカウント数算出部 39 メモリ 41 カウント数比較部 43 誤差補正部 45 秒数カウンタ Reference Signs List 1 crystal oscillator 3 CPU 5 display driver IC 7 display 11 crystal oscillator 13, 15 capacitor 31 frequency divider 33 timer 35 reference count calculation unit 37 timer interrupt count calculation unit 39 memory 41 count comparison unit 43 error correction Part 45 seconds counter

Claims (4)

【特許請求の範囲】[Claims] 【請求項1】 基本発振器で発振した基本発振周波数を
分周器で分周した際に発生する時刻誤差を補正する時刻
補正装置において、 分周器からタイマに出力される信号のクロック周期で単
位時間を除算することにより基準カウント数を求める基
準カウント部と、 タイマに設定されたタイマ割込み時間を前記クロック周
期で除算することにより割込みカウント数を求め、タイ
マ割込み発生毎に割込みカウント数を順次加算するタイ
マ割込みカウント部と、 得られた加算割込みカウント数が基準カウント数を超え
た場合に加算割込みカウント数から基準カウント数を減
算し剰余カウント数を次回のタイマ割込み発生時におけ
る加算割込みカウント数の初期値とすることで時刻誤差
を補正する誤差補正部と、を備えることを特徴とする時
刻補正装置。
1. A time correction device for correcting a time error generated when a basic oscillation frequency oscillated by a basic oscillator is frequency-divided by a frequency divider, wherein a unit is a clock cycle of a signal output from the frequency divider to a timer. A reference count unit for obtaining a reference count number by dividing time; and an interrupt count number obtained by dividing a timer interrupt time set in a timer by the clock cycle, and sequentially adding the interrupt count number each time a timer interrupt occurs. A timer interrupt count unit that performs the following operations: if the obtained added interrupt count exceeds the reference count, subtracts the reference count from the added interrupt count, and sets the remainder count to the value of the added interrupt count when the next timer interrupt occurs. A time correction device for correcting a time error by setting an initial value. .
【請求項2】 前記タイマ割込みカウント部による割込
みカウント数の加算処理及び前記誤差補正部による時刻
誤差の補正処理を繰り返し行なうことを特徴とする請求
項1に記載の時刻補正装置。
2. The time correction device according to claim 1, wherein the timer interrupt counting section repeatedly performs an addition processing of an interrupt count number and a time error correction processing by the error correction section.
【請求項3】 基本発振器で発振した基本発振周波数を
分周器で分周した際に発生する時刻誤差を補正する時刻
補正方法において、 分周器からタイマに出力される信号のクロック周期で単
位時間を除算することにより基準カウント数を求める第
1のステップと、 タイマに設定されたタイマ割込み時間を前記クロック周
期で除算することにより割込みカウント数を求める第2
のステップと、 タイマ割込み発生毎に割込みカウント数を順次加算する
第3のステップと、 得られた加算割込みカウント数が基準カウント数を超え
た場合に加算割込みカウント数から基準カウント数を減
算し剰余カウント数を次回のタイマ割込み発生時におけ
る加算割込みカウント数の初期値とすることで時刻誤差
を補正する第4のステップと、を含むことを特徴とする
時刻補正方法。
3. A time correction method for correcting a time error generated when a basic oscillation frequency oscillated by a basic oscillator is frequency-divided by a frequency divider, wherein a unit is a clock cycle of a signal output from the frequency divider to a timer. A first step of obtaining a reference count number by dividing time; and a second step of obtaining an interrupt count number by dividing a timer interrupt time set in a timer by the clock cycle.
And a third step of sequentially adding the interrupt count number each time a timer interrupt occurs; and, when the obtained additional interrupt count number exceeds the reference count number, subtracting the reference count number from the additional interrupt count number to obtain a remainder. A fourth step of correcting a time error by setting the count number as an initial value of the added interrupt count number when a next timer interrupt occurs.
【請求項4】 前記第3のステップの割込みカウント数
の加算処理及び第4のステップの時刻誤差の補正処理を
繰り返し行なうことを特徴とする請求項3に記載の時刻
補正方法。
4. The time correction method according to claim 3, wherein the addition of the interrupt count in the third step and the correction of the time error in the fourth step are repeated.
JP17127596A 1996-07-01 1996-07-01 Time correction method and device therefor Pending JPH1020052A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP17127596A JPH1020052A (en) 1996-07-01 1996-07-01 Time correction method and device therefor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP17127596A JPH1020052A (en) 1996-07-01 1996-07-01 Time correction method and device therefor

Publications (1)

Publication Number Publication Date
JPH1020052A true JPH1020052A (en) 1998-01-23

Family

ID=15920314

Family Applications (1)

Application Number Title Priority Date Filing Date
JP17127596A Pending JPH1020052A (en) 1996-07-01 1996-07-01 Time correction method and device therefor

Country Status (1)

Country Link
JP (1) JPH1020052A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2693350A1 (en) * 1992-07-13 1994-01-14 Fruchet Monique Compact smoking and cooking unit - comprises stainless steel box contg. grills and drip tray suitable for domestic indoor and outdoor use
JP5143952B2 (en) * 2009-04-24 2013-02-13 三菱電機株式会社 Wireless base station
WO2014118984A1 (en) * 2013-02-04 2014-08-07 三菱電機株式会社 Signal processing apparatus
JP2015171151A (en) * 2014-03-06 2015-09-28 イーエム・ミクロエレクトロニク−マリン・エス アー Time base including oscillator, frequency divider circuit and clocking pulse inhibition circuit
CN105102991A (en) * 2013-03-29 2015-11-25 三菱电机株式会社 Signal processing device
JP2016184366A (en) * 2015-03-27 2016-10-20 日本電気株式会社 Timer correction device, timer correction method, and timer correction program

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2693350A1 (en) * 1992-07-13 1994-01-14 Fruchet Monique Compact smoking and cooking unit - comprises stainless steel box contg. grills and drip tray suitable for domestic indoor and outdoor use
JP5143952B2 (en) * 2009-04-24 2013-02-13 三菱電機株式会社 Wireless base station
US8688059B2 (en) 2009-04-24 2014-04-01 Mitsubishi Electric Corporation Wireless base station with internal clock correction
WO2014118984A1 (en) * 2013-02-04 2014-08-07 三菱電機株式会社 Signal processing apparatus
CN105026938A (en) * 2013-02-04 2015-11-04 三菱电机株式会社 Signal processing apparatus
GB2527685A (en) * 2013-02-04 2015-12-30 Mitsubishi Electric Corp Signal processing apparatus
JP5936716B2 (en) * 2013-02-04 2016-06-22 三菱電機株式会社 Signal processing device
GB2527685B (en) * 2013-02-04 2018-03-21 Mitsubishi Electric Corp Signal processing apparatus
CN105102991A (en) * 2013-03-29 2015-11-25 三菱电机株式会社 Signal processing device
JP2015171151A (en) * 2014-03-06 2015-09-28 イーエム・ミクロエレクトロニク−マリン・エス アー Time base including oscillator, frequency divider circuit and clocking pulse inhibition circuit
JP2016184366A (en) * 2015-03-27 2016-10-20 日本電気株式会社 Timer correction device, timer correction method, and timer correction program

Similar Documents

Publication Publication Date Title
KR100687230B1 (en) Real time clock apparatus and the real time compensating method thereof
JP5886015B2 (en) Time measuring device, microcontroller, program, and time measuring method
JP2624176B2 (en) Electronic clock and time correction method
US4708491A (en) Time of day clock
JP3181396B2 (en) Clock generation circuit
JPH07154243A (en) Electronic clock device and method and device for correction value decision device
JPH1020052A (en) Time correction method and device therefor
JP2000174615A (en) Method and device for automatically correcting internal clock frequency of integrated circuit
US7118269B2 (en) Method of correcting a real-time clock of an electronic apparatus
JP3930773B2 (en) Frequency correction circuit
JP2009165069A (en) Frequency correction circuit and clock installation using the circuit
JP3160137B2 (en) Radio-controlled clock
JP2002228778A (en) Real-time clock and clocking circuit
JP3937026B2 (en) Pointer-type electronic watch
JP2022006391A (en) Frequency measuring device, microcontroller and electronic device
JP2900154B1 (en) Electronic clock with auto calendar
JP2002311173A (en) Electronic clock, method and program for correcting time error of the same
JP3281757B2 (en) Automatic correction device for oscillation error in electronic timepiece
JPH07244540A (en) Highly accurate clock device
JP3736511B2 (en) Time changing method and clock circuit using the same
JP2016184366A (en) Timer correction device, timer correction method, and timer correction program
JP2776791B2 (en) Horizontal frequency measuring device and its measuring method
JP2023151392A (en) Timer circuit, semiconductor device, and interruption control method
KR100762178B1 (en) Timer error correcting method of display apparatus
JPH066211A (en) Reference oscillator and its control method