JP2984591B2 - Timer counter counting method - Google Patents

Timer counter counting method

Info

Publication number
JP2984591B2
JP2984591B2 JP7311257A JP31125795A JP2984591B2 JP 2984591 B2 JP2984591 B2 JP 2984591B2 JP 7311257 A JP7311257 A JP 7311257A JP 31125795 A JP31125795 A JP 31125795A JP 2984591 B2 JP2984591 B2 JP 2984591B2
Authority
JP
Japan
Prior art keywords
timer
time
processing
flag
counter
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.)
Expired - Lifetime
Application number
JP7311257A
Other languages
Japanese (ja)
Other versions
JPH09153790A (en
Inventor
聡子 明田
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.)
NIPPON DENKI AISHII MAIKON SHISUTEMU KK
Original Assignee
NIPPON DENKI AISHII MAIKON SHISUTEMU KK
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 NIPPON DENKI AISHII MAIKON SHISUTEMU KK filed Critical NIPPON DENKI AISHII MAIKON SHISUTEMU KK
Priority to JP7311257A priority Critical patent/JP2984591B2/en
Publication of JPH09153790A publication Critical patent/JPH09153790A/en
Application granted granted Critical
Publication of JP2984591B2 publication Critical patent/JP2984591B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Description

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

【0001】[0001]

【発明の属する技術分野】本発明はタイマカウンタのカ
ウント方法に関し、特にマイクロコンピュータに内蔵さ
れるタイマカウンタのカウント方法に関する。
The present invention relates to a counting method for a timer counter, and more particularly to a counting method for a timer counter incorporated in a microcomputer.

【0002】[0002]

【従来の技術】従来、マイクロコンピュータのソフトウ
ェアにおいて、任意の時間の経過を検知する方法とし
て、第1にマイクロコンピュータの内蔵するタイマカウ
ンタに時間をカウントさせ、指定の時間をカウントした
ら割り込み信号発生することにより、指定時間の経過を
検知する方法がある。
2. Description of the Related Art Conventionally, as a method of detecting the passage of an arbitrary time in microcomputer software, first, a timer counter built in the microcomputer counts the time, and an interrupt signal is generated when a specified time is counted. Thus, there is a method of detecting the elapse of a designated time.

【0003】図4(a),(b)はそれぞれ従来のかか
る内蔵タイマカウンタによる任意時間のカウント処理に
おけるメインモジュール処理フロー図およびタイマ割り
込み処理フロー図である。図4(a)に示すように、こ
の処理フローは、10msごとに処理2を実行するにあ
たり、メインモジュールで内蔵タイマカウンタに10m
sの時間を設定し、内蔵タイマを起動してからタイマカ
ウンタの割り込みを許可するものである。しかる後、図
4(b)に示すように、内蔵タイマカウンタの割り込み
信号が発生したなら、タイマ割り込みモジュールにおい
て、処理2を実行する。
FIGS. 4 (a) and 4 (b) are a flowchart of a main module process and a flowchart of a timer interrupt process, respectively, in a conventional process for counting an arbitrary time by the built-in timer counter. As shown in FIG. 4A, this processing flow is such that when the processing 2 is executed every 10 ms, the built-in timer counter is set to 10 m in the main module.
The time of s is set, the built-in timer is activated, and then the interruption of the timer counter is permitted. Thereafter, as shown in FIG. 4B, when an interrupt signal of the built-in timer counter is generated, the process 2 is executed in the timer interrupt module.

【0004】また第2の時間経過検知方法として、前述
した割り込み信号を使用せず、タイマカウンタが指定の
時間をカウントしたらマイクロコンピュータで内部的に
セットされるフラグをメイン処理で監視し、このフラグ
が1にセットされるのを待つことにより、指定時間の経
過を検知する方法もある。
As a second method of detecting the passage of time, a flag internally set by a microcomputer is monitored by a main process when the timer counter has counted a designated time without using the above-mentioned interrupt signal. There is also a method of detecting the elapse of a designated time by waiting for the set time to be set to 1.

【0005】図5はこのような内蔵タイマカウンタによ
る任意時間のカウント処理におけるメインモジュール処
理フロー図である。図5に示すように、この処理フロー
は、前述した図4の処理フローと同様に、10msごと
に処理2を実行する場合のフローであるが、タイマ割り
込みを使用せずに行うものである。まず、メインモジュ
ールで内部タイマカウンタに10msの時間を設定し、
内蔵タイマを起動する。ついで、タイマカウンタが10
msをカウントすると、内部的にセットされるフラグを
監視し、このフラグが0にクリアされたままなら処理2
の実行待ちとし、1にセットされたなら処理2を実行す
る。この方法では、割り込み処理は不要となる。
FIG. 5 is a flow chart of a main module process in the counting process of an arbitrary time by such a built-in timer counter. As shown in FIG. 5, this processing flow is a flow in the case where the processing 2 is executed every 10 ms, similar to the processing flow of FIG. 4 described above, but is performed without using a timer interrupt. First, the main module sets an internal timer counter to 10 ms,
Start the built-in timer. Then, if the timer counter is 10
After counting ms, a flag that is set internally is monitored, and if this flag is kept cleared to 0, processing 2
, And if set to 1, the process 2 is executed. In this method, no interrupt processing is required.

【0006】この図5のような方法は、小さなシステム
に適用するにあたっては問題がないが、最近ではマイク
ロコンピュータのシステムは大規模化し、複数用途のた
めに複数種類のタイマカウンタを必要とするようになっ
てきている。
The method shown in FIG. 5 has no problem when applied to a small system. However, recently, a microcomputer system has become large-scale and requires a plurality of types of timer counters for a plurality of uses. It is becoming.

【0007】しかし、通常マイクロコンピュータの内蔵
するタイマカウンタは1〜3個程度であるため、上述し
たような1つの用途に1つの内蔵タイマカウンタを割り
当てる方法では、タイマカウンタの個数が到底足りなく
なる。そこで、1個の内蔵タイマカウンタにより基準時
間を作り、この基準時間をソフトウェアにより分周させ
て複数種類の時間をカウントするソフトウェアタイマを
用いることが一般的になっている。
[0007] However, since the microcomputer usually has about one to three timer counters, the method of allocating one built-in timer counter to one use as described above makes the number of timer counters insufficient. Therefore, it is common to use a software timer that creates a reference time by one built-in timer counter, divides this reference time by software, and counts a plurality of types of times.

【0008】この方法は、カウンタをRAMに割り付
け、基準時間(たとえば10ms)ごとにこのRAMカ
ウンタをカウントアップまたはカウントダウンしていく
ものである。1つの用途に1つのRAMを割り当て(5
0の用途では50個のRAMが必要となる)、カウント
したい時間に相当する値(基準時間を10msとし、4
0msをカウントする場合は4)をソフトウェアタイマ
に設定し、基準時間毎に発生するタイマ割り込みですべ
てのソフトウェアタイマをカウントすることが基本処理
となる。ここで、前述したように基準時間を10msと
し、2.55秒(=10ms×255)以下の短い時間
をカウントする場合を例にとると、カウント値は最大2
55であればよく、RAM領域は8ビット長あれば足り
る。また、16ビット長あれば、最大10分程度(約1
0ms×65535)までカウントすることが可能であ
る。
In this method, a counter is allocated to a RAM, and the RAM counter is counted up or down every reference time (for example, 10 ms). Allocate one RAM for one application (5
0 uses 50 RAMs), a value corresponding to the time to be counted (reference time is 10 ms, 4
When counting 0 ms, the basic processing is to set 4) as a software timer and count all software timers with a timer interrupt generated every reference time. Here, as described above, when the reference time is set to 10 ms and a short time of 2.55 seconds (= 10 ms × 255) or less is counted as an example, the maximum count value is 2
55 is sufficient, and the RAM area only needs to be 8 bits long. If it is 16 bits long, it takes about 10 minutes at maximum (about 1 minute).
0 ms × 65535).

【0009】図6(a)〜(c)はそれぞれ従来のソフ
トウェアタイマを用いて任意時間のカウント処理を行う
際のメインモジュール処理フロー図と処理モジュール2
の処理フロー図および内蔵タイマ割り込みモジュール処
理フロー図である。図6(a)に示すように、この処理
フローは、メインモジュールから呼ばれる処理モジュー
ル2において、ソフトウェアタイマでカウントした所定
の時間経過後に、処理2および処理3を行うというもの
である。この処理モジュール2は、図6(b)に示すよ
うに、ある条件下においてのみ起動されるものとする。
また、ソフトウェアタイマは、図6(c)に示すよう
に、10msごとに発生する内蔵タイマ割り込みのモジ
ュールにおいて、すべてカウントするようになってい
る。
FIGS. 6 (a) to 6 (c) show a main module processing flow chart and a processing module 2 for performing an arbitrary time counting process using a conventional software timer.
FIG. 3 is a flowchart of the processing of FIG. As shown in FIG. 6A, in this processing flow, in the processing module 2 called from the main module, the processing 2 and the processing 3 are performed after a predetermined time counted by the software timer has elapsed. This processing module 2 is activated only under certain conditions, as shown in FIG.
Also, as shown in FIG. 6C, all the software timers count in a module of a built-in timer interrupt generated every 10 ms.

【0010】まず、図6(a)に示すメインモジュール
において、内蔵タイマに10msを設定し、内蔵タイマ
を起動した後、割り込みを許可にする。そして、ソフト
ウェアタイマのカウント結果により、所定の処理を行う
処理モジュール2の起動条件を判断し、起動条件を見た
していれば、処理モジュール2で使用する250msタ
イマ(250ms=10m4×25よりRAMのカウン
タに25を設定)と1分タイマ(1分=10ms×60
00より6000)との初期設定を行う。
First, in the main module shown in FIG. 6A, the built-in timer is set to 10 ms, the built-in timer is started, and then the interrupt is enabled. Then, based on the count result of the software timer, the starting condition of the processing module 2 that performs the predetermined processing is determined. If the starting condition is observed, the 250 ms timer (250 ms = 10 m4 × 25 is used from the RAM). Counter is set to 25) and 1 minute timer (1 minute = 10 ms × 60)
(From 00 to 6000).

【0011】一方、10msごとに発生する基準タイマ
割り込みで、図6(c)に示す内蔵タイマ割り込みモジ
ュールでは、250msタイマと1分タイマのRAMの
カウントダウン処理を行う。また、図6(b)に示す処
理モジュール2では、250msタイマのRAMのカウ
ンタが0であれば、250ms経過したということで、
図6(b)に示す処理2を行う。同様に、1分タイマの
RAMのカウンタが0であれば1分が経過したというこ
とで、図6(b)に示す処理3を行う。
On the other hand, with a reference timer interrupt generated every 10 ms, the built-in timer interrupt module shown in FIG. 6C counts down the RAM of the 250 ms timer and the RAM of the 1 minute timer. In the processing module 2 shown in FIG. 6B, if the counter of the RAM of the 250 ms timer is 0, it means that 250 ms has elapsed.
Processing 2 shown in FIG. 6B is performed. Similarly, if the counter of the RAM of the one-minute timer is 0, it means that one minute has elapsed, and the process 3 shown in FIG. 6B is performed.

【0012】この例では、2個のみのソフトウェアタイ
マを使用する例を示したが、ソフトウェアタイマの個数
が何個になっても、図6(a)〜(c)の処理例と同様
に、内蔵タイマの割り込みモジュールでソフトウェアタ
イマをカウントしていく。
In this example, an example is shown in which only two software timers are used. However, no matter how many software timers are used, as in the processing examples of FIGS. The software timer is counted by the built-in timer interrupt module.

【0013】次に、このソフトウェアタイマを具体的に
エアコンシステムに用いた例を説明する。このエアコン
システムのソフトウェアでは、室温のサーモスタット制
御や冷媒の高圧制御、コンプレッサーの起動/停止制御
などで、数秒〜数10分のタイマが50個程度必要とな
る。
Next, an example in which the software timer is specifically used in an air conditioner system will be described. In the software of the air conditioner system, about 50 timers for several seconds to several tens of minutes are required for the thermostat control of the room temperature, the high pressure control of the refrigerant, and the start / stop control of the compressor.

【0014】図7(a)〜(c)はそれぞれ従来のソフ
トウェアタイマによる任意時間のカウントをエアコンシ
ステムに応用した場合のメインモジュール処理フロー図
と室温制御モジュール処理フロー図および内蔵タイマ割
り込みモジュール処理フロー図である。図7(a)に示
すように、室温制御にこのようなソフトウェアタイマを
用いるにあたり、メインモジュールでは、内蔵タイマを
起動し割り込みを許可した後、コンプレッサ起動の判定
を行い、そのコンプレッサが起動されていれば、ソフト
ウェアタイマに2分(2分=10ms×12000より
12000)をセットし、室温制御モジュールを起動す
る。
FIGS. 7 (a) to 7 (c) show a main module processing flow diagram, a room temperature control module processing flow diagram, and a built-in timer interrupt module processing flow, respectively, in a case where the counting of an arbitrary time by a conventional software timer is applied to an air conditioner system. FIG. As shown in FIG. 7 (a), when using such a software timer for room temperature control, the main module activates a built-in timer and permits an interrupt, then determines whether to start the compressor, and activates the compressor. Then, 2 minutes (2 minutes = 10 ms × 12000 to 12000) are set in the software timer, and the room temperature control module is started.

【0015】ついで、図7(b)に示すように、この室
温制御モジュールでは、2分タイマのタイムアップを監
視し、その2分タイマがタイムアップしていれば、室温
サーモをONにして復帰する。一方、この2分タイマ
は、図7(c)に示すように、内蔵タイマの基準時間割
り込みモジュールで10msごとにカウントダウンさ
れ、最終的にはメインモジュールに復帰する。
Next, as shown in FIG. 7 (b), the room temperature control module monitors the expiration of the two-minute timer, and if the two-minute timer has expired, turns on the room temperature thermo and returns. I do. On the other hand, as shown in FIG. 7C, the two-minute timer counts down every 10 ms by the reference time interrupt module of the built-in timer, and finally returns to the main module.

【0016】しかしながら、上述したソフトウェアタイ
マをワンショットタイマ(ある時から1回だけ所定の時
間を計測する)のように使用する場合には、カウントを
終了したら(ダウンカウンタの場合はカウンタが0にな
ったら)カウント動作を停止させたり、ある条件下では
カウント動作を一時的に保留したりといった使用方法を
することがある。このような場合、カウント動作を行っ
て良いのか否かを判断する情報が各ソフトウェアタイマ
に必要となる。また、様々なビット長のソフトウェアタ
イマが存在する場合、タイムアップを判定するモジュー
ル側(前述した図6の例では処理モジュール2)での判
定方法がそれぞれ異なってくる。
However, when the above-mentioned software timer is used like a one-shot timer (measures a predetermined time only once from a certain time), when the counting is completed (in the case of a down counter, the counter is reset to 0). In some cases, the counting operation is stopped, or under certain conditions, the counting operation is temporarily suspended. In such a case, information for determining whether or not the counting operation may be performed is required for each software timer. Further, when software timers having various bit lengths are present, the method of determining the time-up on the module side (the processing module 2 in the example of FIG. 6 described above) differs from one another.

【0017】例えば、8ビットのソフトウェアタイマと
16ビットのソフトウェアタイマでは、カウンタが0か
どうかの判定をするための命令が違い、タイムアップを
判定するモジュール側(図6の例では処理モジュール
2)の処理が煩雑になりかねない。
For example, an instruction for judging whether the counter is 0 is different between an 8-bit software timer and a 16-bit software timer, and the module for judging time-up (processing module 2 in the example of FIG. 6) May be complicated.

【0018】そこで、各ソフトウェアタイマについて、
タイムアップしたかどうかを表わす情報を付加すると、
タイムアップを判定するモジュール側の処理は、そのフ
ラグをチェックするのみとなるため、ソフトウェアタイ
マのビット長に関わらず共通となる。このタイムアップ
の情報を作るには、ソフトウェアタイマをカウントする
基準タイマの割り込み処理側(図6の例では内蔵タイマ
割り込みモジュール)で、カウンタが0か否かの判定を
必要とするが、これは、前述したカウンタが0になった
ときのカウント動作停止の情報を作るときにも必要な判
定処理であるので、共通化することができる。
Then, for each software timer,
If you add information indicating whether the time is up,
The processing on the module side for determining the time-up is only to check the flag, so that it is common regardless of the bit length of the software timer. In order to generate this time-up information, it is necessary to determine whether or not the counter is 0 on the interrupt processing side (internal timer interrupt module in the example of FIG. 6) of the reference timer that counts the software timer. Since the determination process is also required when creating the information of the counting operation stop when the above-mentioned counter becomes 0, it can be shared.

【0019】このようなことから、上述した図6のソフ
トウェアタイマのカウント方法をさらに発展させた例も
提案されている。すなわち、、ソフトウェアタイマの構
成としては、カウンタ部分のみでなく、ソフトウェアタ
イマのタイムアップ情報と、カウント許可/禁止情報を
持たせたソフトウェアタイマが実現されている。
In view of the above, an example has been proposed in which the counting method of the software timer shown in FIG. 6 is further developed. That is, as the configuration of the software timer, not only the counter portion, but also a software timer having time-up information of the software timer and count permission / prohibition information is realized.

【0020】次に、このようなソフトウェアタイマの構
成と動作を図8〜図10を用いて説明する。
Next, the configuration and operation of such a software timer will be described with reference to FIGS.

【0021】図8は従来のソフトウェアタイマ1個のタ
イマエリア構成図である。図8に示すように、従来の1
個あたりのソフトウェアタイマ10aは、複数ビットか
らなるカウンタ11aと1ビット構成のカウント許可フ
ラグ13aと1ビット構成のタイムアップフラグ12a
とを持って形成される。このソフトウェアタイマ10a
がタイムアップしたか否かを表すために、ソフトウェア
タイマ1個につき、RAMの1ビットをタイムアップフ
ラグ12aとして使用するとともに、ソフトウェアタイ
マ10aのカウント動作の許可/禁止を表わすために、
同じくRAMの1ビットをカウント許可フラグ13aと
して使用している。そして、カウンタ11aを前述した
ソフトウェアタイマと同様に、1用途に1個の割合いで
RAMに割り当てる。
FIG. 8 is a diagram showing a timer area configuration of one conventional software timer. As shown in FIG.
Each software timer 10a includes a counter 11a having a plurality of bits, a count enable flag 13a having a 1-bit configuration, and a time-up flag 12a having a 1-bit configuration.
And is formed with. This software timer 10a
Is used as a time-up flag 12a for each software timer to indicate whether or not the timer has timed out, and to indicate permission / inhibition of the count operation of the software timer 10a,
Similarly, one bit of the RAM is used as the count permission flag 13a. Then, the counter 11a is allocated to the RAM at a rate of one for one application similarly to the software timer described above.

【0022】このような1個のソフトウェアタイマ10
aにより、基準時間を10msとして、40msの時間
をカウントする際のカウント方法を、具体的な8ビット
マイクロコンピュータを例にとり、図9および図10を
用いて説明する。なお、図9と図10の処理ステップ番
号は対応している。
One such software timer 10
Referring to FIG. 9A and FIG. 10, a description will be given of a counting method for counting a time of 40 ms by using a specific 8-bit microcomputer as an example. Note that the processing step numbers in FIGS. 9 and 10 correspond to each other.

【0023】図9は図8におけるソフトウェアタイマを
用いたカウント動作説明図であり、図10(a)〜
(d)はそれぞれ図9のカウント動作を説明するための
メイン処理フロー図,処理モジュール3のソフトウェア
タイマ初期設定処理フロー図,内蔵タイマ割り込み処理
フロー図,処理モジュール3の処理フロー図である。
FIG. 9 is an explanatory diagram of the counting operation using the software timer in FIG. 8, and FIG.
10D is a main processing flowchart for explaining the counting operation of FIG. 9, a software timer initialization processing flowchart of the processing module 3, a built-in timer interrupt processing flowchart, and a processing flowchart of the processing module 3.

【0024】まず、図9に示すように、用途11a,1
3a,12aはそれぞれ図8におけるソフトウェアタイ
マ10aのカウンタ11aとフラグ13a,12aを表
わし、処理ステップS11,S13〜S16,S18,
S19は図10(b),(c)の処理ステップを表わし
ている。
First, as shown in FIG.
3a and 12a represent the counter 11a and the flags 13a and 12a of the software timer 10a in FIG. 8, respectively, and show the processing steps S11, S13 to S16, S18,
S19 represents the processing steps in FIGS. 10 (b) and 10 (c).

【0025】また、図10(a)〜(d)において、図
10(a)に示すメイン処理は、図10(d)に示す処
理モジュール3の起動条件が成立している場合は、図1
0(b)に示す処理モジュール3のソフトウェアタイマ
初期設定処理フローを呼び出す。この処理モジュール3
のソフトウェアタイマ初期設定処理では、カウント値4
(40ms=10ms×4)をカウンタに設定し、図8
のカウント許可フラグ13aをセットし、図9の処理ス
テップS11、すなわち図10(b)のステップS11
に示すカウンタ許可状態にしておく。なお、他にもソフ
トウェアタイマを使用している場合は、その初期設定を
それぞれ必要な箇所で行うのが通常である。
10 (a) to 10 (d), the main processing shown in FIG. 10 (a) is executed when the starting condition of the processing module 3 shown in FIG. 10 (d) is satisfied.
A software timer initialization processing flow of the processing module 3 shown in FIG. This processing module 3
In the software timer initialization process, the count value 4
(40 ms = 10 ms × 4) is set in the counter, and FIG.
The count permission flag 13a is set, and the processing step S11 of FIG. 9, that is, the step S11 of FIG.
The counter is enabled as shown in (1). In addition, when a software timer is used in addition, it is usual that the initial setting is performed at a necessary place.

【0026】一方、図10(c)に示す10msごとに
発生する内蔵タイマ割り込み処理において、図8のカウ
ント許可フラグ13aが図10(c)のステップS12
のようにセットされていると(カウント動作許可なら
ば)、図9や図10のS13のように、ソフトウェアタ
イマ10aのカウンタ11aをカウントダウンする。
On the other hand, in the internal timer interrupt processing generated every 10 ms shown in FIG. 10C, the count permission flag 13a shown in FIG.
(If the counting operation is permitted), the counter 11a of the software timer 10a is counted down as in S13 of FIGS. 9 and 10.

【0027】次に、ソフトウェアタイマのタイムアップ
を判定するために、図10(c)のS17に示すとお
り、カウンタ11aが0になったか否かをチェックす
る。このカウンタが0でなければ、未だタイムアップし
ていないということであるので、図10(c)において
次の10ms内蔵タイマ割り込みの処理で、図9のS1
4や図10(c)のS14のように、カウンタ11aを
再びカウントダウンする。この後、図10(c)のステ
ップS20に示すように、ソフトウェアタイマが複数個
ある場合は、引き続きそのソフトウェアタイマに対し、
図10(c)のステップS12〜S17と同様の処理を
行うことになる。
Next, in order to determine the time-up of the software timer, it is checked whether or not the counter 11a has become 0 as shown in S17 of FIG. 10C. If this counter is not 0, it means that the timer has not yet timed up. Therefore, in the processing of the next 10 ms built-in timer interrupt in FIG.
4, and the counter 11a counts down again as in S14 of FIG. 10C. Thereafter, as shown in step S20 of FIG. 10C, if there are a plurality of software timers,
The same processing as steps S12 to S17 in FIG. 10C is performed.

【0028】このように、カウント許可フラグ13aの
チェックとカウンタ11aの減算を、図9のステップS
13〜S16および図10(c)のS12〜S17に示
すように、カウンタ11aが0になるまで繰り返し行
う。このカウンタ11aが0になると、図9や図10
(c)のS18に示すように、タイムアップフラグ12
aをセットし、図9や図10(c)のステップS19に
示すように、カウント許可フラグ13aをクリアしてカ
ウント禁止状態とする。なお、ソフトウェアタイマが複
数個ある場合は、図10(c)のステップS20に示す
ように、引き続きその個数分だけ図10(c)のステッ
プS12〜S19の処理を行う。
As described above, the check of the count permission flag 13a and the subtraction of the counter 11a are performed in step S of FIG.
As shown in steps S13 to S16 and steps S12 to S17 in FIG. 10C, the process is repeated until the counter 11a becomes 0. When the counter 11a reaches 0, the counter shown in FIGS.
As shown in S18 of (c), the time-up flag 12
is set, and the count permission flag 13a is cleared and the count is disabled, as shown in step S19 of FIGS. 9 and 10 (c). When there are a plurality of software timers, as shown in step S20 of FIG. 10C, the processes of steps S12 to S19 of FIG.

【0029】さらに、図10(a)でメイン処理から呼
ばれる図10(d)の処理モジュール3において、該当
するソフトウェアタイマ10aのタイムアップフラグ1
2aをチェックし、そのフラグ12aがセットされてい
るときは、図10(d)のステップS21に示すよう
に、40ms経過ということで、図10(d)のステッ
プS22に示すタイムアップフラグのクリアとステップ
S23の処理4とを行う。逆に、タイムアップフラグが
セットされていなければ40ms未経過ということで、
タイムアップフラグのクリアと処理4は行わない。
Further, in the processing module 3 of FIG. 10D called from the main processing in FIG. 10A, the time-up flag 1 of the corresponding software timer 10a is set.
2a is checked, and when the flag 12a is set, it means that 40 ms has elapsed, as shown in step S21 of FIG. 10D, so that the time-up flag shown in step S22 of FIG. 10D is cleared. And the processing 4 in step S23. Conversely, if the time-up flag is not set, it means that 40 ms has not elapsed,
The clearing of the time-up flag and the processing 4 are not performed.

【0030】[0030]

【発明が解決しようとする課題】上述した従来のソフト
ウェアタイマのカウント方法では、タイムアップ時の内
蔵タイマ割り込み処理内で、1個のソフトウェアタイマ
につき最低5命令〔図10(c)のステップS12〜S
19の処理において、1処理を1命令と仮定した場合〕
の処理を実行するため、ソフトウェアタイマの個数が多
ければ多いほど実行する命令数が多くなり、内蔵タイマ
の割り込み処理時間が長くなっている。
In the conventional software timer counting method described above, at least five instructions per software timer in the internal timer interrupt processing at time-up [Steps S12 to S12 in FIG. S
In the case of processing 19, assuming that one processing is one instruction]
Therefore, the greater the number of software timers, the greater the number of instructions to be executed, and the longer the interrupt processing time of the built-in timer.

【0031】このカウント方法では、ソフトウェアタイ
マカウント処理中に発生する同システムの別の割り込み
処理はその保留される時間がかなり長くなる。すなわ
ち、1個のソフトウェアタイマがタイムアップしたとき
に費やす処理時間は、前述したように、5命令=約10
μs(1命令2μsとした場合)となる。仮に、今行っ
ている内蔵タイマ割り込みで、30個のソフトウェアタ
イマがタイムアップしたとすると、10μs×30=3
00μsの時間が処理にかかることになる。
In this counting method, the time during which another interrupt process of the same system that occurs during the software timer counting process is suspended is considerably long. That is, the processing time spent when one software timer times out is, as described above, 5 instructions = about 10 instructions.
μs (when one instruction is 2 μs). Assuming that 30 software timers have timed out due to the built-in timer interrupt currently being performed, 10 μs × 30 = 3
The processing of 00 μs takes time.

【0032】例えば、エアコン室内機および室外機のフ
ァンモータ制御において、モータからの位相信号を割り
込み処理で取り込むシステムの場合、ソフトウェアタイ
マのカウント処理開始直後に発生した位相信号の割り込
み処理の受け付けが300μs遅れることになり、モー
タの回転制御に多大な影響を及ぼしてしまう。ここでの
位相信号とは、モータの回転速度を滑らかに変化させた
り、あるいは一定速度に保つために、前回のモータ回転
の位相に対する今回の位相のずれを認識し、次回のモー
タへ流す電流もしくは電圧(モータの回転速度)を決定
する際のマイコンへの入力信号である。通常、かかる位
相信号は、内蔵タイマにより信号間の時間を測定するこ
とにより、前回とのずれが算出される。
For example, in a fan motor control of an indoor unit and an outdoor unit of an air conditioner, in the case of a system in which a phase signal from a motor is fetched by an interrupt process, an interrupt process of the phase signal generated immediately after the start of the count process of the software timer is accepted for 300 μs. This results in a delay, which greatly affects the rotation control of the motor. In this case, the phase signal is used to change the rotation speed of the motor smoothly or to maintain a constant speed by recognizing the current phase shift from the previous motor rotation phase, This is an input signal to the microcomputer when determining the voltage (the rotation speed of the motor). Normally, the time difference between the phase signal and the previous signal is calculated by measuring the time between the signals using a built-in timer.

【0033】また、エアコンシステムにおいて、50個
程度のソフトウェアタイマを必要とすることは、前述し
たとおりである。しかも、1回の内蔵タイマ割り込みで
タイムアップするソフトウェアタイマの個数はタイミン
グによってまちまちであるが、仮にあるタイミングでそ
の半数程度の30個のソフトウェアタイマがタイムアッ
プしたとすると、その場合には、ソフトウェアでの位相
信号の検知が最大300μs遅れることになる。その
上、エアコンのファンモータからの位相信号は、1ms
程度の周期で入力される場合もあり、300μsの位相
信号検知のずれは、1周期の約30%にあたる。したが
って、モータを一定速度で回転させるべき場合でも、次
回の回転速度は1.3倍速くなってしまい、回転速度制
御の精度が大幅に低下してしまう。すなわち、位相信号
の検知が遅くなるということは、モータの回転速度が実
際より遅いと認識されるため、本当に必要な速度以上に
速く回転させるようにソフトウェアで処理してしまうた
めである。
As described above, the air conditioner system requires about 50 software timers. In addition, the number of software timers that are timed up by one built-in timer interrupt varies depending on the timing. If half of the 30 software timers have timed out at a certain timing, the software , The detection of the phase signal is delayed by a maximum of 300 μs. In addition, the phase signal from the fan motor of the air conditioner is 1 ms
In some cases, the phase signal is input at about a period, and the deviation of the phase signal detection of 300 μs corresponds to about 30% of one period. Therefore, even if the motor is to be rotated at a constant speed, the next rotation speed will be 1.3 times faster, and the accuracy of the rotation speed control will be greatly reduced. That is, the fact that the detection of the phase signal is delayed is because the rotation speed of the motor is recognized as being lower than the actual speed, so that software processing is performed to rotate the motor at a speed higher than the really necessary speed.

【0034】したがって、かかるエアコンのファンモー
タの速度制御のようなフィードバック制御(制御側の電
流,電圧のような出力によりモータの回転速度を制御
し、そのモータが回転して制御側へ戻される信号により
制御側の次回のモータへの出力が決まるような帰還制
御)において、速度検知(エアコンの例では位相信号検
知)に間違いが連続して発生すると、モータ制御が不能
に陥り、最悪の場合、モータがその最大定格以上の速度
で回転し続けること、すなわちモータに最大定格以上の
電流が流れ続けるか、もしくは電圧がかかり続けること
になる。このような場合、モータの動作は保証されず、
時にはモータが破壊され、エアコンが機能しなくなると
いう欠点がある。
Therefore, the feedback control such as the speed control of the fan motor of the air conditioner (the rotation speed of the motor is controlled by the output such as the current and voltage on the control side, and the signal that the motor rotates and returns to the control side) In the feedback control that determines the next output to the motor on the control side, if errors occur continuously in the speed detection (phase signal detection in the example of an air conditioner), motor control becomes impossible, and in the worst case, The motor continues to rotate at a speed higher than its maximum rating, that is, a current that exceeds the maximum rating or a voltage continues to be applied to the motor. In such a case, the operation of the motor is not guaranteed,
There is a disadvantage that the motor is sometimes destroyed and the air conditioner stops functioning.

【0035】また、上述した従来のソフトウェアタイマ
のようなタイマカウンタのカウント方法では、あるタイ
ミングでのソフトウェアタイマのタイムアップ個数を3
0個と仮定したが、これが35個、40個、45個とな
った場合、前記の事態は、より一層悪くなることはいう
までもない。
Further, in the above-described conventional method of counting a timer counter such as a software timer, the number of times that the software timer has
Although it is assumed that the number is zero, if the number becomes 35, 40, or 45, it goes without saying that the above-mentioned situation becomes worse.

【0036】本発明の目的は、カウンタのタイムアップ
時の処理を簡略化し、CPUの空き時間を増やしてシス
テム全体の処理時間に余裕をもたせるとともに、そのタ
イマカウント処理のプログラムサイズを小さくすること
のできるタイマカウンタのカウント方法を提供すること
にある。
An object of the present invention is to simplify the processing when the time of the counter is up, to increase the idle time of the CPU so that there is a margin in the processing time of the entire system, and to reduce the program size of the timer counting processing. It is an object of the present invention to provide a counting method of a timer counter.

【0037】[0037]

【課題を解決するための手段】本発明のタイマカウンタ
のカウント方法は、所定の周期で割り込みを発生し、そ
の割り込みによって記憶領域上に設けられたタイマカウ
ンタ領域の値をカウントアップまたはカウントダウン処
理することにより時間をカウントするにあたり、あらか
じめ定められた所定の値をカウントしたとき、前記記憶
領域上に設けられたフラグ領域にフラグを設定するタイ
マカウンタのカウント方法において、前記フラグ領域と
前記タイマカウンタ領域を連続した記憶領域に設けると
ともに、前記フラグ領域のビットデータを前記タイマカ
ウンタ領域のビットデータの上位ビット領域に設け、カ
ウント時に前記フラグと前記タイマカウンタのビットデ
ータとを連続したタイマカウンタ領域としてカウントア
ップまたはカウントダウン処理するように構成される。
According to the counting method of the timer counter of the present invention, an interrupt is generated at a predetermined cycle, and the value of the timer counter area provided on the storage area is counted up or down by the interrupt. In counting the time, when a predetermined value is counted, a flag is set in a flag area provided on the storage area. Are provided in a continuous storage area, and the bit data of the flag area is provided in an upper bit area of the bit data of the timer counter area, and the flag and the bit data of the timer counter are counted as a continuous timer counter area at the time of counting. Up or counsel Configured to down processing.

【0038】また、本発明のタイマカウンタのカウント
方法における前記フラグ領域の1ビットは、前記カウン
タ領域の上位ビットにタイムアップフラグとして設ける
ように構成される。
In the counting method of the timer counter according to the present invention, one bit of the flag area is provided as a time-up flag in an upper bit of the counter area.

【0039】さらに、本発明のタイマカウンタのカウン
ト方法における前記フラグ領域の1ビットは、前記カウ
ンタ領域の上位ビットにカウント許可フラグとして設け
るように構成される。
Further, in the counting method of the timer counter according to the present invention, one bit of the flag area is provided as a count permission flag in an upper bit of the counter area.

【0040】要するに、本発明はソフトウェアタイマの
個数が多ければ多いほど実行する命令数が多くなり、内
蔵タイマの割り込み処理時間が長くなるという従来の問
題点を解決するために、ソフトウェアタイマ1個あたり
のカウンタとタイムアップフラグ,カウント許可フラグ
のRAMへの割り付け方を特定するものであり、タイム
アップフラグとカウント許可フラグをカウンタのオーバ
フローもしくはアンダーフローにより制御するととも
に、カウンタ領域の上位ビットにこれらタイムアップフ
ラグおよびカウント許可フラグを割り付けるようにして
いる。
In short, the present invention solves the conventional problem that the number of instructions to be executed increases as the number of software timers increases, and the interrupt processing time of the built-in timer increases. This specifies how the counter, time-up flag, and count permission flag are allocated to the RAM. The time-up flag and the count permission flag are controlled by the overflow or underflow of the counter, and the upper bits of the counter area are used to specify these times. An up flag and a count permission flag are assigned.

【0041】[0041]

【発明の実施の形態】次に、本発明の実施の形態につい
て図面を用いて詳細に説明する。
Next, an embodiment of the present invention will be described in detail with reference to the drawings.

【0042】図1は本発明の一実施の形態を説明するた
めのソフトウェアタイマのタイマエリア構成図である。
図1に示すように、本実施の形態は、8ビットのマイク
ロコンピュータに用いるソフトウェアタイマ10を表わ
し、1個のソフトウェアタイマにつき1バイトのRAM
を割り付けるものである。すなわち、6ビットカウンタ
11をビット0〜5に、タイマがタイムアップしたこと
を示すタイムアップフラグ12をビット6に、ソフトウ
ェアタイマ10のカウント許可/禁止を示すカウント許
可フラグ13をビット7にそれぞれ割り付けたものであ
る。本実施の形態は、このようなソフトウェアタイマ1
0を用い、基準時間を10msとしたときに、40ms
の時間をカウントするカウント方法を示すものである。
FIG. 1 is a configuration diagram of a timer area of a software timer for explaining an embodiment of the present invention.
As shown in FIG. 1, this embodiment shows a software timer 10 used for an 8-bit microcomputer, and one byte of RAM is provided for each software timer.
Is assigned. That is, the 6-bit counter 11 is assigned to bits 0 to 5, the time-up flag 12 indicating that the timer has expired is assigned to bit 6, and the count enable flag 13 indicating whether the count of the software timer 10 is enabled / disabled is assigned to bit 7. It is a thing. In the present embodiment, such a software timer 1
When 0 is used and the reference time is 10 ms, 40 ms
FIG. 6 shows a counting method for counting the time.

【0043】図2は図1におけるソフトウェアタイマを
用いたカウント動作説明図であり、図3(a)〜(d)
はそれぞれ図1のカウント動作を説明するためのメイン
処理フロー図,処理モジュール1のソフトウェアタイマ
初期設定処理フロー図,内蔵タイマ割り込み処理フロー
図,処理モジュール1の処理フロー図である。なお、図
2は前述した従来例の図9に対応しており、また図3
(a)〜(d)は図10(a)〜(d)に対応してい
る。
FIG. 2 is an explanatory diagram of the counting operation using the software timer in FIG. 1, and FIGS. 3 (a) to 3 (d)
3 is a main processing flow diagram for explaining the counting operation of FIG. 1; a software timer initialization processing flow diagram of the processing module 1; a built-in timer interrupt processing flow diagram; and a processing flow diagram of the processing module 1. FIG. 2 corresponds to FIG. 9 of the conventional example described above, and FIG.
(A) to (d) correspond to FIGS. 10 (a) to (d).

【0044】まず、図3(a)のメイン処理において、
図3(d)の処理モジュール1の起動条件が成立してい
ると、図3(b)に示す処理モジュール1のソフトウェ
アタイマ初期設定処理を呼び出す。この処理モジュール
1のソフトウェアタイマ初期設定処理では、カウントし
たい時間に相当する値(40ms=10ms×4)から
−1した値、つまり3をカウンタ11に設定し、図2お
よび図3(b)の処理ステップS1に示すように、カウ
ント許可フラグ13をセット(カウント許可状態に)し
ておく。なお、他にもソフトウェアタイマを使用してい
る場合は、その初期設定をそれぞれ必要な箇所で行う。
ここで、カウントしたい時間に相当する値を−1する理
由は、従来、図8のカウンタ11aが0になったことで
タイムアップを判定していたのに対し、本実施の形態で
は、図1のカウンタ11のオーバーフローを利用してタ
イムアップを判定するためである。
First, in the main processing of FIG.
When the activation condition of the processing module 1 in FIG. 3D is satisfied, the software timer initialization processing of the processing module 1 shown in FIG. 3B is called. In the software timer initial setting processing of the processing module 1, a value obtained by subtracting -1 from a value (40 ms = 10 ms × 4) corresponding to the time to be counted, that is, 3, is set in the counter 11, and the counter shown in FIGS. As shown in processing step S1, the count permission flag 13 is set (to a count permission state). If other software timers are used, their initial settings are made at necessary places.
Here, the reason why the value corresponding to the time to be counted is decremented by one is that the time-up is determined by the counter 11a in FIG. This is to determine the time-up by utilizing the overflow of the counter 11.

【0045】つぎに、図3(c)に示す内蔵タイマの割
り込み処理において、カウント許可フラグ13が、図3
(c)の処理ステップS2のように、セットされている
と(カウント動作許可ならば)、図2の処理ステップS
3のとおり、ソフトウェアタイマ10のカウンタを−1
する。前述した従来のカウント方法では、このあとタイ
ムアップしたか否か(カウンタが0となったか否か)の
チェックを行っていたが、本実施の形態ではこのチェッ
クを行わない。
Next, in the interrupt processing of the built-in timer shown in FIG.
If it is set (if the count operation is permitted) as in the processing step S2 of (c), the processing step S2 of FIG.
As described in 3, the counter of the software timer 10 is set to -1
I do. In the above-described conventional counting method, it is checked whether or not the time has elapsed (whether or not the counter has become 0). However, in the present embodiment, this check is not performed.

【0046】このあと、図3(c)の処理ステップS7
に示すように、ソフトウェアタイマ10が複数個ある場
合は、引き続きそのソフトウェアタイマに対し、処理ス
テップS2〜S7と同様の処理を行うことになる。
Thereafter, the processing step S7 of FIG.
As shown in (1), when there are a plurality of software timers 10, the same processing as the processing steps S2 to S7 is continuously performed on the software timer.

【0047】続いて、図2および図3(c)の処理ステ
ップS4に示すように、次の内蔵タイマ割り込みで再び
カウンタ11をカウントダウンする。この減算を、図2
および図3(c)の処理ステップS3〜S6に示すよう
に、4回繰り返すと、ソフトウェアタイマ10のRAM
値が図2の処理ステップS6のように、カウンタ11の
部分がオーバーフローした形となり、事実上カウント許
可フラグ13がクリアされ、タイムアップフラグ12は
セットされたことになる。同様に、図3(c)の処理ス
テップS7に示すように、ソフトウェアタイマが複数あ
る場合は、その個数分だけ図3(c)の処理ステップS
2〜S6繰り返す。
Subsequently, as shown in the processing step S4 in FIG. 2 and FIG. 3C, the counter 11 counts down again by the next built-in timer interrupt. This subtraction is shown in FIG.
As shown in processing steps S3 to S6 in FIG.
As shown in the processing step S6 in FIG. 2, the value of the counter 11 overflows, and the count permission flag 13 is actually cleared and the time-up flag 12 is set. Similarly, as shown in processing step S7 of FIG. 3C, when there are a plurality of software timers, the number of processing timers of FIG.
Repeat steps 2 to S6.

【0048】さらに、図3(d)に示すステップS8の
ように、メイン処理から呼ばれる処理モジュール1にお
いて、該当するソフトウェアタイマ10のタイムアップ
フラグ12をチェックし、そのフラグ12がセットされ
ていると、40msが経過したということで、図3
(d)のステップS9およびステップS10に示すよう
に、タイムアップフラグのクリアと処理1を行う。ま
た、逆にタイムアップフラグ12がセットされていなけ
れば、40ms未経過ということでタイムアップフラグ
12のクリアと処理1とは、行われない。
Further, as in step S8 shown in FIG. 3D, in the processing module 1 called from the main processing, the time-up flag 12 of the corresponding software timer 10 is checked, and if the flag 12 is set. , 40 ms have passed, and FIG.
As shown in steps S9 and S10 of (d), the time-up flag is cleared and processing 1 is performed. Conversely, if the time-up flag 12 is not set, the clearing of the time-up flag 12 and the processing 1 are not performed because 40 ms has not elapsed.

【0049】本実施の形態におけるソフトウェアタイマ
のカウント方法では、図2の処理ステップS6に示すよ
うに、ソフトウェアタイマ10のタイムアップの判定処
理を行わなくてもタイムアップフラグ12がセットさ
れ、またカウント許可フラグ13のクリア処理を行わな
くてもタイムアップ時にカウント禁止状態(クリア)と
なる。
In the counting method of the software timer according to the present embodiment, as shown in the processing step S6 of FIG. Even if the permission flag 13 is not cleared, the count is prohibited (cleared) when the time is up.

【0050】上述したこれまでのソフトウェアタイマの
カウント方法の説明では、8ビットマイクロコンピュー
タの場合を例に挙げてきたが、マイクロコンピュータの
CPUのビット数が4ビット,16ビット,32ビット
などとなった場合でも同様の方法が適用可能なことはい
うまでもない。
In the above description of the counting method of the software timer, the case of the 8-bit microcomputer has been described as an example. However, the number of bits of the microcomputer CPU is 4 bits, 16 bits, 32 bits, and the like. Needless to say, the same method can be applied even in the case of the above.

【0051】かかるソフトウェアタイマのカウント方法
を用いた応用例では、前述した従来技術で説明した方法
とまったく変わりない。すなわち、これは、従来技術に
おける図6(a)のメインモジュールおよび図6(b)
の処理モジュール2と同様の処理アルゴリズムでソフト
ウェアタイマが実現できるということである。また、同
じ具体例として、エアコンのシステムに適用した場合で
も、従来技術で説明した図7と同様の処理アルゴリズム
でソフトウェアタイマの応用が可能である。
In an application example using the counting method of the software timer, there is no difference from the method described in the prior art described above. That is, this corresponds to the main module of FIG. 6 (a) and FIG.
That is, a software timer can be realized by a processing algorithm similar to that of the processing module 2. In addition, as a specific example, even when applied to an air conditioner system, a software timer can be applied with a processing algorithm similar to that of FIG. 7 described in the related art.

【0052】さらに、本実施の形態では、カウンタ11
のすぐ上のビットにタイムアップフラグ12を、このタ
イムアップフラグ12のすぐ上のビットにカウント許可
フラグ13を割り付けたが、タイムアップフラグ12と
カウント許可フラグ13の割り付け方を上下逆にした場
合でも、このフラグを参照する側〔例えば、図3(b)
の処理モジュール1のソフトウェアタイマ初期設定処
理、図3(d)の処理モジュール1〕で、タイムアップ
フラグ12とカウント許可フラグ13の論理(1/0)
を逆に解釈して使用すれば、本実施の形態におけるの図
2および図3とまったく同様の手順でソフトウェアタイ
マの制御が可能である。
Further, in the present embodiment, the counter 11
When the time-up flag 12 is assigned to the bit immediately above and the count enable flag 13 is assigned to the bit immediately above the time-up flag 12, but the way of assigning the time-up flag 12 and the count enable flag 13 is reversed. However, the side that refers to this flag [for example, FIG.
3 (d), the logic (1/0) of the time-up flag 12 and the count permission flag 13
Is interpreted in reverse, and the software timer can be controlled in exactly the same procedure as in FIGS. 2 and 3 in the present embodiment.

【0053】しかも、本実施の形態では、カウンタ領域
11〜13をダウンカウントする例を述べたが、アップ
カウントとした場合でも図3の処理フローと同様の手順
でソフトウェアタイマの制御が可能である。この場合
は、カウンタ領域11〜13にカウントしたい値の2の
補数(カウントしたい値をビット反転して+1した値)
を初期設定すればよい。例えば、1をカウントしたい場
合は、カウンタ領域11〜13にFFH(16進数でF
F)を設定すれば、1回カウントしたときにカウンタ領
域11〜13の値は00Hとなり、図2のステップS6
に示すように、タイムアップフラグ12の論理(1/
0)が逆の状態となる。この場合は、このフラグを参照
する側〔例えば、図3(d)の処理モジュール1〕で、
タイムアップフラグ12の論理(1/0)を逆に解釈し
て使用すればよい。このとき、図2のステップS6にお
けるカウンタ11は、ダウンカウントした場合とアップ
カウントした場合とでタイムアップ時の値が異なるが、
タイムアップ時のステップS6におけるカウンタ11の
値は使用しないため、まったく問題がない。
Further, in this embodiment, an example has been described in which the counter areas 11 to 13 are down-counted. However, even in the case of up-counting, the software timer can be controlled in the same procedure as the processing flow of FIG. . In this case, the two's complement of the value to be counted in the counter areas 11 to 13 (the value obtained by inverting the bit to be counted and adding +1)
Should be initialized. For example, if you want to count 1, FFH (hexadecimal F
If F) is set, the value of the counter areas 11 to 13 becomes 00H when counting is performed once, and the value of step S6 in FIG.
As shown in the figure, the logic of the time-up flag 12 (1 /
0) is in the opposite state. In this case, the side that refers to this flag [for example, the processing module 1 in FIG.
The logic (1/0) of the time-up flag 12 may be interpreted in reverse and used. At this time, the value of the counter 11 in step S6 in FIG.
Since the value of the counter 11 in step S6 at time-up is not used, there is no problem at all.

【0054】このように、タイムアップフラグ12とカ
ウント許可フラグ13をカウンタ11の上位ビットに配
置しておきさえすれば、タイムアップフラグ12とカウ
ント許可フラグ13の配置順については、本実施の形態
のように配置する場合と、上下逆に配置する場合との2
通りが考えられる。また、カウンタ領域11〜13のカ
ウント方法については、本実施例のようにダウンカウン
トする場合と、アップカウントする場合との2通りの実
現が可能である。
As described above, as long as the time-up flag 12 and the count permission flag 13 are arranged in the upper bits of the counter 11, the arrangement order of the time-up flag 12 and the count permission flag 13 in this embodiment is not limited. And the case where it is arranged upside down.
The street is conceivable. As for the counting method of the counter areas 11 to 13, two kinds of realization are possible, that is, the case of counting down as in this embodiment and the case of counting up.

【0055】[0055]

【発明の効果】以上説明したように、本発明のタイマカ
ウンタのカウント方法は、あらかじめ定められた所定の
値をカウントしたとき、記憶領域上に設けられたフラグ
領域にフラグを設定するにあたり、複数のフラグ領域と
タイマカウンタ領域を連続した記憶領域に設け且つこれ
らフラグ領域のビットデータをタイマカウンタ領域のビ
ットデータの上位ビット領域に設けることにより、カウ
ント時にフラグとタイマカウンタのビットデータとを連
続したタイマカウンタ領域としてカウントアップまたは
カウントダウン処理することができるので、従来のソフ
トウェアタイマのカウンタを減算するたびに行っていた
タイムアップの判定やタイムアップ時に行っていたタイ
ムアップフラグのセットおよびカウント許可フラグのク
リア処理を不要にでき、タイムアップ時の処理を従来の
半分以下にすることができるという効果がある。すなわ
ち、マイコンの命令にして5命令を2命令にでき、処理
時間を半分以下にすることができる。要するに、本発明
によれば、従来例で問題となっていたソフトウェアタイ
マ以外の割り込み処理の受け付けの遅れを半分以下に低
減できることになる。
As described above, the counting method of the timer counter according to the present invention, when counting a predetermined value, sets a plurality of flags in the flag area provided on the storage area. The flag area and the timer counter area are provided in a continuous storage area, and the bit data of these flag areas are provided in the upper bit area of the bit data of the timer counter area. Since the count-up or count-down process can be performed as the timer counter area, the time-up judgment that was performed each time the counter of the conventional software timer is decremented, the setting of the time-up flag that was performed at the time of time-up, and the setting of the count enable flag are performed. No need to clear Come, there is an effect that the processing at the time of time-up can be less than or equal to half of the conventional. In other words, five instructions can be reduced to two instructions, and the processing time can be reduced to half or less. In short, according to the present invention, it is possible to reduce the delay of acceptance of interrupt processing other than the software timer, which has been a problem in the conventional example, to less than half.

【0056】例えば、具体例として挙げたエアコン室内
機および室外機のファンモータ制御システムにおいて、
ソフトウェアタイマをカウントするタイマ割り込み処理
の開始直後に発生した位相信号の割り込み処理受け付け
の遅れ時間が、従来は300μsであったのに対し、本
発明では150μs以下にできるため、モータの回転速
度制御の精度を数段向上させることができる。このこと
は、モータの位相信号入力の周期(モータの回転周期)
が1msである場合、従来方法では実際の位相信号入力
の周期に対するソフトウェアでの位相信号検知タイミン
グのずれ(遅れ)の比率が30%程度(約300μs÷
1ms)であったのに対し、本発明では15%以下(≒
150μs÷1ms)に低減されることになる。したが
って、モータの回転速度制御の精度は約1.2倍向上す
る。
For example, in a fan motor control system for an indoor unit and an outdoor unit of an air conditioner as specific examples,
The delay time for accepting the interrupt processing of the phase signal generated immediately after the start of the timer interrupt processing for counting the software timer can be reduced to 150 μs or less in the present invention, compared to 300 μs in the related art. Accuracy can be improved by several steps. This means that the period of the motor phase signal input (motor rotation period)
Is 1 ms, in the conventional method, the ratio of the shift (delay) of the phase signal detection timing by software to the actual phase signal input cycle is about 30% (about 300 μs ÷).
1 ms), but 15% or less (≒
(150 μs ÷ 1 ms). Therefore, the accuracy of the rotation speed control of the motor is improved about 1.2 times.

【0057】また、本発明のカウント方法は、タイマの
個数が多ければ多いほど、システム全体の処理時間に対
するソフトウェアタイマのカウント処理時間の占める比
率の低減を図ることができるので、その分CPUの空き
時間を増加することができるという効果がある。すなわ
ち、システム全体の処理時間に余裕ができ、その時間を
他の処理に割り当てることができる。
Further, in the counting method of the present invention, as the number of timers increases, the ratio of the count processing time of the software timer to the processing time of the entire system can be reduced. The effect is that the time can be increased. That is, the processing time of the entire system can be spared, and the time can be allocated to other processing.

【0058】さらに、本発明は、前述したように命令数
を従来の半分以下にできるため、ソフトウェアタイマカ
ウント処理のプログラムサイズも従来の半分以下にでき
るという効果もある。
Further, as described above, the present invention can reduce the number of instructions to less than half of the conventional one, so that the program size of the software timer counting process can be reduced to less than half of the conventional one.

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

【図1】本発明の一実施の形態を説明するためのソフト
ウェアタイマのタイマエリア構成図である。
FIG. 1 is a configuration diagram of a timer area of a software timer for describing an embodiment of the present invention.

【図2】図1におけるソフトウェアタイマを用いたカウ
ント動作説明図である。
FIG. 2 is an explanatory diagram of a counting operation using a software timer in FIG. 1;

【図3】図1のカウント動作を説明するためのメイン処
理,処理モジュール1のソフトウェアタイマ初期設定処
理,内蔵タイマ割り込み処理,処理モジュール1の処理
を表わすフロー図である。
3 is a flowchart showing a main process for explaining a counting operation in FIG. 1, a software timer initialization process of the processing module 1, an internal timer interrupt process, and a process of the processing module 1. FIG.

【図4】従来の内蔵タイマカウンタによる任意時間のカ
ウント処理におけるメインモジュール処理およびタイマ
割り込み処理のフロー図である。
FIG. 4 is a flowchart of a main module process and a timer interrupt process in a count process of an arbitrary time by a conventional built-in timer counter.

【図5】従来の内蔵タイマカウンタによる任意時間のカ
ウント処理におけるメインモジュール処理フロー図であ
る。
FIG. 5 is a flowchart of a main module process in a count process of an arbitrary time by a conventional built-in timer counter.

【図6】従来のソフトウェアタイマを用いて任意時間の
カウント処理を行う際のメインモジュール処理,処理モ
ジュール2の処理および内蔵タイマ割り込みモジュール
処理を表わすフロー図である。
FIG. 6 is a flowchart showing a main module process, a process of a processing module 2, and a built-in timer interrupt module process when performing a count process of an arbitrary time using a conventional software timer.

【図7】従来のソフトウェアタイマによる任意時間のカ
ウントをエアコンシステムに応用した場合のメインモジ
ュール処理,室温制御モジュール処理おおよび内蔵タイ
マ割り込みモジュール処理を表わすフロー図である。
FIG. 7 is a flowchart showing a main module process, a room temperature control module process, and a built-in timer interrupt module process when an arbitrary time count by a conventional software timer is applied to an air conditioner system.

【図8】従来のソフトウェアタイマ1個のタイマエリア
構成図である。
FIG. 8 is a configuration diagram of a timer area of one conventional software timer.

【図9】図8におけるソフトウェアタイマを用いたカウ
ント動作説明図である。
9 is an explanatory diagram of a counting operation using a software timer in FIG.

【図10】図9のカウント動作を説明するためのメイン
処理,処理モジュール3のソフトウェアタイマ初期設定
処理,内蔵タイマ割り込み処理,処理モジュール3の処
理を表わすフロー図である。
10 is a flowchart showing a main process, a software timer initialization process of the processing module 3, an internal timer interrupt process, and a process of the processing module 3 for explaining the counting operation of FIG.

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

10 ソフトウェアタイマ 11 カウンタ 12 タイムアップフラグ 13 カウント許可フラグ 10 Software timer 11 Counter 12 Time-up flag 13 Count enable flag

Claims (3)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 所定の周期で割り込みを発生し、その割
り込みによって記憶領域上に設けられたタイマカウンタ
領域の値をカウントアップまたはカウントダウン処理す
ることにより時間をカウントするにあたり、あらかじめ
定められた所定の値をカウントしたとき、前記記憶領域
上に設けられたフラグ領域にフラグを設定するタイマカ
ウンタのカウント方法において、前記フラグ領域と前記
タイマカウンタ領域を連続した記憶領域に設けるととも
に、前記フラグ領域のビットデータを前記タイマカウン
タ領域のビットデータの上位ビット領域に設け、カウン
ト時に前記フラグと前記タイマカウンタのビットデータ
とを連続したタイマカウンタ領域としてカウントアップ
またはカウントダウン処理することを特徴とするタイマ
カウンタのカウント方法。
An interrupt is generated at a predetermined cycle, and when the time is counted by counting up or down a value of a timer counter area provided in a storage area by the interrupt, a predetermined predetermined time is counted. In a timer counter counting method of setting a flag in a flag area provided on the storage area when counting the value, the flag area and the timer counter area are provided in a continuous storage area, and a bit of the flag area is set. Timer counter counting, characterized in that data is provided in an upper bit area of the bit data of the timer counter area, and when counting, the flag and the bit data of the timer counter are counted up or down as a continuous timer counter area. Method.
【請求項2】 前記フラグ領域の1ビットは、前記カウ
ンタ領域の上位ビットにタイムアップフラグとして設け
た請求項1記載のタイマカウンタのカウント方法。
2. The timer counter counting method according to claim 1, wherein one bit of the flag area is provided as a time-up flag in an upper bit of the counter area.
【請求項3】 前記フラグ領域の1ビットは、前記カウ
ンタ領域の上位ビットにカウント許可フラグとして設け
た請求項1記載のタイマカウンタのカウント方法。
3. The counting method of a timer counter according to claim 1, wherein one bit of the flag area is provided as a count permission flag in an upper bit of the counter area.
JP7311257A 1995-11-29 1995-11-29 Timer counter counting method Expired - Lifetime JP2984591B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP7311257A JP2984591B2 (en) 1995-11-29 1995-11-29 Timer counter counting method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP7311257A JP2984591B2 (en) 1995-11-29 1995-11-29 Timer counter counting method

Publications (2)

Publication Number Publication Date
JPH09153790A JPH09153790A (en) 1997-06-10
JP2984591B2 true JP2984591B2 (en) 1999-11-29

Family

ID=18014975

Family Applications (1)

Application Number Title Priority Date Filing Date
JP7311257A Expired - Lifetime JP2984591B2 (en) 1995-11-29 1995-11-29 Timer counter counting method

Country Status (1)

Country Link
JP (1) JP2984591B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6582394B2 (en) * 2014-11-11 2019-10-02 株式会社明電舎 Counter unit
KR102019378B1 (en) * 2017-06-19 2019-09-06 현대오트론 주식회사 Appartus for monitoring microcontroller unit, system having the same and operating method thereof

Also Published As

Publication number Publication date
JPH09153790A (en) 1997-06-10

Similar Documents

Publication Publication Date Title
US6145027A (en) DMA controller with split channel transfer capability and FIFO buffering allowing transmit channel to get ahead of corresponding receive channel by preselected number of elements
JP2984591B2 (en) Timer counter counting method
CN111023416B (en) Oil return control method and device and multi-split air conditioner
US8726099B2 (en) Data processing system
JP2677719B2 (en) Information processing device
JP3214469B2 (en) Method and apparatus for controlling writing of flash EEPROM by microcomputer
JP2773546B2 (en) Pulse generation circuit
US6046965A (en) Timer device having timer counter
JPH09251387A (en) Interruption request priority deciding circuit
RU2265240C2 (en) System control module
JP2738141B2 (en) Single chip microcomputer
JPH04253244A (en) Circuit for protecting data in memory case of program run-away
JPH09261784A (en) Control equipment control system
CN1277205C (en) Method for setting system operating frequency
JP2877465B2 (en) Data transfer control method to memory bank
JPS6126478A (en) Gate controller of inverter
JPH03134732A (en) Buffer controller
JPH11162184A (en) Data writing method for a semiconductor memory
JP2618117B2 (en) Reload timer circuit
JPH07311695A (en) Run-away monitor timer circuit device
JPH10161908A (en) Detection of run-away of microcomputer
JP2003067221A (en) Watchdog timer control circuit
JPH02250116A (en) Control method for discriminating kind of cpu and clock speed
JPH09237205A (en) Program runaway detection device
JP2007280080A (en) Stop method for control processing

Legal Events

Date Code Title Description
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 19990907