JP2007057446A - Device and method for measuring pulse signal - Google Patents

Device and method for measuring pulse signal Download PDF

Info

Publication number
JP2007057446A
JP2007057446A JP2005245127A JP2005245127A JP2007057446A JP 2007057446 A JP2007057446 A JP 2007057446A JP 2005245127 A JP2005245127 A JP 2005245127A JP 2005245127 A JP2005245127 A JP 2005245127A JP 2007057446 A JP2007057446 A JP 2007057446A
Authority
JP
Japan
Prior art keywords
pulse signal
count value
input
timer
interrupt
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
JP2005245127A
Other languages
Japanese (ja)
Other versions
JP4932193B2 (en
Inventor
Masanori Akaza
雅憲 赤座
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.)
Denso Ten Ltd
Original Assignee
Denso Ten 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 Denso Ten Ltd filed Critical Denso Ten Ltd
Priority to JP2005245127A priority Critical patent/JP4932193B2/en
Publication of JP2007057446A publication Critical patent/JP2007057446A/en
Application granted granted Critical
Publication of JP4932193B2 publication Critical patent/JP4932193B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Manipulation Of Pulses (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To accurately measure width and period of pulse signal using a timer for generating an interrupt signal in regard to both of a pulse signal input and overflow. <P>SOLUTION: The interrupt signal is output while reloading to a reload register is performed, the interrupt signal is output without reloading to the reload register when the count value overflows, and the interrupt signal is received and the count value of the reload register is read when the pulse width or period are measured using a timer for putting an overflow flag into the ON state (step ST1). The state of the overflow flag of the timer is determined (step ST2). When the overflow flag lies in the ON state, the existence of input of the pulse signal is determined based on the comparison of the present value read from the reload register with the last value (step ST6). <P>COPYRIGHT: (C)2007,JPO&INPIT

Description

本発明は、カウンタ回路を備えたタイマを用いてパルス幅やパルス周期を測定するパルス信号測定装置及び方法に関する。   The present invention relates to a pulse signal measuring apparatus and method for measuring a pulse width and a pulse period using a timer having a counter circuit.

パルス信号の周期やパルス幅を検出するためのタイマとしては、パルス信号の立ち上がりあるいは立ち下がり(パルス信号のエッジ)に同期してカウンタ回路によりカウント動作すると共にパルス信号のエッジを検出する毎に割り込み信号を出力するものが知られている(例えば、特許文献1参照)。したがって、割り込み要求の発生に応じてカウンタ回路のカウント値を読み出せば、パルス幅やパルス周期を検出することができる。
特開平05−150858号公報
As a timer for detecting the period and width of the pulse signal, the counter circuit counts in synchronization with the rise or fall of the pulse signal (the edge of the pulse signal) and interrupts every time the pulse signal edge is detected A device that outputs a signal is known (for example, see Patent Document 1). Therefore, the pulse width and the pulse period can be detected by reading the count value of the counter circuit in response to the generation of the interrupt request.
Japanese Patent Laid-Open No. 05-150858

ところで、上記のタイマでは、パルス幅や周期が長いパルス信号が入力されてカウンタ回路にオーバーフローが発生した場合には、オーバーフローフラグをオンすると共に上記の割り込み信号をオンさせる。すなわち、上記のタイマでは、パルス信号の入力による場合とオーバーフローが生じた場合とで同じ割り込み信号を生成する。通常は、この割り込み信号がパルス信号の入力によるものか、あるいは、オーバーフローによるものかを判別するには、オーバーフローフラグがオンしているかで判断できる。
しかしながら、オーバーフローフラグがオンしている状態でパルス信号が入力されたような場合には、割り込み要求がオーバーフローによるものなのか、パルス信号の入力による割り込み信号が得られず、オーバーフローが発生するようなパルス信号の幅や周期の正確な測定が困難であった。
By the way, in the timer, when a pulse signal having a long pulse width or cycle is input and an overflow occurs in the counter circuit, the overflow flag is turned on and the interrupt signal is turned on. In other words, the timer generates the same interrupt signal when the pulse signal is input and when an overflow occurs. Normally, in order to determine whether the interrupt signal is due to the input of a pulse signal or due to an overflow, it can be determined based on whether the overflow flag is on.
However, if a pulse signal is input with the overflow flag turned on, the interrupt request may be caused by an overflow, or an interrupt signal due to the input of the pulse signal cannot be obtained, resulting in an overflow. It was difficult to accurately measure the width and period of the pulse signal.

本発明は、上記の事情に鑑みて成されたものであり、その目的とするところは、パルス信号の入力及びカウンタ回路のオーバーフローの双方について割り込み信号を発生するタイマを用いてパルス信号の幅や周期の正確な測定が可能なパルス信号測定装置及び方法を提供することにある。   The present invention has been made in view of the above circumstances, and its object is to use a timer that generates an interrupt signal for both the input of the pulse signal and the overflow of the counter circuit, An object of the present invention is to provide a pulse signal measuring apparatus and method capable of accurately measuring the period.

本発明に係るパルス信号測定方法は、パルス信号のエッジの検出に基づいてカウント動作を実行してそのカウント値をリロードレジスタへリロードすると共に割り込み信号を出力し、カウント値がオーバーフローした場合にはリロードレジスタへリロードせずに割り込み信号を出力すると共にオーバーフローフラグをオン状態にするタイマを用いたパルス信号測定方法であって、タイマからの割り込み信号を受けてリロードレジスタのカウント値を読み出す読出ステップと、タイマからの割り込み信号を受けてタイマのオーバーフローフラグの状態を判別するフラグ判別ステップと、オーバーフローフラグがオンしている場合に、リロードレジスタから読み出した今回のカウント値と前記のカウント値との比較に基づいてオーバーフローフラグがオンしている間におけるパルス信号の入力の有無を判断する入力判別ステップと、を有することを特徴としている。
この構成によれば、オーバーフローによりオーバーフローフラグがオンしている間に新たにパルス信号が入力(新たにパルス信号のエッジが検出)された場合には、リロードレジスタに新たなカウント値がリロードされるので、このリロードレジスタの値から新たなパルス信号の入力の有無を検出できる。
The pulse signal measurement method according to the present invention executes a count operation based on detection of an edge of a pulse signal, reloads the count value to the reload register, outputs an interrupt signal, and reloads when the count value overflows. A pulse signal measurement method using a timer that outputs an interrupt signal without reloading to a register and sets an overflow flag to an on state, wherein a reading step of reading a count value of a reload register in response to an interrupt signal from the timer; A flag determination step for determining the state of the overflow flag of the timer in response to an interrupt signal from the timer, and a comparison between the current count value read from the reload register and the count value when the overflow flag is on. Based on overflow hula There has been characterized as having a an input determination step of determining whether the input of the pulse signal in while on.
According to this configuration, when a new pulse signal is input (a new edge of the pulse signal is detected) while the overflow flag is on due to overflow, a new count value is reloaded into the reload register. Therefore, the presence or absence of a new pulse signal input can be detected from the value of the reload register.

上記構成において、入力判別ステップは、リロードレジスタから読み出した今回と前回とのカウント値が一致しない場合にはパルス信号の入力による割り込み要求があったと判断し、リロードレジスタから読み出した今回と前回とのカウント値が一致する場合には、パルス信号の入力による割り込み要求がないと判断する、構成を採用できる。
この構成によれば、リロードレジスタの前回と今回の値とを比較すれば、新たにパルス信号が入力されたかを検出でき、オーバーフローフラグがオンしている間の新たなパルス信号の入力を検出できる。
In the above configuration, the input determining step determines that there is an interrupt request due to the input of a pulse signal when the count value of the current time read from the reload register and the previous time does not match, and the current time read from the reload register is the previous time When the count values match, a configuration can be adopted in which it is determined that there is no interrupt request due to input of a pulse signal.
According to this configuration, by comparing the previous value and the current value of the reload register, it is possible to detect whether a new pulse signal is input, and it is possible to detect the input of a new pulse signal while the overflow flag is on. .

上記構成において、フラグ判別ステップにおいてオーバーフローフラグがオフ状態と判断される場合、及び、入力判別ステップにおいてパルス信号の入力による割り込み要求があったと判断される場合に、パルス信号のパルス幅又は周期を算出する算出ステップをさらに有する、構成を採用できる。
この構成によれば、オーバーフローによる割り込み要求とパルス信号の入力による割り込み要求とは確実に区別されるので、パルス信号のパルス幅又は周期を正確に算出できる。
In the above configuration, the pulse width or cycle of the pulse signal is calculated when it is determined that the overflow flag is off in the flag determination step, and when it is determined that there is an interrupt request due to the input of the pulse signal in the input determination step. It is possible to employ a configuration that further includes a calculation step.
According to this configuration, since an interrupt request due to overflow and an interrupt request due to input of a pulse signal are reliably distinguished, the pulse width or cycle of the pulse signal can be accurately calculated.

上記構成において、入力判別ステップにおける判別結果を通知するステップをさらに有する、構成を採用できる。
この構成によれば、タイマのカウント値を利用するアプリケーション等に、オーバーフローによる割り込み要求か、パルス信号の入力による割り込み要求かを知らせることができる。
In the above configuration, it is possible to adopt a configuration further including a step of notifying the determination result in the input determining step.
According to this configuration, it is possible to notify an application using the count value of the timer whether an interrupt request is due to overflow or an interrupt request is due to input of a pulse signal.

上記構成において、判別結果の通知後に、オーバーフローフラグをオフする処理をするステップをさらに有する、構成を採用できる。
この構成によれば、オーバーフローフラグをタイマの外部から強制的にオフする処理をするので、一のカウント動作においてオーバーフローフラグがオンする回数をカウントすることによりオーバーフローの発生回数を取得できる。
In the above configuration, it is possible to employ a configuration that further includes a step of performing processing for turning off the overflow flag after notification of the determination result.
According to this configuration, since the process of forcibly turning off the overflow flag from the outside of the timer is performed, the number of occurrences of overflow can be acquired by counting the number of times the overflow flag is turned on in one count operation.

上記構成において、フラグ判別ステップにおいてオーバーフローが発生したと判断される場合に、一のカウント動作中に発生したオーバーフローの回数を更新する更新ステップをさらに有する、構成を採用できる。
この構成によれば、一のカウント動作中に発生したオーバーフローの回数が得られるので、パルス信号の幅や周期が長い場合にも測定可能となる。
In the above configuration, it is possible to adopt a configuration further including an update step of updating the number of overflows that occurred during one count operation when it is determined that an overflow has occurred in the flag determination step.
According to this configuration, the number of overflows that occurred during one counting operation can be obtained, so that measurement is possible even when the width and period of the pulse signal are long.

上記構成において、更新ステップを実行する前にオーバーフローの回数が所定の最大値を超えていないかを判断し、超えている場合には更新ステップを実行させない最大値ガード処理ステップをさらに有する、構成を採用できる。
この構成によれば、誤った幅や周期を算出することを防止できる。
In the above configuration, it is determined whether or not the number of overflows exceeds a predetermined maximum value before executing the update step, and further includes a maximum value guard processing step that does not cause the update step to be executed if it exceeds. Can be adopted.
According to this configuration, it is possible to prevent an erroneous width or cycle from being calculated.

上記構成において、オーバーフローの回数と、前記リロードレジスタから読み出したカウント値とに基づいて、パルス幅又は周期を算出する算出ステップをさらに有する、構成を採用できる。
この構成によれば、オーバーフローの発生するような長いパルス幅又は周期のパルス信号の正確な測定が可能となる。
In the above configuration, it is possible to employ a configuration that further includes a calculation step of calculating a pulse width or a cycle based on the number of overflows and the count value read from the reload register.
According to this configuration, it is possible to accurately measure a pulse signal having a long pulse width or period that causes overflow.

本発明に係るパルス信号測定装置は、パルス信号のエッジの検出に基づいてカウント動作を実行してそのカウント値をリロードレジスタへリロードすると共に割り込み信号を出力し、カウント値がオーバーフローした場合にはリロードレジスタへリロードせずに割り込み信号を出力するタイマを用いたパルス信号測定装置であって、タイマからの割り込み信号を受けてリロードレジスタのカウント値を読み出す読出手段と、タイマからの割り込み信号を受けてタイマのオーバーフローフラグの状態を判別するフラグ判別手段と、オーバーフローフラグがオンしている場合に、リロードレジスタから読み出した今回のカウント値とのカウント値との比較に基づいてオーバーフローフラグがオンしている間におけるパルス信号の入力の有無を判断する入力判別手段と、を有することを特徴としている。   The pulse signal measuring apparatus according to the present invention executes a count operation based on detection of an edge of a pulse signal, reloads the count value to the reload register, outputs an interrupt signal, and reloads when the count value overflows A pulse signal measuring device using a timer that outputs an interrupt signal without reloading to a register, receiving means for receiving an interrupt signal from the timer and reading a count value of the reload register, and receiving an interrupt signal from the timer The flag determination means for determining the state of the overflow flag of the timer, and when the overflow flag is ON, the overflow flag is ON based on the comparison with the count value of the current count value read from the reload register The presence or absence of pulse signal input between Is characterized by having an input determination unit that, the.

本発明によれば、入力されるパルス信号のエッジの検出及びカウンタ回路のオーバーフローの双方について割り込み信号を発生するタイマを用いて幅や周期が長いパルス信号の幅や周期の正確な測定が可能となる。   According to the present invention, it is possible to accurately measure the width and period of a pulse signal having a long width and cycle by using a timer that generates an interrupt signal for both detection of an edge of the input pulse signal and overflow of the counter circuit. Become.

以下、本発明の最良の実施形態について、添付図面を参照しつつ説明する。
図1は、本発明の一実施形態に係るパルス信号測定装置に用いられるタイマの回路構成図である。
このタイマ10は、図1に示すように、パルスエッジ検出回路30、カウンタリセット回路40、オーバーフローフラグ(レジスタ)50、クロック発生回路60、カウンタ回路70、リロードレジスタ80等から構成されている。尚、本実施形態では、タイマ10は、独立の回路として構成されているが、プロセッサの一部の回路として構成されていてもよい。
DESCRIPTION OF EXEMPLARY EMBODIMENTS Hereinafter, exemplary embodiments of the invention will be described with reference to the accompanying drawings.
FIG. 1 is a circuit configuration diagram of a timer used in a pulse signal measuring apparatus according to an embodiment of the present invention.
As shown in FIG. 1, the timer 10 includes a pulse edge detection circuit 30, a counter reset circuit 40, an overflow flag (register) 50, a clock generation circuit 60, a counter circuit 70, a reload register 80, and the like. In the present embodiment, the timer 10 is configured as an independent circuit, but may be configured as a partial circuit of the processor.

パルスエッジ検出回路30は、入力ポート20から入力されるパルス信号PSのエッジを検出し、検出に応じてパルスをカウンタリセット回路40へ出力する。また、パルスエッジ検出回路30は、設定された各検出モードに応じてパルス信号PSの立ち上がりエッジ及び/又は立下りエッジを検出する。例えば、パルス信号PSの周期を検出するモードでは、パルス信号PSの立ち上がりエッジ又は立下りエッジを検出し、パルス信号PSのパルス幅を検出する場合には、立ち上がりエッジ及び立下りエッジの双方を検出する。   The pulse edge detection circuit 30 detects the edge of the pulse signal PS input from the input port 20 and outputs a pulse to the counter reset circuit 40 in response to the detection. Further, the pulse edge detection circuit 30 detects the rising edge and / or the falling edge of the pulse signal PS in accordance with each set detection mode. For example, in the mode for detecting the period of the pulse signal PS, the rising edge or the falling edge of the pulse signal PS is detected. When the pulse width of the pulse signal PS is detected, both the rising edge and the falling edge are detected. To do.

カウンタリセット回路40は、パルス信号PSのエッジの検出に同期してリセットパルスをカウンタ回路70へ出力する。カウンタ回路70はリセットパルスの入力により一のカウント動作を終了して新たなカウント動作を開始する。   The counter reset circuit 40 outputs a reset pulse to the counter circuit 70 in synchronization with detection of the edge of the pulse signal PS. The counter circuit 70 ends one count operation by the input of a reset pulse and starts a new count operation.

オーバーフローフラグ50は、カウンタ回路70においてカウント値CTがオーバーフローした場合にオンされて、オーバーフローの発生を示すためのフラグ(レジスタ)である。オーバーフローフラグ50はオンされると、外部(例えば、パルス信号測定装置100)からソフトウエア処理によりオフされるまでオン状態を維持する。   The overflow flag 50 is turned on when the count value CT overflows in the counter circuit 70, and is a flag (register) for indicating the occurrence of overflow. When the overflow flag 50 is turned on, it remains on until it is turned off by software processing from the outside (for example, the pulse signal measuring device 100).

クロック発生回路60、設定された周波数のクロック信号をカウンタ回路70へ供給する。   The clock generation circuit 60 supplies a clock signal having a set frequency to the counter circuit 70.

カウンタ回路70は、クロック発生回路60から供給されるクロック信号及びカウンタリセット回路から入力されるリセットパルスに基づいてカウント動作をする。
カウンタ回路70は、具体的には、リセットパルスが入力されるとアップカウントを開始し、次にリセットパルスが入力されるとそのときのカウント値CTをリロードレジスタ80へリロードすると共に割り込み信号INTをパルス信号測定装置100へ出力し、かつ、再びアップカウントを開始する。
また、カウンタ回路70は、カウント動作中にオーバーフローが発生した場合には、カウント値CTをリロードレジスタ80へリロードせずに割り込み信号INTを出力すると共にオーバーフローフラグ50をオン状態にし、かつ、アップカウントを継続する。例えば、カウンタ回路70が16ビットのレジスタを有する場合には、カウント値が65536を超えるとオーバーフローが発生する。尚、割り込み信号INTは、オーバーフローフラグ50がオフされるまで出力される。
The counter circuit 70 performs a counting operation based on the clock signal supplied from the clock generation circuit 60 and the reset pulse input from the counter reset circuit.
Specifically, the counter circuit 70 starts counting up when a reset pulse is input, and when the reset pulse is input next, the counter circuit 70 reloads the count value CT at that time to the reload register 80 and outputs an interrupt signal INT. The signal is output to the pulse signal measuring apparatus 100, and the up-count is started again.
When an overflow occurs during the counting operation, the counter circuit 70 outputs the interrupt signal INT without reloading the count value CT to the reload register 80, turns on the overflow flag 50, and counts up. Continue. For example, when the counter circuit 70 has a 16-bit register, overflow occurs when the count value exceeds 65536. The interrupt signal INT is output until the overflow flag 50 is turned off.

リロードレジスタ80は、カウンタ回路70で確定したカウント値CTを次回のカウント値CTが確定するまで保持する。すなわち、リロードレジスタ80は、カウンタ回路70から新たなカウント値CTがリロードされるまでは、前回のカウント値CTを保持する。   The reload register 80 holds the count value CT determined by the counter circuit 70 until the next count value CT is determined. That is, the reload register 80 holds the previous count value CT until a new count value CT is reloaded from the counter circuit 70.

パルス信号測定装置100は、例えば、プロセッサ、メモリ等のハードウエアと所要のソフトウエアから構成され、後述する処理を実行する。   The pulse signal measuring device 100 is constituted by, for example, hardware such as a processor and a memory, and necessary software, and executes processing to be described later.

次に、タイマ10を用いたパルス信号測定装置100による処理の一例について図2ないし図5を参照して説明する。
ここで、図2はパルス信号測定装置における処理の一例を示すフローチャート、図3はパルス信号の入力による割込処理とオーバーフローによる割込処理の一例を示すフローチャート、図4はパルス信号の測定に関する各種変数の一例を示すタイミングチャート、及び図5は各種変数の他の例を示すタイミングチャートである。
Next, an example of processing by the pulse signal measuring apparatus 100 using the timer 10 will be described with reference to FIGS.
Here, FIG. 2 is a flowchart showing an example of processing in the pulse signal measuring apparatus, FIG. 3 is a flowchart showing an example of interrupt processing by input of a pulse signal and interrupt processing by overflow, and FIG. FIG. 5 is a timing chart showing another example of various variables.

先ず、パルス信号測定装置100による処理を説明する前に、タイマ10の動作について図4及び図5を参照して説明する。尚、図4及び図5は、パルス信号PSの周期を測定する場合のタイミングチャートである。
カウンタ回路70は、図4(B)に示すように、パルス信号PS(図4(A))の立ち上がりに同期してアップカウント動作をすると共に、図4(C)に示すように、リロードレジスタ80の値を更新する。
また、カウンタ回路70は、図4(B)に示すように、カウント値CTがオーバーフローした場合には、リロードレジスタ80の値は更新せずに、図4(D)に示すように、オーバーフローフラグ50をオンする。このオーバーフローフラグ50は、ソフトウエアによりオフされるまでオン状態を維持する。
さらに、カウンタ回路70は、図4(E)に示すように、パルス信号PSの立ち上がりに同期して割り込み信号INTを出力すると共に、オーバーフローの発生に同期して割り込み信号INTを出力する。このような場合には、オーバーフローフラグ50の状態を検出することにより、割り込み信号INTの発生原因を特定することができる。
First, before describing the processing by the pulse signal measuring apparatus 100, the operation of the timer 10 will be described with reference to FIGS. 4 and 5 are timing charts for measuring the period of the pulse signal PS.
As shown in FIG. 4B, the counter circuit 70 performs an up-counting operation in synchronization with the rising edge of the pulse signal PS (FIG. 4A), and as shown in FIG. The value of 80 is updated.
In addition, as shown in FIG. 4B, the counter circuit 70 does not update the value of the reload register 80 when the count value CT overflows, as shown in FIG. Turn on 50. This overflow flag 50 remains on until it is turned off by software.
Further, as shown in FIG. 4E, the counter circuit 70 outputs the interrupt signal INT in synchronization with the rising edge of the pulse signal PS, and outputs the interrupt signal INT in synchronization with the occurrence of the overflow. In such a case, the cause of the interrupt signal INT can be specified by detecting the state of the overflow flag 50.

一方、図5(A)ないし(E)に示すように、カウント値CTがオーバーフローしてオーバーフローフラグがオンした状態で、カウンタ回路パルス70にパルス信号PSの立ち上がりエッジが入力された場合、すなわち、オーバーフローとパルス信号PSのエッジの入力が重なった場合には、カウンタ回路70は、割り込み信号INTをオーバーフローの発生により既に出力しているので、パルス信号PSの立ち上がりエッジに同期した割り込み信号INTは出力されない。すなわち、タイマ10へパルス信号PSの立ち上がりエッジが入力されても、これに同期した割り込み信号INTが得られない。   On the other hand, as shown in FIGS. 5A to 5E, when the rising edge of the pulse signal PS is input to the counter circuit pulse 70 in a state where the count value CT overflows and the overflow flag is turned on, that is, When the overflow and the input of the edge of the pulse signal PS overlap, the counter circuit 70 has already output the interrupt signal INT due to the occurrence of the overflow, so the interrupt signal INT synchronized with the rising edge of the pulse signal PS is output. Not. That is, even if the rising edge of the pulse signal PS is input to the timer 10, the interrupt signal INT synchronized with this is not obtained.

次に、図2ないし図5を参照してパルス信号測定装置100による処理について説明する。
パルス信号測定装置100は、タイマ10から割り込み信号INTを受けると、図2に示すタイマ割り込み処理を実行する。
このタイマ割り込み処理は、先ず、リロードレジスタ80の値を読み出して、今回値として記憶する(ステップST1)。
次いで、オーバーフローフラグ50がオンしているかを判断し(ステップST2)、オーバーフローフラグ50がオフしている場合には、タイマ10からの割り込み要求がパルス信号PSの立ち上がりエッジの入力によるものと判断し、後述するパルス信号の入力による割込み処理を実行する(ステップST3)。
Next, processing performed by the pulse signal measuring apparatus 100 will be described with reference to FIGS.
When receiving the interrupt signal INT from the timer 10, the pulse signal measuring apparatus 100 executes a timer interrupt process shown in FIG.
In this timer interrupt process, first, the value of the reload register 80 is read and stored as the current value (step ST1).
Next, it is determined whether the overflow flag 50 is on (step ST2). If the overflow flag 50 is off, it is determined that the interrupt request from the timer 10 is due to the input of the rising edge of the pulse signal PS. Then, an interrupt process is performed by inputting a pulse signal described later (step ST3).

一方、ステップST2において、オーバーフローフラグ50がオンしている場合には、
オーバーフローの回数が所定の最大数(例えば、レジスタのビット数で規定される)を超えているかを判断する最大値ガード処理を実行し(ステップST4)、超えていない場合には、オーバーフローの回数をカウントアップする(ステップST5)。尚、オーバーフローの回数は、パルス信号測定装置100における変数であり、図4(G)や図5(G)に示すように、オーバーフローの発生毎に変化する。また、オーバーフローの回数の初期値は0である。
On the other hand, if the overflow flag 50 is on in step ST2,
A maximum value guard process is performed to determine whether the number of overflows exceeds a predetermined maximum number (for example, specified by the number of bits in the register) (step ST4). Count up (step ST5). The number of overflows is a variable in the pulse signal measuring apparatus 100, and changes every time an overflow occurs, as shown in FIGS. 4 (G) and 5 (G). The initial value of the number of overflows is zero.

次いで、リロードレジスタ80から読み出した今回のカウント値と前回のカウント値とが異なっているかを比較する(ステップST6)。
ここで、今回のカウント値と前回のカウント値とが一致している場合には、パルス信号PSの入力による割り込み要求がないと判断して、後述するオーバーフローによる割り込み処理を実行する(ステップST8)。
一方、今回のカウント値と前回のカウント値とが異なっている場合には、オーバーフローフラグ50がオンしている間にパルス信号PSの入力が有ったものと判断し、後述するパルス信号の入力による割込み処理を実行する(ステップST7)。
Next, it is compared whether the current count value read from the reload register 80 is different from the previous count value (step ST6).
If the current count value matches the previous count value, it is determined that there is no interrupt request due to the input of the pulse signal PS, and an interrupt process due to overflow described later is executed (step ST8). .
On the other hand, if the current count value is different from the previous count value, it is determined that the pulse signal PS has been input while the overflow flag 50 is on, and a pulse signal input to be described later is input. Is executed (step ST7).

ここで、ステップST3、ST7におけるパルス信号の入力による割込み処理、図3(A)に示すように、先ず、パルス幅又は周期の算出する(ステップST21)。パルス幅又は周期は、リロードレジスタ80のカウンタ最大値+1にオーバーフロー回数を掛け合わせた値に、リロードレジスタ80の今回値を加算することにより求められる。したがって、パルス信号測定装置100では、図4(F)や図5(F)に示すように、パルス信号の入力による割り込みが発生する毎に、パルス周期(又はパルス幅)が算出される。   Here, as shown in FIG. 3A, interrupt processing by inputting a pulse signal in steps ST3 and ST7, first, the pulse width or period is calculated (step ST21). The pulse width or cycle is obtained by adding the current value of the reload register 80 to the value obtained by multiplying the counter maximum value +1 of the reload register 80 by the number of overflows. Therefore, in the pulse signal measuring apparatus 100, as shown in FIG. 4 (F) and FIG. 5 (F), the pulse period (or pulse width) is calculated every time an interrupt due to the input of the pulse signal occurs.

次いで、オーバーフローの回数を初期化すると共に(ステップST22)、パルス信号の入力による割り込み要求が発生したことを、アプリケーション等に通知する処理をする(ステップST23)。これにより、アプリケーションでは、割り込み信号INTの発生原因を特定することができる。   Next, the number of overflows is initialized (step ST22), and a process for notifying an application or the like that an interrupt request has been generated by inputting a pulse signal is performed (step ST23). As a result, the application can identify the cause of the generation of the interrupt signal INT.

ステップST8におけるオーバーフローによる割り込み処理は、図3(B)に示すように、オーバーフローによる割り込み要求が発生したことをアプリケーション等に通知する処理をする(ステップST31)。これにより、アプリケーションでは、オーバーフローフラグがオンしている間にパルス信号の入力がなかったことを確実に識別できる。   As shown in FIG. 3B, the interrupt processing due to overflow in step ST8 is processing for notifying an application or the like that an interrupt request due to overflow has occurred (step ST31). As a result, the application can reliably identify that the pulse signal has not been input while the overflow flag is on.

パルス信号測定装置100は、ステップST7の処理を終えたのち、ステップST3,ST7,ST8の割り込み処理が完了するまで所定時間が経過するのを待ち(ステップST9)、その後に、タイマ10のオーバーフローフラグ50を、図4(D)や図5(D)に示すように、オフする処理を実行する(ステップST10)。これにより、タイマ10からの割り込み信号INTの出力は停止する。
次いで、リロードレジスタ80から読み出した今回値を前回値として更新し(ステップST11)、割り込み処理を終了する。
After completing the process of step ST7, the pulse signal measuring apparatus 100 waits for a predetermined time to elapse until the interrupt process of steps ST3, ST7, ST8 is completed (step ST9), and then the overflow flag of the timer 10 is set. As shown in FIG. 4D and FIG. 5D, a process of turning off 50 is executed (step ST10). As a result, the output of the interrupt signal INT from the timer 10 is stopped.
Next, the current value read from the reload register 80 is updated as the previous value (step ST11), and the interrupt process ends.

以上のように、本実施形態によれば、オーバーフローフラグがオンした状態においてもパルス信号の入力の有無が検出できるので、パルス信号の入力に同期した割り込み処理を確実に実行することができ、オーバーフローが発生するような長い周期又は幅のパルス信号の正確な測定が可能となる。   As described above, according to the present embodiment, even when the overflow flag is on, it is possible to detect whether or not a pulse signal is input, so that interrupt processing synchronized with the input of the pulse signal can be reliably executed, and overflow It is possible to accurately measure a pulse signal having a long period or a width such that the above occurs.

上記実施形態では、タイマ10とパルス信号測定装置100とを別々に構成した場合について説明したが、これに限定されるわけではなく、これらを一のプロセッサで構成することも可能である。   In the above embodiment, the case where the timer 10 and the pulse signal measuring device 100 are separately configured has been described. However, the present invention is not limited to this, and it is also possible to configure them with a single processor.

本発明の一実施形態に係るパルス信号測定装置に用いられるタイマの回路構成図である。It is a circuit block diagram of the timer used for the pulse signal measuring device concerning one embodiment of the present invention. パルス信号測定装置における処理の一例を示すフローチャートである。It is a flowchart which shows an example of the process in a pulse signal measuring device. (A)はパルス信号の入力による割込処理の一例を示すフローチャートであり、(B)はオーバーフローによる割り込み処理の一例を示すフローチャートである。(A) is a flowchart showing an example of interrupt processing by input of a pulse signal, and (B) is a flowchart showing an example of interrupt processing by overflow. パルス信号の測定に関する各種変数値の関係の一例を示すタイミングチャートある。It is a timing chart which shows an example of the relationship of the various variable values regarding the measurement of a pulse signal. パルス信号の測定に関する各種変数値の関係の他の例を示すタイミングチャートある。It is a timing chart which shows the other example of the relationship of the various variable values regarding the measurement of a pulse signal.

符号の説明Explanation of symbols

10…タイマ
20…入力ポート
30…パルスエッジ検出回路
40…カウンタリセット回路
50…オーバーフローフラグ
60…クロック発生回路
70…カウンタ回路
80…リロードレジスタ
100…パルス信号測定装置
PS…パルス信号
CT…カウント値
DESCRIPTION OF SYMBOLS 10 ... Timer 20 ... Input port 30 ... Pulse edge detection circuit 40 ... Counter reset circuit 50 ... Overflow flag 60 ... Clock generation circuit 70 ... Counter circuit 80 ... Reload register 100 ... Pulse signal measuring device PS ... Pulse signal CT ... Count value

Claims (9)

パルス信号のエッジの検出に基づいてカウント動作を実行してそのカウント値をリロードレジスタへリロードすると共に割り込み信号を出力し、前記カウント値がオーバーフローした場合には前記リロードレジスタへリロードせずに前記割り込み信号を出力すると共にオーバーフローフラグをオン状態にするタイマを用いたパルス信号測定方法であって、
前記タイマからの割り込み信号を受けて前記リロードレジスタのカウント値を読み出す読出ステップと、
前記タイマからの割り込み信号を受けて前記タイマのオーバーフローフラグの状態を判別するフラグ判別ステップと、
前記オーバーフローフラグがオンしている場合に、前記リロードレジスタから読み出した今回のカウント値と前回のカウント値との比較に基づいて前記オーバーフローフラグがオンしている間における前記パルス信号の入力の有無を判断する入力判別ステップと、
を有することを特徴とするパルス信号測定方法。
Based on the detection of the edge of the pulse signal, the count operation is performed and the count value is reloaded into the reload register and an interrupt signal is output. When the count value overflows, the interrupt is performed without reloading into the reload register. A pulse signal measuring method using a timer that outputs a signal and turns on an overflow flag,
A reading step of receiving the interrupt signal from the timer and reading the count value of the reload register;
A flag determination step of determining an overflow flag state of the timer in response to an interrupt signal from the timer;
Whether or not the pulse signal is input while the overflow flag is on based on a comparison between the current count value read from the reload register and the previous count value when the overflow flag is on. An input determining step for determining;
A pulse signal measurement method comprising:
前記入力判別ステップは、前記リロードレジスタから読み出した今回と前回とのカウント値が一致しない場合には前記パルス信号の入力による割り込み要求があったと判断し、
前記リロードレジスタから読み出した今回と前回とのカウント値が一致する場合には、前記パルス信号の入力による割り込み要求がないと判断する、
ことを特徴とする請求項1に記載のパルス信号測定方法。
The input determining step determines that there is an interrupt request due to the input of the pulse signal when the count value of the current time read from the reload register does not match the previous count value,
If the current and previous count values read from the reload register match, it is determined that there is no interrupt request due to the input of the pulse signal.
The pulse signal measuring method according to claim 1.
前記フラグ判別ステップにおいてオーバーフローフラグがオフ状態と判断される場合、及び、前記入力判別ステップにおいて前記パルス信号の入力による割り込み要求があったと判断される場合に、前記パルス信号のパルス幅又は周期を算出する算出ステップをさらに有する、
ことを特徴とする請求項2に記載のパルス信号測定方法。
When it is determined that the overflow flag is off in the flag determination step, and when it is determined that there is an interrupt request due to the input of the pulse signal in the input determination step, the pulse width or period of the pulse signal is calculated. A calculation step of:
The pulse signal measuring method according to claim 2.
前記入力判別ステップにおける判別結果を通知するステップをさらに有する

ことを特徴とする請求項2又は3に記載のパルス信号測定方法。
A step of notifying the determination result in the input determination step;
The pulse signal measuring method according to claim 2 or 3, characterized in that.
前記判別結果の通知後に、前記オーバーフローフラグをオフする処理をするステップをさらに有する、
ことを特徴とする請求項4に記載のパルス信号測定方法。
A step of turning off the overflow flag after notification of the determination result;
The pulse signal measuring method according to claim 4.
前記フラグ判別ステップにおいてオーバーフローが発生したと判断される場合に、一のカウント動作中に発生したオーバーフローの回数を更新する更新ステップをさらに有する、
ことを特徴とする請求項5に記載のパルス信号測定方法。
An update step of updating the number of overflows that occurred during one counting operation when it is determined that an overflow has occurred in the flag determination step;
The pulse signal measuring method according to claim 5.
前記更新ステップを実行する前にオーバーフローの回数が所定の最大値を超えていないかを判断し、超えている場合には前記更新ステップを実行させない最大値ガード処理ステップをさらに有する、
ことを特徴とする請求項6に記載のパルス信号測定方法。
Before executing the update step, it is determined whether or not the number of overflows exceeds a predetermined maximum value, and if it exceeds, a maximum value guard processing step that does not cause the update step to be performed is further included.
The pulse signal measuring method according to claim 6.
前記オーバーフローの回数と、前記リロードレジスタから読み出したカウント値とに基づいて、前記パルス幅又は周期を算出する算出ステップをさらに有する
ことを特徴とする請求項6又は7に記載のパルス信号測定方法。
8. The pulse signal measuring method according to claim 6, further comprising a calculating step of calculating the pulse width or period based on the number of overflows and the count value read from the reload register.
パルス信号のエッジの検出に基づいてカウント動作を実行してそのカウント値をリロードレジスタへリロードすると共に割り込み信号を出力し、かつ前記カウント値がオーバーフローした場合には前記リロードレジスタへリロードせずに割り込み信号を出力するタイマを用いたパルス信号測定装置であって、
前記タイマからの割り込み信号を受けて前記リロードレジスタのカウント値を読み出す読出手段と、
前記タイマからの割り込み信号を受けて前記タイマのオーバーフローフラグの状態を判別するフラグ判別手段と、
前記オーバーフローフラグがオンしている場合に、前記リロードレジスタから読み出した今回のカウント値と前記のカウント値との比較に基づいて前記オーバーフローフラグがオンしている間における前記パルス信号の入力の有無を判断する入力判別手段と、
を有することを特徴とするパルス信号測定装置。
Based on the detection of the edge of the pulse signal, the count operation is performed and the count value is reloaded into the reload register and the interrupt signal is output. When the count value overflows, the interrupt is performed without reloading into the reload register. A pulse signal measuring device using a timer for outputting a signal,
Read means for receiving the interrupt signal from the timer and reading the count value of the reload register;
Flag determining means for receiving an interrupt signal from the timer and determining the state of an overflow flag of the timer;
Whether or not the pulse signal is input while the overflow flag is on based on a comparison between the current count value read from the reload register and the count value when the overflow flag is on. An input discriminating means for judging;
A pulse signal measuring device comprising:
JP2005245127A 2005-08-26 2005-08-26 Pulse signal measuring apparatus and method Expired - Fee Related JP4932193B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2005245127A JP4932193B2 (en) 2005-08-26 2005-08-26 Pulse signal measuring apparatus and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2005245127A JP4932193B2 (en) 2005-08-26 2005-08-26 Pulse signal measuring apparatus and method

Publications (2)

Publication Number Publication Date
JP2007057446A true JP2007057446A (en) 2007-03-08
JP4932193B2 JP4932193B2 (en) 2012-05-16

Family

ID=37921066

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2005245127A Expired - Fee Related JP4932193B2 (en) 2005-08-26 2005-08-26 Pulse signal measuring apparatus and method

Country Status (1)

Country Link
JP (1) JP4932193B2 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101867437B1 (en) * 2012-03-22 2018-06-14 주식회사 대유위니아 Method for self-diagnosis of inverter driver

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6242086A (en) * 1985-08-17 1987-02-24 Nec Home Electronics Ltd Measuring method for time interval
JPH01304369A (en) * 1988-06-01 1989-12-07 Nec Corp Capture device
JPH1183883A (en) * 1997-09-12 1999-03-26 Unisia Jecs Corp Wheel speed computation device
JPH11160338A (en) * 1997-11-28 1999-06-18 Nec Corp Instrument and method for measuring pulse width for detecting rotation
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
JP2002031654A (en) * 2000-07-17 2002-01-31 Matsushita Electric Ind Co Ltd Method and circuit for frequency detection
JP2002168890A (en) * 2000-11-30 2002-06-14 Matsushita Electric Ind Co Ltd Frequency detection method and device and recording medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6242086A (en) * 1985-08-17 1987-02-24 Nec Home Electronics Ltd Measuring method for time interval
JPH01304369A (en) * 1988-06-01 1989-12-07 Nec Corp Capture device
JPH1183883A (en) * 1997-09-12 1999-03-26 Unisia Jecs Corp Wheel speed computation device
JPH11160338A (en) * 1997-11-28 1999-06-18 Nec Corp Instrument and method for measuring pulse width for detecting rotation
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
JP2002031654A (en) * 2000-07-17 2002-01-31 Matsushita Electric Ind Co Ltd Method and circuit for frequency detection
JP2002168890A (en) * 2000-11-30 2002-06-14 Matsushita Electric Ind Co Ltd Frequency detection method and device and recording medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101867437B1 (en) * 2012-03-22 2018-06-14 주식회사 대유위니아 Method for self-diagnosis of inverter driver

Also Published As

Publication number Publication date
JP4932193B2 (en) 2012-05-16

Similar Documents

Publication Publication Date Title
JP4244231B2 (en) Signal processing device
JPH0528063A (en) Microcomputer
RU2005129270A (en) Detection and elimination of systematic and random errors in processor cascades of an integrated circuit
US8311169B2 (en) Automatic frequency monitoring circuit, electronic device, automatic frequency monitoring method, and automatic frequency monitoring program
US7360109B2 (en) Measuring the interval of a signal using a counter and providing the value to a processor
JP4932193B2 (en) Pulse signal measuring apparatus and method
JP4692514B2 (en) Electronic control unit
JP2016057888A (en) Electronic control device and communication system
JP2007026028A (en) Device for detecting abnormality in microcomputer
JP6227196B2 (en) Clock diagnostic device and clock diagnostic method
CN111052690B (en) Data acquisition method and data acquisition device
JPH09211156A (en) Timer device
JP2010117746A (en) Measurement system
KR100653545B1 (en) Method of sensing time modification of internal time by a computer program
JP2000074962A (en) Cycle-measuring device and method therefor, and storage medium
JPH09114541A (en) Interruption generation time confirming circuit and processor
US20100262402A1 (en) Performance evaluation device and performance evaluation method
JP4842036B2 (en) Semiconductor device and abnormality detection method of timing control circuit
JPH11304539A (en) Rotary encoder counter, counting method and recording medium
JP2006309639A (en) Computer abnormality detection circuit and computer abnormality detection method
JP4826433B2 (en) Timer start circuit
JP2003234639A (en) Data processing method and data processor
JP2005049312A (en) Clocking device
JP2004151846A (en) Runaway detection device
EP2535818A1 (en) Error generation indicator circuit, storage device, information processing device and control method of error generation indicator circuit

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20080819

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20110322

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20110419

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20110610

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: 20120214

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: 20120215

R150 Certificate of patent or registration of utility model

Ref document number: 4932193

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

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

Free format text: PAYMENT UNTIL: 20150224

Year of fee payment: 3

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

LAPS Cancellation because of no payment of annual fees