JP2000029747A - Runaway detecting circuit - Google Patents

Runaway detecting circuit

Info

Publication number
JP2000029747A
JP2000029747A JP10195825A JP19582598A JP2000029747A JP 2000029747 A JP2000029747 A JP 2000029747A JP 10195825 A JP10195825 A JP 10195825A JP 19582598 A JP19582598 A JP 19582598A JP 2000029747 A JP2000029747 A JP 2000029747A
Authority
JP
Japan
Prior art keywords
value
counter
register
predetermined value
wdt
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP10195825A
Other languages
Japanese (ja)
Inventor
Toshiaki Tsuji
敏明 辻
Masato Suzuki
正人 鈴木
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 JP10195825A priority Critical patent/JP2000029747A/en
Publication of JP2000029747A publication Critical patent/JP2000029747A/en
Pending legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To provide a runaway detecting circuit detecting a runaway by, which a loop is formed in a routine containing the initialized instruction (counter resetting instruction) of a counter, and realizing the highly reliable operation of a system. SOLUTION: A runaway detecting circuit is provided with a WDT(watch dot timer) counter part 2 for outputting an overflow output signal 14, when the counting value of a clock CLK exceeds an overflow value, a WDT control register 3 outputting a reset flag signal 12, a register 5 for storing a counting value, a register 6 for storing a value smaller than the overflow value, a comparator 7 for comparing the values of the registers 5 and 6, an AND gate 16 for invalidating the reset flag signal 12 when the value of the register 5 is not more than the value of the register 6, a counter 8 measuring the number of invalidation times, a register 9 storing the upper limit value of the number of invalidation times and a comparator 10 for outputting a system reset signal 15, when the value of the counter 8 is not less than the value of the register 9.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明は、マイクロコントロ
ーラ等の半導体集積回路に用いられる暴走検出回路に関
するものである。
[0001] 1. Field of the Invention [0002] The present invention relates to a runaway detection circuit used for a semiconductor integrated circuit such as a microcontroller.

【0002】[0002]

【従来の技術】近年、携帯機器、家庭用情報家電の分野
において使用されるマイクロコントローラには、プログ
ラム暴走を検知するための暴走検出回路にウオッチドッ
グタイマが搭載されている。このウオッチドッグタイマ
のウオッチドッグ動作によりシステムの安定動作を実現
することが可能になる。
2. Description of the Related Art In recent years, a microcontroller used in the field of portable devices and home information appliances is equipped with a watchdog timer in a runaway detection circuit for detecting a program runaway. A stable operation of the system can be realized by the watchdog operation of the watchdog timer.

【0003】図5は、従来の暴走検出回路の構成図であ
る。図5において、1はマイクロコントローラ、2はウ
オッチドッグタイマ(以下、WDTと略す)カウンタ
部、3はWDT制御レジスタ、4はCPU、11はバ
ス、12はリセットフラグ信号、14はWDTカウンタ
部2のオーバーフロー出力信号である。以上のように構
成された従来の暴走検出回路の動作を、さらに図6を参
照しながら以下に説明する。図6は従来の暴走検出回路
のタイミング図である。
FIG. 5 is a configuration diagram of a conventional runaway detection circuit. In FIG. 5, 1 is a microcontroller, 2 is a watchdog timer (hereinafter abbreviated as WDT) counter unit, 3 is a WDT control register, 4 is a CPU, 11 is a bus, 12 is a reset flag signal, and 14 is a WDT counter unit 2. Is an overflow output signal. The operation of the conventional runaway detection circuit configured as described above will be described below with further reference to FIG. FIG. 6 is a timing chart of the conventional runaway detection circuit.

【0004】WDTカウンタ部2はチップに供給される
クロックCLKをカウントし続け、そのカウント値が所
定値(オーバーフロー値)を超えた時にオーバーフロー
としてその状態を検知する。マイクロコントローラ1内
で、ウオッチドッグ動作を用いてシステムの暴走を検出
するためには、CPU4からバス11を介してWDT制
御レジスタ3内のカウンタリセットフラグを設定する必
要がある。プログラム中で定期的にカウンタリセット命
令を実行することにより、WDT制御レジスタ3内のカ
ウンタリセットフラグを設定し、WDT制御レジスタ3
からリセットフラグ信号12が出力され、WDTカウン
タ部2のオーバーフローが正常動作時(図6の(a)の
期間)には発生しないように制御される。WDTカウン
タ部2のリセット動作が正常に動作しない時、言い替え
ればプログラム内に配置されたカウンタリセット命令が
実行されない時、WDTカウンタ部2のカウンタはオー
バーフローを起こし、オーバーフロー出力信号14によ
りマイクロコントローラ1のプログラム処理になんらか
の異常が発生したことを検出することができる。
[0004] The WDT counter unit 2 keeps counting the clock CLK supplied to the chip, and when the count value exceeds a predetermined value (overflow value), detects the state as an overflow. In order to detect runaway of the system using the watchdog operation in the microcontroller 1, it is necessary to set a counter reset flag in the WDT control register 3 from the CPU 4 via the bus 11. By periodically executing a counter reset instruction in the program, a counter reset flag in the WDT control register 3 is set, and the WDT control register 3
Outputs a reset flag signal 12, and is controlled so that the overflow of the WDT counter unit 2 does not occur during normal operation (period (a) in FIG. 6). When the reset operation of the WDT counter unit 2 does not operate normally, in other words, when the counter reset instruction arranged in the program is not executed, the counter of the WDT counter unit 2 overflows and the overflow output signal 14 It is possible to detect that some abnormality has occurred in the program processing.

【0005】[0005]

【発明が解決しようとする課題】しかしながら、上記従
来の構成では、カウンタリセット命令を含むルーチンで
暴走しループを形成してしまった場合(図6の(b)の
期間)に、WDTカウンタ部2のリセットが定期的に行
われるため、WDTカウンタ部2においてオーバーフロ
ーが生じることはなく、マイクロコントローラ1のプロ
グラム処理の暴走を検出することができなくなるという
問題がある。このような暴走は、例えばノイズによりマ
イクロコントローラ1のプログラムカウンタが誤動作す
ることにより発生し得る。
However, in the above-mentioned conventional configuration, when a runaway occurs in a routine including a counter reset instruction and a loop is formed (period (b) in FIG. 6), the WDT counter unit 2 Is periodically performed, the WDT counter unit 2 does not overflow, and there is a problem that runaway of the program processing of the microcontroller 1 cannot be detected. Such runaway can occur, for example, when the program counter of the microcontroller 1 malfunctions due to noise.

【0006】本発明の目的は、カウンタの初期化命令
(カウンタリセット命令)を含むルーチンでループを形
成するような暴走を検出可能とし、システムの高信頼性
動作を実現できる暴走検出回路を提供することである。
An object of the present invention is to provide a runaway detection circuit which can detect a runaway that forms a loop with a routine including a counter initialization instruction (counter reset instruction) and can realize a highly reliable operation of the system. That is.

【0007】[0007]

【課題を解決するための手段】請求項1記載の暴走検出
回路は、クロックを計数するカウンタと、カウンタの計
数値が第1の所定値を超えたときに異常を検出する異常
検出手段と、カウンタの計数値を初期化する初期化手段
とを備えた暴走検出回路であって、第1の所定値よりも
小さい第2の所定値を予め記憶する第2の所定値の記憶
手段と、カウンタの計数値と第2の所定値の記憶手段に
記憶した第2の所定値とを比較するカウンタ計数値比較
手段と、カウンタ計数値比較手段の比較結果がカウンタ
の計数値が第2の所定値以下であるときに初期化手段に
よる初期化を無効化する無効化手段とを設けたことを特
徴とする。
According to a first aspect of the present invention, there is provided a runaway detection circuit comprising: a counter for counting a clock; an abnormality detection means for detecting an abnormality when a count value of the counter exceeds a first predetermined value; A runaway detection circuit including initialization means for initializing a count value of a counter, wherein storage means for storing a second predetermined value smaller than the first predetermined value in advance; Counter value comparing means for comparing the count value of the counter with the second predetermined value stored in the storage means of the second predetermined value, and the comparison result of the counter count value comparing means indicates that the count value of the counter is the second predetermined value. And an invalidating means for invalidating the initialization by the initializing means when the following conditions are satisfied.

【0008】この構成によれば、カウンタの計数値が第
1の所定値よりも小さい第2の所定値以下であるときに
初期化手段によるカウンタの計数値の初期化を無効化す
ることにより、プログラムに意図的に設定されたタイミ
ング以外のカウンタの初期化命令を排除して、カウンタ
の計数値が第1の所定値を超えると異常検出手段により
異常を検出できるため、カウンタの初期化命令を含むル
ーチン内でループを形成するような暴走を検出すること
が可能となり、これを用いたシステムの高信頼性動作を
実現できる。
According to this configuration, when the count value of the counter is equal to or less than the second predetermined value smaller than the first predetermined value, the initialization of the counter value by the initialization means is invalidated. The counter initialization instruction other than the timing intentionally set in the program is excluded, and when the count value of the counter exceeds the first predetermined value, abnormality can be detected by the abnormality detection means. It is possible to detect a runaway that forms a loop in a routine including the above, and realize a highly reliable operation of a system using the runaway.

【0009】請求項2記載の暴走検出回路は、請求項1
記載の暴走検出回路において、無効化手段による無効化
の回数を計測する計測手段と、無効化回数の上限値とし
て第3の所定値を予め記憶する第3の所定値の記憶手段
と、計測手段の無効化回数計測値と第3の所定値の記憶
手段に記憶した第3の所定値とを比較し、無効化回数計
測値が第3の所定値以上であるときに異常検出信号を出
力する無効化回数比較手段とを設けたことを特徴とす
る。
A runaway detection circuit according to a second aspect of the present invention is the first aspect.
In the runaway detection circuit described above, measuring means for measuring the number of invalidations by the invalidating means, storage means for storing a third predetermined value in advance as an upper limit of the number of invalidations, and measuring means Is compared with the third predetermined value stored in the third predetermined value storage means, and when the invalidation number measured value is equal to or greater than the third predetermined value, an abnormality detection signal is output. And a means for comparing invalidation times.

【0010】この構成により、カウンタの計数値の初期
化手段による初期化の無効化の回数を計測し、その無効
化回数の計測値が無効化回数の上限値である第3の所定
値以上であるときに無効化回数比較手段による異常の検
出が可能となるため、カウンタの初期化命令を含むルー
チン内でループを形成するような暴走が発生し、プログ
ラムに意図的に設定されたタイミング以外で無効化され
たカウンタの初期化命令が第3の所定値以上の回数発生
したときに無効化回数比較手段で異常を検出することが
できる。
With this configuration, the number of times of invalidation of the initialization by the initialization means for the count value of the counter is measured, and when the measured value of the number of invalidations is equal to or more than the third predetermined value which is the upper limit of the number of invalidations. At some point, it is possible to detect abnormalities by the invalidation number comparison means, so that a runaway that forms a loop in a routine including a counter initialization instruction occurs, and at a timing other than the timing intentionally set in the program When the initialization instruction of the invalidated counter is generated a number of times equal to or more than the third predetermined value, the abnormality can be detected by the invalidation number comparing means.

【0011】請求項3記載の暴走検出回路は、請求項1
記載の暴走検出回路において、第2の所定値の記憶手段
は不揮発性メモリで構成されることを特徴とする。この
ように第2の所定値の記憶手段を不揮発性メモリで構成
することにより、第2の所定値の記憶手段に一度第2の
所定値を記憶させれば、システムの電源が遮断され、そ
の後の電源投入時に、第2の所定値を再び記憶させる必
要がなくなる。
A runaway detection circuit according to a third aspect of the present invention is characterized in that:
In the runaway detection circuit described above, the storage means for the second predetermined value is constituted by a nonvolatile memory. By configuring the storage means of the second predetermined value with a non-volatile memory in this way, once the second predetermined value is stored in the storage means of the second predetermined value, the power supply of the system is shut off, and thereafter, When the power is turned on, the second predetermined value need not be stored again.

【0012】請求項4記載の暴走検出回路は、請求項2
記載の暴走検出回路において、第2の所定値の記憶手段
および第3の所定値の記憶手段の一方または両方は不揮
発性メモリで構成されることを特徴とする。このように
第2,第3の所定値の記憶手段を不揮発性メモリで構成
することにより、第2,第3の所定値の記憶手段に一度
記憶させれば、システムの電源が遮断され、その後の電
源投入時に、再び記憶させる必要がなくなる。
A runaway detection circuit according to a fourth aspect is the second aspect.
In the runaway detection circuit described above, one or both of the storage means for the second predetermined value and the storage means for the third predetermined value are constituted by a nonvolatile memory. By configuring the storage means of the second and third predetermined values in a non-volatile memory as described above, once the storage means of the second and third predetermined values is stored once, the power supply of the system is cut off, There is no need to store the data again when the power is turned on.

【0013】[0013]

【発明の実施の形態】以下、本発明の実施の形態につい
て、図面を用いて説明する。図1は本発明の第1の実施
の形態における暴走検出回路の構成図である。図1にお
いて、1はマイクロコントローラ、2は入力クロック又
はその整数倍の周波数の内部クロックをカウントするウ
オッチドッグタイマ(以下、WDTと略す)カウンタ
部、3はWDT制御レジスタ、4はCPU、5,6,9
はレジスタ、7,10は比較器、11はバス、12はリ
セットフラグ信号、13はリセット命令無効化信号、1
4はWDTオーバーフロー出力信号、15はシステムリ
セット信号、16,17はANDゲート、18はインバ
ータである。
Embodiments of the present invention will be described below with reference to the drawings. FIG. 1 is a configuration diagram of a runaway detection circuit according to the first embodiment of the present invention. In FIG. 1, 1 is a microcontroller, 2 is a watchdog timer (hereinafter abbreviated as WDT) counter section for counting an input clock or an internal clock having a frequency that is an integral multiple thereof, 3 is a WDT control register, 4 is a CPU, 6,9
Is a register, 7 and 10 are comparators, 11 is a bus, 12 is a reset flag signal, 13 is a reset command invalidation signal, 1
4 is a WDT overflow output signal, 15 is a system reset signal, 16 and 17 are AND gates, and 18 is an inverter.

【0014】本実施の形態では、クロックCLKをカウ
ントし、そのカウント値が所定のオーバーフロー値(第
1の所定値)を超えたときにオーバーフロー出力信号1
4を出力するWDTカウンタ部(カウンタおよび異常検
出手段)2と、CPU1のカウンタリセット命令の実行
によりWDTカウンタ部2の計数値を初期化するリセッ
トフラグ信号12を出力するWDT制御レジスタ(初期
化手段)3とを備えてあり、これらは従来例と同様であ
る。
In this embodiment, the clock CLK is counted, and when the count value exceeds a predetermined overflow value (first predetermined value), the overflow output signal 1 is output.
And a WDT control register (initializing means) for outputting a reset flag signal 12 for initializing the count value of the WDT counter section 2 by executing a counter reset instruction of the CPU 1. 3), which are the same as in the conventional example.

【0015】さらに本実施の形態では、WDTカウンタ
部2の計数値をクロックCLKに同期して記憶するレジ
スタ5と、オーバーフロー値よりも小さい値を予め記憶
するレジスタ(第2の所定値の記憶手段)6と、レジス
タ5の値とレジスタ6の値とを比較する比較器(カウン
タ計数値比較手段)7と、比較器7の比較結果がレジス
タ5の値がレジスタ6の値以下であるときにリセットフ
ラグ信号12を無効にするためのANDゲート(無効化
手段)16とを設けている。さらに、ANDゲート16
によりリセットフラグ信号12が無効化された回数を計
測する計測手段を構成するインバータ18,ANDゲー
ト17およびカウンタ8と、無効化回数の上限値を予め
記憶するレジスタ(第3の所定値の記憶手段)9と、カ
ウンタ8の値がレジスタ9の値以上であるときにシステ
ムリセット信号15を出力する比較器(無効化回数比較
手段)10とを設けている。
Further, in the present embodiment, the register 5 for storing the count value of the WDT counter unit 2 in synchronization with the clock CLK, and the register for storing in advance a value smaller than the overflow value (the means for storing the second predetermined value) 6), a comparator (counter count value comparing means) 7 for comparing the value of the register 5 with the value of the register 6, and when the comparison result of the comparator 7 indicates that the value of the register 5 is equal to or less than the value of the register 6. An AND gate (invalidating means) 16 for invalidating the reset flag signal 12 is provided. Further, the AND gate 16
, An AND gate 17 and a counter 8 which constitute a measuring means for measuring the number of times the reset flag signal 12 has been invalidated by a register, and a register (a third predetermined value storing means) for preliminarily storing an upper limit value of the number of invalidations. 9) and a comparator (invalidation number comparing means) 10 for outputting a system reset signal 15 when the value of the counter 8 is equal to or greater than the value of the register 9.

【0016】なお、比較器7の出力は、レジスタ5の値
がレジスタ6の値以下であるときにローレベル(論理値
0)、レジスタ5の値がレジスタ6の値より大きいとき
にハイレベル(論理値1)となる。また、カウンタ8
は、比較器7の出力であるリセット命令無効化信号13
がハイレベルのとき、値0に初期化される。また、比較
器10の出力は、カウンタ8の値がレジスタ9の値以上
であるときにハイレベル(論理値1)、カウンタ8の値
がレジスタ9の値より小さいときにローレベル(論理値
0)となる。
The output of the comparator 7 is at a low level (logical value 0) when the value of the register 5 is equal to or less than the value of the register 6, and at a high level (logic value) when the value of the register 5 is larger than the value of the register 6. Logical value 1). Also, counter 8
Is a reset instruction invalidation signal 13 which is an output of the comparator 7.
Is high level, the value is initialized to 0. The output of the comparator 10 is at a high level (logical value 1) when the value of the counter 8 is equal to or greater than the value of the register 9, and at a low level (logical value 0) when the value of the counter 8 is smaller than the value of the register 9. ).

【0017】また、WDTカウンタ部2はクロックCL
Kの立ち上がりエッジのタイミングで計数し、レジスタ
5は、周波数に依るが、同じクロックCLKの立ち上が
りエッジでWDTカウンタ部2の計数値を記憶するよう
にしてもよいし、クロックCLKの立ち下がりエッジで
WDTカウンタ部2の計数値を記憶するようにしてもよ
い。このように、レジスタ5がWDTカウンタ部2の計
数値を記憶するタイミングは、クロックCLKの立ち上
がりエッジまたは立ち下がりエッジとしてもよいし、ま
た、ディレイ(delay)で作ることも可能である。
Further, the WDT counter unit 2 outputs the clock CL
The counter 5 counts at the timing of the rising edge of K, and the register 5 may store the count value of the WDT counter unit 2 at the rising edge of the same clock CLK, depending on the frequency, or at the falling edge of the clock CLK. The count value of the WDT counter unit 2 may be stored. As described above, the timing at which the register 5 stores the count value of the WDT counter unit 2 may be a rising edge or a falling edge of the clock CLK, or may be generated by a delay.

【0018】以上のように構成される本実施の形態の暴
走検出回路の動作を、さらに図3と図4を用いて説明す
る。なお、以下でも、ハイレベルは論理値1を示し、ロ
ーレベルは論理値0を示す。まず、レジスタ6にCPU
からバス11を介して適切な値を設定する。このレジス
タ6の設定値は、WDTカウンタ部2のオーバーフロー
値にできるだけ近く、かつ正常動作時において設定され
た値からオーバーフローするまでの間にカウンタリセッ
ト命令によりリセット可能な範囲で設定する。また、レ
ジスタ9にもCPUからバス11を介して適切な値を設
定しておく。このレジスタ9の設定については後述す
る。
The operation of the runaway detection circuit according to the present embodiment configured as described above will be further described with reference to FIGS. In the following description, a high level indicates a logical value 1 and a low level indicates a logical value 0. First, register 6
To set an appropriate value via the bus 11. The set value of the register 6 is set as close as possible to the overflow value of the WDT counter unit 2 and within a range that can be reset by a counter reset instruction before the value overflows from the value set during normal operation. Also, an appropriate value is set in the register 9 via the bus 11 from the CPU. The setting of this register 9 will be described later.

【0019】正常動作時(図3の(a)の期間)におい
て、図3のA、Bのタイミングで、カウンタリセット命
令を実行することにより、CPU4からバス11を介し
てWDT制御レジスタ3内のカウンタリセットフラグを
設定し、WDT制御レジスタ3からリセットフラグ信号
12が出力される。このとき、レジスタ5に転送される
WDTカウンタ部2の値はレジスタ6の設定値よりも大
きいため、比較器7の比較結果であるリセット命令無効
化信号13はハイレベルになり、リセットフラグ信号1
2とリセット命令無効化信号13とを入力とするAND
ゲート16の出力はハイレベルとなり、WDTカウンタ
部2の計数値は初期化され、オーバーフロー出力信号1
4はローレベルで異常は検出されない。
During normal operation (period (a) in FIG. 3), a counter reset instruction is executed at timings A and B in FIG. A counter reset flag is set, and a reset flag signal 12 is output from the WDT control register 3. At this time, since the value of the WDT counter unit 2 transferred to the register 5 is larger than the set value of the register 6, the reset instruction invalidation signal 13 which is the comparison result of the comparator 7 becomes high level, and the reset flag signal 1
AND which receives reset command invalidation signal 13 and reset instruction invalidation signal 13
The output of the gate 16 becomes high level, the count value of the WDT counter unit 2 is initialized, and the overflow output signal 1
No. 4 is at a low level and no abnormality is detected.

【0020】プログラム暴走時(図3の(b)の期間)
において、図3のCのタイミングで、カウンタリセット
命令が実行され、WDT制御レジスタ3からリセットフ
ラグ信号12が出力されたとする。リセット命令を含む
ルーチンでループを形成するプログラム暴走では暴走が
小ループである可能性が高く、そのときリセットフラグ
信号12の間隔は小さくなる。このとき、レジスタ5に
転送されるWDTカウンタ部2の値はレジスタ6の設定
値よりも小さいため、比較器7の比較結果であるリセッ
ト命令無効化信号13はローレベルになり、ANDゲー
ト16の出力はローレベルとなり、WDTカウンタ部2
の計数値は初期化されずに増え続ける。そして、WDT
カウンタ部2の計数値がオーバーフロー値になるまでの
区間Tの間に、WDT制御レジスタ3から次のリセット
フラグ信号12が出力されなければ、計数値がオーバー
フロー値を超えてオーバーフロー出力信号14はハイレ
ベルとなり、異常が検出され、正常状態(図3の(c)
の期間)に戻る。
During program runaway (period (b) in FIG. 3)
It is assumed that the counter reset instruction is executed at timing C in FIG. 3 and the reset flag signal 12 is output from the WDT control register 3. In a program runaway in which a loop is formed by a routine including a reset instruction, the runaway is likely to be a small loop, and at that time, the interval between the reset flag signals 12 becomes small. At this time, since the value of the WDT counter unit 2 transferred to the register 5 is smaller than the set value of the register 6, the reset instruction invalidation signal 13 which is the comparison result of the comparator 7 becomes low level, and the AND gate 16 The output goes low, and the WDT counter 2
Is not initialized and continues to increase. And WDT
If the next reset flag signal 12 is not output from the WDT control register 3 during the interval T until the count value of the counter unit 2 reaches the overflow value, the count value exceeds the overflow value and the overflow output signal 14 becomes high. Level, an abnormality is detected, and a normal state ((c) in FIG. 3)
Period).

【0021】ところが、区間Tの間で、WDTカウンタ
部2の計数値がレジスタ6の設定値を超えてから、異常
なリセットフラグ信号12がWDT制御レジスタ3から
出力されると、レジスタ5に転送されるWDTカウンタ
部2の値はレジスタ6の設定値よりも大きいため、比較
器7の比較結果であるリセット命令無効化信号13はハ
イレベルになり、ANDゲート16の出力はハイレベル
となり、WDTカウンタ部2の計数値は初期化され、オ
ーバーフロー出力信号14はローレベルで、オーバーフ
ロー出力信号14による異常は検出されない。
However, when the abnormal reset flag signal 12 is output from the WDT control register 3 after the count value of the WDT counter section 2 exceeds the set value of the register 6 during the interval T, the data is transferred to the register 5. Since the value of the WDT counter unit 2 is larger than the set value of the register 6, the reset instruction invalidation signal 13 which is the comparison result of the comparator 7 goes high, the output of the AND gate 16 goes high, and the WDT The count value of the counter unit 2 is initialized, the overflow output signal 14 is at a low level, and no abnormality due to the overflow output signal 14 is detected.

【0022】そこで、前述のようにレジスタ9に値を設
定しておく。このレジスタ9の設定値は1以上であれば
良いが、高信頼性のシステムを実現するために大きめの
値を設定しても良い。以下では、レジスタ9の値を2と
設定した場合について説明する。正常動作時(図4の
(a)の期間)における動作は、図3の(a)の期間で
説明した部分については同じである。この場合、リセッ
ト命令無効化信号13がハイレベルのとき、インバータ
18の出力はローレベルであるため、リセットフラグ信
号12とインバータ18の出力とを入力とするANDゲ
ート17の出力はローレベルとなり、カウンタ8の出力
値は0である。カウンタ8の出力値がレジスタ9の設定
値の2よりも小さいため、比較器10の比較結果である
システムリセット信号15はローレベルである。
Therefore, a value is set in the register 9 as described above. The set value of the register 9 may be 1 or more, but a larger value may be set to realize a highly reliable system. Hereinafter, a case where the value of the register 9 is set to 2 will be described. The operation during the normal operation (period (a) in FIG. 4) is the same as that described in the period (a) in FIG. In this case, when the reset command invalidating signal 13 is at a high level, the output of the inverter 18 is at a low level, and the output of the AND gate 17 that receives the reset flag signal 12 and the output of the inverter 18 is at a low level. The output value of the counter 8 is 0. Since the output value of the counter 8 is smaller than 2 which is the set value of the register 9, the system reset signal 15, which is the comparison result of the comparator 10, is at a low level.

【0023】プログラム暴走時(図4の(b)の期間)
において、図4のCのタイミングで、カウンタリセット
命令が実行され、WDT制御レジスタ3からリセットフ
ラグ信号12が出力されたとする。リセット命令を含む
ルーチンでループを形成するプログラム暴走では暴走が
小ループであり、リセットフラグ信号12の間隔は小さ
くなる。このとき、レジスタ5に転送されるWDTカウ
ンタ部2の値はレジスタ6の設定値よりも小さいため、
比較器7の比較結果であるリセット命令無効化信号13
はローレベルになり、ANDゲート16の出力はローレ
ベルとなり、WDTカウンタ部2の計数値は初期化され
ずに増え続ける。このとき、リセット命令無効化信号1
3がローレベルで、インバータ18の出力はハイレベル
であるため、ANDゲート17の出力はハイレベルとな
り、カウンタ8の出力値は1である。カウンタ8の出力
値がレジスタ9の設定値の2よりも小さいため、比較器
10の比較結果であるシステムリセット信号15はロー
レベルである。
During program runaway (period (b) in FIG. 4)
It is assumed that the counter reset instruction is executed at timing C in FIG. 4 and the reset flag signal 12 is output from the WDT control register 3. In a program runaway in which a loop is formed by a routine including a reset instruction, the runaway is a small loop, and the interval between the reset flag signals 12 is reduced. At this time, since the value of the WDT counter unit 2 transferred to the register 5 is smaller than the set value of the register 6,
Reset command invalidation signal 13 which is a comparison result of comparator 7
Becomes low level, the output of the AND gate 16 becomes low level, and the count value of the WDT counter unit 2 continues to increase without being initialized. At this time, the reset command invalidation signal 1
Since 3 is at low level and the output of the inverter 18 is at high level, the output of the AND gate 17 is at high level and the output value of the counter 8 is 1. Since the output value of the counter 8 is smaller than 2 which is the set value of the register 9, the system reset signal 15, which is the comparison result of the comparator 10, is at a low level.

【0024】この後、WDTカウンタ部2の計数値がレ
ジスタ6の設定値を超えない時刻の図4のDのタイミン
グで、WDT制御レジスタ3から異常なリセットフラグ
信号12が出力されると、レジスタ5に転送されるWD
Tカウンタ部2の値はレジスタ6の設定値よりも小さい
ため、比較器7の比較結果であるリセット命令無効化信
号13はローレベルであり、ANDゲート16の出力は
ローレベルとなり、WDTカウンタ部2の計数値は初期
化されずに増え続ける。このとき、オーバーフロー出力
信号14による異常は検出されないが、リセット命令無
効化信号13を入力とするインバータ18の出力がハイ
レベルであるため、リセットフラグ信号12とインバー
タ18の出力を入力とするANDゲート17の出力はハ
イレベルとなり、カウンタ8の出力値は2となる。カウ
ンタ8の出力値がレジスタ9の設定値の2と同じである
ため、比較器10の比較結果であるシステムリセット信
号15はハイレベルとなり、異常が検出され、正常状態
(図4の(c)の期間)に戻る。なお、カウンタ8で
は、WDTカウンタ部2の計数値がレジスタ6の設定値
以下のときに入力されるリセットフラグ信号12が無効
化された回数をカウントしている。
Thereafter, when an abnormal reset flag signal 12 is output from the WDT control register 3 at the timing D in FIG. 4 at a time when the count value of the WDT counter section 2 does not exceed the set value of the register 6, the register WD transferred to 5
Since the value of the T counter unit 2 is smaller than the set value of the register 6, the reset instruction invalidation signal 13 which is the comparison result of the comparator 7 is at low level, the output of the AND gate 16 is at low level, and the WDT counter unit The count value of 2 keeps increasing without being initialized. At this time, no abnormality due to the overflow output signal 14 is detected, but since the output of the inverter 18 to which the reset command invalidation signal 13 is input is at a high level, an AND gate to which the reset flag signal 12 and the output of the inverter 18 are input is provided. The output of the counter 17 becomes high level, and the output value of the counter 8 becomes 2. Since the output value of the counter 8 is the same as the set value 2 of the register 9, the system reset signal 15, which is the comparison result of the comparator 10, becomes high level, an abnormality is detected, and a normal state ((c) in FIG. 4) Period). The counter 8 counts the number of times the reset flag signal 12 input when the count value of the WDT counter unit 2 is equal to or less than the set value of the register 6 is invalidated.

【0025】以上のように第1の実施の形態によれば、
WDTカウンタ部2およびその計数値を初期化するリセ
ットフラグ信号12を出力するWDT制御レジスタ3に
加えて、WDTカウンタ部2の計数値を記憶するレジス
タ5と、オーバーフロー値よりも小さい値を予め記憶す
るレジスタ6と、レジスタ5の値とレジスタ6の値とを
比較する比較器7と、比較器7の比較結果がレジスタ5
の値がレジスタ6の値以下であるときにリセットフラグ
信号12を無効にするためのANDゲート16とを設け
たことにより、レジスタ5の値がレジスタ6の値以下で
あるときに比較器7からローレベルのリセット命令無効
化信号13が出力され、ANDゲート16でリセットフ
ラグ信号12を無効化することにより、プログラムに意
図的に設定されたタイミング以外のWDTカウンタ部2
のリセット命令を排除して、WDTカウンタ部2の計数
値がオーバーフロー値を超えると異常を検出できるた
め、WDTカウンタ部2のリセット命令を含むルーチン
内でループを形成するような暴走を検出することが可能
となり、マイクロコントローラ1の高信頼性動作を実現
できる。
As described above, according to the first embodiment,
In addition to the WDT counter unit 2 and the WDT control register 3 which outputs a reset flag signal 12 for initializing the count value, a register 5 for storing the count value of the WDT counter unit 2 and a value smaller than the overflow value are stored in advance. Register 6, which compares the value of the register 5 with the value of the register 6, and the comparison result of the comparator 7
And the AND gate 16 for invalidating the reset flag signal 12 when the value of the register 6 is equal to or less than the value of the register 6, the comparator 7 outputs a signal when the value of the register 5 is equal to or less than the value of the register 6. A low-level reset command invalidation signal 13 is output, and the AND flag 16 invalidates the reset flag signal 12, so that the WDT counter unit 2 other than the timing intentionally set in the program
If the count value of the WDT counter unit 2 exceeds the overflow value, an abnormality can be detected by eliminating the reset instruction of the WDT counter unit 2. Therefore, detecting a runaway that forms a loop in the routine including the reset instruction of the WDT counter unit 2 And the highly reliable operation of the microcontroller 1 can be realized.

【0026】さらに、ANDゲート16によりリセット
フラグ信号12が無効化された回数を計測するためのイ
ンバータ18,ANDゲート17およびカウンタ8と、
無効化回数の上限値を予め記憶するレジスタ9と、カウ
ンタ8の値がレジスタ9の値以上であるときにシステム
リセット信号15を出力する比較器10とを設けたこと
により、リセットフラグ信号12の無効化の回数を計測
し、その無効化回数の計測値が無効化回数の上限値以上
であるときに比較器10からシステムリセット信号15
を出力するため、WDTカウンタ部2のリセット命令を
含むルーチン内でループを形成するような暴走が発生
し、プログラムに意図的に設定されたタイミング以外で
無効化されたWDTカウンタ部2のリセット命令がレジ
スタ9の値以上の回数発生したときに異常を検出するこ
とができ、よりマイクロコントローラ1の高信頼性動作
を実現できる。
Further, an inverter 18, an AND gate 17, and a counter 8 for measuring the number of times the reset flag signal 12 has been invalidated by the AND gate 16,
The provision of the register 9 for preliminarily storing the upper limit value of the number of times of invalidation and the comparator 10 for outputting the system reset signal 15 when the value of the counter 8 is equal to or greater than the value of the register 9 allows the reset flag signal 12 The number of invalidations is measured, and when the measured value of the number of invalidations is equal to or more than the upper limit of the number of invalidations, the system reset signal 15 is output from the comparator 10.
Is generated, a runaway that forms a loop occurs in a routine including a reset instruction of the WDT counter unit 2, and the reset instruction of the WDT counter unit 2 invalidated at a timing other than the timing intentionally set in the program. Can be detected when the number of occurrences is equal to or greater than the value of the register 9, and more reliable operation of the microcontroller 1 can be realized.

【0027】なお、レジスタ6,9を不揮発性素子で構
成することにより、一度設定値が最適化され記憶されて
いれば、システムの電源が遮断され、その後の電源投入
時に、再設定をする必要がなくなるという効果が得られ
る。図2は本発明の第2の実施の形態の暴走検出回路の
構成図であり、19は不揮発性メモリである。
By configuring the registers 6 and 9 with nonvolatile elements, if the set values are optimized and stored once, the system power supply is cut off, and it is necessary to reset when the power supply is turned on thereafter. Is obtained. FIG. 2 is a configuration diagram of a runaway detection circuit according to a second embodiment of the present invention, and 19 is a nonvolatile memory.

【0028】第2の実施の形態は、第1の実施の形態と
は不揮発性メモリ19を設けた点が相違している。不揮
発性メモリ19には、レジスタ6に設定される値と、レ
ジスタ9に設定される値と、レジスタ6およびレジスタ
9にそれぞれ設定される値を設定するプログラムとが格
納されており、電源投入時、又はリセット後に自動的に
レジスタ6,9に設定値を設定するプログラムが実行さ
れる。
The second embodiment differs from the first embodiment in that a nonvolatile memory 19 is provided. The nonvolatile memory 19 stores a value set in the register 6, a value set in the register 9, and a program for setting values set in the registers 6 and 9, respectively. Alternatively, a program for automatically setting the set values in the registers 6 and 9 after the reset is executed.

【0029】本実施の形態によれば、不揮発性メモリ1
9を設け、レジスタ6,9の設定値およびそれを設定す
るためのプログラムを格納しておくことにより、システ
ムの電源が遮断された後に、電源投入時、又はリセット
後に自動的にレジスタ6,9に設定することができる。
According to the present embodiment, the nonvolatile memory 1
9 is provided, and the set values of the registers 6 and 9 and the program for setting the same are stored, so that the registers 6 and 9 are automatically turned on when the system power is turned off, when the power is turned on, or after a reset. Can be set to

【0030】[0030]

【発明の効果】以上のように本発明によれば、クロック
を計数するカウンタと、カウンタの計数値が第1の所定
値を超えたときに異常を検出する異常検出手段と、カウ
ンタの計数値を初期化する初期化手段とに加えて、第1
の所定値よりも小さい第2の所定値を予め記憶する第2
の所定値の記憶手段と、カウンタの計数値と第2の所定
値の記憶手段に記憶した第2の所定値とを比較するカウ
ンタ計数値比較手段と、カウンタ計数値比較手段の比較
結果がカウンタの計数値が第2の所定値以下であるとき
に初期化手段による初期化を無効化する無効化手段とを
設けたことにより、カウンタの計数値が第1の所定値よ
りも小さい第2の所定値以下であるときに初期化手段に
よるカウンタの計数値の初期化を無効化することによ
り、プログラムに意図的に設定されたタイミング以外の
カウンタの初期化命令を排除して、カウンタの計数値が
第1の所定値を超えると異常検出手段により異常を検出
できるため、カウンタの初期化命令を含むルーチン内で
ループを形成するような暴走を検出することが可能とな
り、これを用いたシステムの高信頼性動作を実現でき
る。
As described above, according to the present invention, a counter for counting a clock, an abnormality detecting means for detecting an abnormality when the count value of the counter exceeds a first predetermined value, and a count value of the counter In addition to the initialization means for initializing
A second predetermined value smaller than the predetermined value is stored in advance.
Storage means for storing a predetermined value, a counter count value comparison means for comparing the count value of the counter with a second predetermined value stored in the second predetermined value storage means, and a comparison result of the counter count value comparison means. And invalidating means for invalidating the initialization by the initializing means when the count value of the second counter is equal to or smaller than the second predetermined value, whereby the count value of the counter is smaller than the first predetermined value. By invalidating the initialization of the count value of the counter by the initialization means when the count value is equal to or less than the predetermined value, a counter initialization instruction other than the timing intentionally set in the program is eliminated, and the count value of the counter is reduced. When the value exceeds the first predetermined value, the abnormality can be detected by the abnormality detecting means. Therefore, it is possible to detect a runaway that forms a loop in a routine including a counter initialization instruction. It is possible to realize a highly reliable operating systems out.

【0031】さらに、無効化手段による無効化の回数を
計測する計測手段と、無効化回数の上限値として第3の
所定値を予め記憶する第3の所定値の記憶手段と、計測
手段の無効化回数計測値と第3の所定値の記憶手段に記
憶した第3の所定値とを比較し、無効化回数計測値が第
3の所定値以上であるときに異常検出信号を出力する無
効化回数比較手段とを設けたことにより、カウンタの計
数値の初期化手段による初期化の無効化の回数を計測
し、その無効化回数の計測値が無効化回数の上限値であ
る第3の所定値以上であるときに無効化回数比較手段に
よる異常の検出が可能となるため、カウンタの初期化命
令を含むルーチン内でループを形成するような暴走が発
生し、プログラムに意図的に設定されたタイミング以外
で無効化されたカウンタの初期化命令が第3の所定値以
上の回数発生したときに無効化回数比較手段で異常を検
出することができ、よりシステムの高信頼性動作を実現
できる。
Further, measuring means for measuring the number of invalidations by the invalidating means, storage means for storing a third predetermined value as an upper limit of the number of invalidations in advance, and invalidation of the measuring means. Comparing the measured value of the number of times of invalidation with the third predetermined value stored in the storage means of the third predetermined value, and outputting an abnormality detection signal when the measured value of the number of invalidation times is equal to or more than the third predetermined value. By providing the number-of-times comparing means, the number of times of invalidation of the initialization by the means for initializing the count value of the counter is measured, and the measured value of the number of times of invalidation is the third predetermined value which is the upper limit of the number of times of invalidation. When the value is greater than or equal to the value, the invalidation number comparison means can detect an abnormality, so that a runaway that forms a loop in a routine including a counter initialization instruction occurs, and the program is intentionally set. Cows invalidated outside of timing Can data initialization instruction detects an abnormality in the invalidation number comparing means when the number of occurrences of a third predetermined value or more, it is possible to realize a reliable operation of more systems.

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

【図1】本発明の第1の実施の形態の暴走検出回路の構
成図。
FIG. 1 is a configuration diagram of a runaway detection circuit according to a first embodiment of the present invention.

【図2】本発明の第2の実施の形態の暴走検出回路の構
成図。
FIG. 2 is a configuration diagram of a runaway detection circuit according to a second embodiment of the present invention.

【図3】本発明の第1の実施の形態の暴走検出回路のタ
イミング図。
FIG. 3 is a timing chart of the runaway detection circuit according to the first embodiment of the present invention.

【図4】本発明の第1の実施の形態の暴走検出回路のタ
イミング図。
FIG. 4 is a timing chart of the runaway detection circuit according to the first embodiment of the present invention.

【図5】従来の暴走検出回路の構成図。FIG. 5 is a configuration diagram of a conventional runaway detection circuit.

【図6】従来の暴走検出回路のタイミング図。FIG. 6 is a timing chart of a conventional runaway detection circuit.

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

1 マイクロコントローラ 2 WDT(ウオッチドッグタイマ)カウンタ部 3 WDT(ウオッチドッグタイマ)制御レジスタ 4 CPU 5,6,9 レジスタ 7,10 比較器 8 カウンタ 11 バス 12 リセットフラグ信号 13 リセット命令無効化信号 14 WDTオーバーフロー出力信号 15 システムリセット信号 16,17 ANDゲート 18 インバータ 19 不揮発性メモリ Reference Signs List 1 microcontroller 2 WDT (watchdog timer) counter unit 3 WDT (watchdog timer) control register 4 CPU 5, 6, 9 register 7, 10 comparator 8 counter 11 bus 12 reset flag signal 13 reset command invalidation signal 14 WDT Overflow output signal 15 System reset signal 16, 17 AND gate 18 Inverter 19 Non-volatile memory

Claims (4)

【特許請求の範囲】[Claims] 【請求項1】 クロックを計数するカウンタと、前記カ
ウンタの計数値が第1の所定値を超えたときに異常を検
出する異常検出手段と、前記カウンタの計数値を初期化
する初期化手段とを備えた暴走検出回路であって、 前記第1の所定値よりも小さい第2の所定値を予め記憶
する第2の所定値の記憶手段と、 前記カウンタの計数値と前記第2の所定値の記憶手段に
記憶した前記第2の所定値とを比較するカウンタ計数値
比較手段と、 前記カウンタ計数値比較手段の比較結果が前記カウンタ
の計数値が前記第2の所定値以下であるときに前記初期
化手段による初期化を無効化する無効化手段とを設けた
ことを特徴とする暴走検出回路。
1. A counter for counting a clock, abnormality detecting means for detecting an abnormality when the count value of the counter exceeds a first predetermined value, and initialization means for initializing the count value of the counter. A runaway detection circuit comprising: a second predetermined value storage means for storing in advance a second predetermined value smaller than the first predetermined value; a count value of the counter and the second predetermined value And a counter count value comparing means for comparing the count value with the second predetermined value stored in the storage means. When the count value of the counter is equal to or smaller than the second predetermined value, A runaway detection circuit provided with invalidation means for invalidating the initialization by the initialization means.
【請求項2】 無効化手段による無効化の回数を計測す
る計測手段と、 無効化回数の上限値として第3の所定値を予め記憶する
第3の所定値の記憶手段と、 前記計測手段の無効化回数計測値と前記第3の所定値の
記憶手段に記憶した前記第3の所定値とを比較し、前記
無効化回数計測値が前記第3の所定値以上であるときに
異常検出信号を出力する無効化回数比較手段とを設けた
ことを特徴とする請求項1記載の暴走検出回路。
2. A measuring means for measuring the number of invalidations by the invalidating means; a third predetermined value storage means for storing a third predetermined value as an upper limit of the number of invalidations in advance; Comparing the invalidation count measurement value with the third predetermined value stored in the third predetermined value storage means, and when the invalidation count measurement value is equal to or greater than the third predetermined value, an abnormality detection signal 2. The runaway detection circuit according to claim 1, further comprising: an invalidation number comparison unit that outputs the output.
【請求項3】 第2の所定値の記憶手段は不揮発性メモ
リで構成されることを特徴とする請求項1記載の暴走検
出回路。
3. The runaway detection circuit according to claim 1, wherein the storage means for storing the second predetermined value comprises a nonvolatile memory.
【請求項4】 第2の所定値の記憶手段および第3の所
定値の記憶手段の一方または両方は不揮発性メモリで構
成されることを特徴とする請求項2記載の暴走検出回
路。
4. The runaway detection circuit according to claim 2, wherein one or both of the storage means for the second predetermined value and the storage means for the third predetermined value are constituted by a nonvolatile memory.
JP10195825A 1998-07-10 1998-07-10 Runaway detecting circuit Pending JP2000029747A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP10195825A JP2000029747A (en) 1998-07-10 1998-07-10 Runaway detecting circuit

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP10195825A JP2000029747A (en) 1998-07-10 1998-07-10 Runaway detecting circuit

Publications (1)

Publication Number Publication Date
JP2000029747A true JP2000029747A (en) 2000-01-28

Family

ID=16347638

Family Applications (1)

Application Number Title Priority Date Filing Date
JP10195825A Pending JP2000029747A (en) 1998-07-10 1998-07-10 Runaway detecting circuit

Country Status (1)

Country Link
JP (1) JP2000029747A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6832337B2 (en) 2000-04-28 2004-12-14 Denso Corporation Method and apparatus for monitoring microcomputer in electronic control unit
GB2503459A (en) * 2012-06-26 2014-01-01 Nordic Semiconductor Asa Multiple hardware registers for watchdog timer preventing erroneous microprocessor system reset

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6832337B2 (en) 2000-04-28 2004-12-14 Denso Corporation Method and apparatus for monitoring microcomputer in electronic control unit
GB2503459A (en) * 2012-06-26 2014-01-01 Nordic Semiconductor Asa Multiple hardware registers for watchdog timer preventing erroneous microprocessor system reset
US10191793B2 (en) 2012-06-26 2019-01-29 Nordic Semiconductor Asa Microprocessor device with reset timer

Similar Documents

Publication Publication Date Title
US6823224B2 (en) Data processing system having an on-chip background debug system and method therefor
US5576650A (en) Reset circuit of electronic device
US9733952B2 (en) Microprocessor, and method of managing reset events therefor
US6212134B1 (en) Watch dog timer system
US10802742B2 (en) Memory access control
KR100327855B1 (en) System reset method
KR970049537A (en) CPI to prevent program malfunction
US6477658B1 (en) Microprocessor with variable clock operation
JP2000029747A (en) Runaway detecting circuit
US8046634B2 (en) Integrated circuit card with condition detector
KR970004098B1 (en) Timer circuit having comparator comparing contents of counter and register
US7103692B2 (en) Method and apparatus for an I/O controller to alert an external system management controller
EP0462622B1 (en) Microprocessor capable of ensuring flexible recovery time for I/O device
JPH08339308A (en) Digital processor
EP0708446A2 (en) Data processor having operating modes selected by at least one mask option bit and method therefor
JP3114645B2 (en) Reset control circuit for memory cell device
US7174435B2 (en) Memory control circuit, memory device, and microcomputer
JPH0756774A (en) Watching timer
US20220415405A1 (en) Memory-control circuit and method for controlling erasing operation of flash memory
JP3152014B2 (en) Timer circuit
EP0406442B1 (en) Data write control means
CN114696809A (en) Signal generation circuit and operating system
JP3757407B2 (en) Control device
JPH01230136A (en) Run-away preventing circuit
JPH05127780A (en) Semiconductor integrated circuit