JP2002168890A - Frequency detection method and device and recording medium - Google Patents

Frequency detection method and device and recording medium

Info

Publication number
JP2002168890A
JP2002168890A JP2000365501A JP2000365501A JP2002168890A JP 2002168890 A JP2002168890 A JP 2002168890A JP 2000365501 A JP2000365501 A JP 2000365501A JP 2000365501 A JP2000365501 A JP 2000365501A JP 2002168890 A JP2002168890 A JP 2002168890A
Authority
JP
Japan
Prior art keywords
bits
value
input signal
detecting
frequency
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
JP2000365501A
Other languages
Japanese (ja)
Other versions
JP4510274B2 (en
Inventor
Yoshio Hattori
好雄 服部
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.)
Panasonic Holdings Corp
Original Assignee
Matsushita Electric Industrial 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 Matsushita Electric Industrial Co Ltd filed Critical Matsushita Electric Industrial Co Ltd
Priority to JP2000365501A priority Critical patent/JP4510274B2/en
Publication of JP2002168890A publication Critical patent/JP2002168890A/en
Application granted granted Critical
Publication of JP4510274B2 publication Critical patent/JP4510274B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To provide a frequency detection method, device and recording medium cheaply realizing a signal processor capable of accurately detecting frequency of input signal in wide frequency range with a simple processing. SOLUTION: The memory variable of RAM 125 is constituted as a counter enlarged to 31(=N+M-n) bits. At a higher level of the bit-enlarged counter, a count integrating value of the compare match interruption is allotted, and at a lower level, the value of in, put capture register 117 is allotted. For correspondence of an overlapping 1(=N) bit that is, upper one bit of input capture register 117 and a lower one bit of the integrated count of the compare match interruption, the integrated count of the compare match interruption is halved and set to the upper 15(=M-n) bits. By detecting the period of input signal from the difference from the prior value of the bit-enlarged counter, the frequency of the input signal is detected.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明は、マルチスキャンモ
ニタや液晶ディスプレイモニタ等の表示装置における同
期信号の周波数を検出する信号処理装置の周波数検出方
法、周波数検出装置および該周波数検出方法を実行させ
るためのプログラムを記録した記録媒体に係り、特に、
マイクロコンピュータ内蔵のカウンタを変更することな
くビット長を拡張し、入力信号の周波数をより簡単な処
理で広範囲の周波数帯に渡って高精度で検出し得る信号
処理装置を安価で実現可能な周波数検出方法、周波数検
出装置および記録媒体に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a frequency detection method for a signal processing device for detecting the frequency of a synchronization signal in a display device such as a multi-scan monitor or a liquid crystal display monitor, and to execute the frequency detection method. Related to a recording medium recording the program of
A frequency detector that expands the bit length without changing the built-in counter of the microcomputer and can realize a signal processing device that can detect the frequency of the input signal with high accuracy over a wide frequency band by simple processing at low cost. The present invention relates to a method, a frequency detection device, and a recording medium.

【0002】[0002]

【従来の技術】マルチスキャンディスプレイに接続され
た各種タイプのコンピュータ機器では、ディスプレイに
出力される映像信号の水平同期信号および垂直同期信号
の周波数が異なっていることが多い。
2. Description of the Related Art In various types of computer equipment connected to a multi-scan display, the frequency of the horizontal synchronizing signal and the frequency of the vertical synchronizing signal of the video signal output to the display are often different.

【0003】したがって、マルチスキャンディスプレイ
においては、それに接続されるコンピュータ機器からの
データを表示するために、水平同期信号および垂直同期
信号それぞれの周波数を検出すると共に、検出した水平
同期信号および垂直同期信号それぞれの周波数に追従し
て、表示デバイスが例えばCRTであれば水平および垂
直偏向回路、或いは液晶表示パネルであれば駆動回路を
制御する必要がある。
Therefore, in a multi-scan display, in order to display data from a computer device connected to the multi-scan display, the frequency of each of a horizontal synchronization signal and a vertical synchronization signal is detected, and the detected horizontal synchronization signal and vertical synchronization signal are detected. Following the respective frequencies, it is necessary to control horizontal and vertical deflection circuits if the display device is, for example, a CRT, or drive circuits if the display device is a liquid crystal display panel.

【0004】ディスプレイの制御は複雑であるため、組
み込み機器用マイクロコンピュータ等の信号処理装置を
内蔵しているディスプレイが多く、同期信号周波数の検
出についてもコスト低減の効果も兼ねてマイクロコンピ
ュータ内蔵のカウンタを用いて行っていた。
[0004] Since the control of the display is complicated, many displays have a built-in signal processing device such as a microcomputer for embedded devices. Was performed using

【0005】近年の組み込み機器用マイクロコンピュー
タは、基準となるクロック信号をカウントするカウンタ
と、該カウンタの値をラッチするレジスタを内蔵してお
り、入力信号の立ち上がりまたは立ち下がりに同期し
て、カウンタの値を内蔵のレジスタにラッチする機能が
組み込まれている。このラッチ機能は一般的にはインプ
ットキャプチャと呼ばれており、インプットキャプチャ
が発生した時にインプットキャプチャ割込みを発生させ
ることができる。
Recent microcomputers for embedded devices incorporate a counter for counting a reference clock signal and a register for latching the value of the counter. The counter is synchronized with the rising or falling of the input signal. The function of latching the value of into a built-in register is incorporated. This latch function is generally called input capture, and can generate an input capture interrupt when input capture occurs.

【0006】入力信号の周波数検出方法としては、同期
信号の立ち下がりエッジでインプットキャプチャした時
のカウンタ値をA、次の立ち下がりのエッジでインプッ
トキャプチャした時のカウンタ値をBとすると、同期信
号の周期は式B−Aで求まる。このようにして求めた周
期から周波数が検出できる。
As a method of detecting the frequency of an input signal, a counter value when input capture is performed at the falling edge of the synchronization signal is A, and a counter value when input capture is performed at the next falling edge is B. Is obtained by the formula BA. The frequency can be detected from the cycle thus obtained.

【0007】ところで、近年、マルチスキャンディスプ
レイに入力される同期信号の周波数が増大し、UXGA
(Ultra Extended Graphics Array)と呼ばれる高解像
度ディスプレイの規格においては、水平110[kH
z]以上、垂直90[Hz]以上の同期周波数を検出で
きなければならない。さらに、下限は、VESA(Vide
o Electronics Standards Association)のDPMS(D
isplay Power Management Signaling)で10[Hz]
以下を無信号と規定しているため、10[Hz]以下ま
で検出が可能でなければならない。
In recent years, the frequency of a synchronization signal input to a multi-scan display has increased, and
(Ultra Extended Graphics Array), a standard for a high-resolution display is a horizontal 110 [kHz]
z] and a synchronization frequency of 90 [Hz] or more in vertical direction must be detected. Further, the lower limit is VESA (Vide
o Electronics Standards Association's DPMS (D
10 [Hz] with isplay Power Management Signaling
Since the following is defined as no signal, detection must be possible up to 10 [Hz] or less.

【0008】更に、近年普及してきた液晶ディスプレイ
でマルチスキャンを行なおうとすれば、解像度変換に高
精度な入力信号周波数の情報が必要となる。
Further, if multi-scanning is to be performed on a liquid crystal display that has become widespread in recent years, it is necessary to accurately input frequency information of the input signal for resolution conversion.

【0009】ところが、従来の回路では、検出精度を上
げるためにカウンタに入力するクロック周波数を増加さ
せて分解能を向上させた場合に、長い周期の入力信号の
検出を行うための装置コストが上昇することがある。こ
れは、高いクロック周波数で長い周期の入力信号(同期
信号)を検出しようとすると、長いビット長のカウンタ
が必要になるが、現在普及しているマイクロコンピュー
タ内蔵のカウンタのビット数は16ビット長がほとんど
であり、20ビットないし24ビット長のカウンタを備
えた構成にしようとするとコストが上昇するからであ
る。一方、長い周期の入力信号の検出を可能にするため
に、カウンタに入力するクロック周波数を低下させれば
検出精度が低下することになる。
However, in the conventional circuit, if the resolution is improved by increasing the clock frequency input to the counter in order to increase the detection accuracy, the cost of the device for detecting an input signal having a long cycle increases. Sometimes. In order to detect an input signal (synchronization signal) having a long cycle at a high clock frequency, a counter having a long bit length is required. This is because the cost increases if a configuration having a counter having a length of 20 to 24 bits is used. On the other hand, if the clock frequency input to the counter is reduced to enable detection of an input signal having a long cycle, the detection accuracy is reduced.

【0010】このような問題に対処する一手法として、
例えば特開2000−131355号公報には、マイク
ロコンピュータのソフトウェアを用いた同期信号の周波
数検出方法が提案されている。この従来の周波数検出方
法は、マイクロコンピュータ内蔵の機能とソフトウェア
制御を用いてカウンタのビット長を拡張することによ
り、マイクロコンピュータ内蔵のカウンタを変更するこ
となく周波数検出を行うもので、入力信号の入力時点に
おいて、所定周期で動作するカウンタのオーバーフロー
回数とカウンタの値とを用いて入力信号の周期を検出す
るものである。
[0010] As one method for addressing such a problem,
For example, Japanese Patent Laying-Open No. 2000-131355 proposes a method of detecting the frequency of a synchronization signal using software of a microcomputer. This conventional frequency detection method performs frequency detection without changing the built-in counter of the microcomputer by extending the bit length of the counter using the function and software control of the built-in microcomputer. At this point, the cycle of the input signal is detected using the number of overflows of the counter operating at a predetermined cycle and the value of the counter.

【0011】[0011]

【発明が解決しようとする課題】しかしながら、上記従
来の周波数検出方法にあっては、ソフトウェア制御によ
るカウンタのビット長の拡張において、ハードウェアカ
ウンタとソフトウェアで拡張したカウンタとが完全に同
期していないという問題がある。また、入力信号を検出
する割込みとカウンタのビット長を拡張するための割込
みが同時に発生した場合において、拡張したカウンタ値
を使用する際に、ハードウェアカウンタに同期していな
い拡張したカウンタの値を補正する必要があり、さらに
その補正処理のために多重割込みの発生確認や発生の前
後関係を確認するなど、複雑な処理を必要としていた。
However, in the above conventional frequency detection method, when the bit length of the counter is extended by software control, the hardware counter and the counter extended by software are not completely synchronized. There's a problem. When an interrupt to detect an input signal and an interrupt to extend the bit length of the counter occur at the same time, the value of the extended counter that is not synchronized with the hardware counter is corrected when using the extended counter value. In addition, complicated processing such as confirmation of the occurrence of multiple interrupts and confirmation of the context of the occurrence is required for the correction processing.

【0012】図7および図8には、入力信号の入力タイ
ミングとカウンタのオーバーフローのタイミングとが衝
突を起こした場合に、補正処理を行って検出精度を維持
するための従来の周波数検出方法の処理を説明するフロ
ーチャートを示す。
FIGS. 7 and 8 show a conventional frequency detection method for maintaining a detection accuracy by performing a correction process when a collision occurs between the input timing of an input signal and the overflow timing of a counter. Is shown.

【0013】先ず、図7に示したオーバーフロー割込み
処理では、ステップS701において、オーバーフロー
割込み(カウンタのビット長を拡張するための割込み)
と同期信号割込み(入力信号を検出する割込み)とが衝
突を起こしているか否かを判断する。同期信号割込み要
求が無いときには衝突が起こっていないので、ステップ
S702に進んで、ビット拡張されたカウンタの拡張ビ
ット分(以下、拡張BITという)をインクリメントし
て終了する。また、同期信号割込み要求が有るときには
衝突が起こってるので、ステップS703で衝突フラグ
をセットして終了し、拡張BITの内容は同期信号割込
み処理で行われる補正処理の過程で決定されることにな
る。
First, in the overflow interrupt processing shown in FIG. 7, in step S701, an overflow interrupt (interrupt for extending the bit length of the counter) is performed.
Then, it is determined whether or not a collision has occurred with a synchronous signal interrupt (an interrupt for detecting an input signal). When there is no synchronous signal interrupt request, since no collision has occurred, the process proceeds to step S702, where the number of extension bits of the bit-extended counter (hereinafter, referred to as extension BIT) is incremented, and the process ends. Also, when there is a synchronization signal interrupt request, a collision occurs, so the collision flag is set in step S703 and the processing is terminated, and the contents of the extended BIT are determined in the course of the correction processing performed in the synchronization signal interruption processing. .

【0014】次に、図8に示した同期信号割込み処理で
は、ステップS801において、割込み発生時のインプ
ットキャプチャ値をメモリ変数Nowの下位に保存す
る。次に、ステップS802では衝突フラグの内容を確
認し、衝突フラグがクリアで衝突が発生していないとき
には、ステップS803に進んで拡張BITをメモリ変
数Nowの上位に保存した後、ステップS810に進
む。
Next, in the synchronous signal interrupt processing shown in FIG. 8, in step S801, the input capture value at the time of occurrence of the interrupt is stored below the memory variable Now. Next, in step S802, the content of the collision flag is checked. If the collision flag is clear and no collision has occurred, the process proceeds to step S803, where the extended BIT is stored above the memory variable Now, and then the process proceeds to step S810.

【0015】一方、衝突フラグがセットされて衝突が発
生しているときには、ステップS804で衝突フラグを
クリアした後、ステップS805において、メモリ変数
Nowの下位が特定値以下か否かを判断する。特定値以
上の場合は同期信号割込みがオーバーフロー割込みより
も先に起こった場合であり、ステップS806で拡張B
ITをメモリ変数Nowの上位に保存した後、ステップ
S807で拡張BITをインクリメントして、ステップ
S810に進む。また、ステップS805において、特
定値以下の場合は同期信号割込みがオーバーフロー割込
みよりも後に起こった場合であり、ステップS808で
拡張BITをインクリメントした後、ステップS809
で拡張BITをメモリ変数Nowの上位に保存して、ス
テップS810に進む。
On the other hand, when the collision flag has been set and a collision has occurred, the collision flag is cleared in step S804, and in step S805, it is determined whether the lower order of the memory variable Now is equal to or smaller than a specific value. If the value is equal to or more than the specific value, it means that the synchronization signal interrupt occurs before the overflow interrupt.
After the IT is stored above the memory variable Now, the extension BIT is incremented in step S807, and the process proceeds to step S810. If the value is equal to or less than the specific value in step S805, it means that the synchronization signal interrupt has occurred after the overflow interrupt. After the extension BIT is incremented in step S808, the process proceeds to step S809.
To save the extended BIT above the memory variable Now, and then proceed to step S810.

【0016】次に、ステップS810では、メモリ変数
Nowからメモリ変数Lastを差し引く。メモリ変数
Nowには今回の同期信号割込み時点の拡張カウンタの
値が記憶され、メモリ変数Lastには前回の同期信号
割込み時点の拡張カウンタの値が記憶されているので、
これらの差を求めることにより入力信号(同期信号)の
周期を求めることができる。ステップS811では、メ
モリ変数Lastをメモリ変数Nowで更新して次の同
期信号割込み処理に備えて終了する。
Next, in step S810, the memory variable Last is subtracted from the memory variable Now. Since the memory variable Now stores the value of the extension counter at the time of the current synchronization signal interruption, and the memory variable Last stores the value of the extension counter at the time of the previous synchronization signal interruption.
By calculating these differences, the period of the input signal (synchronous signal) can be determined. In step S811, the memory variable Last is updated with the memory variable Now, and the process ends in preparation for the next synchronization signal interruption process.

【0017】本発明は、上記従来の事情に鑑みてなされ
たものであって、マイクロコンピュータ内蔵の機能とソ
フトウェア制御を用いてカウンタのビット長を拡張する
ことにより周波数検出を行うものであって、ハードウェ
アカウンタを変更することなくビット長を拡張し、入力
信号の周波数をより簡単な処理で広範囲の周波数帯に渡
って高精度で検出し得る信号処理装置を安価で実現可能
な周波数検出方法、周波数検出装置および記録媒体を提
供することを目的としている。
The present invention has been made in view of the above-mentioned conventional circumstances, and performs frequency detection by extending the bit length of a counter using a function built in a microcomputer and software control. An inexpensive frequency detection method and frequency that can increase the bit length without changing the hardware counter and realize a signal processing device that can detect the frequency of the input signal with high accuracy over a wide frequency band with simpler processing It is an object to provide a detection device and a recording medium.

【0018】また、本発明の他の目的は、入力信号を検
出する割込みとカウンタのビット長を拡張するための割
込みが同時に発生した場合においても、より簡単な補正
処理によりハードウェアカウンタと拡張したカウンタと
の同期をとって、広範囲の周波数帯に渡って高精度で検
出可能な周波数検出方法、周波数検出装置および記録媒
体を提供することである。
Another object of the present invention is to provide a hardware counter and an extended counter by a simpler correction process even when an interrupt for detecting an input signal and an interrupt for extending the bit length of the counter occur simultaneously. The present invention provides a frequency detection method, a frequency detection device, and a recording medium capable of detecting with high accuracy over a wide frequency band in synchronization with the above.

【0019】[0019]

【課題を解決するための手段】上記課題を解決するため
に、本発明の請求項1に係る周波数検出方法は、入力信
号の周期を検出することで周波数を検出する周波数検出
方法であって、前記入力信号の入力時点において、上位
nビット(nは正整数)が0から2n−1までの2n個の
整数値を持ち、下位N−nビット(Nは正整数)が0を
持つ2n個の比較設定値と、所定クロックで動作するN
ビットカウンタの値とを順次比較して、一致した時に発
生する比較一致割込みを用いて計算される比較一致割込
みの回数と、前記Nビットカウンタの値とを用いて前記
入力信号の周期を検出するものである。
According to a first aspect of the present invention, there is provided a frequency detecting method for detecting a frequency by detecting a period of an input signal. At the time of input of the input signal, upper n bits (n is a positive integer) have 2 n integer values from 0 to 2 n -1 and lower N−n bits (N is a positive integer) have 0 2 n comparison set values and N operating at a predetermined clock
The value of the bit counter is sequentially compared, and the cycle of the input signal is detected by using the number of comparison match interrupts calculated using a comparison match interrupt generated when a match occurs and the value of the N-bit counter. Things.

【0020】また、請求項2に係る周波数検出方法は、
請求項1に記載の周波数検出方法において、前記入力信
号の入力時点における前記Nビットカウンタの値を、イ
ンプットキャプチャ機能を用いて得るものである。
Further, the frequency detecting method according to claim 2 comprises:
2. The frequency detection method according to claim 1, wherein the value of the N-bit counter at the time of input of the input signal is obtained using an input capture function.

【0021】また、請求項3に係る周波数検出方法は、
請求項1または2に記載の周波数検出方法において、前
記入力信号の周期の検出を、前記入力信号の入力時に発
生する入力信号割込み処理において行うものである。
The frequency detecting method according to claim 3 is
3. The frequency detection method according to claim 1, wherein the detection of the cycle of the input signal is performed in an input signal interruption process that occurs when the input signal is input.

【0022】また、請求項4に係る周波数検出方法は、
請求項1、2または3に記載の周波数検出方法におい
て、前記入力信号の入力タイミングと前記比較一致割込
みのタイミングとが衝突を起こした場合には、前記Nビ
ットカウンタの上位nビットと前記比較一致割込みの回
数の下位nビットが一意に対応しているか否かにより、
前記Nビットカウンタの値と前記比較一致割込みの回数
とが同期しているか否かを検出し、同期していないとき
に、前記比較一致割込みの回数を前記Nビットカウンタ
の値で補正するものである。
Further, the frequency detecting method according to claim 4 is
4. The frequency detection method according to claim 1, wherein when the input timing of the input signal collides with the timing of the comparison coincidence interrupt, the upper n bits of the N-bit counter are compared with the comparison coincidence. 5. Depending on whether or not the lower n bits of the number of interrupts uniquely correspond,
It detects whether or not the value of the N-bit counter is synchronized with the number of comparison match interrupts, and when not synchronized, corrects the number of comparison match interrupts with the value of the N-bit counter. is there.

【0023】また、請求項5に係る周波数検出方法は、
所定クロックを計時するNビットカウンタ(Nは正整
数)と、2個のN+M−nビット(M,nは正整数)の
データをそれぞれ第1および第2領域に保持する記憶手
段と、を備え、入力信号の周期を検出することで周波数
を検出する信号処理装置の周波数検出方法において、前
記入力信号の立ち上がりまたは立ち下がりエッジを検出
して同期信号割込みを発生する信号検出ステップと、上
位nビットが0から2n−1までの2n個の整数値を持
ち、下位N−nビットが0を持つ2n個の比較設定値
と、前記Nビットカウンタの値を順次比較して、一致し
た時に比較一致割込みを発生する比較ステップと、前記
比較一致割込みの回数を積算する積算ステップと、前記
同期信号割込み発生時に、前記記憶手段の第1領域の下
位Nビットに前記Nビットカウンタの値をセットし、該
第1領域の上位M−nビットに前記積算ステップの積算
結果を1/2nしてセットする計数値生成ステップと、
前記記憶手段の第1領域から第2領域を引いた差分から
前記入力信号の周期を求める周期検出ステップと、前記
記憶手段の第1領域の内容を第2領域に書込む更新ステ
ップとを具備するものである。
Further, the frequency detecting method according to claim 5 is
An N-bit counter (N is a positive integer) for clocking a predetermined clock; and storage means for holding two N + M-n bits (M and n are positive integers) in the first and second areas, respectively. A signal detection step of detecting a rising or falling edge of the input signal to generate a synchronization signal interrupt, wherein the signal detection step detects a rising or falling edge of the input signal; There has 2 n pieces of integral values from 0 to 2 n -1, 2 n number of comparison settings lower n-n bits has a 0, and sequentially comparing the value of said n-bit counter, consistent A comparing step of generating a comparison coincidence interrupt, an accumulation step of accumulating the number of times of the comparison coincidence interrupt, and, when the synchronizing signal interruption occurs, the lower N bits of the first area of the storage means have the N bits. A count value generating step of setting the value of a counter to the upper M-n bits of the first area and setting the integration result of the integration step as 1/2 n .
A period detecting step of obtaining a period of the input signal from a difference obtained by subtracting a second region from a first region of the storage unit; and an updating step of writing the contents of the first region of the storage unit into the second region. Things.

【0024】また、請求項6に係る周波数検出方法は、
請求項5に記載の周波数検出方法において、前記Nビッ
トカウンタの上位nビットと前記積算ステップの積算結
果の下位nビットとが一致するか否かを検出する同期検
出ステップと、前記同期検出ステップで一致していない
ときに、前記積算ステップの積算結果を前記Nビットカ
ウンタの値で補正して前記計数値生成ステップに与える
補正ステップとを具備するものである。
Further, a frequency detecting method according to claim 6 is
6. The frequency detection method according to claim 5, wherein: a synchronization detection step of detecting whether or not upper n bits of the N-bit counter and lower n bits of the integration result of the integration step match; And a correction step of correcting the integration result of the integration step with the value of the N-bit counter and giving the result to the count value generation step when they do not match.

【0025】また、請求項7に係る周波数検出装置は、
入力信号の周期を検出することで周波数を検出する周波
数検出装置において、前記入力信号の立ち上がりまたは
立ち下がりエッジを検出して同期信号割込みを発生する
信号検出手段と、所定クロックを計時するNビットカウ
ンタ(Nは正整数)と、上位nビット(nは正整数)が
0から2n−1までの2n個の整数値を持ち、下位N−n
ビットが0を持つ2n個の比較設定値と、前記Nビット
カウンタの値を順次比較して、一致した時に比較一致割
込みを発生する比較手段と、前記比較一致割込みの回数
を積算する積算手段と、2個のN+M−nビット(Mは
正整数)のデータをそれぞれ第1および第2領域に保持
する記憶手段と、前記同期信号割込み発生時に、前記記
憶手段の第1領域の下位Nビットに前記Nビットカウン
タの値をセットし、該第1領域の上位M−nビットに前
記積算手段の積算結果を1/2nしてセットする計数値
生成手段と、前記記憶手段の第1領域から第2領域を引
いた差分から前記入力信号の周期を求める周期検出手段
と、前記記憶手段の第1領域の内容を第2領域に書込む
更新手段とを具備するものである。
Further, the frequency detecting device according to claim 7 is
In a frequency detection device for detecting a frequency by detecting a cycle of an input signal, a signal detection means for detecting a rising or falling edge of the input signal to generate a synchronization signal interrupt, and an N-bit counter for timing a predetermined clock (N is a positive integer) and the upper n bits (n is a positive integer) have 2 n integer values from 0 to 2 n -1 and the lower N−n
A comparison means for sequentially comparing 2 n comparison set values whose bits are 0 and the value of the N-bit counter and generating a comparison match interrupt when they match, and an integration means for integrating the number of comparison match interrupts Storage means for holding two N + M-n bits (M is a positive integer) of data in the first and second areas, respectively, and when the synchronous signal interrupt occurs, the lower N bits of the first area of the storage means A count value generating means for setting the value of the N-bit counter to the upper M-n bits of the first area by setting the integration result of the integrating means to 1/2 n; and a first area of the storage means. A period detecting means for obtaining a period of the input signal from a difference obtained by subtracting a second area from the first area; and an updating means for writing the contents of the first area of the storage means into the second area.

【0026】また、請求項8に係る周波数検出装置は、
請求項7に記載の周波数検出装置において、前記Nビッ
トカウンタの上位nビットと前記積算手段の積算結果の
下位nビットとが一致するか否かを検出する同期検出手
段と、前記同期検出手段で一致していないときに、前記
積算手段の積算結果を前記Nビットカウンタの値で補正
して前記計数値生成手段に与える補正手段とを具備する
ものである。
Further, the frequency detecting device according to claim 8 is:
8. The frequency detection device according to claim 7, wherein the synchronization detection means detects whether the upper n bits of the N-bit counter match the lower n bits of the integration result of the integration means, and the synchronization detection means. And correcting means for correcting the integration result of the integration means with the value of the N-bit counter and providing the correction result to the count value generation means when they do not match.

【0027】さらに、請求項9に係るコンピュータによ
り読み取り可能な記録媒体は、請求項1、2、3、4、
5または6に記載の周波数検出方法をコンピュータに実
行させるためのプログラムとして記録したものである。
According to a ninth aspect of the present invention, there is provided a computer-readable recording medium.
It is recorded as a program for causing a computer to execute the frequency detection method described in 5 or 6.

【0028】本発明の請求項1、2および3に係る周波
数検出方法および請求項9に係る記録媒体では、入力信
号の入力時点において、上位nビットが0から2n−1
までの2n個の整数値を持ち、下位N−nビットが0を
持つ2n個の比較設定値と、所定クロックで動作するN
ビットカウンタの値とを順次比較して、一致した時に発
生する比較一致割込みを用いて計算される比較一致割込
みの回数と、Nビットカウンタの値とを用いて入力信号
の周期を検出し、該検出周期から周波数を求めるように
している。また特に、請求項2に係る周波数検出方法で
は、入力信号の入力時点におけるNビットカウンタの値
をインプットキャプチャ機能を用いて得るようにし、さ
らに、請求項3に係る周波数検出方法では、入力信号の
周期の検出を入力信号の入力時に発生する入力信号割込
み処理において行うようにしている。
In the frequency detecting method according to the first, second and third aspects of the present invention and the recording medium according to the ninth aspect, the upper n bits are 0 to 2 n -1 at the time of input of the input signal.
2 n comparison setting values having 2 n integer values up to and having lower N−n bits of 0, and N operating at a predetermined clock.
The value of the bit counter is sequentially compared, and the number of times of the comparison coincidence interrupt calculated using the comparison coincidence interrupt generated at the time of coincidence is detected, and the cycle of the input signal is detected using the value of the N bit counter. The frequency is obtained from the detection cycle. In particular, in the frequency detection method according to the second aspect, the value of the N-bit counter at the time of input of the input signal is obtained by using the input capture function. The detection of the period is performed in an input signal interruption process that occurs when an input signal is input.

【0029】このように、マイクロコンピュータ内蔵の
機能とソフトウェア制御を用いてハードウェアカウンタ
を変更することなくカウンタのビット長を拡張し、カウ
ンタのビット長の制限を受けないため、入力信号の周波
数を広範囲の周波数帯に渡って高精度で検出し得る信号
処理装置を安価で実現できる。
As described above, the bit length of the counter is extended without changing the hardware counter by using the functions and software control built in the microcomputer and the bit length of the counter is not restricted. Thus, a signal processing device capable of detecting with high accuracy over the frequency band described above can be realized at low cost.

【0030】また、請求項5に係る周波数検出方法、請
求項7に係る周波数検出装置および請求項9に係る記録
媒体では、信号検出手段(信号検出ステップ)により入
力信号の立ち上がりまたは立ち下がりエッジを検出して
同期信号割込みを発生し、比較手段(比較ステップ)に
より、上位nビットが0から2n−1までの2n個の整数
値を持ち、下位N−nビットが0を持つ2n個の比較設
定値と、所定クロックを計時するNビットカウンタの値
を順次比較して、一致した時に比較一致割込みを発生
し、積算手段(積算ステップ)により比較一致割込みの
回数を積算し、計数値生成手段(計数値生成ステップ)
では、同期信号割込み発生時に、記憶手段の第1領域の
下位NビットにNビットカウンタの値をセットし、該第
1領域の上位M−nビットに積算手段(積算ステップ)
の積算結果を1/2nしてセットし、周期検出手段(周
期検出ステップ)により記憶手段の第1領域から第2領
域を引いた差分から入力信号の周期を求め、更新手段
(更新ステップ)により記憶手段の第1領域の内容を第
2領域に書込むようにしている。
In the frequency detecting method according to the fifth aspect, the frequency detecting apparatus according to the seventh aspect, and the recording medium according to the ninth aspect, the rising edge or the falling edge of the input signal is determined by the signal detecting means (signal detecting step). detects and generates a synchronizing signal interruption, the comparison means (comparison step), the upper n bits has 2 n pieces of integral values from 0 to 2 n -1, 2 n with lower n-n bits is 0 The comparison setting values are sequentially compared with the value of an N-bit counter that counts a predetermined clock, and when they match, a comparison match interrupt is generated, and the number of comparison match interrupts is integrated by the integration means (integration step). Numeric value generation means (count value generation step)
Then, when a synchronization signal interrupt occurs, the value of the N-bit counter is set to the lower N bits of the first area of the storage means, and the integrating means (integrating step) is set to the upper M-n bits of the first area.
Is set as 1/2 n, and the period of the input signal is obtained from the difference obtained by subtracting the second region from the first region of the storage unit by the period detecting unit (period detecting step). Thus, the contents of the first area of the storage means are written to the second area.

【0031】このように、記憶手段の第1領域にN+M
−nビットにビット拡張したカウンタを構成し、該ビッ
ト拡張カウンタの上位には比較一致割込みの回数を積算
した値を、下位にはNビットカウンタの値をそれぞれ割
り当て、重複するnビット(Nビットカウンタの上位n
ビットと比較一致割込みの回数の下位nビット)を一意
に対応させるために、比較一致割込みの積算回数を記憶
手段の第1領域にセットする際に積算回数を1/2n
て上位M−nビットにセットするようにしているので、
カウンタのビット長の制限を受けることなく入力信号の
周期を求めることができ、入力信号の周波数をより簡単
な処理で広範囲の周波数帯に渡って高精度で検出し得る
信号処理装置を安価で実現できる。
As described above, N + M is stored in the first area of the storage means.
-A bit-extended counter is configured with n bits, a value obtained by integrating the number of comparison match interrupts is assigned to the upper bit of the bit extension counter, and a value of the N-bit counter is assigned to the lower bit. Top n of counter
In order to uniquely associate the bit with the lower n bits of the number of comparison match interrupts), when the number of comparison match interrupts is set in the first area of the storage means, the number of integrations is reduced by 1/2 n and the upper M− Since it is set to n bits,
An inexpensive signal processing device that can determine the input signal cycle without being limited by the bit length of the counter and that can detect the frequency of the input signal with high accuracy over a wide frequency band with simpler processing it can.

【0032】また、請求項4に係る周波数検出方法およ
び請求項9に係る記録媒体では、入力信号の入力タイミ
ングと比較一致割込みのタイミングとが衝突を起こした
場合には、Nビットカウンタの上位nビットと比較一致
割込みの回数の下位nビットが一意に対応しているか否
かにより、Nビットカウンタの値と比較一致割込みの回
数とが同期しているか否かを検出し、同期していないと
きに、比較一致割込みの回数をNビットカウンタの値で
補正するようにしている。
In the frequency detecting method according to the fourth aspect and the recording medium according to the ninth aspect, when a collision occurs between the input timing of the input signal and the timing of the comparison match interrupt, the upper n bits of the N-bit counter are used. Whether the value of the N-bit counter is synchronized with the number of comparison match interrupts is detected based on whether the bit and the lower n bits of the number of comparison match interrupts uniquely correspond to each other. Then, the number of comparison match interrupts is corrected by the value of the N-bit counter.

【0033】さらに、請求項6に係る周波数検出方法、
請求項8に係る周波数検出装置および請求項9に係る記
録媒体では、同期検出手段(同期検出ステップ)によ
り、Nビットカウンタの上位nビットと積算手段(積算
ステップ)の積算結果の下位nビットとが一致するか否
かを検出し、補正手段(補正ステップ)により、同期検
出手段(同期検出ステップ)で一致していないときに、
積算手段(積算ステップ)の積算結果をNビットカウン
タの値で補正して計数値生成手段(計数値生成ステッ
プ)に与えるようにしている。
Further, a frequency detecting method according to claim 6,
In the frequency detection device according to the eighth aspect and the recording medium according to the ninth aspect, the synchronization detection means (synchronization detection step) uses the upper n bits of the N-bit counter and the lower n bits of the integration result of the integration means (integration step). Is detected by the correction means (correction step). When the synchronization detection means (synchronization detection step) does not match,
The integration result of the integration means (integration step) is corrected by the value of the N-bit counter and given to the count value generation means (count value generation step).

【0034】このように、多重割込みの発生確認を行う
必要が無く、Nビットカウンタの上位nビットと比較一
致割込みの回数の下位nビットが一意に対応しているか
否かの判断で行うことができ、また、入力信号の入力タ
イミングと比較一致割込みのタイミングとが衝突を起こ
した場合においても、より簡単な補正処理によりNビッ
トカウンタとビット拡張カウンタとの同期をとることが
できるので、広範囲の周波数帯に渡って高精度で入力信
号の周波数を検出することが可能である。
As described above, it is not necessary to confirm the occurrence of multiple interrupts, and the determination can be made by determining whether the upper n bits of the N-bit counter and the lower n bits of the number of comparison match interrupts uniquely correspond to each other. Even if the input signal input timing and the comparison match interrupt timing collide, the N-bit counter and the bit extension counter can be synchronized by simpler correction processing, so that a wide range It is possible to detect the frequency of an input signal with high accuracy over a frequency band.

【0035】[0035]

【発明の実施の形態】以下、本発明の周波数検出方法、
周波数検出装置および記録媒体の実施の形態について、
〔第1の実施形態〕、〔第2の実施形態〕の順に図面を
参照して詳細に説明する。なお、それぞれの実施形態の
説明では、本発明に係る周波数検出方法、周波数検出装
置について詳述するが、本発明に係る記録媒体について
は、周波数検出方法を実行させるためのプログラムを記
録した記録媒体であることから、その説明は以下の周波
数検出方法の説明に含まれるものである。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Hereinafter, a frequency detection method according to the present invention,
Regarding embodiments of the frequency detection device and the recording medium,
[First embodiment] and [Second embodiment] will be described in detail with reference to the drawings in this order. In the description of each embodiment, the frequency detection method and the frequency detection device according to the present invention will be described in detail. However, the recording medium according to the present invention is a recording medium on which a program for executing the frequency detection method is recorded. Therefore, the description is included in the following description of the frequency detection method.

【0036】〔第1の実施形態〕図1は本発明の第1の
実施形態に係る周波数検出装置の構成図である。本実施
形態の周波数検出装置は、表示装置に通常使用されてい
る組み込み機器用マイクロコンピュータ101を用いて
実現されるものであり、該組み込み機器用マイクロコン
ピュータ101においては、少なくとも基準となるクロ
ックCLKを計数するカウンタ115と、該カウンタ1
15の値を入力信号の立ち上がりまたは立ち下がりに同
期してラッチするインプットキャプチャレジスタ117
を内蔵して、このラッチ(インプットキャプチャ)が発
生した時にインプットキャプチャ割込みを発生させる。
また、カウンタ115の値を所定値と常時比較している
コンパレータ123を内蔵しており、カウンタ115の
値が所定値と一致した時にコンペアマッチ割込みを発生
させる機能も組み込まれている。
[First Embodiment] FIG. 1 is a block diagram of a frequency detecting apparatus according to a first embodiment of the present invention. The frequency detection device of the present embodiment is realized by using a microcomputer 101 for an embedded device usually used for a display device. In the microcomputer 101 for an embedded device, at least a reference clock CLK is used. A counter 115 for counting and the counter 1
Input capture register 117 that latches the value of 15 in synchronization with the rise or fall of the input signal
To generate an input capture interrupt when this latch (input capture) occurs.
Further, a comparator 123 that constantly compares the value of the counter 115 with a predetermined value is built in, and a function of generating a compare match interrupt when the value of the counter 115 matches the predetermined value is also incorporated.

【0037】図1において装置構成を具体的に列挙する
と、本実施形態の周波数検出装置は、同期信号入力回路
103、基本クロック回路105、CPU111、分周
器113、カウンタ115、インプットキャプチャレジ
スタ117、コンペアレジスタ119、インプットキャ
プチャ検出回路121、コンパレータ123およびRA
M125を備えて構成されており、本発明を実現するた
めに既存の組み込み機器用マイクロコンピュータ101
に新たに追加された構成要素は無い。
1, the frequency detector of the present embodiment comprises a synchronous signal input circuit 103, a basic clock circuit 105, a CPU 111, a frequency divider 113, a counter 115, an input capture register 117, Compare register 119, input capture detection circuit 121, comparator 123 and RA
M125, and the existing embedded device microcomputer 101 for realizing the present invention.
There are no newly added components.

【0038】ここで、同期信号入力回路103は、パー
ソナルコンピュータ本体またはビデオテープレコーダ等
の電子機器から送られてきた同期信号SINをマイクロ
コンピュータ101に出力する回路である。また、基本
クロック回路105は、マイクロコンピュータ101の
動作の基準となるクロックパルスを発生する回路であ
る。
Here, the synchronizing signal input circuit 103 is a circuit for outputting a synchronizing signal SIN sent from an electronic device such as a personal computer or a video tape recorder to the microcomputer 101. The basic clock circuit 105 is a circuit that generates a clock pulse that is a reference for the operation of the microcomputer 101.

【0039】また、分周器113は、基本クロック回路
105が生成する基本クロックを分周して、マイクロコ
ンピュータ101内部の動作クロックとなるクロックC
LKを出力する回路である。またカウンタ115は、分
周器113が生成するクロックCLKを計数するNビッ
トカウンタ(N=16)である。
The frequency divider 113 divides the frequency of the basic clock generated by the basic clock circuit 105 and generates a clock C which is an operation clock inside the microcomputer 101.
This is a circuit that outputs LK. The counter 115 is an N-bit counter (N = 16) that counts the clock CLK generated by the frequency divider 113.

【0040】また、インプットキャプチャ検出回路12
1は特許請求の範囲にいう信号検出手段に該当し、同期
信号入力回路103から同期信号を入力して、立ち上が
りエッジ(または立ち下がりエッジ)を検出したときに
割込み信号(同期信号割込み)を発生させる回路であ
る。インプットキャプチャ検出回路121が同期信号割
込みを発生する時、インプットキャプチャレジスタ11
7は、カウンタ115の値をラッチする。
The input capture detection circuit 12
Numeral 1 corresponds to a signal detection means described in the claims, and receives a synchronization signal from the synchronization signal input circuit 103 and generates an interrupt signal (synchronization signal interrupt) when a rising edge (or a falling edge) is detected. It is a circuit to make it. When the input capture detection circuit 121 generates a synchronization signal interrupt, the input capture register 11
7 latches the value of the counter 115.

【0041】また、コンペアレジスタ119は、上位n
ビットが0から2n−1までの2n個の整数値を持ち、下
位N−nビットが0を持つ2n個の比較設定値を保持す
るもので、本実施形態では、n=1とし、比較設定値と
して「0000h」または「8000h」がセットされ
る。なお、添字hはその数値が16進表記であることを
示す。コンパレータ123は比較手段に該当し、カウン
タ115の値Coutとコンペアレジスタ119の値C
refとを常に比較して、両者が一致した時にコンペア
マッチ割込み(比較一致割込み)Icmpを発生する。
The compare register 119 stores the upper n
Bit has the 2 n integer of 0 to 2 n -1, in which the lower N-n bits hold the 2 n pieces of comparison set value with 0, in this embodiment, the n = 1 "0000h" or "8000h" is set as the comparison set value. The subscript h indicates that the numerical value is in hexadecimal notation. The comparator 123 corresponds to comparison means, and the value Cout of the counter 115 and the value C of the compare register 119 are
ref is always compared, and when they match, a compare match interrupt (comparison match interrupt) Icmp is generated.

【0042】また、RAM125には、CPU111の
制御によりコンペアマッチ割込みの回数積算値を保持す
るメモリ変数A−HIGH(M=16ビット)と、今回
の同期信号割込みにおけるビット拡張カウンタの値を保
持するメモリ変数Now(31ビット)と、前回の同期
信号割込みにおけるビット拡張カウンタの値を保持する
メモリ変数Last(31ビット)の記憶領域を備えて
いる。
The RAM 125 holds a memory variable A-HIGH (M = 16 bits) for holding the integrated value of the number of compare match interrupts under the control of the CPU 111 and the value of the bit extension counter for the current synchronization signal interrupt. A storage area for a memory variable Now (31 bits) and a memory variable Last (31 bits) for holding the value of the bit extension counter in the previous synchronization signal interrupt is provided.

【0043】また、CPU111は、インプットキャプ
チャレジスタ117、同期信号割込みおよびコンペアマ
ッチ割込みに基づき入力信号(同期信号)の周波数を検
出するもので、コンペアマッチ割込みの回数を積算する
積算手段と、同期信号割込み発生時に、メモリ変数No
wの下位16ビットにインプットキャプチャレジスタ1
17の値をセットし、上位15ビットにコンペアマッチ
割込みの回数積算値を1/2してセットする計数値生成
手段と、メモリ変数Nowからメモリ変数Lastを引
いた差分から入力信号(同期信号)の周期を求める周期
検出手段と、メモリ変数Nowの内容をメモリ変数La
stに書込む更新手段と、については、このCPU11
1上で実行される制御プログラムによって実現される。
The CPU 111 detects the frequency of the input signal (synchronous signal) based on the input capture register 117, the synchronous signal interrupt, and the compare match interrupt. The CPU 111 integrates the number of compare match interrupts, When an interrupt occurs, the memory variable No.
Input capture register 1 in lower 16 bits of w
A count value generating means for setting a value of 17 and setting the integrated value of the number of compare match interrupts to 1/2 in the upper 15 bits, and an input signal (synchronization signal) from a difference obtained by subtracting the memory variable Last from the memory variable Now Cycle detecting means for determining the cycle of the memory variable Now
The update means for writing to the st.
1 is realized by a control program executed on the computer.

【0044】従来例においては、カウンタのビット数を
拡張するためにオーバーフロー割込みを発生させてオー
バーフロー回数を計算していたのに対し、本実施形態で
は、所定の周期でコンペアマッチ割込みを発生させ、コ
ンペアマッチ割込みの回数を積算している点が異なる。
In the conventional example, an overflow interrupt is generated to extend the number of bits of the counter, and the number of overflows is calculated. In the present embodiment, a compare match interrupt is generated at a predetermined cycle. The difference is that the number of compare match interrupts is accumulated.

【0045】また本実施形態では、31(=N+M−
n)ビットに拡張したビット拡張カウンタをメモリ変数
Nowとして構成し、該メモリ変数Nowの上位にはコ
ンペアマッチ割込みの回数を積算した値を、下位にはイ
ンプットキャプチャレジスタ117の値をそれぞれ割り
当て、重複する1(=n)ビット、即ち、16ビットイ
ンプットキャプチャレジスタ117の上位1ビットとコ
ンペアマッチ割込みの積算回数の下位1ビットを一意に
対応させるために、コンペアマッチ割込みの積算回数を
メモリ変数Nowの上位15ビットにセットする際に積
算回数を1/2してセットする。
In this embodiment, 31 (= N + M-
The bit extension counter expanded to n) bits is configured as a memory variable Now, and a higher value of the memory variable Now is assigned a value obtained by integrating the number of compare match interrupts, and a lower value is assigned a value of the input capture register 117. In order to uniquely correspond 1 (= n) bits, that is, the upper 1 bit of the 16-bit input capture register 117 and the lower 1 bit of the cumulative number of compare match interrupts, the cumulative number of compare match interrupts is When the upper 15 bits are set, the integration count is set to 1 /.

【0046】なお、コンペアレジスタ119に設定され
る比較設定値には、上位nビットが0から2n−1まで
の2n個の整数値を持ち、下位N−nビットが0を持つ
n個の設定値が「0000h」から順次設定される。
つまり、カウンタ115の周期の1/2n毎にコンペア
マッチ割込みが発生して、該コンペアマッチ割込み回数
を積算してカウンタが拡張されることになる。
[0046] Note that the comparison setting value set in the compare register 119, the upper n bits has 2 n pieces of integral values from 0 to 2 n -1, 2 n with lower N-n bits is 0 Are set sequentially from "0000h".
That is, a compare match interrupt occurs every 1/2 n of the period of the counter 115, and the counter is expanded by integrating the number of compare match interrupts.

【0047】ただし、カウンタ115の周期に1回のコ
ンペアマッチ割込みを発生させる場合(n=0の場合)
は、インプットキャプチャレジスタ117の上位ビット
とコンペアマッチ割込みの積算回数の下位ビットを一意
に対応させることができないため、カウンタ115の値
とビット拡張カウンタ(メモリ変数Now)の値とが同
期していることを検出できない。
However, when a compare match interrupt is generated once in the cycle of the counter 115 (when n = 0)
Since the upper bits of the input capture register 117 cannot be uniquely associated with the lower bits of the integration count of the compare match interrupt, the value of the counter 115 and the value of the bit extension counter (memory variable Now) are synchronized. Cannot be detected.

【0048】次に、本実施形態の周波数検出装置におけ
る周波数検出方法を、図2、図3および図4を用いて説
明する。図2は本実施形態の周波数検出方法におけるコ
ンペアマッチ割込み処理を説明するフローチャートであ
り、図3はインプットキャプチャによる同期信号割込み
処理を説明するフローチャートであり、図4は本実施形
態の周波数検出方法を説明するタイミングチャートであ
る。
Next, a frequency detecting method in the frequency detecting apparatus according to the present embodiment will be described with reference to FIGS. 2, 3 and 4. FIG. 2 is a flowchart illustrating a compare match interrupt process in the frequency detection method according to the present embodiment, FIG. 3 is a flowchart illustrating a synchronization signal interrupt process by input capture, and FIG. 4 is a flowchart illustrating the frequency detection method according to the present embodiment. It is a timing chart explaining.

【0049】先ず、図2を参照して、CPU111がコ
ンペアマッチ割込みIcmpを受けて行うコンペアマッ
チ割込み処理について説明する。ステップS201で
は、コンペアマッチ割込みの回数を積算すべく、16ビ
ットメモリ変数A−HIGHのコンペアマッチ割込み回
数XをインクリメントしてX+1とする。
First, with reference to FIG. 2, a description will be given of a compare match interrupt process performed by the CPU 111 in response to the compare match interrupt Icmp. In step S201, the number of compare match interrupts X of the 16-bit memory variable A-HIGH is incremented to X + 1 in order to accumulate the number of compare match interrupts.

【0050】次にステップS202では、コンペアレジ
スタ119の内容を確認して、「8000h」が設定さ
れていれば、ステップS203でコンペアレジスタ11
9に「0000h」を設定し、「0000h」が設定さ
れていれば、ステップS204でコンペアレジスタ11
9に「8000h」を設定して、割込み処理を終了す
る。
Next, in step S202, the contents of the compare register 119 are confirmed, and if "8000h" is set, the compare register 11 is determined in step S203.
9 is set to “0000h”, and if “0000h” is set, the compare register 11 is set in step S204.
9 is set to “8000h”, and the interrupt processing ends.

【0051】次に、図3を参照して、CPU111がイ
ンプットキャプチャにより同期信号割込みを受けて行う
同期信号割込み処理について説明する。先ず、ステップ
S301では、同期信号割込み発生時のインプットキャ
プチャレジスタ117の値をメモリ変数Nowの下位1
6ビットに保存する。
Next, referring to FIG. 3, a description will be given of a synchronous signal interruption process performed by the CPU 111 upon receiving a synchronous signal interruption by input capture. First, in step S301, the value of the input capture register 117 at the time of occurrence of the synchronization signal interrupt is set to the lower one of the memory variable Now.
Save to 6 bits.

【0052】次に、ステップS302では、RAM12
5の所定領域に一時変数TEMPを設け、該一時変数T
EMPにメモリ変数A−HIGHのコンペアマッチ割込
み回数をセットする。そしてステップS303では、一
時変数TEMPの値を1/2(1ビット右シフト)した
後、メモリ変数Nowの上位15ビットに保存する。こ
れにより、インプットキャプチャレジスタ117の上位
1ビットとコンペアマッチ割込みの積算回数の下位1ビ
ットとを一意に対応させつつ、31ビットメモリ変数N
owがビット拡張カウンタとして構成されたことにな
る。
Next, in step S302, the RAM 12
5 is provided with a temporary variable TEMP in a predetermined area.
The number of compare match interrupts of the memory variable A-HIGH is set in EMP. Then, in step S303, the value of the temporary variable TEMP is 1 / (shifted right by 1 bit), and then stored in the upper 15 bits of the memory variable Now. Thereby, the upper 1 bit of the input capture register 117 and the lower 1 bit of the number of times of the compare match interrupt are uniquely associated with each other, and the 31-bit memory variable N
ow is configured as a bit extension counter.

【0053】次に、ステップS304では、前回の同期
信号割込み処理によるビット拡張カウンタの値を持つメ
モリ変数Lastを、今回の同期信号割込み処理による
ビット拡張カウンタの値を持つメモリ変数Nowから差
し引くことにより、入力信号(同期信号)の周期をクロ
ックCLKの計数値で得ることになり、クロックCLK
の周波数を該減算結果で割ることにより入力信号(同期
信号)の周波数を得ることができる。さらにステップS
305では、次回の同期信号割込み処理のために、メモ
リ変数Nowの内容をメモリ変数Lastに書込んで、
割込み処理を終了する。
Next, in step S304, the memory variable Last having the value of the bit extension counter by the previous synchronization signal interruption processing is subtracted from the memory variable Now having the value of the bit extension counter by the current synchronization signal interruption processing. , The period of the input signal (synchronous signal) is obtained by the count value of the clock CLK,
Is divided by the subtraction result to obtain the frequency of the input signal (synchronous signal). Step S
At 305, the contents of the memory variable Now are written to the memory variable Last for the next synchronization signal interrupt processing,
The interrupt processing ends.

【0054】次に、図4に例示されている具体的な数値
を示しながら、本実施形態の周波数検出方法を説明す
る。なお、図4では、メモリ変数A−HIGHの初期値
を「0000h」とし、コンペアレジスタ119の初期
設定値を「8000h」としている。
Next, the frequency detection method of the present embodiment will be described with reference to specific numerical values illustrated in FIG. In FIG. 4, the initial value of the memory variable A-HIGH is “0000h”, and the initial setting value of the compare register 119 is “8000h”.

【0055】先ず、カウンタ115の値が「7FFF
h」から「8000h」になる時に、コンペアレジスタ
119には「8000h」が設定されているので、コン
パレータ123においてコンペアマッチ割込みIcmp
が発生し、CPU111は、メモリ変数A−HIGHの
値「0002h」を「0003h」にカウントアップす
る(ステップS201)。
First, when the value of the counter 115 is "7FFF
Since “8000h” is set in the compare register 119 when “8000h” is changed from “h” to “8000h”, the compare match interrupt Icmp in the comparator 123 is performed.
Is generated, the CPU 111 counts up the value “0002h” of the memory variable A-HIGH to “0003h” (step S201).

【0056】一方、カウンタ115の値が「8005
h」の時に、入力信号(同期信号)の立ち下がりエッジ
を検出して同期信号割込みが発生すると、CPU111
は、先ず、インプットキャプチャレジスタ117の値を
メモリ変数Nowの下位16ビットに保存する(ステッ
プS301)。次に、メモリ変数A−HIGHの値「0
003h」を一時変数TEMPに保存して(ステップS
302)、これを1/2(1ビット右シフト)した後、
「0001h」をメモリ変数Nowの上位15ビットに
保存する(ステップS303)。
On the other hand, if the value of the counter 115 is "8005
h ”, when a falling edge of the input signal (synchronization signal) is detected and a synchronization signal interrupt occurs, the CPU 111
First, the value of the input capture register 117 is stored in the lower 16 bits of the memory variable Now (step S301). Next, the value “0” of the memory variable A-HIGH
003h ”in a temporary variable TEMP (step S
302), and after こ れ (shift right by 1 bit),
“0001h” is stored in the upper 15 bits of the memory variable Now (step S303).

【0057】この1/2(1ビット右シフト)により、
コンペアマッチ割込みの積算回数がカウンタ115の値
と重複している1ビットが削除され、結果として、イン
プットキャプチャレジスタ117の値「8005h」の
上位1ビット「1」とコンペアマッチ割込みの積算回数
「0003h」の下位1ビット「1」とを一意に対応さ
せつつ、31ビットメモリ変数Nowがビット拡張カウ
ンタとして構成されたことになる。
By this 1/2 (1 bit right shift),
One bit in which the number of times of the compare match interrupt overlaps with the value of the counter 115 is deleted, and as a result, the upper 1 bit “1” of the value “8005h” of the input capture register 117 and the number of times of the compare match interrupt “0003h” , The 31-bit memory variable Now is configured as a bit extension counter while uniquely associating the lower 1 bit “1” of “.

【0058】なお、図4では、コンペアマッチ割込みが
発生してからコンペアマッチ割込み回数が積算されるま
での間は、カウンタ115の最上位ビットとコンペアマ
ッチ割込み回数の積算回数の最下位ビットは一意に対応
しておらず、積算回数がカウントアップされた後に、カ
ウンタ115の最上位ビットとコンペアマッチ割込み回
数の積算回数の最下位ビットが一意に対応することにな
る。
In FIG. 4, the most significant bit of the counter 115 and the least significant bit of the number of times of comparison of the number of compare match interrupts are unique from the occurrence of the compare match interrupt until the number of compare match interrupts is counted. After the number of integrations is counted up, the most significant bit of the counter 115 and the least significant bit of the number of integrations of the compare match interrupt number uniquely correspond to each other.

【0059】以上説明したように、本実施形態の周波数
検出方法および周波数検出装置では、RAM125のメ
モリ変数Nowを31(=N+M−n)ビットにビット
拡張したカウンタとして構成し、該ビット拡張カウンタ
の上位にはコンペアマッチ割込みの回数積算値を、下位
には16ビットインプットキャプチャレジスタ117の
値をそれぞれ割り当て、重複する1(=n)ビット、即
ち、インプットキャプチャレジスタ117の上位1ビッ
トとコンペアマッチ割込みの積算回数の下位1ビットを
一意に対応させるために、コンペアマッチ割込みの積算
回数をメモリ変数Nowにセットする際に、該積算回数
を1/2して上位15ビットにセットするようにしたの
で、インプットキャプチャレジスタ117のビット長の
制限を受けることなく入力信号の周期を求めることがで
き、入力信号の周波数をより簡単な処理で広範囲の周波
数帯に渡って高精度で検出し得る信号処理装置を安価で
実現できる。
As described above, in the frequency detecting method and the frequency detecting apparatus according to the present embodiment, the memory variable Now of the RAM 125 is configured as a counter in which bits are expanded to 31 (= N + M−n) bits. The number of integrated values of the number of compare match interrupts is assigned to the high order, and the value of the 16-bit input capture register 117 is assigned to the low order. The overlapping 1 (= n) bits, ie, the upper 1 bit of the input capture register 117 and the compare match interrupt are assigned. In order to uniquely correspond the lower 1 bit of the number of times of integration, the number of times of the compare match interrupt is set in the memory variable Now, the number of times of integration is halved and set to the upper 15 bits. , The bit length of the input capture register 117 is limited Ku period of the input signal can be obtained, a signal processing apparatus capable of detecting with high accuracy over a wide frequency band by a simpler process the frequency of the input signal can be realized at low cost.

【0060】〔第2の実施形態〕次に、本発明の第2の
実施形態に係る周波数検出方法および周波数検出装置に
ついて説明する。本実施形態は、入力信号の入力タイミ
ングとコンペアマッチ割込みのタイミングとが衝突を起
こした場合にも、インプットキャプチャ割込みをコンペ
アマッチ割込みより優先することにより、簡単な補正処
理の追加で高精度な周波数検出を実現するものである。
[Second Embodiment] Next, a frequency detection method and a frequency detection device according to a second embodiment of the present invention will be described. In the present embodiment, even when the input timing of the input signal and the timing of the compare match interrupt occur, the input capture interrupt is given priority over the compare match interrupt. This is to realize detection.

【0061】本実施形態の周波数検出装置の構成は、第
1の実施形態(図1参照)と同様の構成であるが、イン
プットキャプチャレジスタ117の上位1ビットとコン
ペアマッチ割込み回数の積算結果の下位1ビットとが一
致するか否かを検出する同期検出手段と、該同期検出手
段で一致していないときに、コンペアマッチ割込み回数
の積算結果をインプットキャプチャレジスタ117の値
で補正して計数値生成手段に与える補正手段が、CPU
111上で実行される制御プログラムによって実現され
る点が第1の実施形態とは異なる。
The configuration of the frequency detection device of the present embodiment is the same as that of the first embodiment (see FIG. 1), except that the upper one bit of the input capture register 117 and the lower one of the integration result of the number of compare match interrupts. A synchronization detecting means for detecting whether or not one bit matches; and, when the synchronization detecting means does not match, correcting the integration result of the number of compare match interrupts with the value of the input capture register 117 to generate a count value. The correction means given to the means is a CPU
This embodiment is different from the first embodiment in that it is realized by a control program executed on the control program 111.

【0062】入力信号の立ち下がりエッジの検出は、コ
ンペアマッチ割込みが発生した後のインプットキャプチ
ャレジスタ117の値とコンペアマッチ割込みの積算回
数の両者が同期しているときに行われるべきであるが、
第1の実施形態でも説明したように、コンペアマッチ割
込みが発生してからコンペアマッチ割込み回数が積算さ
れるまでの間は、インプットキャプチャレジスタ117
の最上位ビットとコンペアマッチ割込み回数の積算回数
の最下位ビットは一意に対応しておらず、両者は同期し
ていない。
The detection of the falling edge of the input signal should be performed when both the value of the input capture register 117 after the occurrence of the compare match interrupt and the integration count of the compare match interrupt are synchronized.
As described in the first embodiment, the input capture register 117 is provided between the occurrence of the compare match interrupt and the accumulation of the number of compare match interrupts.
And the least significant bit of the number of times the number of compare match interrupts does not uniquely correspond to each other, and they are not synchronized.

【0063】したがって、コンペアマッチ割込みと同期
信号割込みが同時(コンペアマッチ割込みが発生してか
らコンペアマッチ割込み回数が積算されるまでの間)に
発生した場合には、コンペアマッチ割込み回数が積算さ
れる前にインプットキャプチャによる同期信号割込みに
よってコンペアマッチ割込みの積算回数(メモリ変数A
−HIGH)が参照される。その場合には、コンペアマ
ッチ割込みの積算回数を補正した後に使用するようにし
なければならない。
Therefore, if the compare match interrupt and the synchronization signal interrupt occur simultaneously (between the occurrence of the compare match interrupt and the number of compare match interrupts added), the number of compare match interrupts is added. Previously, the number of compare match interrupt integrations (memory variable A
-HIGH). In this case, it is necessary to use the memory after correcting the number of times of the compare match interrupt.

【0064】本実施形態の周波数検出装置における周波
数検出方法を、図5および図6を用いて説明する。図5
は本実施形態の周波数検出方法における同期信号割込み
処理を説明するフローチャートであり、図6は本実施形
態の周波数検出方法を説明するタイミングチャートであ
る。なお、コンペアマッチ割込みIcmpの発生を受け
てCPU111が行うコンペアマッチ割込み処理につい
ては、第1の実施形態(図2参照)と同様である。
A frequency detection method in the frequency detection device according to the present embodiment will be described with reference to FIGS. FIG.
FIG. 6 is a flowchart illustrating a synchronization signal interruption process in the frequency detection method according to the present embodiment, and FIG. 6 is a timing chart illustrating the frequency detection method according to the present embodiment. Note that the compare match interrupt process performed by the CPU 111 in response to the occurrence of the compare match interrupt Icmp is the same as in the first embodiment (see FIG. 2).

【0065】先ず、図5を参照して、CPU111が同
期信号割込みを受けて行う同期信号割込み処理について
説明する。先ず、ステップS501では、同期信号割込
み発生時のインプットキャプチャレジスタ117の値を
メモリ変数Nowの下位16ビットに保存する。次に、
ステップS502では、RAM125の所定領域の一時
変数TEMPにメモリ変数A−HIGHのコンペアマッ
チ割込み回数をセットする。
First, with reference to FIG. 5, a description will be given of a synchronization signal interruption process performed by the CPU 111 in response to a synchronization signal interruption. First, in step S501, the value of the input capture register 117 at the time of occurrence of the synchronization signal interrupt is stored in the lower 16 bits of the memory variable Now. next,
In step S502, the number of compare match interrupts of the memory variable A-HIGH is set to a temporary variable TEMP in a predetermined area of the RAM 125.

【0066】そして、ステップS503、S504にお
いて補正処理が行われる。ステップS503では、コン
ペアマッチ割込みの積算回数を参照するに際して、イン
プットキャプチャレジスタ117の値とコンペアマッチ
割込みの積算回数が同期(一意に対応)しているか否か
を確認するべく、インプットキャプチャレジスタ117
の最上位ビットと一時変数TEMPの最下位ビットが一
致しているか否かを判断している。
Then, a correction process is performed in steps S503 and S504. In step S503, when referring to the number of times of the compare match interrupt, the input capture register 117 is checked in order to confirm whether or not the value of the input capture register 117 and the number of times of the compare match interrupt are synchronized (uniquely corresponding).
Is determined whether or not the most significant bit of the temporary variable TEMP matches the least significant bit of the temporary variable TEMP.

【0067】第1の実施形態で参照した図4のように、
コンペアマッチ割込みの積算回数の最下位ビットとイン
プットキャプチャレジスタ117の最上位ビットの両者
が一意に対応しておれば、インプットキャプチャレジス
タ117の値とコンペアマッチ割込みの積算回数は同期
していると判断でき、コンペアマッチ割込みの積算回数
をそのまま使用することができる。しかしながら、両者
が一意に対応していなければ、インプットキャプチャレ
ジスタ117の値とコンペアマッチ割込みの積算回数は
同期していないと判断され、この場合にはステップS5
04に進んで、一時変数TEMPをインクリメントし、
コンペアマッチ割込みの積算回数の最下位ビットをイン
プットキャプチャレジスタ117の最上位ビットに一致
させることで補正を行っている。
As shown in FIG. 4 referred to in the first embodiment,
If both the least significant bit of the number of times of the compare match interrupt and the most significant bit of the input capture register 117 uniquely correspond, it is determined that the value of the input capture register 117 and the number of times of the compare match interrupt are synchronized. It is possible to use the number of accumulations of the compare match interrupt as it is. However, if the two do not uniquely correspond to each other, it is determined that the value of the input capture register 117 and the integration count of the compare match interrupt are not synchronized. In this case, step S5
Proceeding to 04, the temporary variable TEMP is incremented,
The correction is performed by matching the least significant bit of the number of times of the compare match interrupt with the most significant bit of the input capture register 117.

【0068】次にステップS505では、一時変数TE
MPの値を1/2(1ビット右シフト)した後、メモリ
変数Nowの上位15ビットに保存する。これにより、
インプットキャプチャレジスタ117の上位1ビットと
コンペアマッチ割込みの積算回数の下位1ビットとを一
意に対応させつつ、31ビットメモリ変数Nowがビッ
ト拡張カウンタとして構成されたことになる。
Next, in step S505, the temporary variable TE
After the value of MP is 1 / (shifted right by 1 bit), it is stored in the upper 15 bits of the memory variable Now. This allows
This means that the 31-bit memory variable Now is configured as a bit extension counter while uniquely associating the upper 1 bit of the input capture register 117 with the lower 1 bit of the integration count of the compare match interrupt.

【0069】次に、ステップS506では、前回の同期
信号割込み処理によるビット拡張カウンタの値を持つメ
モリ変数Lastを、今回の同期信号割込み処理による
ビット拡張カウンタの値を持つメモリ変数Nowから差
し引くことにより、入力信号(同期信号)の周期を得
て、クロックCLKの周波数を該減算結果で割ることに
より入力信号(同期信号)の周波数を得る。さらにステ
ップS507では、次回の同期信号割込み処理のため
に、メモリ変数Nowの内容をメモリ変数Lastに書
込んで、割込み処理を終了する。
Next, in step S506, the memory variable Last having the value of the bit extension counter by the previous synchronization signal interruption processing is subtracted from the memory variable Now having the value of the bit extension counter by the current synchronization signal interruption processing. , The frequency of the input signal (synchronous signal) is obtained by dividing the frequency of the clock CLK by the subtraction result. Further, in step S507, the contents of the memory variable Now are written to the memory variable Last for the next synchronous signal interrupt processing, and the interrupt processing is terminated.

【0070】次に、図6に例示されている具体的な数値
を示しながら、本実施形態の周波数検出方法を説明す
る。なお、図6は、カウンタ115が「8000h」に
なってコンペアマッチ割込みが発生したと同時に、入力
信号のエッジを検出してインプットキャプチャ割込みが
発生した場合を示している。また図6では、メモリ変数
A−HIGHの初期値を「0000h」とし、コンペア
レジスタ119の初期設定値を「8000h」としてい
る。
Next, the frequency detection method of the present embodiment will be described with reference to specific numerical values illustrated in FIG. FIG. 6 shows a case in which the edge of the input signal is detected and an input capture interrupt is generated at the same time when the counter 115 becomes “8000h” and a compare match interrupt is generated. In FIG. 6, the initial value of the memory variable A-HIGH is “0000h”, and the initial setting value of the compare register 119 is “8000h”.

【0071】先ず、カウンタ115の値が「7FFF
h」から「8000h」になる時に、コンペアレジスタ
119には「8000h」が設定されているので、コン
パレータ123においてコンペアマッチ割込みIcmp
が発生し、CPU111は、メモリ変数A−HIGHの
値「0002h」を「0003h」にカウントアップす
る(ステップS201)。
First, when the value of the counter 115 is "7FFF
Since “8000h” is set in the compare register 119 when “8000h” is changed from “h” to “8000h”, the compare match interrupt Icmp in the comparator 123 is performed.
Is generated, the CPU 111 counts up the value “0002h” of the memory variable A-HIGH to “0003h” (step S201).

【0072】一方、カウンタ115の値が「8002
h」の時に、入力信号(同期信号)の立ち下がりエッジ
を検出して同期信号割込みが発生すると、CPU111
は、先ず、インプットキャプチャレジスタ117の値を
メモリ変数Nowの下位16ビットに保存する(ステッ
プS501)。次に、メモリ変数A−HIGHの値「0
002h」を一時変数TEMPに保存する(ステップS
502)。
On the other hand, if the value of the counter 115 is "8002
h ”, when a falling edge of the input signal (synchronization signal) is detected and a synchronization signal interrupt occurs, the CPU 111
First, the value of the input capture register 117 is stored in the lower 16 bits of the memory variable Now (step S501). Next, the value “0” of the memory variable A-HIGH
002h ”is stored in a temporary variable TEMP (step S
502).

【0073】この時、一時変数TEMP(コンペアマッ
チ割込みの積算回数)の最下位ビットは「0」であり、
インプットキャプチャレジスタ117の最上位ビットは
「1」であるので、両者は一致せず、コンペアマッチ割
込みの積算回数とインプットキャプチャレジスタ117
の値が同期していないと判断される(ステップS50
3)。この場合、一時変数TEMP(コンペアマッチ割
込みの積算回数)の値を補正する必要があるが、本実施
形態では重複が1ビット(n=1)であるため、1回だ
け1を足して(ステップS504)、コンペアマッチ割
込みの積算回数の最下位ビットをインプットキャプチャ
レジスタ117の最上位ビットと一意に対応させればよ
い。さらに、これを1/2(1ビット右シフト)した
後、「0001h」をメモリ変数Nowの上位15ビッ
トに保存する(ステップS505)。
At this time, the least significant bit of the temporary variable TEMP (the number of times the compare match interrupt is integrated) is “0”,
Since the most significant bit of the input capture register 117 is “1”, they do not match, and the number of times of the compare match interrupt integration and the input capture register 117
Are determined to be out of synchronization (step S50).
3). In this case, it is necessary to correct the value of the temporary variable TEMP (the number of times the compare match interrupt has been accumulated). However, in this embodiment, since the duplication is 1 bit (n = 1), 1 is added only once (step 1). S504), the least significant bit of the integration count of the compare match interrupt may be uniquely associated with the most significant bit of the input capture register 117. Furthermore, after this is shifted by 1/2 (right shift by one bit), “0001h” is stored in the upper 15 bits of the memory variable Now (step S505).

【0074】以上説明したように、本実施例の周波数検
出方法および周波数検出装置では、第1の実施形態と同
様に、16ビットインプットキャプチャレジスタ117
とコンペアマッチ割込みの積算回数とを用いて、RAM
125のメモリ変数Nowを31ビット長にビット拡張
したカウンタとして構成することにより、入力信号の同
期検出に用いるマイクロコンピュータ内蔵カウンタのビ
ット長を拡張することができ、また、インプットキャプ
チャレジスタ117の上位1ビットとコンペアマッチ割
込みの積算回数の下位1ビットが一意に対応しているか
否かという簡単な判断により、多重割込みの発生、換言
すれば、インプットキャプチャレジスタ117の値とコ
ンペアマッチ割込みの積算回数との同期を確認すること
ができ、さらに、両者が同期していない場合には、コン
ペアマッチ割込みの積算回数をインプットキャプチャレ
ジスタ117の値を使って補正して両者を一意に対応さ
せるので、入力信号の周波数検出を高精度で実現すると
共に、検出可能な周波数範囲を広げることが可能とな
る。
As described above, in the frequency detecting method and the frequency detecting apparatus according to the present embodiment, similarly to the first embodiment, the 16-bit input capture register 117 is used.
And the number of comparison match interrupts
By configuring the memory variable Now of 125 as a counter in which the bit is extended to a 31-bit length, the bit length of the microcomputer built-in counter used for synchronization detection of the input signal can be extended. A simple determination as to whether or not the bit and the lower 1 bit of the integration count of the compare match interrupt uniquely correspond to each other, the occurrence of multiple interrupts, in other words, the value of the input capture register 117 and the integration count of the compare match interrupt, Can be confirmed, and if they are not synchronized, the number of times of the compare match interrupt is corrected using the value of the input capture register 117 so that the two are uniquely associated with each other. Frequency detection with high accuracy and detectable It is possible to widen the wavenumber range.

【0075】なお、第1および第2の実施形態では、カ
ウンタ115を16(=N)ビット長とし、コンペアマ
ッチ割込みの積算回数を保存するメモリ変数A−HIG
Hを16(=M)ビット長とし、インプットキャプチャ
レジスタ117の上位ビットとコンペアマッチ割込みの
積算回数の下位ビットの一意の対応(重複するビット)
を1(=n)ビットでとることとしたが、これに限定さ
れることはなく、パラメータN,M,nは、n<N,n
<Mの範囲で任意の正整数としてもよい。
In the first and second embodiments, the counter 115 has a length of 16 (= N) bits, and the memory variable A-HIG for storing the number of times the compare match interrupt is integrated.
H is a 16 (= M) bit length, and a unique correspondence (overlapping bits) between the upper bits of the input capture register 117 and the lower bits of the number of integrations of the compare match interrupt
Is 1 (= n) bits, but the present invention is not limited to this, and the parameters N, M, and n are n <N, n
Any positive integer within the range of <M may be used.

【0076】また、ビット拡張カウンタにおいて重複す
るビット数nを2以上の値にする場合は、カウンタ11
5の周期の1/2n毎に等間隔にコンペアマッチ割込み
が発生するように「0000h」から始まる数値を比較
設定値として設定することになる。例えば、n=2の場
合には、コンペアレジスタ119には、4つの比較設定
値「0000h」、「4000h」、「8000h」ま
たは「C000h」が設定される。
When the number of overlapping bits n in the bit extension counter is set to a value of 2 or more, the counter 11
A numerical value starting from "0000h" is set as a comparison set value so that a compare match interrupt is generated at equal intervals every 1/2 n of the period of 5. For example, when n = 2, four comparison setting values “0000h”, “4000h”, “8000h”, or “C000h” are set in the compare register 119.

【0077】また、重複するビット数nを2以上の値に
する場合は、コンペアマッチ割込みの積算回数の補正処
理(図5のステップS503,S504)は、重複して
いるビット数nに対して、最大2n−1回のインクリメ
ント(カウントアップ)を行うことになり、重複してい
るnビットが一意に対応したときに、コンペアマッチ割
込みの積算回数がインプットキャプチャレジスタ117
の値によって正しく補正されたことになる。
When the number of overlapping bits n is set to a value of 2 or more, the process of correcting the number of times of the compare match interrupt (steps S503 and S504 in FIG. 5) is performed for the number of overlapping bits n. Is incremented (counted up) by a maximum of 2 n -1 times, and when the overlapping n bits uniquely correspond to each other, the cumulative number of compare match interrupts is increased by the input capture register 117.
Is correctly corrected by the value of.

【0078】[0078]

【発明の効果】以上説明したように、本発明によれば、
入力信号の入力時点において、上位nビットが0から2
n−1までの2n個の整数値を持ち、下位N−nビットが
0を持つ2n個の比較設定値と、所定クロックで動作す
るNビットカウンタの値とを順次比較して、一致した時
に発生する比較一致割込みを用いて計算される比較一致
割込みの回数と、Nビットカウンタの値とを用いて入力
信号の周期を検出し、該検出周期から周波数を求めるよ
うにし、入力信号の入力時点におけるNビットカウンタ
の値をインプットキャプチャ機能を用いて得るように
し、さらに、入力信号の周期の検出を入力信号の入力時
に発生する入力信号割込み処理において行うようにした
ので、ハードウェアカウンタを変更することなくカウン
タのビット長を拡張し、カウンタのビット長の制限を受
けることなく、入力信号の周波数を広範囲の周波数帯に
渡って高精度で検出し得る信号処理装置を安価で実現で
きる。
As described above, according to the present invention,
At the time of input of the input signal, the upper n bits are 0 to 2
The 2 n comparison setting values having 2 n integer values up to n −1 and having the lower N−n bits of 0 are sequentially compared with the value of an N-bit counter that operates at a predetermined clock, and are compared. The cycle of the input signal is detected by using the number of comparison match interrupts calculated by using the comparison match interrupt generated at the time of the occurrence and the value of the N-bit counter, and the frequency is obtained from the detection cycle. Change the hardware counter because the value of the N-bit counter at the time of input is obtained using the input capture function, and the period of the input signal is detected in the input signal interrupt processing that occurs when the input signal is input. The bit length of the counter can be expanded without the need for detection, and the frequency of the input signal can be detected with high accuracy over a wide frequency band without being limited by the bit length of the counter. The obtained signal processing apparatus can be realized at low cost.

【0079】また、本発明によれば、記憶手段の第1領
域にN+M−nビットにビット拡張したカウンタを構成
し、該ビット拡張カウンタの上位には比較一致割込みの
回数を積算した値を、下位にはNビットカウンタの値を
それぞれ割り当て、重複するnビット(Nビットカウン
タの上位nビットと比較一致割込みの回数の下位nビッ
ト)を一意に対応させるために、比較一致割込みの積算
回数を記憶手段の第1領域にセットする際に積算回数を
1/2nして上位M−nビットにセットするようにした
ので、カウンタのビット長の制限を受けることなく入力
信号の周期を求めることができ、入力信号の周波数をよ
り簡単な処理で広範囲の周波数帯に渡って高精度で検出
し得る信号処理装置を安価で実現できる。
Further, according to the present invention, a counter in which bits are extended to N + M-n bits is formed in the first area of the storage means, and a value obtained by integrating the number of times of the comparison coincidence interrupt is stored above the bit extension counter. The value of the N-bit counter is assigned to the lower bits, and the accumulated number of comparison match interrupts is set to uniquely correspond to the overlapping n bits (the upper n bits of the N-bit counter and the lower n bits of the number of comparison match interrupts). Since the number of integrations is set to 1/2 n and set to the upper M-n bits when setting in the first area of the storage means, the period of the input signal can be obtained without being limited by the bit length of the counter. Thus, a signal processing device capable of detecting the frequency of an input signal over a wide frequency band with higher accuracy by simpler processing can be realized at low cost.

【0080】さらに、本発明によれば、入力信号の入力
タイミングと比較一致割込みのタイミングとが衝突を起
こした場合には、Nビットカウンタの上位nビットと比
較一致割込みの回数の下位nビットが一意に対応してい
るか否かにより、Nビットカウンタの値と比較一致割込
みの回数とが同期しているか否かを検出し、同期してい
ないときに、比較一致割込みの回数をNビットカウンタ
の値で補正することとしたので、多重割込みの発生確認
を行うことなく、Nビットカウンタの上位nビットと比
較一致割込みの回数の下位nビットが一意に対応してい
るか否かの判断で行うことができ、また、入力信号の入
力タイミングと比較一致割込みのタイミングとが衝突を
起こした場合においても、より簡単な補正処理によりN
ビットカウンタとビット拡張カウンタとの同期をとるこ
とができるので、広範囲の周波数帯に渡って高精度で入
力信号の周波数を検出することが可能である。
Further, according to the present invention, when a collision occurs between the input timing of the input signal and the timing of the comparison match interrupt, the upper n bits of the N-bit counter and the lower n bits of the number of comparison match interrupts are changed. Whether the value of the N-bit counter and the number of comparison match interrupts are synchronized or not is detected based on whether or not they uniquely correspond to each other. Because the value is corrected by the value, it is necessary to judge whether the upper n bits of the N-bit counter and the lower n bits of the number of comparison match interrupts uniquely correspond without confirming the occurrence of multiple interrupts. In addition, even when the input timing of the input signal and the timing of the comparison coincidence interrupt collide with each other, N can be reduced by a simpler correction process.
Since the bit counter and the bit extension counter can be synchronized, it is possible to detect the frequency of the input signal with high accuracy over a wide frequency band.

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

【図1】本発明の第1の実施形態に係る周波数検出装置
の構成図である。
FIG. 1 is a configuration diagram of a frequency detection device according to a first embodiment of the present invention.

【図2】第1の実施形態の周波数検出方法におけるコン
ペアマッチ割込み処理を説明するフローチャートであ
る。
FIG. 2 is a flowchart illustrating a compare match interrupt process in the frequency detection method according to the first embodiment.

【図3】第1の実施形態の周波数検出方法における同期
信号割込み処理を説明するフローチャートである。
FIG. 3 is a flowchart illustrating a synchronization signal interruption process in the frequency detection method according to the first embodiment.

【図4】第1の実施形態の周波数検出方法を説明するタ
イミングチャートである。
FIG. 4 is a timing chart illustrating a frequency detection method according to the first embodiment.

【図5】第2の実施形態の周波数検出方法における同期
信号割込み処理を説明するフローチャートである。
FIG. 5 is a flowchart illustrating a synchronization signal interruption process in the frequency detection method according to the second embodiment.

【図6】第2の実施形態の周波数検出方法を説明するタ
イミングチャートである。
FIG. 6 is a timing chart illustrating a frequency detection method according to a second embodiment.

【図7】従来の周波数検出方法におけるオーバーフロー
割込み処理を説明するフローチャートである。
FIG. 7 is a flowchart illustrating overflow interrupt processing in a conventional frequency detection method.

【図8】従来の周波数検出方法における同期信号割込み
処理を説明するフローチャートである。
FIG. 8 is a flowchart illustrating a synchronization signal interruption process in a conventional frequency detection method.

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

101 マイクロコンピュータ 103 同期信号入力回路 SIN 同期信号 105 基本クロック回路 111 CPU 113 分周器 115 カウンタ 117 インプットキャプチャレジスタ 119 コンペアレジスタ 121 インプットキャプチャ検出回路 123 コンパレータ 125 RAM IBUS 内部バス CLK クロック Cout カウンタ出力 Cref 比較設定値 Icmp コンペアマッチ割込み 101 microcomputer 103 synchronization signal input circuit SIN synchronization signal 105 basic clock circuit 111 CPU 113 frequency divider 115 counter 117 input capture register 119 compare register 121 input capture detection circuit 123 comparator 125 RAM IBUS internal bus CLK clock Cout counter output Cref comparison setting Value Icmp Compare match interrupt

Claims (9)

【特許請求の範囲】[Claims] 【請求項1】 入力信号の周期を検出することで周波数
を検出する周波数検出方法であって、 前記入力信号の入力時点において、上位nビット(nは
正整数)が0から2n−1までの2n個の整数値を持ち、
下位N−nビット(Nは正整数)が0を持つ2n個の比
較設定値と、所定クロックで動作するNビットカウンタ
の値とを順次比較して、一致した時に発生する比較一致
割込みを用いて計算される比較一致割込みの回数と、前
記Nビットカウンタの値とを用いて前記入力信号の周期
を検出することを特徴とする周波数検出方法。
1. A frequency detecting method for detecting a frequency by detecting a cycle of an input signal, wherein at the time of input of the input signal, upper n bits (n is a positive integer) from 0 to 2 n -1. Has 2 n integer values of
The 2 n comparison setting values in which the lower N-n bits (N is a positive integer) are 0 and the value of an N-bit counter that operates at a predetermined clock are sequentially compared, and a comparison coincidence interrupt that occurs when they match is generated. A frequency detection method, comprising: detecting a period of the input signal using a number of comparison match interrupts calculated using the value and a value of the N-bit counter.
【請求項2】 前記入力信号の入力時点における前記N
ビットカウンタの値は、インプットキャプチャ機能を用
いて得られることを特徴とする請求項1に記載の周波数
検出方法。
2. The method according to claim 1, wherein the N signal at the time of input of the input signal is
The frequency detection method according to claim 1, wherein the value of the bit counter is obtained by using an input capture function.
【請求項3】 前記入力信号の周期の検出は、前記入力
信号の入力時に発生する入力信号割込み処理において行
われることを特徴とする請求項1または2に記載の周波
数検出方法。
3. The frequency detection method according to claim 1, wherein the detection of the cycle of the input signal is performed in an input signal interruption process that occurs when the input signal is input.
【請求項4】 前記入力信号の入力タイミングと前記比
較一致割込みのタイミングとが衝突を起こした場合に
は、前記Nビットカウンタの上位nビットと前記比較一
致割込みの回数の下位nビットが一意に対応しているか
否かにより、前記Nビットカウンタの値と前記比較一致
割込みの回数とが同期しているか否かを検出し、同期し
ていないときに、前記比較一致割込みの回数を前記Nビ
ットカウンタの値で補正することを特徴とする請求項
1、2または3記載の周波数検出方法。
4. When the input timing of the input signal and the timing of the comparison match interrupt collide, the upper n bits of the N-bit counter and the lower n bits of the number of comparison match interrupts are uniquely determined. Whether the value of the N-bit counter is synchronized with the number of comparison match interrupts is detected based on whether or not the number of comparison match interrupts is synchronized. 4. The frequency detection method according to claim 1, wherein the correction is performed using a counter value.
【請求項5】 所定クロックを計時するNビットカウン
タ(Nは正整数)と、2個のN+M−nビット(M,n
は正整数)のデータをそれぞれ第1および第2領域に保
持する記憶手段と、を備え、入力信号の周期を検出する
ことで周波数を検出する信号処理装置の周波数検出方法
において、 前記入力信号の立ち上がりまたは立ち下がりエッジを検
出して同期信号割込みを発生する信号検出ステップと、 上位nビットが0から2n−1までの2n個の整数値を持
ち、下位N−nビットが0を持つ2n個の比較設定値
と、前記Nビットカウンタの値を順次比較して、一致し
た時に比較一致割込みを発生する比較ステップと、 前記比較一致割込みの回数を積算する積算ステップと、 前記同期信号割込み発生時に、前記記憶手段の第1領域
の下位Nビットに前記Nビットカウンタの値をセット
し、該第1領域の上位M−nビットに前記積算ステップ
の積算結果を1/2nしてセットする計数値生成ステッ
プと、 前記記憶手段の第1領域から第2領域を引いた差分から
前記入力信号の周期を求める周期検出ステップと、 前記記憶手段の第1領域の内容を第2領域に書込む更新
ステップと、を有することを特徴とする周波数検出方
法。
5. An N-bit counter (N is a positive integer) for clocking a predetermined clock, and two N + M-n bits (M, n
Storage means for holding data of the input signal in the first and second areas, respectively, wherein the frequency of the input signal is detected by detecting the frequency of the input signal. A signal detection step of detecting a rising or falling edge to generate a synchronization signal interrupt; upper n bits have 2 n integer values from 0 to 2 n -1; lower N−n bits have 0 A comparison step of sequentially comparing the 2 n comparison set values with the value of the N-bit counter and generating a comparison match interrupt when they match; an integration step of integrating the number of comparison match interrupts; When an interrupt occurs, the value of the N-bit counter is set to the lower N bits of the first area of the storage means, and the integration result of the integration step is set to the upper M-n bits of the first area. 1/2 and n and the count value generating step is set, the period detecting step from the difference obtained by subtracting the second region from the first region determining the period of said input signal of said memory means, in the first region of the storage unit Updating the content into the second area.
【請求項6】 前記Nビットカウンタの上位nビットと
前記積算ステップの積算結果の下位nビットとが一致す
るか否かを検出する同期検出ステップと、 前記同期検出ステップで一致していないときに、前記積
算ステップの積算結果を前記Nビットカウンタの値で補
正して前記計数値生成ステップに与える補正ステップ
と、を有することを特徴とする請求項5に記載の周波数
検出方法。
6. A synchronization detection step for detecting whether or not the upper n bits of the N-bit counter and the lower n bits of the integration result of the integration step coincide with each other. 6. The frequency detection method according to claim 5, further comprising: a correction step of correcting an integration result of the integration step with a value of the N-bit counter and giving the result to the count value generation step.
【請求項7】 入力信号の周期を検出することで周波数
を検出する周波数検出装置において、 前記入力信号の立ち上がりまたは立ち下がりエッジを検
出して同期信号割込みを発生する信号検出手段と、 所定クロックを計時するNビットカウンタ(Nは正整
数)と、 上位nビット(nは正整数)が0から2n−1までの2n
個の整数値を持ち、下位N−nビットが0を持つ2n
の比較設定値と、前記Nビットカウンタの値を順次比較
して、一致した時に比較一致割込みを発生する比較手段
と、 前記比較一致割込みの回数を積算する積算手段と、 2個のN+M−nビット(Mは正整数)のデータをそれ
ぞれ第1および第2領域に保持する記憶手段と、 前記同期信号割込み発生時に、前記記憶手段の第1領域
の下位Nビットに前記Nビットカウンタの値をセット
し、該第1領域の上位M−nビットに前記積算手段の積
算結果を1/2nしてセットする計数値生成手段と、 前記記憶手段の第1領域から第2領域を引いた差分から
前記入力信号の周期を求める周期検出手段と、 前記記憶手段の第1領域の内容を第2領域に書込む更新
手段と、を有することを特徴とする周波数検出装置。
7. A frequency detecting apparatus for detecting a frequency by detecting a cycle of an input signal, comprising: signal detecting means for detecting a rising or falling edge of the input signal to generate a synchronization signal interrupt; the n-bit counter for counting (n is a positive integer), 2 n upper n bits (n is a positive integer) from zero to 2 n -1
A comparison means for sequentially comparing 2 n comparison setting values having N integer values and having the lower N−n bits of 0 and the value of the N-bit counter, and generating a comparison coincidence interrupt when they coincide with each other; Integrating means for integrating the number of times of the comparison coincidence interrupt, storage means for holding two N + M-n bits (M is a positive integer) data in first and second areas, respectively, count value for the set value of the n-bit counter, sets the accumulation result of said accumulating means to the upper M-n bits of the first region is 1/2 n to the lower n bits of the first region of the storage unit Generating means; cycle detecting means for obtaining a cycle of the input signal from a difference obtained by subtracting a second area from a first area of the storing means; updating means for writing the contents of the first area of the storing means into a second area And characterized by having The wave number detecting device.
【請求項8】 前記Nビットカウンタの上位nビットと
前記積算手段の積算結果の下位nビットとが一致するか
否かを検出する同期検出手段と、 前記同期検出手段で一致していないときに、前記積算手
段の積算結果を前記Nビットカウンタの値で補正して前
記計数値生成手段に与える補正手段と、を有することを
特徴とする請求項7に記載の周波数検出装置。
8. A synchronous detecting means for detecting whether or not the upper n bits of the N-bit counter and the lower n bits of the integrating result of the integrating means coincide with each other. 8. The frequency detection device according to claim 7, further comprising: a correction unit that corrects the integration result of the integration unit with the value of the N-bit counter and provides the result to the count value generation unit.
【請求項9】 請求項1、2、3、4、5または6に記
載の周波数検出方法をコンピュータに実行させるための
プログラムとして記録したコンピュータにより読み取り
可能な記録媒体。
9. A computer-readable recording medium recorded as a program for causing a computer to execute the frequency detection method according to claim 1, 2, 3, 4, 5, or 6.
JP2000365501A 2000-11-30 2000-11-30 Frequency detection method, frequency detection apparatus, and recording medium Expired - Fee Related JP4510274B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2000365501A JP4510274B2 (en) 2000-11-30 2000-11-30 Frequency detection method, frequency detection apparatus, and recording medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2000365501A JP4510274B2 (en) 2000-11-30 2000-11-30 Frequency detection method, frequency detection apparatus, and recording medium

Publications (2)

Publication Number Publication Date
JP2002168890A true JP2002168890A (en) 2002-06-14
JP4510274B2 JP4510274B2 (en) 2010-07-21

Family

ID=18836264

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2000365501A Expired - Fee Related JP4510274B2 (en) 2000-11-30 2000-11-30 Frequency detection method, frequency detection apparatus, and recording medium

Country Status (1)

Country Link
JP (1) JP4510274B2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007057446A (en) * 2005-08-26 2007-03-08 Fujitsu Ten Ltd Device and method for measuring pulse signal

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS58214951A (en) * 1982-06-08 1983-12-14 Fujitsu Ten Ltd Time counting system using free running counter
JPS58215567A (en) * 1982-06-10 1983-12-15 Nec Corp Rectangular wave control circuit
JPH09113556A (en) * 1995-10-16 1997-05-02 Nec Ic Microcomput Syst Ltd Pulse measuring circuit and measuring method thereof
JPH09189780A (en) * 1995-11-08 1997-07-22 Denso Corp Time measuring device
JPH1031044A (en) * 1996-07-15 1998-02-03 Fujitsu Ltd Pulse width measuring circuit
JP2000074962A (en) * 1998-08-28 2000-03-14 Nec Ic Microcomput Syst Ltd Cycle-measuring device and method therefor, and storage medium
JP2000131355A (en) * 1998-10-22 2000-05-12 Matsushita Electric Ind Co Ltd Frequency detecting method

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS58214951A (en) * 1982-06-08 1983-12-14 Fujitsu Ten Ltd Time counting system using free running counter
JPS58215567A (en) * 1982-06-10 1983-12-15 Nec Corp Rectangular wave control circuit
JPH09113556A (en) * 1995-10-16 1997-05-02 Nec Ic Microcomput Syst Ltd Pulse measuring circuit and measuring method thereof
JPH09189780A (en) * 1995-11-08 1997-07-22 Denso Corp Time measuring device
JPH1031044A (en) * 1996-07-15 1998-02-03 Fujitsu Ltd Pulse width measuring circuit
JP2000074962A (en) * 1998-08-28 2000-03-14 Nec Ic Microcomput Syst Ltd Cycle-measuring device and method therefor, and storage medium
JP2000131355A (en) * 1998-10-22 2000-05-12 Matsushita Electric Ind Co Ltd Frequency detecting method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007057446A (en) * 2005-08-26 2007-03-08 Fujitsu Ten Ltd Device and method for measuring pulse signal

Also Published As

Publication number Publication date
JP4510274B2 (en) 2010-07-21

Similar Documents

Publication Publication Date Title
JPH04270570A (en) Digital phase-locked loop circuit
JP4510274B2 (en) Frequency detection method, frequency detection apparatus, and recording medium
JP2006189742A (en) Method for recognizing video signal timing of analog input of display
JPH01232393A (en) Frequency detector
JP2000131355A (en) Frequency detecting method
JP3399450B2 (en) Frequency detection method and frequency detection circuit
JP3821913B2 (en) Horizontal frequency detection circuit
JP3876794B2 (en) Vertical sync signal processing circuit
JP2003337149A (en) Frequency detecting method
JP2936800B2 (en) Signal generator
JP3495672B2 (en) Display device
JP2811067B2 (en) Tuning display circuit
JPH07281650A (en) Horizontal frequency detection circuit
JP3054498B2 (en) Image display device and input signal determination circuit
JP3523059B2 (en) Horizontal synchronization signal frequency detection method and horizontal synchronization signal frequency detection circuit
JP2001324954A (en) Circuit for detecting picture display position
JP4903074B2 (en) Synchronization signal generation circuit
KR0166860B1 (en) Specific line detecting apparatus of composite image signal
JP2005048698A (en) Signal processor
JP2008199277A (en) Clock control circuit, integrated circuit device, and electronic apparatus
JPH0620278B2 (en) Synchronous frequency mode judgment circuit
JP2000201281A (en) Method and device for measuring horizontal frequency
JPH11220677A (en) Frequency detecting circuit
JPH08123348A (en) Horizontal frequency detection circuit
JPH0476530B2 (en)

Legal Events

Date Code Title Description
RD04 Notification of resignation of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7424

Effective date: 20060324

RD02 Notification of acceptance of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7422

Effective date: 20071114

RD04 Notification of resignation of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7424

Effective date: 20071121

RD02 Notification of acceptance of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7422

Effective date: 20071128

A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20071129

RD04 Notification of resignation of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7424

Effective date: 20071205

RD04 Notification of resignation of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7424

Effective date: 20071212

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20100126

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20100202

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20100315

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20100406

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20100430

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20130514

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

LAPS Cancellation because of no payment of annual fees