JPH04332056A - Microcomputer - Google Patents

Microcomputer

Info

Publication number
JPH04332056A
JPH04332056A JP3102334A JP10233491A JPH04332056A JP H04332056 A JPH04332056 A JP H04332056A JP 3102334 A JP3102334 A JP 3102334A JP 10233491 A JP10233491 A JP 10233491A JP H04332056 A JPH04332056 A JP H04332056A
Authority
JP
Japan
Prior art keywords
clear
signal
program
microcomputer
cleared
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
JP3102334A
Other languages
Japanese (ja)
Inventor
Masahiro Hayama
葉山 雅洋
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.)
NEC IC Microcomputer Systems Co Ltd
Original Assignee
NEC IC Microcomputer Systems 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 NEC IC Microcomputer Systems Co Ltd filed Critical NEC IC Microcomputer Systems Co Ltd
Priority to JP3102334A priority Critical patent/JPH04332056A/en
Publication of JPH04332056A publication Critical patent/JPH04332056A/en
Pending legal-status Critical Current

Links

Landscapes

  • Microcomputers (AREA)
  • Debugging And Monitoring (AREA)

Abstract

PURPOSE:To detect a program runaway state such as an infinite loop in a microcomputer. CONSTITUTION:The microcomputer is provided with an interval timer 4 for counting up clocks 106, and after counting the prescribed number of clocks, outputting an overflow signal 107 including a reset signal or an interruption signal and to be cleared at its counter value by a clear signal 105 and a clear signal generating circuit 1 for outputting the clear signal 105 when the 1st and 2nd clear instructions 101, 102 are alternately executed and inhibiting the generation of a clear signal when the same clear instruction is continuously executed.

Description

【発明の詳細な説明】[Detailed description of the invention]

【0001】0001

【産業上の利用分野】本発明はマイクロコンピュータに
関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to microcomputers.

【0002】0002

【従来の技術】マイクロプロセッサあるいは1チップマ
イクロコンピュータ等を含むマイクロコンピュータにお
いては、年々集積度の向上に伴い、アドレッシング可能
なプログラムメモリ空間あるいは内蔵プログラムメモリ
容量が増大し、また、さまざまな周辺機能内蔵による時
分割制御など、ますます複雑な制御を行うことが可能と
なってきている。また、応用分野も、これに伴ない家電
など身近な民生分野から、情報処理装置,通信機器,自
動車のエンジンコントロールなど、多岐に亘っており、
これらの制御の中枢となるマイクロコンピュータのプロ
グラムが暴走するなどの異常動作が発生した場合には、
これをいち早く検出する事は非常に重要になってきてい
る。
2. Description of the Related Art In microcomputers, including microprocessors and one-chip microcomputers, as the degree of integration increases year by year, the addressable program memory space or built-in program memory capacity increases, and various peripheral functions are built-in. It is becoming possible to perform increasingly complex control, such as time-sharing control. In addition, the field of application is wide-ranging, from familiar consumer fields such as home appliances to information processing equipment, communication equipment, and automobile engine controls.
If the microcomputer program that is the center of these controls malfunctions, such as going out of control,
It is becoming very important to detect this as early as possible.

【0003】従来、何らかの外的要因あるいは当初予期
しなかったような特殊条件などにより、プログラムが無
限ループに入るなど暴走した場合、これを検出する回路
としてはウォッチドッグタイマが知られている。ウォッ
チドッグタイマは、所定のクロックソースをカウントし
て、一定時間ごとにオーバーフローすることにより、マ
イクロコンピュータに対する割込み、またはリセット信
号を発生するインターバルタイマで、プログラムにより
クリアすることができる。すなわちプログラム実行にお
ける一連の処理が所定時間内に終了しない場合に、この
状態をプログラム実行異常とみなして割り込み信号を発
生したり、内部リセット信号を発生する機能を持った回
路である。従来におけるウォッチドッグタイマの構成を
図4に示す。
Conventionally, a watchdog timer has been known as a circuit that detects when a program goes out of control, such as entering an infinite loop, due to some external factor or an unexpected special condition. The watchdog timer is an interval timer that counts a predetermined clock source and generates an interrupt or reset signal to the microcomputer by overflowing at regular intervals, and can be cleared by a program. That is, if a series of processes in program execution are not completed within a predetermined time, this circuit has a function of regarding this state as a program execution abnormality and generating an interrupt signal or an internal reset signal. FIG. 4 shows the configuration of a conventional watchdog timer.

【0004】図4において、インターバルタイマ5は、
クロック107を入力してカウントする所定ビット長の
ウォッチドッグタイマで、オーバーフロー信号109は
、割り込み信号またはリセット信号として出力され、マ
イクロコンピュータに対して割り込みまたはリセットが
かかる。また、前記インターバルタイマ5は、カウント
動作中に、クリア命令108が入力されるとクリアされ
る。従って、図5(a)および(b)のプログラムの流
れ図に示されるように、プログラム処理ルーチン中に、
インターバルタイマ(ウォッチドッグタイマ)がオーバ
ーフローするより短い周期で、クリア命令301,30
2,303および304を適宜配置しておくことにより
、プログラムが正しい処理ルーチンで実行されている場
合には、これらのクリア命令によりインターバルタイマ
がクリアされ、オーバーフローが発生しないが、もし何
らかの原因でプログラムが暴走し、図5(b)の■のよ
うに無限ループに入った場合には、クリア命令が実行さ
れないためにオーバーフローし、割り込みまたはリセッ
トが発生して異常状態から抜け出すことができる。 実際のプログラム処理ルーチンは、図5(b)に示され
る処理ルーチン例よりも複雑であり、途中でサブルーチ
ンや周辺機能からの割り込み処理ルーチンなどに分岐さ
れているので、これらの分岐処理時間も考慮して、クリ
ア命令を配置する必要があるが、本筋を離れるので簡単
のために省略した。
In FIG. 4, the interval timer 5 is
The watchdog timer has a predetermined bit length and counts by inputting a clock 107. An overflow signal 109 is output as an interrupt signal or a reset signal, and interrupts or resets the microcomputer. Further, the interval timer 5 is cleared when a clear command 108 is input during the counting operation. Therefore, as shown in the program flowcharts of FIGS. 5(a) and (b), during the program processing routine,
Clear commands 301 and 30 are executed at a shorter period than the interval timer (watchdog timer) overflows.
By arranging 2, 303 and 304 appropriately, if the program is being executed with the correct processing routine, these clear instructions will clear the interval timer and no overflow will occur, but if for some reason the program If the process goes out of control and enters an infinite loop as shown in (2) in FIG. 5(b), an overflow occurs because the clear instruction is not executed, and an interrupt or reset occurs to escape from the abnormal state. The actual program processing routine is more complex than the processing routine example shown in Figure 5(b), and branches to subroutines and interrupt processing routines from peripheral functions, etc., so the processing time for these branches should also be taken into account. It is necessary to place a clear command, but this is omitted for the sake of simplicity as it departs from the main topic.

【0005】[0005]

【発明が解決しようとする課題】上述した従来のマイク
ロコンピュータにおけるウォッチドッグタイマの対暴走
機能は、図5(b)に示される■のように、クリア命令
を含まない無限ループに入った場合には有効であるが、
図5(b)の■のようにクリア命令を含む部分のプログ
ラムで無限ループに入った場合には、ウォッチドッグタ
イマがクリアされるため、暴走状態にもかかわらず無限
ループから抜け出すことが出来ないという欠点がある。
[Problems to be Solved by the Invention] The anti-runaway function of the watchdog timer in the conventional microcomputer described above is such that when the watchdog timer enters an infinite loop that does not include a clear instruction, as shown in Figure 5(b), is valid, but
If a part of the program that includes a clear instruction enters an infinite loop, as shown in ■ in Figure 5(b), the watchdog timer will be cleared, so it will not be possible to escape from the infinite loop despite the runaway state. There is a drawback.

【0006】[0006]

【課題を解決するための手段】本発明のマイクロコンピ
ュータは、所定のクロックソースを入力として、所定ク
ロック数カウント後にリセット信号または割り込み信号
を発生し、所定のクリア信号によりカウンタ値がクリア
されるインターバルタイマと、所定の第1のクリア命令
実行ならびに第2のクリア命令実行が交互に実行された
ときに前記クリア信号を発生し、同一のクリア命令が続
けて実行されても前記クリア信号を発生しないクリア信
号発生回路とを有している。
[Means for Solving the Problems] A microcomputer of the present invention receives a predetermined clock source as input, generates a reset signal or an interrupt signal after counting a predetermined number of clocks, and provides an interval at which a counter value is cleared by a predetermined clear signal. Generates the clear signal when a timer and a predetermined first clear command and second clear command are executed alternately, and does not generate the clear signal even if the same clear command is executed continuously. and a clear signal generation circuit.

【0007】[0007]

【実施例】次に本発明について図面を参照して説明する
。図1は本発明の一実施例を示すブロック図である。 図1において、インターバルタイマ4は、所定のクロッ
ク106に基づきカウント動作を行い、所定カウント数
を越えるとオーバーフロー信号107を発生する所定ビ
ット長のインターバルタイマである。ラッチ2は、S端
子に入力されるクリア命令(1)101によってセット
され、R端子に入力されるクリア命令(2)102によ
ってクリアされて、ラッチ2の状態がセットであるかク
リアであるかを示す出力信号104をQ端子より出力す
る。パルス発生回路3は、ラッチ2のQ端子より出力さ
れる出力信号104の立ち上がりと立ち下がりのエッジ
を検出して、インターバルタイマ4に対するクリア信号
105を生成して出力する。そして、これらのラッチ2
およびパルス発生回路3により、クリア信号発生回路1
が形成されている。
DESCRIPTION OF THE PREFERRED EMBODIMENTS Next, the present invention will be explained with reference to the drawings. FIG. 1 is a block diagram showing one embodiment of the present invention. In FIG. 1, the interval timer 4 is an interval timer with a predetermined bit length that performs a counting operation based on a predetermined clock 106 and generates an overflow signal 107 when the predetermined count number is exceeded. Latch 2 is set by a clear command (1) 101 input to the S terminal, and cleared by a clear command (2) 102 input to the R terminal to determine whether the state of latch 2 is set or cleared. An output signal 104 indicating this is output from the Q terminal. The pulse generating circuit 3 detects the rising and falling edges of the output signal 104 output from the Q terminal of the latch 2, and generates and outputs a clear signal 105 for the interval timer 4. And these latches 2
and pulse generation circuit 3, clear signal generation circuit 1
is formed.

【0008】また、マイクロコンピュータの処理開始の
ためのリセットの場合、またはインターバルタイマ4が
オーバーフローして、割り込みが発生した場合には、リ
セット信号/割り込み信号103の入力に対応して、ラ
ッチ2はクリアされ初期化される。
Furthermore, in the case of a reset to start processing of the microcomputer, or when the interval timer 4 overflows and an interrupt occurs, the latch 2 is activated in response to the input of the reset signal/interrupt signal 103. Cleared and initialized.

【0009】次に、図2(a)および(b)と、図3(
a),(b),(c)および(d)に基づいてプログラ
ムの実行について説明する。説明を簡単にするために、
図2(a)の矢印で示したようなプログラム実行の流れ
で、一連の処理を繰り返えすものとする。この時、図1
におけるインターバルタイマ4のオーバーフロー時間T
以内の時間間隔で、クリア命令(1)201とクリア命
令(2)202とを置く。例えば、図2(a)のように
、正常時には、A番地→B番地→C番地→D番地→A番
地を、この順に各間隔が前記時間T以内にアクセスする
ような場合には、図2(b)に示されるように、A番地
とC番地にクリア命令(1)201および203を置き
、B番地とD番地にクリア命令(2)202および20
4を置く。マイクロコンピュータに対するリセット入力
により、リセット信号103がラッチ2に入力されイニ
シャライズされる。また、リセット信号103によりイ
ンターバル4のカウント値はすべてクリアされる。 マイクロコンピュータが正常動作して、プログラムを正
常のシーケンスで実行する場合には、まずA番地に置い
たクリア命令(1)201を実行すると、ラッチ2のQ
端子の出力信号104が“1”にセットされ、出力信号
104の立ち上がりがパルス発生回路3により検出され
てクリア信号105を発生し、インターバル4がクリア
される。次に、インターバルタイマ4がオーバーフロー
するまでの時間T以内にB番地に置かれたクリア命令(
2)202を実行することにより、ラッチ2の出力信号
104が“0”にクリアされ、ラッチ2の出力信号10
4の立ち下がりが、パルス発生回路3により検出されて
、インターバル4に対するクリア信号105が発生され
る。同様に、C番地,D番地,A番地…と、順次上述の
動作が繰り返される。
Next, FIGS. 2(a) and (b) and FIG. 3(
Execution of the program will be explained based on a), (b), (c), and (d). To simplify the explanation,
It is assumed that a series of processes can be repeated in the flow of program execution as shown by the arrows in FIG. 2(a). At this time, Figure 1
Overflow time T of interval timer 4 at
A clear command (1) 201 and a clear command (2) 202 are placed at a time interval of less than or equal to the time interval. For example, as shown in FIG. 2(a), in a normal state, address A→address B→address C→address D→address A is accessed in this order within the time T at each interval. As shown in (b), clear instructions (1) 201 and 203 are placed at addresses A and C, and clear instructions (2) 202 and 20 are placed at addresses B and D.
Place 4. In response to a reset input to the microcomputer, a reset signal 103 is input to the latch 2 and initialized. Further, all the count values of interval 4 are cleared by the reset signal 103. When the microcomputer operates normally and executes the program in the normal sequence, first execute the clear instruction (1) 201 placed at address A, then the Q of latch 2 will be cleared.
The output signal 104 of the terminal is set to "1", and the rising edge of the output signal 104 is detected by the pulse generating circuit 3 to generate the clear signal 105, and the interval 4 is cleared. Next, a clear instruction (
2) By executing 202, the output signal 104 of latch 2 is cleared to "0", and the output signal 10 of latch 2 is cleared to "0".
The falling edge of interval 4 is detected by the pulse generating circuit 3, and a clear signal 105 for interval 4 is generated. Similarly, the above-described operation is repeated sequentially for address C, address D, address A, and so on.

【0010】次に、A番地及びB番地実行後に、図2(
b)に示される■のような無限ループに入った場合につ
いて説明する。A番地及びB番地実行後には、ラッチ2
の出力信号104は“0”になっている。この状態にお
いて、図2(b)の■のような無限ループに入った場合
に、時間Tを経過してもいずれのクリア命令も実行され
ないため、インターバル4のオーバーフローにより、割
り込みまたはリセットが発生し、異常動作が検出される
Next, after executing the A address and B address, FIG.
The case where an infinite loop like ■ shown in b) is entered will be explained. After executing address A and address B, latch 2
The output signal 104 of is "0". In this state, if an infinite loop like ■ in Figure 2(b) is entered, no clear instruction will be executed even after time T has elapsed, so an interrupt or reset will occur due to the overflow of interval 4. , an abnormal operation is detected.

【0011】次に、図3(a),(b),(c)および
(d)に示されるタイミング図を用いて、図2(b)の
■のような無限ループに入った場合について説明する。 A番地,B番地,C番地と正常なシーケンスを実行した
後に、プログラムの実行に異常が起こり、C番地を含ん
だ■の無限ループに入った場合、従来のウォッチドッグ
タイマでは、C番地に置いたクリア命令が実行されて、
動作異常が検出されなかった。
Next, using the timing diagrams shown in FIGS. 3(a), (b), (c), and (d), we will explain the case where an infinite loop like ■ in FIG. 2(b) is entered. do. If an abnormality occurs in program execution after executing a normal sequence of addresses A, B, and C, and the program enters an infinite loop containing address C, the conventional watchdog timer would The cleared command is executed and
No operational abnormality was detected.

【0012】本実施例においては、同じ様にプログラム
の実行に異常が起きた場合、図3(a),(b),(c
)および(d)に示されるように、直前に行ったC番地
のクリア命令(1)203によるクリア信号(1)によ
ってラッチ2の出力信号104は“1”にセットされて
いる。プログラムの異常なシーケンスにおいては、この
状態においてC番地の命令を何度も繰り返すことになる
。即ち、ラッチ2の出力信号104を“1”にセットす
る命令を実行する。しかしながら、ラッチ2はすでに“
1”にセットされているため、ラッチ2の出力信号10
4の状態は変化せず、図3(d)に示されるように、パ
ルス発生回路3からはインターバルタイマ4に対するク
リア信号105は発生されない。従って、インターバル
タイムは、図3(a)および(d)に示されるように、
時間T以内においてクリアされないため、オーバーフロ
ーが発生し、オーバーフロー信号107が出力されて、
動作異常が検出される。
In this embodiment, if a similar abnormality occurs in the execution of the program, FIGS. 3(a), (b), and (c)
) and (d), the output signal 104 of the latch 2 is set to "1" by the clear signal (1) generated by the clear instruction (1) 203 for address C that was executed immediately before. In an abnormal program sequence, the instruction at address C will be repeated many times in this state. That is, an instruction to set the output signal 104 of latch 2 to "1" is executed. However, latch 2 is already “
1”, the output signal of latch 2 is 10.
4 does not change, and the pulse generating circuit 3 does not generate the clear signal 105 for the interval timer 4, as shown in FIG. 3(d). Therefore, the interval time is, as shown in FIGS. 3(a) and (d),
Since it is not cleared within time T, an overflow occurs and an overflow signal 107 is output.
An operational abnormality is detected.

【0013】[0013]

【発明の効果】以上説明したように、本発明はインター
バルタイマ(ウォッチドッグタイマ)をクリアする際に
、第1のクリア命令と第2のクリア命令が交互に実行さ
れないと、インターバルタイマがクリアされないように
するために、従来のウォッチドッグタイマに対して、前
回のクリア命令がどれであったかを記憶するためのラッ
チと、ラッチの内容の変化によりクリア信号を発生する
パルス発生回路とを付加することにより、プログラムの
無限ループを、より確実に検出することができるという
効果がある。
[Effects of the Invention] As explained above, when clearing the interval timer (watchdog timer) of the present invention, the interval timer is not cleared unless the first clear command and the second clear command are executed alternately. In order to do this, a latch for storing the previous clear command and a pulse generation circuit that generates a clear signal when the contents of the latch change are added to the conventional watchdog timer. This has the effect that infinite program loops can be detected more reliably.

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

【図1】本発明の一実施例を示すブロック図である。FIG. 1 is a block diagram showing one embodiment of the present invention.

【図2】本実施例におけるプログラムの流れを示す図で
ある。
FIG. 2 is a diagram showing the flow of a program in this embodiment.

【図3】本実施例における信号のタイミング図である。FIG. 3 is a timing chart of signals in this embodiment.

【図4】従来例を示すブロック図である。FIG. 4 is a block diagram showing a conventional example.

【図5】従来例におけるプログラムの流れを示す図であ
る。
FIG. 5 is a diagram showing the flow of a program in a conventional example.

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

1    クリア信号発生回路 2    ラッチ 3    パルス発生回路 4,5    インターバルタイマ 1 Clear signal generation circuit 2 Latch 3 Pulse generation circuit 4, 5 Interval timer

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】  所定のクロックソースを入力として、
所定クロック数カウント後にリセット信号または割り込
み信号を発生し、所定のクリア信号によりカウンタ値が
クリアされるインターバルタイマと、所定の第1のクリ
ア命令ならびに第2のクリア命令が交互に実行されたと
きに前記クリア信号を発生し、同一のクリア命令が続け
て実行されても前記クリア信号を発生しないクリア信号
発生回路と、を備えることを特徴とするマイクロコンピ
ュータ。
[Claim 1] With a predetermined clock source as input,
When an interval timer generates a reset signal or an interrupt signal after counting a predetermined number of clocks and the counter value is cleared by a predetermined clear signal, and a predetermined first clear instruction and second clear instruction are executed alternately. A microcomputer comprising: a clear signal generating circuit that generates the clear signal and does not generate the clear signal even if the same clear command is successively executed.
JP3102334A 1991-05-08 1991-05-08 Microcomputer Pending JPH04332056A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP3102334A JPH04332056A (en) 1991-05-08 1991-05-08 Microcomputer

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP3102334A JPH04332056A (en) 1991-05-08 1991-05-08 Microcomputer

Publications (1)

Publication Number Publication Date
JPH04332056A true JPH04332056A (en) 1992-11-19

Family

ID=14324620

Family Applications (1)

Application Number Title Priority Date Filing Date
JP3102334A Pending JPH04332056A (en) 1991-05-08 1991-05-08 Microcomputer

Country Status (1)

Country Link
JP (1) JPH04332056A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015126807A (en) * 2013-12-27 2015-07-09 株式会社三共 Game machine

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015126807A (en) * 2013-12-27 2015-07-09 株式会社三共 Game machine

Similar Documents

Publication Publication Date Title
US4763296A (en) Watchdog timer
US5367550A (en) Break address detecting circuit
US5541943A (en) Watchdog timer lock-up prevention circuit
JPH04332056A (en) Microcomputer
JPH0320776B2 (en)
JP3714141B2 (en) Runaway monitoring device for electronic control system
JPH01140350A (en) Circuit for detecting runway of program in microcomputer
JPH04107748A (en) Microcomputer
JP2693885B2 (en) Microcomputer
JPH0573361A (en) Microcomputer
JP2864630B2 (en) Microcomputer runaway detection circuit
JP2557785Y2 (en) Single chip microcomputer
JPS5916054A (en) Microprocessor
JP2516711B2 (en) Watchdog timer device
KR960018893A (en) Controller with Watchdog Timer
JP2712730B2 (en) Evaluation chip
JPH0465407B2 (en)
SU1552186A2 (en) Device for monitoring program run
JPH10161908A (en) Detection of run-away of microcomputer
JPH0683652A (en) Microcomputer system
JPH04205152A (en) Monitor device for controller
JPH0436841A (en) Microcomputer
JP2631541B2 (en) Programmable controller
JPS63118948A (en) Single chip microcomputer
JPS5844261B2 (en) Subroutine operation failure detection device