JP2002259139A - Microcomputer, program and recording medium - Google Patents

Microcomputer, program and recording medium

Info

Publication number
JP2002259139A
JP2002259139A JP2001060194A JP2001060194A JP2002259139A JP 2002259139 A JP2002259139 A JP 2002259139A JP 2001060194 A JP2001060194 A JP 2001060194A JP 2001060194 A JP2001060194 A JP 2001060194A JP 2002259139 A JP2002259139 A JP 2002259139A
Authority
JP
Japan
Prior art keywords
processing
executed
module
microcomputer
execution
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
JP2001060194A
Other languages
Japanese (ja)
Inventor
Tomoyuki Kashiwagi
智之 柏木
Kenji Sunami
堅二 角南
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Denso Corp
Original Assignee
Denso Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Denso Corp filed Critical Denso Corp
Priority to JP2001060194A priority Critical patent/JP2002259139A/en
Publication of JP2002259139A publication Critical patent/JP2002259139A/en
Pending legal-status Critical Current

Links

Abstract

PROBLEM TO BE SOLVED: To suppress or cancel the delay of each time synchronizing processing when an interruption request is generated in a microcomputer for executing a plurality of time synchronizing processings having respectively different periods. SOLUTION: In the microcomputer, each of a plurality of time synchronizing processings (4 ms processing, 8 ms processing, 16 ms processing, etc.), having respectively different periods is divided into a plurality of module units, which are stepwise executed in its period. When a certain module can not be executed within the reference time due to the generation of an interruption request, the module concerned is executed together with a succeeding module within the reference time in which the succeeding module is to be executed. Since processing is executed in each module, overlap with interruption processing can be suppressed, the delay of the processing ca be suppressed and he delayed time synchronizing processing can be successively returned to original timing in each module.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明は、実行周期の異なる
複数の時間同期処理を実行するマイクロコンピュータに
おいて、割込要求が発生した場合の各時間同期処理の遅
れを解消又は抑制することができるマイクロコンピュー
タ、当該マイクロコンピュータを機能させるためのプロ
グラム、及び当該プログラムを記録した記録媒体に関す
る。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a microcomputer which executes a plurality of time synchronization processes having different execution periods and which can eliminate or suppress the delay of each time synchronization process when an interrupt request occurs. The present invention relates to a computer, a program for causing the microcomputer to function, and a recording medium on which the program is recorded.

【0002】[0002]

【従来の技術】従来より、マイクロコンピュータ(以下
「マイコン」という)には、実行周期が異なる複数の時
間同期処理を時分割で実行するものがある。例えば図7
に示すように、マイコンの動作クロックに基づいて、4
ms毎の処理,8ms毎の処理,又は16ms毎の処
理,・・・といったように、夫々4×2nms毎(nは
整数)に特定の処理を行うように設定されたプログラム
を実行するものがある(以下、これらの各処理を「4m
s処理,8ms処理,16ms処理,・・・」と略記す
る)。
2. Description of the Related Art Conventionally, some microcomputers (hereinafter referred to as "microcomputers") execute a plurality of time synchronization processes having different execution cycles in a time-division manner. For example, FIG.
As shown in (4), based on the operation clock of the microcomputer, 4
A program set to perform a specific process every 4 × 2 nm (n is an integer), such as a process every ms, a process every 8 ms, a process every 16 ms,... (Hereinafter, these processes are referred to as “4 m
s processing, 8 ms processing, 16 ms processing,... ").

【0003】このような時間同期処理を実行するには、
まずメインルーチンにて、マイコン内蔵のRAM上に設
定された1バイトのカウンタ(CSCH)を、4ms毎
に1LSBずつカウントアップさせる。この4msのタ
イミングは、所謂フリーランニングカウンタ(FRC)
を用いたタイマ割込により提供される。各時間同期処理
には、その処理を開始すべきCSCHの値が予め割り当
てられており、その値とCSCHの値とが一致した時に
各時間同期処理が開始される。
In order to execute such a time synchronization process,
First, in a main routine, a 1-byte counter (CSCH) set on a RAM built in a microcomputer is counted up by 1 LSB every 4 ms. The timing of this 4 ms is a so-called free running counter (FRC).
Provided by a timer interrupt using Each time synchronization process is assigned in advance a CSCH value at which the process is to be started, and each time synchronization process is started when the value matches the CSCH value.

【0004】具体的には、図8に示すように、4ms処
理はCSCHのカウントアップ毎(つまり4ms毎)に
実行され(これについては図示略)、8ms処理はCS
CHの最下位ビットが「0」の場合に実行される。同様
に、16ms処理はCSCHの下位2ビットが「01」
の場合に実行され、32ms処理はCSCHの下位3ビ
ットが「011」の場合、64ms処理はCSCHの下
位4ビットが「0111」の場合、128ms処理はC
SCHの下位5ビットが「01111」の場合、256
ms処理はCSCHの下位6ビットが「011111」
の場合、512ms処理はCSCHの下位7ビットが
「0111111」の場合、1024ms処理はCSC
Hが「01111111」の場合、に夫々実行される。
尚、CSCHの最上位ビットに桁上がりが発生した場合
には、CSCHはクリアされるため、上述の処理が繰り
返し実行されることになる。
[0004] Specifically, as shown in FIG. 8, the 4 ms process is executed every CSCH count-up (ie, every 4 ms) (this is not shown), and the 8 ms process is performed by the CS.
This is executed when the least significant bit of CH is “0”. Similarly, in the 16 ms processing, the lower two bits of the CSCH are “01”.
The 32 ms process is performed when the lower 3 bits of the CSCH are “011”, the 64 ms process is performed when the lower 4 bits of the CSCH are “0111”, and the 128 ms process is performed when the lower 3 bits of the CSCH are “0111”.
When the lower 5 bits of the SCH are “01111”, 256
In ms processing, the lower 6 bits of CSCH are “011111”.
, The 512 ms process is CSC if the lower 7 bits of the CSCH are “0111111”.
When H is "01111111", each is executed.
When a carry occurs in the most significant bit of the CSCH, the CSCH is cleared, and the above processing is repeatedly executed.

【0005】図7には、このようにCSCHがカウント
アップされることにより実行される各時間同期処理の様
子が示されている。尚、同図では簡単のため、CSCH
のカウント値を10進数で表記している。すなわち、4
ms毎にまず4ms処理が実行され、続いて、その4m
sの期間に設定された他の処理(8ms処理,16ms
処理,32ms処理・・・)が実行される。このように
各時間同期処理毎にCSCHが割り当てられた結果、各
時間同期処理の実行タイミングが時系列的に分散される
ため、複数の時間同期処理の重なりによる処理の破綻を
効果的に防止することができる。
FIG. 7 shows the state of each time synchronization process executed by counting up the CSCH as described above. It should be noted that, in FIG.
Are expressed in decimal numbers. That is, 4
First, a 4 ms process is executed every ms, and then the 4 ms process is executed.
Other processing (8 ms processing, 16 ms
Processing, 32 ms processing...) Are executed. As a result of allocating the CSCH for each time synchronization process as described above, the execution timing of each time synchronization process is dispersed in a time-series manner, so that a failure of the process due to the overlapping of a plurality of time synchronization processes is effectively prevented. be able to.

【0006】[0006]

【発明が解決しようとする課題】しかしながら、このよ
うにして各時間同期処理が分散された場合でも、メイン
ルーチンの実行過程で別の割込要求(割込ルーチン)が
発生した場合には、問題が生じる場合がある。図9に
は、このような問題が生じる場合が、4ms処理と16
ms処理との関係を例に示されている。
However, even if the respective time synchronization processes are distributed in this way, if another interrupt request (interrupt routine) occurs during the execution of the main routine, the problem may occur. May occur. FIG. 9 shows a case where such a problem occurs, in which 4 ms processing and 16 ms processing are performed.
The relationship with the ms processing is shown as an example.

【0007】すなわち、同図中段に示すような割込要求
が入った場合には、マイコンは当該割込処理を優先的に
実行する。このため、CSCHをインクリメントする処
理が遅れ、これに同期して実行される4ms処理、16
ms処理が遅れることになる。従来はこのCSCHのカ
ウントの遅れによる弊害を防止するために、状態に応じ
て上記タイマ割込のタイミングを早める補正をしつつ、
時間同期処理を継続する方法もとられたが、割込要求が
頻繁に入力された場合にはその効果にも限界があった。
同図では、3番目の割込処理により16ms処理が一回
分脱落し、16msの処理の遅れが発生している。
That is, when an interrupt request as shown in the middle part of FIG. 1 is received, the microcomputer preferentially executes the interrupt processing. For this reason, the process of incrementing the CSCH is delayed, and the 4 ms process, 16
ms processing will be delayed. Conventionally, in order to prevent the adverse effects caused by the delay of the count of the CSCH, while making a correction to advance the timing of the timer interrupt according to the state,
Although a method of continuing the time synchronization processing has been adopted, the effect is limited when interrupt requests are frequently input.
In the figure, the 16 ms processing is dropped by one time by the third interrupt processing, and a processing delay of 16 ms occurs.

【0008】このような処理の遅れは、割込要求のタイ
ミングや割込処理の長さ等に応じて累積的に大きくなる
ため、制御対象の動作遅れや誤制御を引き起こす要因に
もなっていた。そこで、本発明は、実行周期の異なる複
数の時間同期処理を実行するマイクロコンピュータにお
いて、割込要求が発生した場合の各時間同期処理の遅れ
を抑制又は解消することにより、処理の安定化を図るこ
とを目的とする。
Such a processing delay is cumulatively increased in accordance with the timing of the interrupt request, the length of the interrupt processing, and the like, and has been a factor of causing an operation delay of a control target and erroneous control. . In view of the above, the present invention aims to stabilize processing by suppressing or eliminating delays in time synchronization processing when an interrupt request occurs in a microcomputer that executes a plurality of time synchronization processings having different execution cycles. The purpose is to:

【0009】[0009]

【課題を解決するための手段】上記課題に鑑み、請求項
1に記載のマイコンは、タイマ部が供給する基準時間に
基づいて、互いに実行周期が異なる複数の時間同期処理
を実行するように構成されている。ここでいう「基準時
間」は、マイコンの動作クロックに基づいて予め設定さ
れるものであり、タイマ部が計時用カウンタによるカウ
ント値を用いて当該基準時間の経過を通知する。各時間
同期処理の周期は、この基準時間の整数倍の時間に夫々
設定されている。
SUMMARY OF THE INVENTION In view of the above problems, a microcomputer according to claim 1 is configured to execute a plurality of time synchronization processes having different execution periods based on a reference time supplied by a timer unit. Have been. The “reference time” here is set in advance based on the operation clock of the microcomputer, and the timer unit notifies the elapse of the reference time using the count value of the time counter. The cycle of each time synchronization process is set to a time that is an integral multiple of the reference time.

【0010】ここまでは上記従来技術と同様であるが、
上述の従来技術においては、各時間同期処理を実行する
ためのプログラムの全体が各周期毎に実行されていた。
このため、その実行過程で入力された割込要求により当
該プログラムの実行が完了しなかった場合には、その周
期分の経過を待たないと実行を再開することができなか
った。そして、次の周期においてさらに割込要求が入力
された場合には、もう一周期待たなければならず、この
ような繰り返しにより処理時間が累積的に遅延してい
た。
Up to here, it is the same as the above prior art,
In the above-described related art, the entire program for executing each time synchronization process is executed in each cycle.
Therefore, when the execution of the program is not completed by the interrupt request input in the execution process, the execution cannot be resumed without waiting for the elapse of the cycle. If another interrupt request is input in the next cycle, one more round must be expected, and the processing time is cumulatively delayed due to such repetition.

【0011】このような問題は、各時間同期処理をその
周期毎に一度に実行しようとするために発生するものと
考えられる。しかし、各時間同期処理は、設定された周
期毎に実行されることが重要なのであって、その周期内
において一度に実行されることは必ずしも要しない。換
言すれば、各時間同期処理がその周期内において完結す
れば、その実行タイミングでの処理は確保される。一
方、割込要求の入力がない基準時間内では、マイコンに
よる処理に比較的余裕があるとも考えられる。
It is considered that such a problem occurs because each time synchronization process is to be executed at once in each cycle. However, it is important that each time synchronization process is executed at a set cycle, and it is not always necessary to execute the time synchronization processing at one time within that cycle. In other words, if each time synchronization process is completed within the cycle, the process at the execution timing is secured. On the other hand, it is considered that there is relatively room for the processing by the microcomputer during the reference time when no interrupt request is input.

【0012】かかる点に着目し、請求項1記載のマイコ
ンでは、記憶手段が、各時間同期処理を実行するための
プログラムの夫々を、モジュール単位で構成されたプロ
グラムとして記憶しており、実行手段が、この記憶手段
に記憶された各プログラムを、該当する時間同期処理の
周期内にて、基準時間に基づき、モジュール単位で段階
的に実行する。
Focusing on this point, in the microcomputer according to the first aspect, the storage means stores each of the programs for executing each time synchronization process as a program configured in a module unit. Executes the programs stored in the storage means step by step on a module-by-module basis within the cycle of the corresponding time synchronization process based on the reference time.

【0013】かかる構成では、各時間同期処理がモジュ
ールに細分化され、そのモジュールがその時間同期処理
の周期内において分散されて順次実行される。このた
め、いずれかのモジュールの実行過程で割込要求が発生
したとしても、その時間同期処理と割込処理との重なり
を防止又は抑制することができる。また、仮に処理が重
なったとしても、そのモジュール分の処理の遅延しか発
生しない。このため、全体として割込要求による時間同
期処理の遅延を抑制することができ、マイコンによる処
理の破綻を有効に防止又は抑制することができる。
In such a configuration, each time synchronization process is subdivided into modules, and the modules are dispersed and sequentially executed within the cycle of the time synchronization process. For this reason, even if an interrupt request occurs during the execution of any of the modules, it is possible to prevent or suppress the overlap between the time synchronization processing and the interrupt processing. Further, even if the processing is overlapped, only the processing delay for the module occurs. For this reason, the delay of the time synchronization process due to the interrupt request can be suppressed as a whole, and the failure of the process by the microcomputer can be effectively prevented or suppressed.

【0014】ところで、かかる観点からは、時間同期処
理を細分化するほど上記効果が大きくなるものと考えら
れる。そこで、請求項2に記載のマイコンでは、上記記
憶手段が、各プログラムを、該当する時間同期処理の周
期を基準時間で除した数のモジュールに細分化して記憶
し、上記実行手段が、この細分化されたモジュールを基
準時間毎に順次実行する。
From this viewpoint, it is considered that the more the time synchronization process is subdivided, the greater the above-mentioned effect becomes. Therefore, in the microcomputer according to the present invention, the storage means stores each program in a number of modules obtained by dividing a corresponding period of the time synchronization process by a reference time, and the execution means includes Module is sequentially executed every reference time.

【0015】かかる構成によれば、各プログラムが実行
可能な範囲で最も小さく分割される。このため、各モジ
ュールと割込処理との重なりを最も有効に防止又は抑制
することができ、時間同期処理の遅延を最も効果的に抑
制することができる。また、かかる構成においては、全
ての時間同期処理がモジュール単位に分割されて基準時
間毎に実行されるため、上記従来技術にて示したように
時間同期処理の種類によってその実行タイミングを時系
列的に振り分ける必要がなくなる。
According to such a configuration, each program is divided into the smallest parts within the executable range. For this reason, the overlap between each module and the interrupt processing can be most effectively prevented or suppressed, and the delay of the time synchronization processing can be suppressed most effectively. Further, in such a configuration, since all the time synchronization processing is divided into modules and executed at each reference time, the execution timing is time-sequentially determined according to the type of the time synchronization processing as shown in the above-described related art. There is no need to sort them.

【0016】このため、計時用カウンタとしてRAM上
のカウンタ(上記「CSCH」)を設け、これをカウン
トアップさせる必要もなくなり、その分の処理(つまり
プログラム)を短く構成することができる。このため、
マイコンによる処理時間を有効に活用することができ、
このことが更なる時間同期処理の遅延防止につながる。
For this reason, it is not necessary to provide a counter on the RAM (the above-mentioned "CSCH") as a time counter, and it is not necessary to count up the counter, and the processing (that is, the program) can be shortened. For this reason,
The processing time of the microcomputer can be used effectively,
This leads to further prevention of delay in the time synchronization processing.

【0017】以上の構成により、時間同期処理の遅延を
防止又は抑制することができるのであるが、遅延した時
間同期処理の処理タイミングを本来の処理タイミングに
戻すことができればより好ましい。そこで、請求項3に
記載のマイコンでは、上記実行手段が、割込要求の発生
により、いずれかの基準時間内にて該当するモジュール
を実行できなかった場合には、当該モジュールを、これ
に後続するモジュールが実行される基準時間内にて、こ
の後続するモジュールと共に実行する。
With the above configuration, it is possible to prevent or suppress the delay of the time synchronization processing. However, it is more preferable that the processing timing of the delayed time synchronization processing can be returned to the original processing timing. Therefore, in the microcomputer according to the third aspect, when the execution unit cannot execute the corresponding module within any one of the reference times due to the generation of the interrupt request, the execution unit executes the subsequent module. The module is executed together with the following module within a reference time at which the module to be executed is executed.

【0018】かかる構成は、後続するモジュールが実行
される基準時間において、マイコンによる処理に余裕が
ある場合に実現されるが、上述のように、時間同期処理
がモジュール単位に細分化されており、その処理に要す
る時間も短いため、有効に実現されるものと考えられ
る。
Such a configuration is realized when there is a margin for the processing by the microcomputer at the reference time at which the subsequent module is executed. However, as described above, the time synchronization processing is subdivided into module units. Since the time required for the processing is short, it is considered that the processing is effectively realized.

【0019】かかる構成によれば、遅延した時間同期処
理を、モジュール単位で徐々に本来のタイミングに戻す
ことが可能となる。このため、特に処理タイミングに精
度が要求される処理にはその効果は絶大である。尚、こ
のようなマイコンを、上記記憶手段及び実行手段として
機能させる請求項4に記載のプログラムは、請求項5に
記載のように、例えばフロッピー(登録商標)ディス
ク、光磁気ディスク、CD−ROM、ハードディスク等
のコンピュータ読取可能な記録媒体に記録し、必要に応
じてコンピュータシステムにロードして起動することに
より用いることができる。この他、ROMやバックアッ
プRAMをコンピュータ読取可能な記録媒体として上記
プログラムに記録しておき、このROM或いはバックア
ップRAMをコンピュータシステムに組み込んで用いて
もよい。
According to this configuration, it is possible to gradually return the delayed time synchronization processing to the original timing for each module. For this reason, the effect is particularly great for processing that requires precision in processing timing. The program according to claim 4 for causing such a microcomputer to function as the storage means and the execution means includes, for example, a floppy (registered trademark) disk, a magneto-optical disk, and a CD-ROM. It can be used by recording it on a computer-readable recording medium such as a hard disk, loading it into a computer system as needed, and activating it. Alternatively, a ROM or a backup RAM may be recorded in the above program as a computer-readable recording medium, and the ROM or the backup RAM may be incorporated in a computer system and used.

【0020】[0020]

【発明の実施の形態】以下、本発明の好適な実施例を図
面に基づいて説明する。本実施例は、本発明のマイコン
をエンジン制御装置(ECU)に適用したものであり、
図1は当該ECU周辺の電気的構成を示したブロック図
である。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Preferred embodiments of the present invention will be described below with reference to the drawings. In this embodiment, the microcomputer of the present invention is applied to an engine control device (ECU).
FIG. 1 is a block diagram showing an electric configuration around the ECU.

【0021】図1に示すように、ECU1が備えるマイ
コン2は、各種機器を制御するCPU21、予め各種の
数値やプログラムが書き込まれたROM22、演算過程
の数値やフラグが所定の領域に書き込まれるRAM2
3、タイマ割込要求を発生するタイマ部24、各種ディ
ジタル信号が入力され、各種ディジタル信号が出力され
る入出力ポート(I/O)25、及び、これら各機器が
それぞれ接続されるバスライン26等から構成されてい
る。ROM22内には、エンジン制御用プログラム(後
述する時間同期処理のプログラムを含む)、その他の処
理プログラム、及びこれらの演算処理に必要な種々のデ
ータ等が予め格納されている。
As shown in FIG. 1, a microcomputer 2 provided in the ECU 1 includes a CPU 21 for controlling various devices, a ROM 22 in which various numerical values and programs are preliminarily written, and a RAM 2 in which numerical values and flags in the operation process are written in a predetermined area.
3, a timer section 24 for generating a timer interrupt request, an input / output port (I / O) 25 to which various digital signals are input and various digital signals are output, and a bus line 26 to which each of these devices is connected And so on. In the ROM 22, an engine control program (including a time synchronization processing program described later), other processing programs, and various data necessary for these arithmetic processings are stored in advance.

【0022】タイマ部24は、マイコン2の内部クロッ
ク(本実例では、1MHz(メガヘルツ))によって常
時カウントアップされるフリーランニングカウンタ(F
RC)27、FRC27のカウント値と比較される時間
情報としての値がCPU21によってセットされるアウ
トプットコンペアレジスタ(OCR)28、及び、FR
C27のカウント値とOCR28にセットされた値とを
比較し、両値が一致すると所定のタイマ割込要求を発生
する比較器29を備えている。
The timer section 24 is a free running counter (F) which is constantly counted up by an internal clock of the microcomputer 2 (in this example, 1 MHz (megahertz)).
RC) 27, an output compare register (OCR) 28 in which a value as time information to be compared with the count value of the FRC 27 is set by the CPU 21, and FR
A comparator 29 is provided for comparing the count value of C27 with the value set in the OCR 28, and generating a predetermined timer interrupt request when the two values match.

【0023】そして、本実施例のマイコン2では、上記
従来技術でも述べたように、4msの時間間隔を基準時
間として、4ms処理、8ms処理、16ms処理、3
2ms処理、64ms処理、128ms処理、256m
s処理、512ms処理、及び1024ms処理の時間
同期処理(以下、これらをまとめて「複数種類の時間同
期処理」ともいう)が実行される。このため、OCR2
8には、4msの時間間隔に相当するFRC27のカウ
ント値がセットされており、FRC27のカウント値と
OCR28の値が一致した時点でタイマ割込要求(後述
のTCNT割込)が発生する。FRC27は、このタイ
マ割込要求の発生毎にクリアされ、再度カウントアップ
を繰り返す。
In the microcomputer 2 according to the present embodiment, as described in the prior art, the 4 ms processing, the 8 ms processing, the 16 ms processing,
2ms processing, 64ms processing, 128ms processing, 256m
Time synchronization processing of the s processing, the 512 ms processing, and the 1024 ms processing (hereinafter, collectively referred to as “a plurality of types of time synchronization processing”) is executed. For this reason, OCR2
8, a count value of the FRC 27 corresponding to a time interval of 4 ms is set. When the count value of the FRC 27 matches the value of the OCR 28, a timer interrupt request (a TCNT interrupt described later) is generated. The FRC 27 is cleared every time this timer interrupt request is generated, and repeats the count up again.

【0024】また、ECU1には、電源電圧を供給する
ためのバッテリ31、エアフローメータ,吸気圧セン
サ,水温センサ、エンジン回転数センサ等のセンサ群3
2、及び、アクチュエータ群33等が接続されている。
そして、バッテリ31からの電源電圧は、電源回路3を
介してマイコン2に供給される。また、センサ群32か
らの電圧信号は、A/D変換器4にてデジタル信号に変
換された後、入出力ポート25に入力される。
The ECU 1 also includes a battery 31 for supplying a power supply voltage, a sensor group 3 such as an air flow meter, an intake pressure sensor, a water temperature sensor, and an engine speed sensor.
2 and the actuator group 33 are connected.
Then, the power supply voltage from the battery 31 is supplied to the microcomputer 2 via the power supply circuit 3. The voltage signal from the sensor group 32 is converted into a digital signal by the A / D converter 4 and then input to the input / output port 25.

【0025】そして、マイコン2では、このようにして
取り込まれたデータに基づいて、所定のプログラムに従
った複数種類の演算処理が実行される。この演算処理に
ついては、その内容によって上記複数種類の時間同期処
理のうちどのタイミングの時間同期処理にて実行するか
が予め設定されている。そして、この演算結果に基づい
て生成された出力データが、入出力ポート25,出力回
路5を介してアクチュエータ群33に出力され、所望の
エンジン制御が行われる。
Then, the microcomputer 2 executes a plurality of types of arithmetic processing according to a predetermined program based on the data thus captured. With respect to this arithmetic processing, which timing of the plurality of types of time synchronization processing is to be executed is set in advance depending on the content. Then, output data generated based on the calculation result is output to the actuator group 33 via the input / output port 25 and the output circuit 5, and desired engine control is performed.

【0026】次に、本実施例のマイコンが実行する時間
同期処理の方法について、図2基づいて説明する。同図
において、「TCNT割込処理」は、時間同期処理の基
準時間(4ms)を供給するものであり、4ms毎に入
力されるタイマ割込処理である。図中の斜線の時間領域
は、このTCNT割込処理が実行されている期間を示
す。従って、4ms処理については、このTCNT割込
処理が入力される毎に実行される。
Next, a method of time synchronization processing executed by the microcomputer of the present embodiment will be described with reference to FIG. In the figure, "TCNT interrupt processing" supplies a reference time (4 ms) for the time synchronization processing, and is a timer interrupt processing input every 4 ms. A hatched time region in the drawing indicates a period during which the TCNT interrupt processing is being executed. Therefore, the 4 ms process is executed every time the TCNT interrupt process is input.

【0027】そして、8ms処理,16ms処理,32
ms処理・・・は、夫々複数のモジュールに細分化さ
れ、4msの基準時間に、全ての時間同期処理の予め定
めるモジュールが夫々実行されるように設定されてい
る。具体的には、各時間同期処理を、その周期を基準時
間4msで除した数に相当する数に細分化している。つ
まり、8ms処理は2つのモジュールに細分化され、1
6ms処理は4つのモジュールに細分化され、32ms
処理は8つのモジュールに細分化され、・・・というよ
うに設定されている。同図の各時間同期処理の上に付さ
れた番号は、このモジュールの番号を表している。
Then, 8 ms processing, 16 ms processing, 32
ms processing is subdivided into a plurality of modules, and the predetermined modules of all time synchronization processing are set to be executed at a reference time of 4 ms. Specifically, each time synchronization process is subdivided into a number corresponding to the number obtained by dividing the period by 4 ms of the reference time. That is, the 8 ms process is subdivided into two modules,
6ms processing is subdivided into 4 modules, 32ms
The processing is subdivided into eight modules, and so on. The number given above each time synchronization process in the figure represents the number of this module.

【0028】すなわち、各時間同期処理全体としての処
理タイミングは、8ms処理なら8ms毎、16ms処
理なら16ms毎、・・・といったように維持されるの
であるが、その細分化されたモジュール単位の処理は、
各基準時間内に分散され毎回実行されることになる。
That is, the processing timing of each time synchronization process as a whole is maintained at every 8 ms for 8 ms processing, every 16 ms for 16 ms processing, and so on. Is
It is distributed and executed every time within each reference time.

【0029】次に、上記時間同期処理のさらなる詳細に
ついて、図3及び図4〜図6のフローチャートに基づい
て説明する。尚、本実施例では、上述のように4msの
基準時間内において複数の時間同期処理が実行されるの
であるが、これら各時間同期処理の処理の方法は同様で
あるため、便宜上16ms処理についてのみ説明を行う
ことにする。
Next, further details of the time synchronization process will be described with reference to the flowcharts of FIGS. 3 and 4 to 6. In this embodiment, as described above, a plurality of time synchronization processes are executed within the reference time of 4 ms. However, since the method of each time synchronization process is the same, only the 16 ms process is described for convenience. I will explain.

【0030】図3の横軸は時間の経過を表し、その縦軸
は時間同期処理を実行するために用いられる各種パラメ
ータを表している。まず、各種パラメータの内容につい
て、同図の上段からその説明をする。「TCNT割込処
理」については、上述した通りである。尚、TCNT割
込処理の詳細については後述する。
The horizontal axis of FIG. 3 represents the passage of time, and the vertical axis thereof represents various parameters used for executing the time synchronization processing. First, the contents of various parameters will be described from the top of FIG. The “TCNT interrupt processing” is as described above. The details of the TCNT interrupt processing will be described later.

【0031】「Fnum」は、実行を要求する上記モジ
ュールの番号を示す。上述したように、16ms処理
は、4つのモジュールF(1),F(2),F(3),
F(4)に細分化されて実行されるため、これら各モジ
ュールF(1),F(2),F(3),F(4)に対す
るFnumとして、夫々1,2,3,4が割り当てられ
る。従って、例えばFnumが「1」のときは、モジュ
ールF(1)の実行が要求されていることを示す。この
Fnumの値は、RAM23上に設定された所定の記憶
領域に格納され、後述するTCNT割込処理において随
時更新される。
"Fnum" indicates the number of the module requested to be executed. As described above, the 16 ms processing includes four modules F (1), F (2), F (3),
Since F (4) is subdivided and executed, 1, 2, 3, and 4 are assigned as Fnums for these modules F (1), F (2), F (3), and F (4), respectively. Can be Therefore, for example, when Fnum is “1”, it indicates that execution of the module F (1) is requested. The value of Fnum is stored in a predetermined storage area set on the RAM 23, and is updated as needed in a TCNT interrupt process described later.

【0032】「ベース周回タイミング」は、後述するベ
ース処理が実行されるタイミング(つまり、メインルー
チンが一周りするタイミング)を表す。このベース処理
は、後述するように上記TCNT割込処理の完了後に実
行が開始されるため、通常処理においては一定のタイミ
ングで実行される。しかし、別の割込要求が入力される
と当該割込処理が優先されるため、実行が中止される。
The "base rotation timing" indicates the timing at which the base processing described later is executed (ie, the timing at which the main routine goes around). This base processing is started after the completion of the TCNT interrupt processing as described later, and thus is executed at a certain timing in the normal processing. However, when another interrupt request is input, the interrupt processing is prioritized, and the execution is stopped.

【0033】「FLAG」は、基準時間内にベース処理
の実行タイミングが2回以上入るような場合に、ベース
処理が2回以上実行されるのを禁止するためのフラグで
ある。この「FLAG」がONである場合にベース処理
の実行開始が許可され、「FLAG」がOFFである場
合にはベース処理の実行開始が禁止される。つまり、各
モジュールを4ms毎に実行するために、ある基準時間
内において指定されたモジュールの実行が開始されると
「FLAG」をONからOFFに切り替える。すると、
その基準時間内において次のモジュールの実行が禁止さ
れる。このFLAGの情報は、RAM23上に設定され
た所定の記憶領域に格納され、後述するTCNT割込処
理及びベース処理において随時書き替えられる。
"FLAG" is a flag for prohibiting the execution of the base process more than once when the execution timing of the base process comes within the reference time more than once. When "FLAG" is ON, execution of the base process is permitted, and when "FLAG" is OFF, execution of the base process is prohibited. That is, in order to execute each module every 4 ms, "FLAG" is switched from ON to OFF when the execution of the specified module is started within a certain reference time. Then
Execution of the next module is prohibited within the reference time. The FLAG information is stored in a predetermined storage area set on the RAM 23, and is rewritten as needed in a TCNT interrupt process and a base process described later.

【0034】「F(1)処理」は、F(1)処理の実行
を示し、図中の斜線の時間領域がこのF(1)処理が実
行されている期間を示す。「F(1)実行フラグ」は、
F(1)処理の実行完了を示すためのフラグであり、F
(1)処理の実行待ちの場合に「待機」となり、その実
行が完了すると「済み」となる。このF(1)の情報
は、RAM23上に設定された所定の記憶領域に格納さ
れ、後述するTCNT割込処理及びベース処理において
随時書き替えられる。
The "F (1) process" indicates the execution of the F (1) process, and the hatched time region in the figure indicates the period during which the F (1) process is being executed. "F (1) execution flag"
F (1) is a flag for indicating the completion of execution of the process.
(1) When the process is waiting for execution, the status is “standby”, and when the process is completed, the status is “completed”. The information of F (1) is stored in a predetermined storage area set on the RAM 23, and is rewritten as needed in a TCNT interrupt process and a base process described later.

【0035】「N(1)」は、F(1)処理の実行要求
回数を示し、N(1)≧1のときにF(1)が実行され
る。従って、このN(1)の実行要求があっても、割込
処理によりベース処理が実行できなかった場合には、N
(1)が累積されることになる。処理の遅れがなけれ
ば、N(1)は「0」と「1」とを繰り返すことにな
る。このN(1)の値は、RAM23上に設定された所
定の記憶領域に格納され、後述するTCNT割込処理に
おいて随時更新される。
"N (1)" indicates the number of execution requests for the F (1) process. When N (1) ≧ 1, F (1) is executed. Therefore, even if there is an execution request of N (1), if the base processing cannot be executed by the interrupt processing, N
(1) will be accumulated. If there is no processing delay, N (1) repeats "0" and "1". This value of N (1) is stored in a predetermined storage area set on the RAM 23, and is updated as needed in a TCNT interrupt process described later.

【0036】以下、F(2)処理についての「F(2)
処理」,「F(2)実行フラグ」,「N(2)」、F
(3)処理についての「F(3)処理」,「F(3)実
行フラグ」,「N(3)」、及びF(4)処理について
の「F(4)処理」,「F(4)実行フラグ」,「N
(4)」についても同様であるため、その説明について
は省略する。
Hereinafter, "F (2) processing" for the F (2) processing will be described.
Processing "," F (2) execution flag "," N (2) ", F
“F (3) process”, “F (3) execution flag”, “N (3)” for process (3), and “F (4) process”, “F (4) process” for F (4) process ) Execution flag "," N
The same applies to “(4)”, and a description thereof will be omitted.

【0037】次に、本時間同期処理における、割込要求
(TCNT割込処理を除く)が入らない通常時の処理
と、割込処理が入ったときの処理について説明する。
尚、図3には、説明の便宜上、16ms処理の本来の周
期毎に場面を分けて示している(フェーズ0〜フェーズ
5)。ここで、フェーズ0は初期設定を示し、続いてフ
ェーズ1、フェーズ2、フェーズ3、フェーズ4、フェ
ーズ5・・・の順に時間が経過している例を示す。本実
施例では、フェーズ1及びフェーズ5が割込要求が入ら
ない通常時の処理を示し、フェーズ2,3,4が割込要
求が入った場合の処理の一例を示す。
Next, a description will be given of a normal process in which an interrupt request (excluding the TCNT interrupt process) is not entered and a process in which an interrupt process is entered in the time synchronization process.
In FIG. 3, scenes are shown separately for each original cycle of the 16 ms processing (phase 0 to phase 5) for convenience of explanation. Here, phase 0 indicates an initial setting, and subsequently, an example in which time elapses in the order of phase 1, phase 2, phase 3, phase 4, phase 5,... In this embodiment, phase 1 and phase 5 show normal processing in which an interrupt request is not input, and phases 2, 3, and 4 show examples of processing in the case where an interrupt request is input.

【0038】まず、CPU21が通常実行する時間同期
処理について説明する。図4は初期化処理を示し、図5
はTCNT割込処理を示し、図6はベース処理を示すフ
ローチャートである。ECU1に電源が投入されると、
図4に示す初期化処理が実行される。すなわち、図3に
示すフェーズ0においては、まず4msの基準時間を供
給するTCNT割込要求の入力を許可するため、TCN
T割込フラグを「許可」にする(S1)。そしてFRC
27のカウント値(TCNT)を「0」にクリアしてカ
ウントアップを開始させると共に(S2)、OCR28
に4msに相当するFRC27のカウント値(TCM
P)をセットする(S3)。
First, the time synchronization processing normally executed by the CPU 21 will be described. FIG. 4 shows the initialization process, and FIG.
Shows a TCNT interrupt process, and FIG. 6 is a flowchart showing a base process. When power is supplied to the ECU 1,
The initialization processing shown in FIG. 4 is executed. That is, in the phase 0 shown in FIG. 3, the TCN interrupt request for supplying the reference time of 4 ms
The T interrupt flag is set to "permitted" (S1). And FRC
27, the count value (TCNT) is cleared to "0" to start counting up (S2), and the OCR 28
To the FRC27 count value (TCM equivalent to 4 ms)
P) is set (S3).

【0039】そして、後述の処理の都合上、便宜上Fn
umを「4」にセットし(S4)、N(1),N
(2),N(3),及びN(4)を夫々「0」をセット
し(S5〜S8)、さらに、F(1)実行フラグ,F
(2)実行フラグ,F(3)実行フラグ,及びF(4)
実行フラグを、夫々「待機」にセットする(S9〜S1
2)。
Then, for convenience of processing described later, for convenience, Fn
um is set to “4” (S4), N (1), N
(2), N (3), and N (4) are each set to “0” (S5 to S8), and the F (1) execution flag
(2) execution flag, F (3) execution flag, and F (4)
The execution flags are set to “standby” (S9 to S1)
2).

【0040】そして、上述のようにS1にてTCNT割
込フラグが「許可」された結果、4msの基準時間毎に
TCNT割込要求が入力されると、図5に示すTCNT
割込処理を実行する。このTCNT割込処理において
は、まずフェーズ1において各モジュールF(1)処理
〜F(4)処理をこの順に実行するために、S22〜S
26にて、これらの処理の実行が既に完了しているか否
かを判断する。
As described above, as a result of the TCNT interrupt flag being "permitted" at S1, when a TCNT interrupt request is input every 4 ms reference time, the TCNT shown in FIG.
Execute interrupt processing. In this TCNT interruption process, first, in order to execute each of the modules F (1) to F (4) in this order in phase 1, S22 to S22 are executed.
At 26, it is determined whether or not the execution of these processes has already been completed.

【0041】この際、まずRAM上に便宜上記憶される
変数kの値として「1」をセットする(S21)。そし
て、F(k)実行フラグ(つまりF(1)実行フラグ)
が「済み」であるか否かを判断する(S22)。この場
合、上述の初期化処理においてF(1)実行フラグは
「待機」状態となっているため(S22:NO)、S2
5に移行する。そして、次のF(2)処理の実行完了を
判断するために変数kを1インクリメントする(S2
5)。続くS26は、最後のモジュールであるF(4)
処理の実行完了判定が終了したときにこの完了判定処理
を抜けるためのものであり、kが4以下であるか否かを
判断する。この場合k=2となっているため(S26:
YES)、S22に戻る。
At this time, "1" is set as the value of the variable k stored for convenience in the RAM (S21). Then, the F (k) execution flag (that is, the F (1) execution flag)
Is determined to be "completed" (S22). In this case, since the F (1) execution flag is in the “standby” state in the above-described initialization processing (S22: NO), S2 is executed.
Move to 5. Then, the variable k is incremented by 1 to determine the completion of the execution of the next F (2) processing (S2).
5). The following S26 is the last module F (4)
This is for exiting the completion determination processing when the execution completion determination of the processing ends, and it is determined whether or not k is 4 or less. In this case, since k = 2 (S26:
YES), and returns to S22.

【0042】続いて、S22においてF(k)実行フラ
グ(つまりF(2)実行フラグ)が「済み」であるか否
かを判断する(S22)。この場合、上述の初期化処理
においてF(2)実行フラグは「待機」状態となってい
るため(S22:NO)、上記と同様にS25に移行す
る。同様にして、F(3)実行フラグ及びF(4)実行
フラグの状態についても判定される。
Subsequently, in S22, it is determined whether or not the F (k) execution flag (ie, F (2) execution flag) is "completed" (S22). In this case, since the F (2) execution flag is in the “standby” state in the above-described initialization processing (S22: NO), the process proceeds to S25 in the same manner as described above. Similarly, the states of the F (3) execution flag and the F (4) execution flag are determined.

【0043】このようにして、F(1)〜F(4)の完
了判定処理が全て終了するとS25にてk=5となるた
め(S26:NO)、S27に移行する。尚、現時点で
は、F(1)実行フラグ〜F(4)実行フラグは全て
「待機」となっているため、S23及びS24の処理は
行われない。
In this manner, when all the completion determination processings of F (1) to F (4) are completed, k = 5 in S25 (S26: NO), and the flow shifts to S27. Note that, at present, the F (1) execution flag to the F (4) execution flag are all "standby", so that the processes of S23 and S24 are not performed.

【0044】続くS27〜S31では、該当するモジュ
ールの実行要求を行うために、該当するNの値をインク
リメントする。すなわち、S27において、まずFnu
mが「4」であるか否かが判定される。この場合、上述
の初期化処理においてFnumが「4」となっているた
め(S27:YES)、Fnumが次のモジュール番号
である「1」にセットされる(S28)。このため、F
(1)処理の実行モードに入ることができる。
In S27 to S31, the value of N is incremented in order to request execution of the module. That is, in S27, first, Fnu
It is determined whether or not m is “4”. In this case, since Fnum is "4" in the above-described initialization processing (S27: YES), Fnum is set to "1" which is the next module number (S28). Therefore, F
(1) The execution mode of the process can be entered.

【0045】具体的には、RAM上に便宜上記憶される
変数iにFnumの値(この場合「1」)をセットし
(S30)、N(i)を1インクリメントする(S3
1)。ここで、上述の初期化処理においてN(1)が
「0」となっているため、N(1)=1となる。こうし
て、N(1)≧1とすることにより、16ms処理の第
1モジュールであるF(1)処理についての実行要求が
なされる。尚、このとき、次のベース周回タイミングに
てベース処理を実行するために、FLAGを「ON」に
しておく(S32)。
More specifically, the value of Fnum (in this case, "1") is set to a variable i stored for convenience on the RAM (S30), and N (i) is incremented by 1 (S3).
1). Here, since N (1) is “0” in the above-described initialization processing, N (1) = 1. In this way, by setting N (1) ≧ 1, an execution request is made for the F (1) process which is the first module of the 16 ms process. At this time, FLAG is set to “ON” to execute the base processing at the next base rotation timing (S32).

【0046】以上のTCNT割込処理が終了し、ベース
周回タイミングがくると、図6のベース処理が実行され
る。このベース処理では、まずFLAGが「ON」であ
り、ベース処理の実行が許可されていることを確認する
(S41)。この場合、上記S32においてFLAGが
「ON」にセットされているため、S42に移行する。
When the above-described TCNT interrupt processing is completed and the base circuit circulating timing comes, the base processing of FIG. 6 is executed. In this base processing, first, it is confirmed that FLAG is "ON" and execution of the base processing is permitted (S41). In this case, since the FLAG is set to “ON” in S32, the process proceeds to S42.

【0047】S42では、これから実行する処理に用い
るNの値を一旦バッファに格納するため、TCNT割込
フラグを「禁止」にする。これは、各モジュールの実行
過程においてTCNT割込処理が許可されると、Nの値
が変化して処理に異常を来すため、これを防止するため
に一旦バッファにNを格納し、このNに基づいて処理を
実行することとしたものである。
At S42, the TCNT interrupt flag is set to "prohibited" in order to temporarily store the value of N to be used in the processing to be executed from now on in the buffer. This is because, when the TCNT interrupt process is permitted in the execution process of each module, the value of N changes and causes an abnormality in the process. To prevent this, N is temporarily stored in a buffer, and this N is temporarily stored. The processing is executed based on.

【0048】そして、それ以降、基準時間内においてベ
ース処理をこの一回だけ実行するために(つまり2回以
上のベース処理を実行しないように)、FLAGを「O
FF」にした後(S43)、現在のN(1),N
(2),N(3),N(4)の値を、夫々Nb(1),
Nb(2),Nb(3),Nb(4)としてバッファに
格納する(S44〜S47)。そして、このバッファへ
の格納が終わると、次のTCNT割込要求を許可するた
めに、TCNT割込フラグを「許可」に切り替える。
尚、現時点においてはNb(1)が「1」となってお
り、Nb(2),Nb(3)及びNb(4)が「0」に
なっている。
Thereafter, in order to execute the base processing only once within the reference time (that is, not to execute the base processing more than once), FLAG is set to "O".
FF ”(S43), and the current N (1), N
The values of (2), N (3) and N (4) are changed to Nb (1) and Nb (1), respectively.
Nb (2), Nb (3), and Nb (4) are stored in the buffer (S44 to S47). Then, when the storage in the buffer is completed, the TCNT interrupt flag is switched to “permitted” in order to permit the next TCNT interrupt request.
At this time, Nb (1) is “1”, and Nb (2), Nb (3) and Nb (4) are “0”.

【0049】そして、実行要求があったモジュールの処
理を順に実行するために、RAM上に便宜上記憶される
変数nの値に「1」をセットし(S49)、上記Nb
(n)が1以上であるか否かを順に判定する(S5
0)。この場合、Nb(1)=1であるため(S50:
YES)、F(1)処理が実行される(S51)。そし
て、このF(1)処理の実行が終了すると、F(1)実
行フラグを「済み」に切り替え、Nb(2)処理の実行
のために変数nを1インクリメントする(S53)。そ
して、同様にしてF(2)処理、F(3)処理、及びF
(4)処理についてもS50〜S54の処理を繰り返す
ため、n≦4である間はS50に戻る。尚、この場合、
Nb(2),Nb(3),Nb(4)が「0」であるた
め(S50:NO)、F(2)処理、F(3)処理、及
びF(4)処理については実行されない。
Then, in order to sequentially execute the processes of the modules requested to be executed, the value of a variable n stored for convenience in the RAM is set to "1" (S49), and the Nb is set.
It is sequentially determined whether (n) is 1 or more (S5).
0). In this case, since Nb (1) = 1 (S50:
YES), F (1) processing is executed (S51). Then, when the execution of the F (1) processing is completed, the F (1) execution flag is switched to “completed”, and the variable n is incremented by 1 for the execution of the Nb (2) processing (S53). Then, similarly, F (2) processing, F (3) processing, and F (3) processing
(4) Since the processing of S50 to S54 is also repeated for the processing, the processing returns to S50 while n ≦ 4. In this case,
Since Nb (2), Nb (3), and Nb (4) are “0” (S50: NO), the F (2) processing, the F (3) processing, and the F (4) processing are not executed.

【0050】尚、上記S43においてFLAGが「OF
F」にされているため、同一の基準時間内において次の
ベース処理は行われない。以上のような処理により、図
3に示すフェーズ1の第1ターム(最初の基準時間)の
タイミングチャートが得られる。
In the above-mentioned S43, FLAG is set to "OF".
F ", the next base processing is not performed within the same reference time. With the above processing, the timing chart of the first term (first reference time) of phase 1 shown in FIG. 3 is obtained.

【0051】そして、上記S48にてTCNT割込フラ
グが「許可」にされた結果、4msの基準時間が経過し
て次のTCNT割込要求が入力されると、フェーズ1の
第2タームに移行し、図5のTCNT割込処理が同様に
再度実行される。この処理の詳細については、その大部
分が上記第1タームの処理と同様であるため、同様の部
分についてはその説明を省略する。
When the TCNT interrupt flag is set to "permitted" in S48 and the next TCNT interrupt request is input after the reference time of 4 ms has elapsed, the phase shifts to the second term of phase 1. Then, the TCNT interrupt processing of FIG. 5 is executed again in the same manner. Most of the details of this processing are the same as those of the above-described first term, so that the description of the same parts will be omitted.

【0052】すなわち、ここでは、図5のS22の処理
において、F(1)実行フラグのみが「済み」となって
いるため(上記S52にて設定)、N(1)が1デクリ
メントされ、N(1)=0となる。このことは、第2タ
ームにおいては、F(1)処理を実行しないことを意味
する。
That is, in this case, in the processing of S22 in FIG. 5, only the F (1) execution flag is "completed" (set in S52), so N (1) is decremented by one and N (1) is decremented. (1) = 0. This means that the F (1) process is not executed in the second term.

【0053】そして、現在のFnumが「1」であるこ
とから(S27:NO)、Fnumが1インクリメント
されてFnum=2となり(S29)、S31にてN
(2)が「1」となる。このため、続く図6に示すベー
ス処理のS44〜S47では、Nb(2)が「1」とな
り、Nb(1),Nb(3)及びNb(4)が「0」に
なり、S51にてF(2)処理のみが実行される。
Since the current Fnum is "1" (S27: NO), Fnum is incremented by one to become Fnum = 2 (S29), and N is determined at S31.
(2) becomes “1”. Therefore, in S44 to S47 of the base processing shown in FIG. 6, Nb (2) becomes “1”, Nb (1), Nb (3) and Nb (4) become “0”, and in S51, Only the F (2) processing is executed.

【0054】以上のような処理により、フェーズ1の第
2タームのタイミングチャートが得られる。そして、同
様の処理を繰り返すことにより、続く第3ターム、第4
タームで夫々F(3)処理、F(4)処理が実行され、
全体として、フェーズ1に示されるタイミングチャート
が実現される。
With the above processing, a timing chart of the second term of the phase 1 is obtained. Then, by repeating the same processing, the following third term and fourth term
The F (3) processing and the F (4) processing are executed in terms, respectively.
As a whole, the timing chart shown in Phase 1 is realized.

【0055】このため、TCNT割込処理を除く割込処
理が入らない通常処理においては、フェーズ1に示すよ
うな処理が繰り返されることになり、16ms処理の時
間同期処理が所定の周期で実行されることになる。次
に、CPU21が実行する時間同期処理において、割込
要求(TCNT割込要求を除く)が入った場合の処理に
ついて説明する。図3においては、フェーズ2の第1タ
ーム,第3ターム及び第4タームにおいて割込要求が入
り、フェーズ3の第1ターム,第2ターム及び第3ター
ムにおいて割込要求が入っている。
For this reason, in the normal processing in which no interrupt processing other than the TCNT interrupt processing is performed, the processing shown in phase 1 is repeated, and the time synchronization processing of the 16 ms processing is executed at a predetermined cycle. Will be. Next, a description will be given of a process when an interrupt request (excluding a TCNT interrupt request) is received in the time synchronization process executed by the CPU 21. In FIG. 3, an interrupt request is received in the first term, the third term, and the fourth term of the phase 2, and an interrupt request is received in the first term, the second term, and the third term of the phase 3.

【0056】まず、フェーズ2の第1タームにおいてT
CNT割込処理が実行されることにより、N(1)が
「1」となると共にFLAGが「ON」にされる。しか
し、このTCNT割込処理の直後に別の割込要求(図中
散点模様)が入ったため、ベース周回タイミングが訪れ
ることなく、基準時間である4msを経過してしまって
いる。この場合、F(1)処理が未処理のままであるた
め、N(1)は図5のS23において「0」にデクリメ
ントされることなく「1」の状態で保持される。また、
FnumはS27及びS28によって「1」となってい
る。
First, in the first term of phase 2, T
By executing the CNT interrupt processing, N (1) becomes “1” and FLAG is turned “ON”. However, since another interrupt request (dotted pattern in the figure) is received immediately after the TCNT interrupt processing, the reference time of 4 ms has passed without the base circuit timing coming. In this case, since the F (1) process remains unprocessed, N (1) is held in the state of “1” without being decremented to “0” in S23 of FIG. Also,
Fnum is set to "1" by S27 and S28.

【0057】そして、第2タームにおいて再度TCNT
割込処理が実行されると、S27及びS29によってF
numが1インクリメントされて「2」となり、N
(2)が「1」となる。このため、TCNT割込処理が
終了してベース処理に移行した際には、図6のS44〜
S47の処理において、Nb(1)及びNb(2)が
「1」となり、Nb(3)及びNb(4)が「0」にな
る。この結果、S50〜S54の処理においてF(1)
処理及びF(2)処理が順に実行されることになる。従
って、同図に示すフェーズ2の第1ターム及び第2ター
ムのタイミングチャートのようになる。
Then, in the second term, TCNT again
When the interrupt processing is executed, F27 is executed by S27 and S29.
num is incremented by 1 to “2” and N
(2) becomes “1”. For this reason, when the TCNT interruption processing is completed and the processing shifts to the base processing, S44 to S44 in FIG.
In the process of S47, Nb (1) and Nb (2) become “1”, and Nb (3) and Nb (4) become “0”. As a result, in the processing of S50 to S54, F (1)
The processing and the F (2) processing are sequentially executed. Accordingly, the timing chart of the first term and the second term of the phase 2 shown in FIG.

【0058】続くフェーズ2の第3タームからフェーズ
3の第3タームには、同様の割込処理が入っているた
め、ベース処理が実行されることなく処理に遅れが生じ
る。ただし、この間においても、TCNT割込処理はそ
の割込処理の優先度が高いために実行されることにな
る。このため、図5のS27〜S31の処理によって、
Fnumの値が順次変化すると共に、N(1),N
(2),N(3),N(4)の値がインクリメントされ
る。この結果、フェーズ3の第4タームにおいては、N
(1)及びN(2)の値が「1」となっており、N
(3)及びN(4)の値が「2」となっている。このこ
とは、F(1)処理及びF(2)処理が一回ずつ遅れ、
F(3)処理及びF(4)処理が二回ずつ遅れているこ
とを表している。
In the subsequent third term of phase 2 to the third term of phase 3, similar interrupt processing is included, so that the base processing is not executed and the processing is delayed. However, even during this time, the TCNT interrupt processing is executed because the priority of the interrupt processing is high. Therefore, by the processes of S27 to S31 in FIG.
As the value of Fnum changes sequentially, N (1), N
The values of (2), N (3) and N (4) are incremented. As a result, in the fourth term of phase 3, N
The values of (1) and N (2) are “1” and N
The values of (3) and N (4) are “2”. This means that the F (1) processing and the F (2) processing are delayed by one time,
The F (3) processing and the F (4) processing are delayed twice each.

【0059】そして、この遅れを解消するための処理が
フェーズ3の第4ターム及びフェーズ4に第1タームに
て行われる。すなわち、フェーズ3の第4タームにおい
てTCNT割込処理が終了してベース処理に移行した際
には、図6のS44〜S47の処理において、Nb
(1)及びNb(2)が「1」となり、Nb(3)及び
Nb(4)が「2」になる。この結果、S50〜S54
の処理においてF(1)処理,F(2)処理,F(3)
処理及びF(4)処理が順次実行されることになる。従
って、同図に示すフェーズ3の第4タームのタイミング
チャートのようになる。尚、図中、F(3)処理及びF
(4)処理において「ph2」とあるのは、本来フェー
ズ2にて実行されるべきであった処理であることを意味
する。
Then, processing for eliminating this delay is performed in the fourth term of phase 3 and the first term in phase 4. That is, when the TCNT interruption process is completed in the fourth term of the phase 3 and the process shifts to the base process, Nb is set in the processes of S44 to S47 in FIG.
(1) and Nb (2) become “1”, and Nb (3) and Nb (4) become “2”. As a result, S50 to S54
Processing, F (1) processing, F (2) processing, F (3)
The processing and the F (4) processing are sequentially executed. Accordingly, the timing chart of the fourth term of the phase 3 shown in FIG. In the figure, F (3) processing and F
(4) In the process, “ph2” means that the process was originally to be executed in phase 2.

【0060】これを受けて、続くフェーズ4の第1ター
ムのTCNT割込処理における図5のS22〜S25の
処理では、N(1),N(2),N(3)及びN(4)
の値が夫々デクリメントされ、N(1)及びN(2)の
値が「0」になり、N(3)及びN(4)の値が「1」
になる。ただし、Fnumの値が「4」であるため、S
28においてN(1)=1となる。
In response to this, in the processing of S22 to S25 in FIG. 5 in the TCNT interrupt processing of the first term of the subsequent phase 4, N (1), N (2), N (3) and N (4)
Are decremented, the values of N (1) and N (2) become “0”, and the values of N (3) and N (4) become “1”.
become. However, since the value of Fnum is “4”, S
At 28, N (1) = 1.

【0061】このため、TCNT割込処理が終了してベ
ース処理に移行した際には、図6のS44〜S47の処
理において、Nb(1),Nb(3)及びNb(4)が
「1」となり、Nb(3)が「0」になる。この結果、
S50〜S54の処理においてF(1)処理,F(3)
処理及びF(4)処理が順次実行されることになる。従
って、同図に示すフェーズ4の第1タームのタイミング
チャートのようになる。尚、図中、F(3)処理及びF
(4)処理において「ph3」とあるのは、本来フェー
ズ3にて実行されるべきであった処理であることを意味
する。
For this reason, when the TCNT interruption processing is completed and the processing shifts to the base processing, Nb (1), Nb (3) and Nb (4) are set to "1" in the processing of S44 to S47 in FIG. And Nb (3) becomes “0”. As a result,
In the processing of S50 to S54, F (1) processing, F (3)
The processing and the F (4) processing are sequentially executed. Accordingly, a timing chart of the first term of the phase 4 shown in FIG. In the figure, F (3) processing and F
(4) In the process, “ph3” means that the process was originally to be executed in phase 3.

【0062】このようにして、割込要求による遅れがフ
ェーズ4の第1タームにおいて全て解消することにな
る。尚、これ以降は、上述した通常処理の要領で時間同
期処理が継続されることになる。以上に説明したよう
に、本実施例の時間同期処理においては、16ms処理
が4つのモジュールに細分化され、各ターム(基準時
間)に分散されて実行される。そして、割込処理のため
に一部のモジュールの処理が遅れた場合には、この遅れ
た処理を含める複数の処理を、それ以降の基準時間内に
おいてまとめて実行するようにしている。
In this way, all delays due to interrupt requests are eliminated in the first term of phase 4. After that, the time synchronization processing is continued in the manner of the normal processing described above. As described above, in the time synchronization process of the present embodiment, the 16 ms process is subdivided into four modules, and is executed by being distributed to each term (reference time). When the processing of some modules is delayed due to the interrupt processing, a plurality of processings including the delayed processing are collectively executed within a reference time thereafter.

【0063】このため、処理の遅れを比較的早い時期に
解消することができ、本来の処理のタイミングに戻すこ
とができる。その結果、ECU1が実行する各種制御の
遅れ又は誤動作等を有効に抑制又は防止することができ
る。尚、上記においては16ms処理についてのみ説明
したが、これ以外の4ms処理、8ms処理、32ms
処理、64ms処理、128ms処理、256ms処
理、512ms処理、及び1024ms処理について
も、4msの基準時間内において同様の時間同期処理が
行われる。
Therefore, the processing delay can be eliminated at a relatively early stage, and the original processing timing can be returned. As a result, delays or malfunctions of various controls executed by the ECU 1 can be effectively suppressed or prevented. Although only the 16 ms processing has been described above, other 4 ms processing, 8 ms processing, 32 ms processing
In the processing, the 64 ms processing, the 128 ms processing, the 256 ms processing, the 512 ms processing, and the 1024 ms processing, the same time synchronization processing is performed within the reference time of 4 ms.

【0064】尚、本実施例において、CPU21が実行
手段に該当し、ROM22が記憶手段に該当する。以
上、本発明の実施例について説明したが、本発明の実施
の形態は、上記実施例に何ら限定されることなく、本発
明の技術的範囲に属する限り種々の形態をとり得ること
はいうまでもない。
In this embodiment, the CPU 21 corresponds to the execution means, and the ROM 22 corresponds to the storage means. The embodiments of the present invention have been described above. However, the embodiments of the present invention are not limited to the above-described embodiments, and may take various forms as long as they fall within the technical scope of the present invention. Nor.

【0065】例えば、上記実施例では、各時間同期処理
を、その周期を基準時間である4msで除した数のモジ
ュールに分割した例を示したが、プログラムの構成の都
合等により、分割数をこれより少なく設定してもよいこ
とはもちろんである。
For example, in the above-described embodiment, an example has been shown in which each time synchronization process is divided into a number of modules obtained by dividing the period by 4 ms, which is the reference time. Of course, it may be set smaller than this.

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

【図1】 本発明の実施例に係るマイコンが組み込まれ
るエンジン制御装置周辺の構成図である。
FIG. 1 is a configuration diagram around an engine control device in which a microcomputer according to an embodiment of the present invention is incorporated.

【図2】 マイコンが実行するプログラムの動作の概要
を表す説明図である。
FIG. 2 is an explanatory diagram showing an outline of an operation of a program executed by a microcomputer.

【図3】 マイコンが実行するプログラムの動作の詳細
を表す説明図である。
FIG. 3 is an explanatory diagram showing details of an operation of a program executed by a microcomputer.

【図4】 マイコンが実行する処理を表すフローチャー
トである。
FIG. 4 is a flowchart illustrating a process executed by a microcomputer.

【図5】 マイコンが実行する処理を表すフローチャー
トである。
FIG. 5 is a flowchart illustrating a process executed by a microcomputer.

【図6】 マイコンが実行する処理を表すフローチャー
トである。
FIG. 6 is a flowchart illustrating a process executed by a microcomputer.

【図7】 従来のマイコンが実行するプログラムの動作
を表す説明図である。
FIG. 7 is an explanatory diagram showing an operation of a program executed by a conventional microcomputer.

【図8】 従来のマイコンが実行するプログラムの動作
を表す説明図である。
FIG. 8 is an explanatory diagram showing the operation of a program executed by a conventional microcomputer.

【図9】 従来のマイコンが実行するプログラムの動作
を表す説明図である。
FIG. 9 is an explanatory diagram illustrating an operation of a program executed by a conventional microcomputer.

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

1・・・ECU、 2・・・マイコン 1 ... ECU, 2 ... microcomputer

Claims (5)

【特許請求の範囲】[Claims] 【請求項1】 タイマ部が供給する基準時間に基づい
て、互いに実行周期が異なる複数の時間同期処理を実行
するように構成されたマイクロコンピュータにおいて、 前記各時間同期処理を実行するためのプログラムの夫々
を、モジュール単位で構成されたプログラムとして記憶
する記憶手段と、 該記憶手段に記憶された前記各プログラムを、該当する
時間同期処理の周期内で、前記基準時間に基づき前記モ
ジュール単位で段階的に実行する実行手段と、 を備えたことを特徴とするマイクロコンピュータ。
1. A microcomputer configured to execute a plurality of time synchronization processes having different execution periods based on a reference time supplied by a timer unit, wherein the microcomputer executes a program for executing each of the time synchronization processes. A storage unit for storing each of the programs as a program configured in units of a module, and storing the programs stored in the storage unit in a stepwise manner in a unit of the module based on the reference time within a cycle of a corresponding time synchronization process. A microcomputer comprising: an execution unit that executes the program.
【請求項2】 前記記憶手段は、前記各プログラムを、
該当する時間同期処理の周期を前記基準時間で除した数
のモジュールに細分化して記憶し、 前記実行手段は、該細分化されたモジュールを前記基準
時間毎に順次実行することを特徴とする請求項1記載の
マイクロコンピュータ。
2. The storage means stores the programs,
The method according to claim 1, wherein the time synchronization processing cycle is divided into a number of modules obtained by dividing the cycle by the reference time, and the execution unit sequentially executes the subdivided modules for each reference time. Item 18. The microcomputer according to Item 1.
【請求項3】 前記実行手段は、 割込要求の発生により、前記いずれかの基準時間内にて
該当するモジュールを実行できなかった場合には、 該実行できなかったモジュールを、これに後続するモジ
ュールが実行される基準時間内にて、該後続するモジュ
ールと共に実行することを特徴とする請求項1又は請求
項2に記載のマイクロコンピュータ。
3. If the corresponding module cannot be executed within one of the reference times due to the generation of an interrupt request, the execution means replaces the failed module with the next module. The microcomputer according to claim 1, wherein the microcomputer is executed together with the succeeding module within a reference time at which the module is executed.
【請求項4】 請求項1〜3のいずれかに記載のマイク
ロコンピュータを、前記記憶手段及び前記実行手段とし
て機能させるためのプログラム。
4. A program for causing the microcomputer according to claim 1 to function as said storage means and said execution means.
【請求項5】 請求項4に記載のプログラムを記録した
コンピュータ読取可能な記録媒体。
5. A computer-readable recording medium on which the program according to claim 4 is recorded.
JP2001060194A 2001-03-05 2001-03-05 Microcomputer, program and recording medium Pending JP2002259139A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2001060194A JP2002259139A (en) 2001-03-05 2001-03-05 Microcomputer, program and recording medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2001060194A JP2002259139A (en) 2001-03-05 2001-03-05 Microcomputer, program and recording medium

Publications (1)

Publication Number Publication Date
JP2002259139A true JP2002259139A (en) 2002-09-13

Family

ID=18919648

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2001060194A Pending JP2002259139A (en) 2001-03-05 2001-03-05 Microcomputer, program and recording medium

Country Status (1)

Country Link
JP (1) JP2002259139A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005190461A (en) * 2003-12-05 2005-07-14 Yokogawa Electric Corp Multi-variable transmitter and arithmetic processing method therefor
WO2011114495A1 (en) * 2010-03-18 2011-09-22 富士通株式会社 Multi-core processor system, thread switching control method, and thread switching control program

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005190461A (en) * 2003-12-05 2005-07-14 Yokogawa Electric Corp Multi-variable transmitter and arithmetic processing method therefor
JP4636428B2 (en) * 2003-12-05 2011-02-23 横河電機株式会社 Multivariable transmitter and arithmetic processing method of multivariable transmitter
WO2011114495A1 (en) * 2010-03-18 2011-09-22 富士通株式会社 Multi-core processor system, thread switching control method, and thread switching control program
JP5376042B2 (en) * 2010-03-18 2013-12-25 富士通株式会社 Multi-core processor system, thread switching control method, and thread switching control program

Similar Documents

Publication Publication Date Title
US9588916B1 (en) Interrupt latency reduction
US7627730B1 (en) System and method for optimizing a memory controller
US20030009701A1 (en) Computer system and computer-readable recording medium
US20070150707A1 (en) Processor and pipeline reconfiguration control method
JP2003050739A (en) Memory controller
JP2002259139A (en) Microcomputer, program and recording medium
JPH0844594A (en) Data processor
JPS61246840A (en) Performance adjusting system for information processor
US7417915B2 (en) Multiport memory device
JP3987277B2 (en) Pulse signal generator
US7257729B2 (en) System and method for processing an instruction according to a clock and adjusting the phase of the clock according to the instruction
US20030046600A1 (en) Processor
JP2021163425A (en) Electronic control device
JP2005284760A (en) Interrupt control circuit
JP5722988B2 (en) Circuit configuration and method of a data processing system for predicting the time of at least one operation to be performed or other physical quantities related to the time
JPH06259115A (en) Programmable controller
JP2006202172A (en) Bus timing control circuit
JP2003345404A (en) Electronic control device and program
JPH0784670A (en) Timer
JP2616151B2 (en) Memory refresh circuit
JP3405513B2 (en) Redundant controller for programmable controller
JPS61153701A (en) Process control device
JPH03246603A (en) Rapid counter
JP2005071203A (en) Microprocessor
JP3145292B2 (en) Digital signal processing circuit