JPH086823A - Abnormal signal output method of microcomputer - Google Patents
Abnormal signal output method of microcomputerInfo
- Publication number
- JPH086823A JPH086823A JP6141550A JP14155094A JPH086823A JP H086823 A JPH086823 A JP H086823A JP 6141550 A JP6141550 A JP 6141550A JP 14155094 A JP14155094 A JP 14155094A JP H086823 A JPH086823 A JP H086823A
- Authority
- JP
- Japan
- Prior art keywords
- processing
- interrupt
- abnormality determination
- determination flag
- signal
- 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
Links
- 238000000034 method Methods 0.000 title claims description 157
- 230000002159 abnormal effect Effects 0.000 title claims description 17
- 238000012545 processing Methods 0.000 claims abstract description 169
- 230000005856 abnormality Effects 0.000 claims abstract description 134
- 230000001360 synchronised effect Effects 0.000 claims description 5
- 230000002401 inhibitory effect Effects 0.000 claims description 4
- 238000012544 monitoring process Methods 0.000 abstract description 33
- 238000001514 detection method Methods 0.000 abstract description 6
- 238000012790 confirmation Methods 0.000 description 4
- 238000010586 diagram Methods 0.000 description 3
- 229910017435 S2 In Inorganic materials 0.000 description 1
- 239000003990 capacitor Substances 0.000 description 1
- 238000007796 conventional method Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 239000012530 fluid Substances 0.000 description 1
- 230000009191 jumping Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000000737 periodic effect Effects 0.000 description 1
- 230000002265 prevention Effects 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
Landscapes
- Debugging And Monitoring (AREA)
Abstract
(57)【要約】
【目的】 マイクロコンピュータの暴走を監視するWD
監視回路の簡略化と暴走検出性能を高める。
【構成】 割込み指令があると、通常の処理ルーチンを
中断して割込み処理ルーチンを実行するマイクロコンピ
ュータにおいて、通常の処理プログラムの所定のブロッ
ク毎に異常判定用フラグをセットし、それ以外の処理ブ
ロックでは異常判定用フラグをリセットするようにする
と共に、割込み処理のプログラムの実行時に、異常判定
用フラグを読み込み、異常判定用フラグに対応するレベ
ルの異常判定用信号を出力するようにし、出力される異
常判定用信号のレベルの状態から異常の有無を判定す
る。
(57) [Abstract] [Purpose] WD for monitoring microcomputer runaway
The monitoring circuit is simplified and the runaway detection performance is improved. [Arrangement] When an interrupt command is issued, in a microcomputer that interrupts a normal processing routine and executes an interrupt processing routine, an abnormality determination flag is set for each predetermined block of a normal processing program, and other processing blocks Then, the abnormality determination flag is reset, and when the interrupt processing program is executed, the abnormality determination flag is read, and the abnormality determination signal of the level corresponding to the abnormality determination flag is output and output. The presence / absence of an abnormality is determined from the state of the level of the abnormality determination signal.
Description
【0001】[0001]
【産業上の利用分野】本発明は、マイクロコンピュータ
を用いて制御を行うコントローラにおいて、マイクロコ
ンピュータの暴走を検知し異常判定信号を出力する方法
に関する。BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a method of detecting a runaway of a microcomputer and outputting an abnormality determination signal in a controller that controls using a microcomputer.
【0002】[0002]
【従来の技術】従来の、マイクロコンピュータの暴走を
監視し、マイクロコンピュータの暴走を検知する方法
が、特公昭60−32217号明細書及び特開平6−1
2293号明細書で開示されている。2. Description of the Related Art A conventional method for monitoring the runaway of a microcomputer and detecting the runaway of the microcomputer is disclosed in Japanese Patent Publication No. Sho 60-32217 and Japanese Patent Laid-Open No. 6-1.
2293.
【0003】上記特公昭60−32217号明細書で
は、割込み機能を有する制御用コンピュータにおいて、
メイン処理及び割込み処理で異常判定用信号をそれぞれ
異なったレベルに設定し、出力することにより、通常は
メイン処理又は割込み処理が所定の周期で交互に行われ
るため、Hiレベル及びLoレベルの時間がそれぞれ所定
の時間継続され、所定の周期のパルス、すなわちウォッ
チドッグ(以下WDと呼ぶ)パルスが異常判定用信号と
して出力され、異常判定用信号が同一レベルを所定時間
以上継続した場合に異常と判定して異常判定信号を出力
する装置が開示されている。In the above Japanese Patent Publication No. 60-32217, in a control computer having an interrupt function,
By setting and outputting the abnormality determination signals to different levels in the main process and the interrupt process, the main process and the interrupt process are normally alternately performed at a predetermined cycle. Each is continued for a predetermined time, and a pulse of a predetermined cycle, that is, a watchdog (hereinafter referred to as WD) pulse is output as an abnormality determination signal, and it is determined to be abnormal when the abnormality determination signal continues at the same level for a predetermined time or more. Then, a device for outputting an abnormality determination signal is disclosed.
【0004】また、上記特開平6−12293号明細書
では、割込み機能を有するマイクロコンピュータにおい
て、割込み処理のルーチンの中で割込みがかかったこと
を確認するための割込み確認フラグをセットし、メイン
処理のルーチンで割込み確認フラグの状態を検出し、通
常は割込み確認フラグがセットされていると同割込み確
認フラグをリセットした後、出力ポートの出力が反転し
て出力されるため、Hiレベル及びLoレベルの時間がそ
れぞれ所定の時間継続され、所定の周期のパルスが異常
判定用信号としてのWDパルスとして出力され、異常判
定用信号が同一レベルを所定時間以上継続した場合、す
なわち上記WDパルスが所定時間以内に入力されなかっ
た場合に異常と判定して所定の安全措置を行うマイクロ
コンピュータの暴走防止方法が開示されている。Further, in the above-mentioned Japanese Patent Application Laid-Open No. 6-12293, in a microcomputer having an interrupt function, an interrupt confirmation flag for confirming that an interrupt has been issued is set in the interrupt processing routine, and main processing is performed. Routine detects the status of the interrupt confirmation flag and normally resets the interrupt confirmation flag if the interrupt confirmation flag is set, then the output of the output port is inverted and output. Is continued for a predetermined time, a pulse having a predetermined cycle is output as a WD pulse as an abnormality determination signal, and the abnormality determination signal continues at the same level for a predetermined time or more, that is, the WD pulse is for a predetermined time. If it is not entered within the specified range, it is judged to be abnormal and the prescribed safety measures are taken. Prevention method is disclosed.
【0005】[0005]
【発明が解決しようとする課題】しかしながら、プログ
ラム暴走が起こると、WDパルスが出力されなくなる場
合と、例えば、メイン処理におけるWDパルス出力処理
を含むメイン処理の無限ループ(暴走)のように、WD
パルスの周期又はHiレベル及びLoレベルの時間が正常
時に比べて変化する場合とがあり、プログラム暴走を検
出するためのWD監視回路においては、無パルスの検出
と共にWDパルスの周期並びにHiレベル及びLoレベル
の時間の監視を行う高機能な回路が必要であった。However, when a program runaway occurs, the WD pulse is not output, and, for example, in the infinite loop (runaway) of the main process including the WD pulse output process in the main process, the WD
The pulse cycle or the time of the Hi level and the Lo level may change compared to the normal time. Therefore, in the WD monitoring circuit for detecting the program runaway, the WD pulse cycle and the Hi level and the Lo level are detected together with the detection of no pulse. A sophisticated circuit was needed to monitor the level time.
【0006】[0006]
【課題を解決するための手段】したがって、本発明の特
許請求の範囲における請求項1は、割込み指令がある
と、通常の処理ルーチンを中断して割込み処理ルーチン
を実行するマイクロコンピュータにおいて、通常の処理
プログラムの所定のブロック毎に異常判定用フラグをセ
ットし、それ以外の処理ブロックでは異常判定用フラグ
をリセットするようにすると共に、割込み処理のプログ
ラムの実行時に、異常判定用フラグを読み込み、異常判
定用フラグに対応するレベルの異常判定用信号を出力す
るようにし、出力される異常判定用信号のレベルの状態
から異常の有無を判定するようにしたことを特徴とする
マイクロコンピュータの異常信号出力方法を提供するこ
とにある。Therefore, according to claim 1 of the present invention, when an interrupt command is issued, a normal processing routine is interrupted to execute the interrupt processing routine. Set the abnormality determination flag for each predetermined block of the processing program, reset the abnormality determination flag in the other processing blocks, and read the abnormality determination flag during execution of the interrupt processing program An abnormality signal output of a microcomputer, characterized in that an abnormality determination signal of a level corresponding to a determination flag is output, and whether or not there is an abnormality is determined based on the level state of the output abnormality determination signal. To provide a method.
【0007】更に、本発明の特許請求の範囲における請
求項2は、上記請求項1の割込み処理のプログラムの先
頭において、割込みを禁止する処理の後に、上記異常判
定用フラグを読み込み、該異常判定用フラグに対応する
レベルの異常判定用信号を出力するようにしたことを特
徴とするマイクロコンピュータの異常信号出力方法を提
供することにある。Further, according to claim 2 of the present invention, the abnormality determination flag is read at the beginning of the interrupt processing program of the above-mentioned claim 1 after the processing for inhibiting the interrupt, and the abnormality determination is performed. Another object of the present invention is to provide an abnormality signal output method for a microcomputer, which is characterized in that an abnormality determination signal of a level corresponding to the operation flag is output.
【0008】本発明の特許請求の範囲における請求項3
は、上記請求項1から更に、上記各処理ブロック内に割
込みを禁止して処理を行うサブブロックを設定し、該各
割込み禁止区間では上記異常判定用フラグを上記設定と
相反する状態に設定するようにしたことを特徴とするマ
イクロコンピュータの異常信号出力方法を提供すること
にある。Claim 3 of the present invention
Further sets a sub-block for prohibiting interrupt processing in each of the processing blocks, and sets the abnormality determination flag in a state inconsistent with the setting in each of the interrupt prohibited sections. An object of the present invention is to provide a method of outputting an abnormal signal of a microcomputer characterized by the above.
【0009】また、本発明の特許請求の範囲における請
求項4は、上記請求項2から更に、メイン処理のプログ
ラムと非同期し、上記割込み処理が所定の周期で割り込
む、定時割込み処理を行う場合において、メイン処理の
プログラムにおける前半の各処理ブロックの先頭で、上
記各異常判定用フラグをセット又はリセットするように
それぞれ設定し、メイン処理のプログラムにおける後半
の各処理ブロックの先頭で、上記各異常判定用フラグ
を、上記前半の各処理ブロックで設定された異常判定用
フラグと相反する状態に設定し、割込み処理のプログラ
ムの最後に割込み禁止を解除し、メイン処理に復帰させ
る割込み許可処理を行うようにしたことを特徴とするマ
イクロコンピュータの異常信号出力方法を提供すること
にある。According to claim 4 of the present invention, in addition to the above claim 2, in the case where the interrupt processing is performed asynchronously with the program of the main processing, the interrupt processing interrupts at a predetermined cycle. , At the beginning of each processing block in the first half of the main processing program, set or reset each of the above abnormality determination flags, and at the beginning of each processing block in the latter half of the main processing program, perform the above abnormality determination The flag is set to a state that conflicts with the abnormality determination flag set in each processing block in the first half above, and interrupt prohibition is released at the end of the interrupt processing program, and interrupt enable processing is performed to return to main processing. Another object of the present invention is to provide a method for outputting an abnormal signal of a microcomputer characterized by the above.
【0010】更にまた、本発明の特許請求の範囲におけ
る請求項5は、上記請求項1から更に、割込み処理以外
のメイン処理のプログラムと同期し、所定の周期で割り
込む、同期割込み処理を行う場合において、メイン処理
のプログラムにおける各処理ブロックの先頭で、上記異
常判定用フラグをセット又はリセットするようにそれぞ
れ設定し、割込み処理のプログラムにおいて、先頭にあ
る割込みを禁止する処理の後に、カウンタを加算する処
理を行い、割込み処理のプログラムの最後に割込み禁止
を解除し、メイン処理に復帰させる割込み許可処理を行
い、割込み処理のプログラムで、上記カウンタが少なく
とも1つの所定の数値になると、そのときの上記異常判
定用フラグを読み込み、該異常判定用フラグに対応する
レベルの異常判定用信号を出力し、上記異常判定用信号
が交互に相反するレベルとなるように、上記異常判定用
フラグを設定したことを特徴とするマイクロコンピュー
タの異常信号出力方法を提供することにある。Further, claim 5 in the claims of the present invention is, in addition to the above-mentioned claim 1, a case of performing a synchronous interrupt process which is synchronized with a program of a main process other than the interrupt process and interrupts at a predetermined cycle. In the main processing program, at the beginning of each processing block, the abnormality determination flag is set or reset, and in the interrupt processing program, the counter is incremented after the processing of prohibiting the interrupt at the beginning. When the above counter reaches at least one predetermined numerical value in the interrupt processing program, the interrupt prohibition is released at the end of the interrupt processing program and the interrupt permission processing for returning to the main processing is performed. The abnormality determination flag is read, and the abnormality determination of the level corresponding to the abnormality determination flag is performed. Outputs a signal, so that the abnormality determination signal is alternately in opposite level to provide an abnormality signal output method of a microcomputer, characterized in that setting the abnormality determination flag.
【0011】本発明の特許請求の範囲における請求項6
は、上記請求項3から更に、メイン処理のプログラムに
おける各処理ブロックの先頭で、上記異常判定用フラグ
をセット又はリセットするようにそれぞれ設定し、上記
各処理ブロック内に割込み禁止区間を設定し、該各割込
み禁止区間の先頭で、上記異常判定用フラグを、各処理
ブロックの先頭で設定した状態と相反する状態にそれぞ
れ設定し、上記割込み禁止区間の最後で、上記異常判定
用フラグを、各処理ブロックの先頭で設定した状態と同
じ状態に設定し、割込み処理のプログラムにおいて、先
頭にある割込みを禁止する処理の後に、上記各異常判定
用フラグと同じレベルの異常判定用信号を出力し、割込
み処理のプログラムの最後に割込み禁止を解除し、メイ
ン処理に復帰させる割込み許可処理を行うことを特徴と
するマイクロコンピュータの異常信号出力方法を提供す
ることにある。Claim 6 in the claims of the present invention
Further sets the abnormality determination flag to be set or reset at the head of each processing block in the main processing program, and sets an interrupt prohibited section in each processing block. At the beginning of each interrupt prohibited section, the abnormality determination flag is set to a state that conflicts with the state set at the beginning of each processing block, and at the end of the interrupt prohibited section, the abnormality determination flag is set to Set the same state as the state set at the beginning of the processing block, and in the interrupt processing program, after the process of prohibiting the interrupt at the beginning, output the abnormality determination signal at the same level as the above abnormality determination flags, At the end of the interrupt processing program, the interrupt enable processing is released to cancel the interrupt disable and return to the main processing. It is to provide an abnormality signal output method Yuta.
【0012】[0012]
【作用及び効果】本発明の特許請求の範囲の請求項1に
記載の方法は、異常判定用信号の出力状態を割込み処理
以外のメイン処理内で設定される異常判定用フラグから
決定し、異常判定用信号の出力処理を割込み処理内で行
うことにより、割込み機能を有するマイクロコンピュー
タの割込み処理以外の処理及び割込み処理での暴走とい
った異常動作に対して、マイクロコンピュータから出力
される異常判定用信号はHiレベル又はLoレベル一定と
なるようにしたことから、マイクロコンピュータの暴走
を監視するWD監視回路は、無パルス状態のみを検出す
ればよく、非常に簡単で安価な構成の回路で形成するこ
とができる。According to the method described in claim 1 of the present invention, the output state of the abnormality determination signal is determined from the abnormality determination flag set in the main processing other than the interrupt processing, and the abnormality is detected. By performing the output processing of the determination signal in the interrupt processing, the abnormality determination signal output from the microcomputer in response to an abnormal operation such as a runaway in processing other than the interrupt processing of the microcomputer having an interrupt function and the interrupt processing. Is set to a high level or a low level, the WD monitoring circuit for monitoring the runaway of the microcomputer only needs to detect the non-pulse state, and should be formed by a circuit of a very simple and inexpensive structure. You can
【0013】また、本発明の特許請求の範囲の請求項2
に記載の方法は、割込み処理のプログラムの先頭におい
て、割込みを禁止する処理の後に、上記異常判定用フラ
グを読み込み、該異常判定用フラグに対応するレベルの
異常判定用信号を出力するようにしたことから、1つの
割込み処理中に次々と他の割込み処理が行われることに
より、マイクロコンピュータが正常に動作している場合
でも異常判定用信号が同一レベル一定となることを防ぐ
ことから、WD監視回路は、より精度よく簡単にマイク
ロコンピュータの暴走を検出することができる。Further, claim 2 of the present invention
In the method described in (1), the above-described abnormality determination flag is read at the beginning of the interrupt processing program, and the abnormality determination signal of the level corresponding to the abnormality determination flag is output. Therefore, it is possible to prevent the abnormality determination signal from becoming constant at the same level even when the microcomputer is operating normally by performing other interrupt processing one after another during one interrupt processing. The circuit can detect the runaway of the microcomputer more accurately and easily.
【0014】また、本発明の特許請求の範囲の請求項3
に記載の方法は、パルス状のWD信号の周期、Hiレベ
ル時間及びLoレベル時間の検出ができる高機能なWD
監視回路を使用する場合においては、割込み禁止機能が
正常に作動しているかどうかも検出することができ、よ
り高度な暴走検出機能を備えることができる。Further, claim 3 of the present invention
The method described in 1) is a highly functional WD capable of detecting the period of a pulsed WD signal, Hi level time and Lo level time.
When the monitoring circuit is used, it is possible to detect whether the interrupt prohibition function is operating normally, and a more advanced runaway detection function can be provided.
【0015】更に、本発明の特許請求の範囲の請求項4
に記載の方法は、割込み処理がメイン処理のプログラム
と非同期に所定の周期で行われる場合において、メイン
処理の前半の処理ブロックと後半の処理ブロックで設定
される異常判定フラグを相反する状態に設定することに
より、WD監視回路は、より精度よく簡単にマイクロコ
ンピュータの暴走を検出することができる。Further, claim 4 of the present invention
When the interrupt process is performed asynchronously with the program of the main process at a predetermined cycle, the method described in (1) sets the abnormality determination flags set in the first half processing block and the second half processing block of the main process to conflicting states. By doing so, the WD monitoring circuit can detect the runaway of the microcomputer more accurately and easily.
【0016】更にまた、本発明の特許請求の範囲の請求
項5に記載の方法は、割込み処理がメイン処理のプログ
ラムと同期して所定の周期で行われる場合において、割
込み処理で、先頭にある割込みを禁止する処理の後に、
カウンタを加算する処理を行い、上記カウンタが少なく
とも1つの所定の数値になるとそのときの上記異常判定
用フラグを読み込み、該異常判定用フラグに対応するレ
ベルの異常判定用信号を出力し、上記異常判定用信号が
交互に相反するレベルとなるように、上記異常判定用フ
ラグを設定することにより、WD監視回路は、より精度
よく簡単にマイクロコンピュータの暴走を検出すること
ができる。Furthermore, in the method according to claim 5 of the present invention, when the interrupt processing is performed at a predetermined cycle in synchronization with the program of the main processing, the interrupt processing is at the beginning. After disabling interrupts,
A process of adding a counter is performed, and when the counter reaches at least one predetermined numerical value, the abnormality determination flag at that time is read, and an abnormality determination signal of a level corresponding to the abnormality determination flag is output to output the abnormality. By setting the abnormality determination flag so that the determination signals have mutually opposite levels, the WD monitoring circuit can detect the runaway of the microcomputer more accurately and easily.
【0017】また、本発明の特許請求の範囲の請求項6
に記載の方法は、各割込み禁止区間の先頭で、上記異常
判定用フラグを、各処理ブロックの先頭で設定した状態
と相反する状態にそれぞれ設定し、上記割込み禁止区間
の最後で、上記異常判定用フラグを、各処理ブロックの
先頭で設定した状態と同じ状態に設定することから、パ
ルス状のWD信号の周期、Hiレベル時間及びLoレベル
時間の検出ができる高機能なWD監視回路を使用する場
合においては、割込み禁止機能が正常に作動しているか
どうかをより確実に検出することができ、更に高度な暴
走検出機能を備えることができる。Further, claim 6 of the present invention
The method described in (1) sets the abnormality determination flag at the beginning of each interrupt prohibited section to a state that conflicts with the state set at the beginning of each processing block, and at the end of the interrupt prohibited section, the abnormality determination Since the flag for use is set to the same state as the state set at the beginning of each processing block, a highly functional WD monitoring circuit that can detect the period of the pulsed WD signal, the Hi level time and the Lo level time is used. In this case, it is possible to more reliably detect whether the interrupt prohibition function is operating normally, and it is possible to provide a more advanced runaway detection function.
【0018】[0018]
【実施例】次に、図面に示す実施例に基づき、本発明に
ついて詳細に説明する。図1は、本発明のマイクロコン
ピュータの異常信号出力方法が適用される、マイクロコ
ンピュータと異常判定用信号、すなわちWD信号の監視
回路を主な構成要素とするマイクロコンピュータシステ
ムを示した概略ブロック図である。The present invention will now be described in detail with reference to the embodiments shown in the drawings. FIG. 1 is a schematic block diagram showing a microcomputer system to which the microcomputer abnormal signal output method of the present invention is applied, which mainly includes a microcomputer and an abnormality determination signal, that is, a WD signal monitoring circuit. is there.
【0019】図1において、1は、本発明の異常信号出
力方法を適用したマイクロコンピュータ(以下マイコン
と呼ぶ)を示し、2は、マイコン1からのWD信号の状
態を監視し、WD信号からマイコン1の暴走を検知する
とマイコン1に暴走状態検知信号を出力するWD監視回
路であり、上記マイコン1のWD信号出力端子が、該W
D監視回路の入力端子に接続され、WD監視回路2の正
常/異常判定信号出力端子(以下出力端子と呼ぶ)がマ
イコン1のリセット端子に接続されている。In FIG. 1, reference numeral 1 denotes a microcomputer (hereinafter referred to as a microcomputer) to which the abnormal signal output method of the present invention is applied, and 2 denotes the state of the WD signal from the microcomputer 1 and monitors the WD signal from the microcomputer. 1 is a WD monitoring circuit that outputs a runaway state detection signal to the microcomputer 1 when the runaway of the microcomputer 1 is detected.
It is connected to the input terminal of the D monitoring circuit, and the normal / abnormal determination signal output terminal of the WD monitoring circuit 2 (hereinafter referred to as the output terminal) is connected to the reset terminal of the microcomputer 1.
【0020】また、上記WD監視回路2の出力端子は、
マイコン1のリセット端子の代わりに、システムの電源
を遮断したり、警告灯を点灯させるなどの安全処理又は
警告処理を行う他の装置に接続されてもよく、これらの
装置は、WD監視回路2からの正常/異常判定信号によ
って所定の作動を行うものである。The output terminal of the WD monitoring circuit 2 is
Instead of the reset terminal of the microcomputer 1, it may be connected to another device that performs safety processing or warning processing such as shutting off the power supply of the system or turning on a warning light. These devices are connected to the WD monitoring circuit 2 A predetermined operation is performed by a normal / abnormal determination signal from.
【0021】ここで、WD監視回路2は、パルス信号
と、Hi又はLoレベル一定の信号とを識別できればよ
く、このような回路は公知のものとしてよく知られてお
り、一例を図2で示している。図2で示したWD監視回
路は、特開平5−134899号明細書で開示されたも
のであり、パルス状のWD信号をそのデューティ比に対
応した電圧に変換する積分回路を備え、該積分回路によ
って変換された電圧を所定の基準値を設定した比較回路
によってパルス信号か否かを判定することができる。Here, the WD monitor circuit 2 is only required to be able to distinguish between a pulse signal and a signal having a constant Hi or Lo level. Such a circuit is well known, and an example is shown in FIG. ing. The WD monitor circuit shown in FIG. 2 is disclosed in the specification of Japanese Patent Application Laid-Open No. 5-134899, and includes an integrator circuit for converting a pulsed WD signal into a voltage corresponding to its duty ratio. It is possible to determine whether or not the voltage converted by is a pulse signal by a comparison circuit in which a predetermined reference value is set.
【0022】図2において、マイクロコンピュータ51
からライン61に導出されたパルス信号は、抵抗R1,
R2及びコンデンサC1を含む積分回路62により上記
パルス信号のデューティ比に対応した電圧に変換され
る。ライン63には、上記パルス信号のデューティ比に
対応した電圧が導出される。In FIG. 2, a microcomputer 51
The pulse signal derived from the line 61 to the resistor R1,
An integrating circuit 62 including R2 and a capacitor C1 converts the voltage into a voltage corresponding to the duty ratio of the pulse signal. A voltage corresponding to the duty ratio of the pulse signal is derived from the line 63.
【0023】上記積分回路62の出力電圧Vは、抵抗R
3を介して比較器71の反転入力端子に与えられてい
る。この比較器71の非反転入力端子には、電源電圧V
ccを抵抗R4、抵抗R5及び抵抗R6とで分圧した分
圧点64に現れる電圧が、基準電圧V1として与えられ
ている。積分回路62の出力電圧Vは更に、抵抗R7を
介して比較器72の非反転入力端子に与えられている。
この比較器72の反転入力端子には、電源電圧Vccを
抵抗R4、R5及び抵抗R6とで分圧した分圧点65に
現れる電圧が基準電圧V2(V2<V1)として入力さ
れている。The output voltage V of the integrating circuit 62 is equal to the resistance R
3 to the inverting input terminal of the comparator 71. The power supply voltage V is applied to the non-inverting input terminal of the comparator 71.
The voltage appearing at the voltage dividing point 64 obtained by dividing cc by the resistors R4, R5, and R6 is given as the reference voltage V1. The output voltage V of the integrating circuit 62 is further supplied to the non-inverting input terminal of the comparator 72 via the resistor R7.
The voltage appearing at the voltage dividing point 65 obtained by dividing the power supply voltage Vcc by the resistors R4, R5 and R6 is input to the inverting input terminal of the comparator 72 as the reference voltage V2 (V2 <V1).
【0024】比較器71,72の出力はマイクロコンピ
ュータ51のリセット入力端子Resetに接続したライン
66に共通に接続されている。したがって、比較器7
1,72の少なくともいずれか一方がローレベルの信号
を出力すれば、ライン66の電位はローレベルとなる。
このライン66には、抵抗R8を介して電源電圧Vcc
が与えられている。これは、比較器71,72がオープ
ンコレクタ出力型のものであるためである。The outputs of the comparators 71 and 72 are commonly connected to the line 66 connected to the reset input terminal Reset of the microcomputer 51. Therefore, the comparator 7
When at least one of 1 and 72 outputs a low level signal, the potential of the line 66 becomes low level.
This line 66 is connected to the power source voltage Vcc via the resistor R8.
Is given. This is because the comparators 71 and 72 are of the open collector output type.
【0025】上記の構成によって、積分回路62の出力
電圧Vが、V2<V<V1のときには、比較器71,7
2の出力はいずれもハイレベルとなる。一方、積分回路
62の出力電圧Vが、V<V2のときには、比較器71
の出力はハイレベルとなり、比較器72の出力はローレ
ベルとなる。この結果、抵抗R8を電流が流れて、この
電流が比較器72に吸収されるから、ライン66は接地
電位となる。このライン66に導出されたローレベルの
信号が暴走状態検知信号として、V1<Vのときには、
比較器71の出力はローレベルとなり、比較器72の出
力はハイレベルとなる。これにより、ライン66は接地
電位となるから、上記の場合と同様に、マイクロコンピ
ュータ51がリセットされる。With the above configuration, when the output voltage V of the integrating circuit 62 is V2 <V <V1, the comparators 71 and 7 are provided.
Both outputs of 2 become high level. On the other hand, when the output voltage V of the integrating circuit 62 is V <V2, the comparator 71
Output becomes high level, and the output of the comparator 72 becomes low level. As a result, a current flows through the resistor R8 and this current is absorbed by the comparator 72, so that the line 66 becomes the ground potential. When V1 <V, the low-level signal derived on the line 66 is used as the runaway state detection signal,
The output of the comparator 71 becomes low level, and the output of the comparator 72 becomes high level. As a result, the line 66 becomes the ground potential, so that the microcomputer 51 is reset as in the above case.
【0026】次に、図3と図4は、本発明の方法の第1
実施例を示したフローチャートであり、図3は、マイコ
ンのプログラムのメイン処理を示したフローチャートで
あり、図4は、マイコンのプログラムの割込み処理を示
したフローチャートであり、メイン処理の周期が10ms
ecで動作し、該メイン処理とは非同期に、例えばマイコ
ンのタイマ割込み機能を用いて1msec間隔で割込み処理
が行われる、定時割込み処理が行われるプログラムを示
したものである。このような構成は、一定周期で外部の
信号をモニタする、又は負荷への駆動信号を出力するな
どの処理を行う場合によく用いられる。Next, FIGS. 3 and 4 show a first method of the present invention.
3 is a flow chart showing an embodiment, FIG. 3 is a flow chart showing a main process of a microcomputer program, and FIG. 4 is a flow chart showing an interrupt process of a microcomputer program, and a main process cycle is 10 ms.
This is a program which operates in ec and performs a periodic interrupt process in which the interrupt process is performed at an interval of 1 msec using the timer interrupt function of a microcomputer asynchronously with the main process. Such a configuration is often used when performing processing such as monitoring an external signal at a fixed cycle or outputting a drive signal to a load.
【0027】図3で示すように、メイン処理は、n(n
は2以上の整数)個の処理ブロックMB1からMBnと
時間待ちブロックTBで構成されており、処理ブロック
MB1からMBnのそれぞれは、異常判定用フラグFを
設定するフローと、所定の処理を行うフローからなる。
ここで、本実施例のように、上記各処理ブロックMB1
からMBnの処理時間があらかじめ分かっている場合に
は、異常判定用フラグFを前半の処理ブロックでは0
に、後半の処理ブロックでは1に設定する。なお、異常
判定用フラグFを前半の処理ブロックでは1に、後半の
処理ブロックでは0に設定してもよいことは言うまでも
ない。As shown in FIG. 3, the main process is n (n
Is an integer greater than or equal to 2) processing blocks MB1 to MBn and a time waiting block TB, and each of the processing blocks MB1 to MBn sets a flow for setting an abnormality determination flag F and a flow for performing a predetermined process. Consists of.
Here, as in the present embodiment, each of the processing blocks MB1
If the processing time from MBn to MBn is known in advance, the abnormality determination flag F is set to 0 in the first processing block.
Is set to 1 in the latter half processing block. Needless to say, the abnormality determination flag F may be set to 1 in the first processing block and to 0 in the second processing block.
【0028】まず最初に、処理ブロックMB1におい
て、ステップS1aで異常判定用フラグFを0に設定し
た後、ステップS1bで所定の処理1を行い、その次
に、処理ブロックMB2に進み、処理ブロックMB2に
おいて、ステップS2aで異常判定用フラグFを0に設
定した後、ステップS2bで所定の処理2を行う。この
ように、前半の処理ブロックでは同様のフローを行う。
なお、上記整数nが2の場合、処理ブロック2は、後述
する後半の処理ブロックと同様のフローを行う。First, in the processing block MB1, the abnormality determination flag F is set to 0 in step S1a, and then a predetermined processing 1 is performed in step S1b, and then the processing block MB2 is proceeded to. In step S2a, the abnormality determination flag F is set to 0, and then a predetermined process 2 is performed in step S2b. In this way, the same flow is performed in the processing blocks in the first half.
When the integer n is 2, the processing block 2 performs the same flow as the latter processing block described later.
【0029】次に、後半の処理ブロックを、n−1番目
の処理ブロックMBn-1から説明する。処理ブロックM
Bn-1において、ステップSn-1aで異常判定用フラグF
を1に設定した後、ステップSn-1bで所定の処理n-1を
行い、その次に、処理ブロックMBnに進み、処理ブロ
ックMBnにおいて、ステップSnaで異常判定用フラ
グFを1に設定した後、ステップSnbで所定の処理n
を行い、時間待ちブロックTBに進む。このように、後
半の処理ブロックでは同様のフローを行う。なお、上記
整数nが2の場合、処理ブロックn-1は、上記前半の処
理ブロックと同様のフローを行う。Next, the processing blocks in the latter half will be described from the (n-1) th processing block MBn-1. Processing block M
In Bn-1, in step Sn-1a, the abnormality determination flag F
Is set to 1, and then a predetermined process n-1 is performed in step Sn-1b, and then the process proceeds to process block MBn. In process block MBn, the abnormality determination flag F is set to 1 in step Sna. , A predetermined process n in step Snb
And proceed to the time waiting block TB. In this way, the same flow is performed in the latter processing blocks. When the integer n is 2, the processing block n-1 performs the same flow as the processing block in the first half.
【0030】時間待ちブロックTBは、ステップS10
からなり、ステップS10で、メイン処理が始まってか
ら10msec経過していれば(YES)、処理ブロックM
B1のステップS1aに戻る。ステップS10で、10
msec経過していなければ(NO)ステップS10を繰り
返す。The time waiting block TB has a step S10.
In step S10, if 10 msec has elapsed from the start of the main processing (YES), the processing block M
It returns to step S1a of B1. In step S10, 10
If msec has not elapsed (NO), step S10 is repeated.
【0031】次に、図4を用いて、割込み処理の説明を
行う。最初に、ステップS20で、他の割込みを禁止す
る割込み禁止処理を行い、次にステップS21で、メイ
ン処理で設定されているこのときの異常判定用フラグF
を読み込み、該異常判定用フラグFに対応するレベルの
信号、例えば異常判定用フラグが0であればLoレベル
の信号がマイコン1のWD信号出力端子から出力され
る。Next, the interrupt processing will be described with reference to FIG. First, in step S20, an interrupt prohibition process for prohibiting other interrupts is performed, and then in step S21, the abnormality determination flag F set in the main process at this time.
And a signal of a level corresponding to the abnormality determination flag F, for example, if the abnormality determination flag is 0, a Lo level signal is output from the WD signal output terminal of the microcomputer 1.
【0032】次に、ステップS22に進み、所定の割込
みブロック1の処理を行い、ステップS23で最後の所
定の割込みブロックm(mは1以上の整数)の処理を行
い、ステップS24に進む。なお、ここでは説明を省略
したが、ステップS22とステップS23の間におい
て、上記整数mに対応する回数の所定の割込みブロック
の処理が行われ、上記整数mが1の場合は、上記ステッ
プS23は行われず、ステップS22からステップS2
4へ進む。Next, in step S22, a predetermined interrupt block 1 is processed, in step S23, the last predetermined interrupt block m (m is an integer of 1 or more) is processed, and then the process proceeds to step S24. Although not described here, between step S22 and step S23, a predetermined number of interrupt blocks are processed corresponding to the integer m, and when the integer m is 1, the step S23 is executed. No, step S22 to step S2
Go to 4.
【0033】ステップS24で、他の割込みの禁止を解
く割込み許可処理を行って、割込み処理が終了し、割込
み処理が行われる前のメイン処理のフローに戻る。In step S24, an interrupt permission process for unlocking other interrupts is performed, the interrupt process ends, and the process returns to the main process flow before the interrupt process is performed.
【0034】このように、図4で示した割込み処理は、
メイン処理とは非同期に1msec毎に行われ、その度にそ
のときにメイン処理で設定された異常判定用フラグFを
読み込み、その異常判定用フラグFに対応するレベルの
信号をマイコン1のWD信号出力端子から出力されるこ
とから、これらの処理が正常に動作している場合には、
メイン処理の流れにしたがって割込み処理にて一定の周
期のパルスがWD信号としてWD監視回路2に出力さ
れ、WD監視回路2は正常判定信号を出力する。As described above, the interrupt processing shown in FIG.
The process is performed asynchronously with the main process every 1 msec. At each time, the abnormality determination flag F set in the main process is read, and the level signal corresponding to the abnormality determination flag F is read as the WD signal of the microcomputer 1. Since these are output from the output terminal, if these processes are operating normally,
In the interrupt process according to the flow of the main process, a pulse having a constant cycle is output as a WD signal to the WD monitoring circuit 2, and the WD monitoring circuit 2 outputs a normal determination signal.
【0035】次に、上記第1実施例に対して、いくつか
のマイコンの暴走例に対する本発明の動作を説明する。
暴走例1として、図3で示したメイン処理において、1
つの処理ブロックが無限ループとなり、図4の割込み処
理は1msec毎に正常に処理されている場合について説明
する。Next, the operation of the present invention for some runaway examples of microcomputers will be described with respect to the first embodiment.
As a runaway example 1, in the main process shown in FIG.
A case where one processing block becomes an infinite loop and the interrupt processing of FIG. 4 is normally processed every 1 msec will be described.
【0036】メイン処理における処理ブロックMB2が
無限ループとなった場合、割込み処理が正常に動作して
いるが、メイン処理において設定される異常判定用フラ
グFは常に0となり、割込み処理において、メイン処理
で設定されているこのときの異常判定用フラグFを読み
込み、その異常判定用フラグFに対応するLoレベル一
定のWD信号がマイコン1のWD信号出力端子から出力
され、WD信号の反転が行われないため、WD監視回路
2は異常と判定し、異常判定信号を出力する。When the processing block MB2 in the main processing is in an infinite loop, the interrupt processing is operating normally, but the abnormality determination flag F set in the main processing is always 0, and the main processing is performed in the interrupt processing. The abnormality determination flag F set at this time is read, and a WD signal having a constant Lo level corresponding to the abnormality determination flag F is output from the WD signal output terminal of the microcomputer 1 to invert the WD signal. Therefore, the WD monitoring circuit 2 determines that there is an abnormality and outputs an abnormality determination signal.
【0037】次に、暴走例2として図3で示したメイン
処理は正常に処理されており、図4の割込み処理の割込
みブロックの1つが無限ループとなった場合について説
明する。Next, a case where the main process shown in FIG. 3 as the runaway example 2 is normally processed and one of the interrupt blocks of the interrupt process of FIG. 4 becomes an infinite loop will be described.
【0038】割込み処理における割込みブロック1が無
限ループとなった場合、割込み処理の先頭で割込みを禁
止する処理を行っているため、メイン処理に復帰するこ
とができず、これより先に1msec毎の割込み処理要求を
受けても、割込み禁止となっているため割込み処理は行
われない。このことから、上記無限ループ中はWD信号
の新たな出力は行われず、上記無限ループが起こる直前
の割込み処理で行った出力状態が保持されるため、WD
信号はHi又はLoレベル一定となり、WD監視回路2は
異常と判定し、異常判定信号を出力する。When the interrupt block 1 in the interrupt process becomes an infinite loop, the interrupt process is prohibited at the beginning of the interrupt process, so that the main process cannot be resumed and every 1 msec thereafter. Even if an interrupt processing request is received, interrupt processing is not performed because interrupts are disabled. From this, the WD signal is not newly output during the infinite loop, and the output state performed by the interrupt process immediately before the infinite loop occurs is held.
The signal becomes Hi or Lo level constant, the WD monitoring circuit 2 determines that there is an abnormality, and outputs an abnormality determination signal.
【0039】次に、暴走例3として、図3で示したメイ
ン処理は正常に処理されており、図4の割込み処理のス
テップS21における、メイン処理で設定された異常判
定用フラグFを読み込み、その異常判定用フラグFに対
応するレベルの信号をマイコン1のWD信号出力端子か
ら出力する処理が無限ループとなった場合について説明
する。Next, as a runaway example 3, the main processing shown in FIG. 3 is normally processed, and the abnormality determination flag F set in the main processing in step S21 of the interrupt processing of FIG. 4 is read. A case where the process of outputting the signal of the level corresponding to the abnormality determination flag F from the WD signal output terminal of the microcomputer 1 becomes an infinite loop will be described.
【0040】この場合も、上記暴走例2と同様に割込み
処理の先頭で割込みを禁止する処理を行っているため、
メイン処理に復帰することができない。また、WD信号
出力処理は不定周期で繰り返されるが、メイン処理で設
定する異常判定用フラグFの状態が変化しないため、W
D信号はHi又はLoレベル一定となり、WD監視回路2
は異常と判定し、異常判定信号を出力する。In this case as well, since the interrupt prohibition process is performed at the beginning of the interrupt process as in Runaway Example 2 above,
Cannot return to main processing. Further, the WD signal output process is repeated in an indefinite cycle, but since the state of the abnormality determination flag F set in the main process does not change, W
The D signal becomes Hi or Lo level constant, and the WD monitoring circuit 2
Determines that there is an abnormality and outputs an abnormality determination signal.
【0041】次に、暴走例4として、図3で示したメイ
ン処理は正常に処理されているが、図4で示した割込み
処理が行われなくなった場合について説明する。Next, as a runaway example 4, a case will be described in which the main processing shown in FIG. 3 is normally processed, but the interrupt processing shown in FIG. 4 is no longer performed.
【0042】この場合、メイン処理が正常周期で動作し
ていても、WD信号の新たな出力は行われず、上記異常
が起こる直前の割込み処理で行った出力状態が保持され
るため、WD信号はHi又はLoレベル一定となり、WD
監視回路2は異常と判定し、異常判定信号を出力する。In this case, even if the main process operates in a normal cycle, the WD signal is not newly output, and the output state performed by the interrupt process immediately before the occurrence of the above abnormality is held, so that the WD signal becomes Hi or Lo level becomes constant and WD
The monitoring circuit 2 determines that there is an abnormality and outputs an abnormality determination signal.
【0043】次に、暴走例5として、図3で示したメイ
ン処理は正常に処理されているが、図4で示した割込み
処理の途中でメイン処理に異常ジャンプした場合につい
て説明する。Next, as a runaway example 5, a case will be described in which the main processing shown in FIG. 3 is normally processed, but an abnormal jump is made to the main processing during the interrupt processing shown in FIG.
【0044】この場合、割込み処理で割込みが禁止され
ている状態でメイン処理が行われるため、次の割込み処
理が受け付けられず、WD信号はHi又はLoレベル一定
となり、WD監視回路2は異常と判定し、異常判定信号
を出力する。In this case, since the main process is performed in a state where the interrupt is disabled in the interrupt process, the next interrupt process is not accepted, the WD signal becomes Hi or Lo level constant, and the WD monitoring circuit 2 is abnormal. Judges and outputs an abnormality determination signal.
【0045】次に、暴走例6として、図3で示したメイ
ン処理は正常に処理されているが、1msec毎に行われる
図4で示した割込み処理が異常頻度で行われる場合につ
いて説明する。Next, as a runaway example 6, a case will be described in which the main processing shown in FIG. 3 is normally processed, but the interrupt processing shown in FIG. 4 executed every 1 msec is executed with an abnormal frequency.
【0046】この場合、1つの割込み処理が終了してメ
イン処理に復帰しても、次の割込み処理要求を受け付け
るため、メイン処理を行う時間がなく、上記暴走例3と
同様にWD信号はHi又はLoレベル一定となり、WD監
視回路2は異常と判定し、異常判定信号を出力する。In this case, even if one interrupt process ends and the main process returns, the next interrupt request is accepted, so there is no time to perform the main process, and the WD signal is Hi as in the runaway example 3 described above. Alternatively, the Lo level becomes constant, and the WD monitoring circuit 2 determines that there is an abnormality and outputs an abnormality determination signal.
【0047】次に、メイン処理が割込み処理と同期して
処理されるプログラムの場合における本発明の方法を示
した第2実施例を図5及び図6を用いて説明する。Next, a second embodiment showing the method of the present invention when the main process is a program processed in synchronization with the interrupt process will be described with reference to FIGS. 5 and 6.
【0048】図5と図6は、本発明の方法の第2実施例
を示したフローチャートであり、図5は、マイコンのプ
ログラムのメイン処理を示したフローチャートであり、
図6は、マイコンのプログラムの割込み処理を示したフ
ローチャートであり、メイン処理の周期が8msecで動作
し、3ビットカウンタを使用して該メイン処理と同期し
て、割込み周期が1msecの割込み処理が行われる、同期
割込み処理が行われるプログラムを示したものである。
ここでは、上記第1実施例と同じフローは同じ符号で示
しており、ここでは上記第1実施例との相違点のみ説明
する。5 and 6 are flow charts showing the second embodiment of the method of the present invention, and FIG. 5 is a flow chart showing the main processing of the program of the microcomputer.
FIG. 6 is a flowchart showing the interrupt processing of the program of the microcomputer. The main processing cycle operates at 8 msec, and the interrupt processing with the interrupt cycle of 1 msec is performed in synchronization with the main processing by using the 3-bit counter. It shows a program to be executed, which is a synchronous interrupt process.
Here, the same flows as those in the first embodiment are indicated by the same reference numerals, and only differences from the first embodiment will be described here.
【0049】図5において、図3との相違点は、メイン
処理と割込み処理の間に所定の時間関係が規定できるよ
うな場合、すなわち、プログラムの処理時間上、メイン
処理の最初の部分、例えば処理ブロックMB1及び処理
ブロックMB2よりも早く4回目の割込みが処理されな
いことが明確な場合、処理ブロックMB1及び処理ブロ
ックMB2では、ステップS1a及びステップS2aで
異常判定用フラグFを0に設定し、処理ブロックMB3
におけるステップS3aで異常判定用フラグFを1に設
定する。5 is different from FIG. 3 in the case where a predetermined time relationship can be defined between the main process and the interrupt process, that is, in the processing time of the program, the first part of the main process, for example, When it is clear that the fourth interrupt is not processed earlier than the processing block MB1 and the processing block MB2, in the processing block MB1 and the processing block MB2, the abnormality determination flag F is set to 0 in steps S1a and S2a, and the processing is executed. Block MB3
In step S3a, the abnormality determination flag F is set to 1.
【0050】また、処理ブロックMB3以降の処理ブロ
ックの先頭で同様に異常判定用フラグFを1に設定する
ことと、ステップS30を追加し、図3における時間待
ちブロックTBの代わりにステップS31及びステップ
S32からなる時間待ちブロックTB1を行うことにあ
る。Further, similarly, the abnormality determination flag F is set to 1 at the beginning of the processing blocks after the processing block MB3, and step S30 is added to replace the time waiting block TB in FIG. 3 with steps S31 and step S31. The purpose is to execute the time waiting block TB1 consisting of S32.
【0051】図5におけるメイン処理のフローの最初に
ステップS30を行い、ステップS30では、3ビット
カウンタの数値が000になっているかを調べ、000
になっていれば(YES)、処理ブロックMB1のステ
ップS1aに進む。また、ステップS30でカウンタの
数値が000になっていない場合(NO)は、ステップ
S30を繰り返す。At the beginning of the flow of the main processing in FIG. 5, step S30 is carried out. At step S30, it is checked whether or not the numerical value of the 3-bit counter is 000, and 000
If YES (YES), the process proceeds to step S1a of the processing block MB1. If the counter value is not 000 in step S30 (NO), step S30 is repeated.
【0052】処理ブロックMBnの処理が終わると時間
待ちブロックTB1に進む。時間待ちブロックTB1
は、ステップS31とステップS32とからなり、ステ
ップS31で、カウンタの数値が111になっていれば
(YES)、ステップS32に進み、ステップS32で
異常判定用フラグFは0に設定されて、ステップS30
に戻る。ステップS31で、カウンタの数値が111に
なっていなければ(NO)、ステップS31を繰り返
す。When the processing of the processing block MBn is completed, the process proceeds to the time waiting block TB1. Waiting block TB1
Consists of step S31 and step S32. If the numerical value of the counter is 111 in step S31 (YES), the process proceeds to step S32, in which the abnormality determination flag F is set to 0, S30
Return to If the numerical value of the counter is not 111 in step S31 (NO), step S31 is repeated.
【0053】次に図6の割込み処理について説明する。
図6において、最初にステップS20で割込みを禁止し
て、ステップS40に進み、ステップS40で3ビット
カウンタをインクリメントしてステップS41に進む。Next, the interrupt processing of FIG. 6 will be described.
In FIG. 6, first, interrupt is prohibited in step S20, the process proceeds to step S40, the 3-bit counter is incremented in step S40, and the process proceeds to step S41.
【0054】次にステップS41で、3ビットカウンタ
の数値が000か否かを調べ、000であるならば(Y
ES)、ステップS42に進む。次にステップS42
で、メイン処理で設定されているこのときの異常判定用
フラグFを読み込み、その異常判定用フラグFに対応す
るレベルの信号をマイコン1のWD信号出力端子から出
力される。Next, in step S41, it is checked whether or not the numerical value of the 3-bit counter is 000, and if it is 000 (Y
ES), and proceeds to step S42. Next in step S42
Then, the abnormality determination flag F set at this time set in the main process is read, and a signal of a level corresponding to the abnormality determination flag F is output from the WD signal output terminal of the microcomputer 1.
【0055】次にステップS43で所定の割込みブロッ
ク1aの処理を行い、ステップS24に進む。Next, in step S43, the process of the predetermined interrupt block 1a is performed, and the process proceeds to step S24.
【0056】ステップS41で、3ビットカウンタの数
値が000でなかった場合(NO)には、ステップS4
4に進み、ステップS44で、3ビットカウンタの数値
が001か否かを調べ、001であるならば(YE
S)、ステップS45に進む。ステップS45で所定の
割込みブロック2aの処理を行い、ステップS24に進
む。When the value of the 3-bit counter is not 000 in step S41 (NO), step S4
In step S44, it is checked whether or not the numerical value of the 3-bit counter is 001, and if it is 001 (YE
S), the process proceeds to step S45. The predetermined interrupt block 2a is processed in step S45, and the process proceeds to step S24.
【0057】ステップS44で、3ビットカウンタの数
値が001でなかった場合(NO)には、ステップS4
6に進み、ステップS46で、3ビットカウンタの数値
が010か否かを調べ、010であるならば(YE
S)、ステップS47に進む。ステップS47で所定の
割込みブロック3aの処理を行い、ステップS24に進
む。When the numerical value of the 3-bit counter is not 001 in step S44 (NO), step S4
In step S46, it is checked whether or not the numerical value of the 3-bit counter is 010, and if it is 010 (YE
S), the process proceeds to step S47. The predetermined interrupt block 3a is processed in step S47, and the process proceeds to step S24.
【0058】同様に、ステップS46で、3ビットカウ
ンタの数値が010でなかった場合(NO)には、ステ
ップS48に進み、ステップS48で、3ビットカウン
タの数値が011か否かを調べ、011であるならば
(YES)、ステップS49に進む。ステップS49で
所定の割込みブロック4aの処理を行い、ステップS2
4に進む。Similarly, if the numerical value of the 3-bit counter is not 010 in step S46 (NO), the process proceeds to step S48, and it is checked in step S48 whether the numerical value of the 3-bit counter is 011 or not. If (YES), the process proceeds to step S49. The predetermined interrupt block 4a is processed in step S49, and then step S2
Go to 4.
【0059】ステップS48で、3ビットカウンタの数
値が011でなかった場合(NO)には、ステップS5
0に進み、ステップS50で、3ビットカウンタの数値
が100か否かを調べ、100であるならば(YE
S)、ステップS51に進み、ステップS51で、メイ
ン処理で設定されているこのときの異常判定用フラグF
を読み込み、その異常判定用フラグFに対応するレベル
の信号をマイコン1のWD信号出力端子から出力され
る。なお上述したように、処理ブロックMB1及び処理
ブロックMB2よりも早く4回目の割込みが処理されな
いことが明確であることから、ステップS51で出力さ
れるWD信号は、ステップS42で出力されるWD信号
とは相反するレベルのWD信号が出力される。If the numerical value of the 3-bit counter is not 011 in step S48 (NO), step S5
In step S50, it is checked whether or not the numerical value of the 3-bit counter is 100, and if it is 100 (YE
S), the process proceeds to step S51, and in step S51, the abnormality determination flag F set in the main process at this time
Is read and a signal of a level corresponding to the abnormality determination flag F is output from the WD signal output terminal of the microcomputer 1. As described above, since it is clear that the fourth interrupt is not processed earlier than the processing block MB1 and the processing block MB2, the WD signal output in step S51 is the same as the WD signal output in step S42. Output WD signals of opposite levels.
【0060】次にステップS52に進み、ステップS5
2で、所定の割込みブロック5aの処理を行い、ステッ
プS24に進む。Then, the process proceeds to step S52 and step S5.
In step 2, the predetermined interrupt block 5a is processed, and the process proceeds to step S24.
【0061】ステップS50で、3ビットカウンタの数
値が100でなかった場合(NO)には、ステップS5
3に進み、ステップS53で、3ビットカウンタの数値
が101か否かを調べ、101であるならば(YE
S)、ステップS54に進む。ステップS54で所定の
割込みブロック6aの処理を行い、ステップS24に進
む。When the numerical value of the 3-bit counter is not 100 in step S50 (NO), step S5
In step S53, it is checked whether or not the numerical value of the 3-bit counter is 101, and if it is 101 (YE
S), and proceeds to step S54. The predetermined interrupt block 6a is processed in step S54, and the process proceeds to step S24.
【0062】同様に、ステップS53で、3ビットカウ
ンタの数値が101でなかった場合(NO)には、ステ
ップS55に進み、ステップS55で、3ビットカウン
タの数値が110か否かを調べ、110であるならば
(YES)、ステップS56に進む。ステップS56で
所定の割込みブロック7aの処理を行い、ステップS2
4に進む。Similarly, when the numerical value of the 3-bit counter is not 101 in step S53 (NO), the process proceeds to step S55, and it is checked in step S55 whether the numerical value of the 3-bit counter is 110 or not. If (YES), the process proceeds to step S56. The predetermined interrupt block 7a is processed in step S56, and then step S2
Go to 4.
【0063】ステップS55で、3ビットカウンタの数
値が110でなかった場合(NO)には、ステップS5
7に進み、ステップS57で所定の割込みブロック8a
の処理を行い、ステップS24に進む。If the value of the 3-bit counter is not 110 in step S55 (NO), step S5
7, the predetermined interrupt block 8a in step S57.
Processing is performed, and the process proceeds to step S24.
【0064】ここで、上記第2実施例において、開発途
中などで処理ブロックの時間が定まらずメイン処理の処
理時間が流動的な場合は、メインブロックMB1で異常
判定用フラグFを1に設定し、時間待ちブロックTB1
で異常判定用フラグFを0に設定すると、メイン処理の
各処理の変更に影響されずにWD信号を正常なパルスと
してマイコン1から出力することができる。In the second embodiment, if the processing block time is not fixed and the main processing time is fluid during development, the abnormality determination flag F is set to 1 in the main block MB1. , Waiting block TB1
When the abnormality determination flag F is set to 0, the WD signal can be output from the microcomputer 1 as a normal pulse without being affected by changes in each process of the main process.
【0065】また、本第2実施例において、マイコンの
暴走に対する動作は、上記第1実施例と同様であり、こ
こではその説明を省略する。In the second embodiment, the operation of the microcomputer against runaway is the same as in the first embodiment, and the description thereof is omitted here.
【0066】上記第1及び第2実施例においては、WD
監視回路2としては無パルス状態のみを検出すればよか
ったが、パルス状のWD信号のHi及びLoレベルの時間
をも監視できるWD監視回路2を設置することができる
場合における本発明の方法を示した第3実施例を図7を
用いて説明する。In the first and second embodiments, the WD
Although it suffices to detect only the non-pulse state as the monitoring circuit 2, the method of the present invention in the case where the WD monitoring circuit 2 capable of monitoring the time of the Hi and Lo levels of the pulsed WD signal can be installed will be described. A third embodiment will be described with reference to FIG.
【0067】図7は、本発明の方法の第3実施例を示し
たフローチャートであり、図7は、マイコンのプログラ
ムのメイン処理を示したフローチャートであり、メイン
処理の各処理ブロック内に割込みを禁止して処理を行う
サブブロックを設定しており、このような処理は、例え
ば割込み処理において用いられる変数をメイン処理にて
操作する場合に必要となるもので、種々の文献において
公知の処理方法である。また、割込み処理を示したフロ
ーチャートは上記第1実施例の図4で示したフローチャ
ートと同じであり、ここでは上記第1実施例との相違点
のみを説明する。FIG. 7 is a flow chart showing the third embodiment of the method of the present invention, and FIG. 7 is a flow chart showing the main processing of the program of the microcomputer, and an interrupt is made in each processing block of the main processing. A sub-block for prohibiting processing is set, and such processing is necessary, for example, when a variable used in interrupt processing is manipulated in the main processing, and processing methods known in various documents are set. Is. The flowchart showing the interrupt processing is the same as the flowchart shown in FIG. 4 of the first embodiment, and only the differences from the first embodiment will be described here.
【0068】図7において、図3で示したフローチャー
トとの相違点は、各処理ブロック内にそれぞれ割込みを
禁止して処理を行うサブブロックを設定しており、処理
ブロックMB2Aを例にして図3の処理ブロックMB2
と対比させて説明する。In FIG. 7, the difference from the flowchart shown in FIG. 3 is that subblocks for prohibiting interrupts are set in each processing block, and processing block MB2A is used as an example. Processing block MB2
This will be explained in comparison with.
【0069】処理ブロックMB2Aにおいて、最初にス
テップS2Aで、図3の各処理ブロックの最初に行った
フロー、例えば図3の処理ブロックMB2におけるステ
ップS2aと同様に異常判定用フラグFを設定し、ここ
では0に設定する。In the processing block MB2A, first in step S2A, the abnormality determination flag F is set in the same manner as in step S2a in the processing block MB2 in FIG. Then set it to 0.
【0070】また、図7の処理ブロックMB2Aにおけ
るステップS2BからステップS2Hは、図3における
ステップS2bに相当し、すなわち、ステップS2bの
処理2内に割込みを禁止して処理を行う、ステップS2
CからステップS2GよりなるサブブロックSB2Aを
設けた形となっている。Further, steps S2B to S2H in the processing block MB2A in FIG. 7 correspond to step S2b in FIG. 3, that is, the interrupt is prohibited in the processing 2 in step S2b, and the processing is performed in step S2.
The sub-block SB2A is formed from C to step S2G.
【0071】次に、ステップS2Bに進み、ステップS
2Bで所定の処理Aを行って、サブブロックSB2Aの
ステップS2Cに進み、ステップS2Cで割込みを禁止
する処理を行う。Then, the process proceeds to step S2B and step S2.
The predetermined process A is performed in 2B, the process proceeds to step S2C of the sub-block SB2A, and the process of inhibiting the interrupt is performed in step S2C.
【0072】次に、ステップS2Dに進み、ステップS
2Dで異常判定用フラグFを上記ステップS2Aで設定
されたフラグと相反する設定を行う。すなわち本実施例
においては、異常判定用フラグFを1に設定し、ステッ
プS2Eに進む。Next, in step S2D, step S2
In 2D, the abnormality determination flag F is set to conflict with the flag set in step S2A. That is, in this embodiment, the abnormality determination flag F is set to 1 and the process proceeds to step S2E.
【0073】ステップS2Eで、所定の処理Bを行っ
て、ステップS2Fに進み、ステップS2Fで異常判定
用フラグFをステップS2Aと同じ状態に、すなわち、
ここでは0に設定し、ステップS2Gに進む。In step S2E, a predetermined process B is performed, and the process proceeds to step S2F. In step S2F, the abnormality determination flag F is set to the same state as in step S2A, that is,
Here, it is set to 0, and the process proceeds to step S2G.
【0074】ステップS2Gで、割込み禁止処理を解除
して割込みを許可する処理が行われてサブブロックSB
2Aの処理が終わった後、ステップS2Hに進み、ステ
ップS2Hで所定の処理Cが行われて、1つの処理ブロ
ックが終わり、次の処理ブロックへとフローが進む。こ
のような構成の処理ブロックが、処理ブロックMB1A
から始まり処理ブロックMBnAまで行われた後、時間
待ちブロックTBAに進む。In step S2G, the process of releasing the interrupt prohibition process and permitting the interrupt is performed, and the sub-block SB is executed.
After the processing of 2A is completed, the process proceeds to step S2H, a predetermined process C is performed in step S2H, one processing block ends, and the flow proceeds to the next processing block. The processing block having such a configuration is the processing block MB1A.
The process starts from the processing block MBnA and proceeds to the time waiting block TBA.
【0075】上記時間待ちブロックTBAは、ステップ
S80からなり、ステップS80でメイン処理における
所定の1周期の時間が経過したか否かを調べ、所定の1
周期の時間が経過した場合(YES)は、メイン処理の
先頭にある処理ブロックMB1Aに戻り、ステップS8
0で、上記所定の1周期の時間が経過していない場合
(NO)は、ステップS80を繰り返す。The time-waiting block TBA is composed of step S80. In step S80, it is checked whether or not a predetermined period of one cycle in the main process has elapsed, and the predetermined period of 1
If the period of time has elapsed (YES), the process returns to the process block MB1A at the beginning of the main process, and step S8 is performed.
If the predetermined one cycle time has not elapsed (NO) at 0, step S80 is repeated.
【0076】ここで、図7における各処理ブロックのサ
ブブロック内にある割込み禁止機能が正常に働かずに、
サブブロック内の割込み禁止区間で割込み処理へジャン
プしてしまった場合には、WD信号が反転してしまうこ
とになり、正常時に比べWD信号のパルスの所定のHi
レベル時間又はLoレベル時間が短くなり、これをWD
監視回路2で検出して、WD監視回路2は異常と判定
し、異常判定信号を出力することによりサブブロック内
の割込み禁止区間での暴走検出が可能となる。Here, the interrupt prohibition function in the sub-block of each processing block in FIG. 7 does not work normally,
When jumping to the interrupt processing in the interrupt prohibited section in the sub-block, the WD signal is inverted, and compared with the normal case, the pulse of the WD signal has a predetermined Hi level.
Level time or Lo level time becomes short and this is WD
When the WD monitoring circuit 2 detects the abnormality by the monitoring circuit 2 and outputs an abnormality determination signal, the runaway can be detected in the interrupt prohibited section in the sub-block.
【0077】本発明は、上記第1実施例、第2実施例及
び第3実施例に限定されるものではなく、様々な変形例
が考えられることは言うまでもなく、本発明の範囲は、
特許請求の範囲によって定められるべきものであること
は言うまでもない。The present invention is not limited to the above-mentioned first embodiment, second embodiment and third embodiment, and it is needless to say that various modifications can be considered.
Needless to say, it should be defined by the scope of the claims.
【図1】 本発明のマイクロコンピュータの異常信号出
力方法が適用される、マイクロコンピュータとWD信号
の監視回路を主な構成要素とするマイクロコンピュータ
システムを示した概略ブロック図である。FIG. 1 is a schematic block diagram showing a microcomputer system to which a method for outputting an abnormal signal of a microcomputer of the present invention is applied, which mainly includes a microcomputer and a WD signal monitoring circuit.
【図2】 WD信号監視回路の回路例を示した図であ
る。FIG. 2 is a diagram showing a circuit example of a WD signal monitoring circuit.
【図3】 本発明の方法の第1実施例におけるマイコン
のプログラムのメイン処理を示したフローチャートであ
る。FIG. 3 is a flowchart showing main processing of a program of a microcomputer in the first embodiment of the method of the present invention.
【図4】 本発明の方法の第1実施例におけるマイコン
のプログラムの割込み処理を示したフローチャートであ
る。FIG. 4 is a flowchart showing interrupt processing of a program of a microcomputer in the first embodiment of the method of the present invention.
【図5】 本発明の方法の第2実施例におけるマイコン
のプログラムのメイン処理を示したフローチャートであ
る。FIG. 5 is a flowchart showing a main process of a microcomputer program in the second embodiment of the method of the present invention.
【図6】 本発明の方法の第2実施例におけるマイコン
のプログラムの割込み処理を示したフローチャートであ
る。FIG. 6 is a flowchart showing interrupt processing of a program of a microcomputer in the second embodiment of the method of the present invention.
【図7】 本発明の方法の第3実施例におけるマイコン
のプログラムのメイン処理を示したフローチャートであ
る。FIG. 7 is a flow chart showing main processing of a program of a microcomputer in the third embodiment of the method of the present invention.
1 マイクロコンピュータ 2 WD信号監視回路 F 異常判定用フラグ 1 Microcomputer 2 WD signal monitoring circuit F Abnormality judgment flag
Claims (6)
ンを中断して割込み処理ルーチンを実行するマイクロコ
ンピュータにおいて、 通常の処理プログラムの所定のブロック毎に異常判定用
フラグをセットし、それ以外の処理ブロックでは異常判
定用フラグをリセットするようにすると共に、割込み処
理のプログラムの実行時に、異常判定用フラグを読み込
み、異常判定用フラグに対応するレベルの異常判定用信
号を出力するようにし、出力される異常判定用信号のレ
ベルの状態から異常の有無を判定するようにしたことを
特徴とするマイクロコンピュータの異常信号出力方法。1. A microcomputer that interrupts a normal processing routine and executes the interrupt processing routine when an interrupt instruction is issued sets an abnormality determination flag for each predetermined block of a normal processing program, and The processing block resets the abnormality determination flag, reads the abnormality determination flag when the interrupt processing program is executed, and outputs the abnormality determination signal at the level corresponding to the abnormality determination flag, and outputs the signal. An abnormality signal output method for a microcomputer, wherein the presence or absence of abnormality is determined from the state of the level of the abnormality determination signal.
み処理のプログラムの先頭において、割込みを禁止する
処理の後に、上記異常判定用フラグを読み込み、該異常
判定用フラグに対応するレベルの異常判定用信号を出力
するようにしたことを特徴とするマイクロコンピュータ
の異常信号出力方法。2. The method according to claim 1, wherein at the beginning of the interrupt processing program, the abnormality determination flag is read after the processing for inhibiting the interrupt, and the level corresponding to the abnormality determination flag is read. An abnormality signal output method for a microcomputer, characterized in that it outputs an abnormality determination signal.
記各処理ブロック内に割込みを禁止して処理を行うサブ
ブロックを設定し、該各割込み禁止区間では上記異常判
定用フラグを上記設定と相反する状態に設定するように
したことを特徴とするマイクロコンピュータの異常信号
出力方法。3. The method according to claim 1, further comprising setting a sub-block in each of the processing blocks for prohibiting interrupts and performing processing, wherein the abnormality determination flag is set in the interrupt prohibition section. A method for outputting an abnormal signal of a microcomputer, characterized in that the setting is made in a state in which the setting conflicts with the setting.
イン処理のプログラムと非同期し、上記割込み処理が所
定の周期で割り込む、定時割込み処理を行う場合におい
て、メイン処理のプログラムにおける前半の各処理ブロ
ックの先頭で、上記各異常判定用フラグをセット又はリ
セットするようにそれぞれ設定し、メイン処理のプログ
ラムにおける後半の各処理ブロックの先頭で、上記各異
常判定用フラグを、上記前半の各処理ブロックで設定さ
れた異常判定用フラグと相反する状態に設定し、割込み
処理のプログラムの最後に割込み禁止を解除し、メイン
処理に復帰させる割込み許可処理を行うようにしたこと
を特徴とするマイクロコンピュータの異常信号出力方
法。4. The method according to claim 2, further comprising: in the case of performing a timed interrupt process in which the interrupt process interrupts at a predetermined cycle asynchronously with the main process program, the first half of the main process program is executed. The respective abnormality determination flags are set to be set or reset at the beginning of each processing block, and the above abnormality determination flags are set at the beginning of each processing block in the latter half of the main processing program. A micro that is characterized by setting a state that conflicts with the abnormality determination flag set in the processing block, canceling interrupt prohibition at the end of the interrupt processing program, and performing interrupt enable processing to return to main processing. Computer abnormal signal output method.
込み処理以外のメイン処理のプログラムと同期し、所定
の周期で割り込む、同期割込み処理を行う場合におい
て、メイン処理のプログラムにおける各処理ブロックの
先頭で、上記異常判定用フラグをセット又はリセットす
るようにそれぞれ設定し、割込み処理のプログラムにお
いて、先頭にある割込みを禁止する処理の後に、カウン
タを加算する処理を行い、割込み処理のプログラムの最
後に割込み禁止を解除し、メイン処理に復帰させる割込
み許可処理を行い、割込み処理のプログラムで、上記カ
ウンタが少なくとも1つの所定の数値になると、そのと
きの上記異常判定用フラグを読み込み、該異常判定用フ
ラグに対応するレベルの異常判定用信号を出力し、上記
異常判定用信号が交互に相反するレベルとなるように、
上記異常判定用フラグを設定したことを特徴とするマイ
クロコンピュータの異常信号出力方法。5. The method according to claim 1, further comprising: synchronous processing with a program for main processing other than interrupt processing, interrupting at a predetermined cycle, and performing synchronous interrupt processing, each processing in the program for main processing Set the above abnormality determination flags at the beginning of the block to set or reset respectively, and in the interrupt processing program, perform the processing of adding the counter after the processing of inhibiting the interrupt at the beginning, and execute the interrupt processing program. At the end of the above, the interrupt prohibition process is released, and the interrupt permission process for returning to the main process is performed. When the counter reaches at least one predetermined numerical value in the interrupt process program, the abnormality determination flag at that time is read and Outputs the abnormality judgment signal of the level corresponding to the abnormality judgment flag, and the above abnormality judgment signals alternate. So that the level is
An abnormality signal output method for a microcomputer, characterized in that the abnormality determination flag is set.
イン処理のプログラムにおける各処理ブロックの先頭
で、上記異常判定用フラグをセット又はリセットするよ
うにそれぞれ設定し、上記各処理ブロック内に割込み禁
止区間を設定し、該各割込み禁止区間の先頭で、上記異
常判定用フラグを、各処理ブロックの先頭で設定した状
態と相反する状態にそれぞれ設定し、上記割込み禁止区
間の最後で、上記異常判定用フラグを、各処理ブロック
の先頭で設定した状態と同じ状態に設定し、割込み処理
のプログラムにおいて、先頭にある割込みを禁止する処
理の後に、上記各異常判定用フラグと同じレベルの異常
判定用信号を出力し、割込み処理のプログラムの最後に
割込み禁止を解除し、メイン処理に復帰させる割込み許
可処理を行うことを特徴とするマイクロコンピュータの
異常信号出力方法。6. The method according to claim 3, further comprising setting the abnormality determination flag to be set or reset at the beginning of each processing block in the main processing program, and setting the abnormality determination flag in each processing block. The interrupt prohibition section is set to, and at the beginning of each interrupt prohibition section, the abnormality determination flag is set to a state that conflicts with the state set at the beginning of each processing block, and at the end of the interruption prohibition section, Set the abnormality determination flag to the same state as the state set at the beginning of each processing block, and in the interrupt processing program, after the process of prohibiting the interrupt at the beginning, set the same level as each abnormality determination flag. A special feature is that it outputs an error judgment signal, cancels the interrupt prohibition at the end of the interrupt processing program, and performs the interrupt permission processing to return to the main processing. A method of outputting an abnormal signal from a microcomputer.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP6141550A JPH086823A (en) | 1994-06-23 | 1994-06-23 | Abnormal signal output method of microcomputer |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP6141550A JPH086823A (en) | 1994-06-23 | 1994-06-23 | Abnormal signal output method of microcomputer |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| JPH086823A true JPH086823A (en) | 1996-01-12 |
Family
ID=15294576
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP6141550A Pending JPH086823A (en) | 1994-06-23 | 1994-06-23 | Abnormal signal output method of microcomputer |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JPH086823A (en) |
-
1994
- 1994-06-23 JP JP6141550A patent/JPH086823A/en active Pending
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US10006455B2 (en) | Drive control apparatus | |
| JPH0528063A (en) | Microcomputer | |
| JPH086823A (en) | Abnormal signal output method of microcomputer | |
| CN113868856B (en) | Multifunctional linear desalter design method based on state transition | |
| JP2008225807A (en) | Control device and program runaway monitoring method thereof | |
| JPH09167107A (en) | Microcomputer abnormality monitoring device | |
| JPH04142635A (en) | Abnormal operation detecting device for processor | |
| JPH0395636A (en) | Diagnostic system for fail-safe circuit | |
| JPS5855535B2 (en) | Multi-computer device for vehicles | |
| JP2003015888A (en) | Cpu load measuring system | |
| JPH0812656B2 (en) | Microcomputer operation abnormality detection method | |
| JPS62145336A (en) | Program loop detection system for computer system | |
| JPH03119441A (en) | Detection system for abnormality of account timer | |
| JPH0612294A (en) | Monitoring device | |
| JPH05257748A (en) | Microprocessor device | |
| JPH02244208A (en) | Information processor control system | |
| JPH0375882B2 (en) | ||
| JPH0240747A (en) | Data input/output method for microcomputer | |
| JPH04195437A (en) | Program runaway monitoring device | |
| JPS6349855A (en) | Detecting device for interruption cycle abnormality of cpu | |
| JPH03208137A (en) | Abnormality detection system for control microcomputer | |
| JPH02101540A (en) | System for detecting runaway of cpu | |
| JPH04349542A (en) | Diagnostic system for real time operating system | |
| JPH01193945A (en) | System for detecting program error | |
| JP2000010824A (en) | Software monitor circuit |