JP3338722B2 - Counter circuit - Google Patents

Counter circuit

Info

Publication number
JP3338722B2
JP3338722B2 JP22627593A JP22627593A JP3338722B2 JP 3338722 B2 JP3338722 B2 JP 3338722B2 JP 22627593 A JP22627593 A JP 22627593A JP 22627593 A JP22627593 A JP 22627593A JP 3338722 B2 JP3338722 B2 JP 3338722B2
Authority
JP
Japan
Prior art keywords
signal
circuit
input
level
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 - Fee Related
Application number
JP22627593A
Other languages
Japanese (ja)
Other versions
JPH0786922A (en
Inventor
光充 西村
Original Assignee
エヌイーシーマイクロシステム株式会社
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 エヌイーシーマイクロシステム株式会社 filed Critical エヌイーシーマイクロシステム株式会社
Priority to JP22627593A priority Critical patent/JP3338722B2/en
Publication of JPH0786922A publication Critical patent/JPH0786922A/en
Application granted granted Critical
Publication of JP3338722B2 publication Critical patent/JP3338722B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Landscapes

  • Microcomputers (AREA)

Description

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

【0001】[0001]

【産業上の利用分野】本発明はカウンタ回路に関し、特
にワッチップ・マイクロコンピュータに内蔵され、外部
クロック信号入力を計数するカウンタ回路に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a counter circuit, and more particularly to a counter circuit built in a chip microcomputer for counting an external clock signal input.

【0002】[0002]

【従来の技術】近年、マイクロコンピュータの応用分野
は急速に拡大しており、多方面において活用されてい
る。特に、最近においては、OA化およびFA化等の分
野において、物体を駆動するモータの制御用として使用
されることが多くなってきている。このようなモータの
制御用として使用する場合には、モータ制御用に適した
ハードウェアを備えたマイクロコンピュータが必要とな
る。
2. Description of the Related Art In recent years, the application fields of microcomputers have been rapidly expanding, and microcomputers are being used in various fields. In particular, recently, in the fields of OA, FA, and the like, it is increasingly used for controlling a motor that drives an object. When used for controlling such a motor, a microcomputer including hardware suitable for controlling the motor is required.

【0003】一般に、マイクロコンピュータの構成は図
6に示されるとうり、外付け回路28に対応して、当該
マイクロコンピュータ24は、モメリ25、CPU26
および周辺制御回路27により構成されており、メモリ
25内に格納されている命令に従ってCPU26におい
て演算処理が行われ、周辺制御回路27による種々の制
御信号およびステータス信号等の入出力制御作用を介し
て、外付け機器28に対する制御が行われる。本発明
は、外付け機器28よりマイクロコンピュータ24に入
力されるパルス信号をカウントするカウンタ回路に関
し、以下、当該カウンタ回路の従来例について説明す
る。
In general, as shown in FIG. 6, a microcomputer 24 has a microcomputer 25 and a CPU 26 corresponding to an external circuit 28.
And a peripheral control circuit 27. The CPU 26 performs arithmetic processing in accordance with instructions stored in the memory 25, and performs various control signals and status signal input / output operations by the peripheral control circuit 27. , The external device 28 is controlled. The present invention relates to a counter circuit that counts pulse signals input from an external device 28 to the microcomputer 24. Hereinafter, a conventional example of the counter circuit will be described.

【0004】図7は、従来の、この種のカウンタ回路の
構成を示す図であり、データのビット数が8ビットの場
合の一例である。図7に示されるように、本従来例は、
データバス201、バス202およびカウンタバス20
3に対応して、OR回路1と、ぞれぞれバス202およ
びカウンタバス203に対するバス接続機能を有するト
ランスファゲート2および6と、コンペアレジスタ3お
よび4と、インバータ5と、カウンタ7と、クリア回路
29と、インクリメンタ9と、リード/ライト制御回路
10とを備えて構成される。また、図8は本従来例にお
けるインクリメンタ9およびクリア回路29の内部構成
を示す図であり、インクリメンタ9は、8ビット値に対
応する加算器22-0、22-1、………、22-7により構
成され、クリア回路29は、8ビット値に対応するAN
D回路19-0、19-1、………、19-7および30と、
同様に、それぞれ8ビット値に対応するトランスファゲ
ート20-0、20-1、………、20-7ならびに21-0
20-1、………、21-7と、OR回路31と、インバー
タ17および32と、RSフリップフロップ33と、D
ラッチ34とを備えて構成される。なお、インクリメン
タ9を構成する加算器22-0および加算器22-1は、そ
れぞれ最下位ビットおよび次の上位ビットに対応する加
算器であり、加算器22-7は最上位ビットに対応する加
算器である。その他のビットに対応する加算器は、全て
記載が省略されている。また、図9(a)、(b)、
(c)、(d)、(e)、(f)、(g)、(h)、
(i)および(j)は、本従来例の動作状態を示すタイ
ミング図である。
FIG. 7 is a diagram showing the configuration of a conventional counter circuit of this type, and is an example in which the number of data bits is eight. As shown in FIG.
Data bus 201, bus 202 and counter bus 20
3, transfer gates 2 and 6, each having a bus connection function to bus 202 and counter bus 203, compare registers 3 and 4, inverter 5, counter 7, and clear, respectively. It comprises a circuit 29, an incrementer 9, and a read / write control circuit 10. FIG. 8 is a diagram showing the internal configuration of the incrementer 9 and the clear circuit 29 in the conventional example. The incrementer 9 includes adders 22 -0 , 22 -1 ,... 22 -7 , and the clear circuit 29 includes an AN corresponding to an 8-bit value.
D circuits 19 -0 , 19 -1 ,..., 19 -7 and 30;
Similarly, transfer gates 20 -0 , 20 -1 ,..., 20 -7 and 21 -0 , each corresponding to an 8-bit value,
20 -1 ,..., 21 -7 , OR circuit 31, inverters 17 and 32, RS flip-flop 33, D
And a latch 34. Incidentally, the adder 22 -0 and the adder 22 -1 constituting the incrementer 9 are each adder corresponding to the least significant bit and the next higher-order bit, adder 22-7 corresponds to the most significant bit It is an adder. The description of the adders corresponding to the other bits is omitted. 9 (a), 9 (b),
(C), (d), (e), (f), (g), (h),
(I) and (j) are timing charts showing the operation state of the conventional example.

【0005】図7において、CPU26(図6参照)よ
り出力されるアドレス信号106、リード信号107お
よびライト信号108は、周辺制御回路27に含まれる
当該カウンタ回路のOR回路1およびリード/ライト制
御回路10に入力される。リード/ライト制御回路10
においては、これらのアドレス信号106、リード信号
107およびライト信号108の入力を受けて、選択信
号109、110、111および112が生成されて出
力され、選択信号109および110はコンペアレジス
タ3に入力され、選択信号111および112はコンペ
アレジスタ4に入力される。また、OR回路1において
は、リード信号107およびライト信号108の入力を
受けて、リード時およびライト時の何れの場合において
も、それぞれ“1”レベルが出力され、トランスファゲ
ート2のゲートに入力される。これによりトランスファ
ゲート2はオンの状態となり、データバス201はトラ
ンスファゲート2およびバス202を介してコンペアレ
ジスタ3および4に連結される。この状態においては、
当該データバス201を介して、各コンペアレジスタの
値の読み出しが行われ、或はまた、データバス201上
のデータの各コンペアレジスタに対する書き込みが行わ
れる。
In FIG. 7, an address signal 106, a read signal 107, and a write signal 108 output from the CPU 26 (see FIG. 6) are provided by an OR circuit 1 and a read / write control circuit of the counter circuit included in the peripheral control circuit 27. 10 is input. Read / write control circuit 10
Receives input of these address signal 106, read signal 107 and write signal 108, selection signals 109, 110, 111 and 112 are generated and output, and selection signals 109 and 110 are input to compare register 3. , Select signals 111 and 112 are input to the compare register 4. In addition, the OR circuit 1 receives the input of the read signal 107 and the write signal 108, and outputs a “1” level in both cases of reading and writing, and inputs the “1” level to the gate of the transfer gate 2. You. As a result, the transfer gate 2 is turned on, and the data bus 201 is connected to the compare registers 3 and 4 via the transfer gate 2 and the bus 202. In this state,
The value of each compare register is read out via the data bus 201, or the data on the data bus 201 is written into each compare register.

【0006】システムクロック101が“0”レベルの
時にはインバータ5を介して“1”レベルがトランスフ
ァゲート6のゲートに入力され、これによりオン状態と
なるトランスファゲート6およびカウンタバス203を
介して、カウンタ7における計数値がコンペアレジスタ
3および4に入力され、これらのコンペアレジスタ3お
よび4においては、書き込まれたデータとカウンタ7に
おける計数値とが比較される。コンペアレジスタ3およ
び4における比較結果が一致する場合には、それぞれ一
致信号105および104が出力され、それぞれ割り込
み要求信号としてCPU26(図6参照)に出力され
る。また一致信号104はクリア信号としてクリア回路
29にも入力される。
When the system clock 101 is at the "0" level, the "1" level is input to the gate of the transfer gate 6 via the inverter 5, and the counter is then turned on via the transfer gate 6 and the counter bus 203 which are turned on. The count value at 7 is input to compare registers 3 and 4, where the written data is compared with the count value at counter 7. When the comparison results in compare registers 3 and 4 match, match signals 105 and 104 are output, respectively, and output to CPU 26 (see FIG. 6) as interrupt request signals, respectively. The coincidence signal 104 is also input to the clear circuit 29 as a clear signal.

【0007】カウンタ7には8ビットの値が保持されて
おり、その値はクリア回路29に入力される。外部クロ
ック信号103が“1”レベルの時にはインクリメンタ
9においてインクリメント(+1)され、クリア回路2
9を介してカウンタ7に書き戻され、また外部クロック
信号103が“0”レベルの時にはインクリメントは行
われない。クリア回路29にシステムリセット信号10
2が入力される場合、またはコンペアレジスタ4より一
致信号104が出力されて、クリア信号としてクリア回
路29に入力される場合には、カウンタ7に書き戻され
る値は強制的に“00H”にクリアされる。
The counter 7 holds an 8-bit value, and the value is input to a clear circuit 29. When the external clock signal 103 is at “1” level, the increment is incremented (+1) by the incrementer 9 and the clear circuit 2
When the external clock signal 103 is at the "0" level, the increment is not performed. The system reset signal 10 is applied to the clear circuit 29.
When 2 is input, or when the match signal 104 is output from the compare register 4 and input to the clear circuit 29 as a clear signal, the value written back to the counter 7 is forcibly cleared to “00H”. Is done.

【0008】次に、図8のインクリメンタ9およびクリ
ア回路29の内部構成図と、図9(a)、(b)、
(c)、(d)、(e)、(f)、(g)、(h)、
(i)のタイミング図を参照して、カウンタ値のインク
リメントとクリアに関する動作について説明する。な
お、図8においては、インクリメンタ9およびクリア回
路29における各ビットに対応する部分の回路構成はそ
れぞれ同一であり、各ビットに対応する部分の回路にお
いては、全て同様の動作が行われるため、以下の説明に
おいては、最下位ビットに対応する部分の回路について
のみ動作説明を行うものとする。
Next, the internal configuration of the incrementer 9 and the clear circuit 29 shown in FIG. 8 and FIGS.
(C), (d), (e), (f), (g), (h),
The operation related to increment and clear of the counter value will be described with reference to the timing chart of (i). In FIG. 8, the circuit configuration of the portion corresponding to each bit in the incrementer 9 and the clear circuit 29 is the same, and the circuits of the portion corresponding to each bit all perform the same operation. In the following description, the operation will be described only for the circuit corresponding to the least significant bit.

【0009】インクリメンタ9に含まれる最下位ビット
に対応する加算器22-0に対しては、外部クロック信号
103がA端子に入力されるとともに、システムクロッ
ク信号101の“1”レベルの期間においてオンの状態
となるトランスファゲート21-0を介して、最下位ビッ
トQ0 がB端子に入力される。加算器22-0において
は、外部クロック信号103と最下位ビットQ0 との加
算が行われ、その加算値はのQ端子より出力されてAN
D回路19-0に入力される。なお、この場合、桁上げが
ある場合には、CY端子より“1”レベルが出力されて
次の上位ビットの加算器22-1のA端子に入力され、次
の上位ビットに対応する加算器22-1のA端子に入力さ
れて、同様な手順によりビットQ1 との加算が行われ
る。以下、同様にして、カウンタバス203に対応し
て、Q2 、Q3 、Q4 、Q5 、Q6 およびQ7 を含む各
ビットに対して、それぞれ対応する下位ビットからの桁
上げ出力との加算が行われる。
The external clock signal 103 is input to the A terminal of the adder 22-0 corresponding to the least significant bit included in the incrementer 9, and during the period of the "1" level of the system clock signal 101, The least significant bit Q 0 is input to the B terminal via the transfer gate 21-0 which is turned on. In the adder 22 -0 is performed the addition of the external clock signal 103 and the least significant bit Q 0, is output from the Q terminal of the added value is AN
It is input to the D circuit 19-0 . In this case, if there is a carry is "1" level is outputted from the CY terminal is inputted to the A terminal of the next higher bit adder 22 -1, adder corresponding to the next significant bit It is input to the a terminal of the 22 -1 and adding a bit Q 1 is performed by a similar procedure. Hereinafter, similarly, for each bit including Q 2 , Q 3 , Q 4 , Q 5 , Q 6, and Q 7 corresponding to the counter bus 203, the carry output from the corresponding lower-order bit and Are added.

【0010】一方において、システムリセット信号10
2およびクリア信号104がOR回路31に入力されて
おり、これらのシステムリセット信号102またはクリ
ア信号104の何れかが“1”レベルになると、“1”
レベルの信号が出力されてインバータ32およびRSフ
リップフロップ33のR端子に入力される。インバータ
32の出力はAND回路30に入力されており、AND
回路30においては、当該インバータ32の出力と外部
クロック信号103の論理積がとられて、その出力はR
Sフリップフロップ33のS端子に入力される。また、
システムクロック信号101はインバータ17により反
転されて、RSフリップフロップ33のC端子に入力さ
れるとともに、トランスファゲート20-0、20-1、…
……、20-7のゲートにも入力されている。
On the other hand, the system reset signal 10
2 and the clear signal 104 are input to the OR circuit 31, and when either of the system reset signal 102 or the clear signal 104 becomes "1" level, "1" is output.
The level signal is output and input to the R terminals of the inverter 32 and the RS flip-flop 33. The output of the inverter 32 is input to the AND circuit 30, and
In the circuit 30, the logical product of the output of the inverter 32 and the external clock signal 103 is obtained, and the output is R
The signal is input to the S terminal of the S flip-flop 33. Also,
The system clock signal 101 is inverted by the inverter 17 and input to the C terminal of the RS flip-flop 33, and at the same time, the transfer gates 20 -0 , 20 -1 ,.
..., it is also input to the gate of the 20 -7.

【0011】今、コンペアレジスタ4には“00H”が
書き込まれているものとする。図9(a)に示されるス
テージAまでの期間においては、システムリセット信号
102が“1”レベルとなっているために、OR回路3
1よりは“1”レベルのシステムリセット信号102が
出力されて、RSフリップフロップ33のR端子に入力
される。これにより、RSフリップフロップ33はリセ
ット状態となり、Q端子出力信号116は“0”レベル
で出力される。このQ端子出力信号116は、Dラッチ
34を介して各ビットに対応するAND回路19-0、1
-1、………、19-7に入力されており、これらのAN
D回路の出力は全て“0”レベルとなる。従って、シス
テムリセット期間中においては、各ビットQ0 、Q1 、
………、Q7 としては、全て“00H”が出力されてカ
ウンタ7の値は“00H”に初期化される。
It is now assumed that "00H" is written in the compare register 4. In the period up to stage A shown in FIG. 9A, since the system reset signal 102 is at the “1” level, the OR circuit 3
A “1” level system reset signal 102 is output from “1” and input to the R terminal of the RS flip-flop 33. As a result, the RS flip-flop 33 is reset, and the Q terminal output signal 116 is output at the “0” level. The Q terminal output signal 116 is supplied to the AND circuits 19 -0 , 1
9 -1 ,..., 19 -7 ,
The outputs of the D circuits all become "0" level. Therefore, during the system reset period, each bit Q0, Q1,.
,..., Q7 are all output "00H" and the value of the counter 7 is initialized to "00H".

【0012】次に、ステージAにおいて、システムリセ
ット信号102が“1”レベルから“0”レベルに変化
したものとする。この場合には、システムリセット信号
102およびクリア信号104は、双方ともに“0”レ
ベルであるため、OR回路31からは“0”レベルの信
号が出力され、RSフリップフロップ33のR端子に入
力されるとともに、インバータ32を介してAND回路
30には“1”レベルの信号が入力される。図9(a)
のステージAにおいては、外部クロック信号103は
“0”レベルの状態にあるため、AND回路30の出力
信号は“0”レベルの状態のままであり以前と変わると
ころはない。しかし、ステージBにおいては、外部クロ
ック信号103が“1”レベルに変化するために、AN
D回路30の出力信号は“1”レベルとなり、RSフリ
ップフロップ33のS端子に“1”レベルが入力され
る。図9のステーズBにおいて、システムクロック信号
101が“0”レベルになった時には、これにより、R
Sフリップフロップ33のQ端子出力信号116は
“1”レベルとなり、Dラッチ34に入力される。Dラ
ッチ34のC端子には、システムクロック信号101
が、インバータ17により反転されて入力されており、
ステージCにおいてシステムクロック信号101が
“1”レベルとなった状態において、Dラッチ34は
“1”レベルとなる。しかし、ステージBにおいては、
Dラッチは未だ“0”レベルの状態にあるため、Dラッ
チ34のQ出力信号は“0”レベルで出力され、各ビッ
トに対応するAND回路19-0、19-1、………、19
-7に入力される。従って、ステージBにおいて最初の外
部クロック信号103が入力されてはいるものの、カウ
ンタ7の値は“00H”のままでありカウントアップは
行われない。
Next, in the stage A, it is assumed that the system reset signal 102 has changed from "1" level to "0" level. In this case, since both the system reset signal 102 and the clear signal 104 are at “0” level, a signal of “0” level is output from the OR circuit 31 and input to the R terminal of the RS flip-flop 33. At the same time, a “1” level signal is input to the AND circuit 30 via the inverter 32. FIG. 9 (a)
In the stage A, since the external clock signal 103 is at the "0" level, the output signal of the AND circuit 30 remains at the "0" level and remains unchanged. However, in stage B, since the external clock signal 103 changes to “1” level,
The output signal of the D circuit 30 becomes “1” level, and the “1” level is input to the S terminal of the RS flip-flop 33. In the stage B of FIG. 9, when the system clock signal 101 becomes “0” level,
The Q terminal output signal 116 of the S flip-flop 33 becomes “1” level and is input to the D latch 34. The system clock signal 101 is connected to the C terminal of the D latch 34.
Are inverted by the inverter 17 and input.
In the state where the system clock signal 101 is at the “1” level in stage C, the D latch 34 is at the “1” level. However, in stage B,
Since the D latch is still at the "0" level, the Q output signal of the D latch 34 is output at the "0" level, and AND circuits 19 -0 , 19 -1 ,...
-7 is entered. Therefore, although the first external clock signal 103 is input in the stage B, the value of the counter 7 remains "00H" and the count is not performed.

【0013】次いで、ステージDにおいて、次の外部ク
ロック信号103が入力されたものとすると、この時点
においては、Dラッチ34のQ端子出力信号は“1”レ
ベルの状態にあるため、ステージDにおけるシステムク
ロック信号101が“0”レベルの状態にあるタイミン
グにおいて、加算器22-0における外部クロック信号1
03とビットQ0 との加算結果“1”は、AND回路1
-0およびトランスファゲート20-0を介して、ビット
0 として出力され、カウンタ7に“00H”が書き戻
される。以下同様にして、カウンタ7におけるカウント
アップが行われる。
Next, assuming that the next external clock signal 103 has been input at stage D, the Q terminal output signal of D latch 34 is at the "1" level at this time. At the timing when the system clock signal 101 is at the “0” level, the external clock signal 1 in the adder 22-0 is output.
03 and bit Q 0 are added to the AND circuit 1
9 through -0 and transfer gate 20 -0, output as bits Q 0, "00H" is written back to the counter 7. Thereafter, the counter 7 counts up in the same manner.

【0014】ステージFにおいてカウンタ7の値が“0
2H”になった時に、システムクロック信号101が
“0”レベルとなるタイミングにおいて、コンペアレジ
スタ4より一致信号(クリア信号)104が出力され
る。このクリア信号104は、OR回路31を介して、
当該ステージFのシステムクロック信号101が“0”
レベルとなるタイミングにおいて、RSフリップフロッ
プ33のR端子に入力される。これによりRSフリップ
フロップ33のQ端子出力信号116は“0”レベルと
なる。ステージGにおけるシステムクロック信号101
が“1”レベルとなるタイミングにおいては、Dラッチ
34のQ端子出力は“0”レベルとなり、AND回路1
-0、19-1、………、19-7に入力され、これにより
これらのAND回路出力は、対応する加算器22-0、2
2-1、………、22-7より出力される加算結果の如何を
関せず“0”レベルとなる。また、ステージHにおい
て、システムクロック信号101が“0”レベルのタイ
ミングにおいては、トランスファゲート20-0、2
-1、………、20-7のゲートには、それぞれ“1”レ
ベルが入力される状態となり、これにより、これらの各
トランスファゲートは、全てオンの状態となり、上記の
AND回路19-0、19-1、………、19-7の“0”レ
ベル出力は、それぞれ対応するトランスファゲートを介
してビットQ0 、Q1 、…………、Q7 として出力され
る。従って、ステージHのシステムクロック信号が
“0”レベルとなるタイミングにおいて、カウンタ7は
“00H”に初期化される。
In the stage F, the value of the counter 7 becomes "0".
When the signal becomes 2H, the match signal (clear signal) 104 is output from the compare register 4 at the timing when the system clock signal 101 becomes "0" level.
The system clock signal 101 of the stage F is “0”
At the timing of the level, it is input to the R terminal of the RS flip-flop 33. As a result, the Q terminal output signal 116 of the RS flip-flop 33 becomes “0” level. System clock signal 101 in stage G
Is at the "1" level, the Q terminal output of the D latch 34 is at the "0" level, and the AND circuit 1
9 -0 , 19 -1 ,..., 19 -7 , whereby the outputs of these AND circuits are supplied to the corresponding adders 22-0, 2
..,..., Regardless of the addition result output from 22-7. Further, in stage H, in the timing of the system clock signal 101 is "0" level, the transfer gate 20 - 0,2
0 -1, ........., the 20 -7 gate of a state in which each "1" level is inputted, thereby, each of these transfer gates, all become on, the above AND circuit 19 - 0, 19 -1, ........., "0" level output of 19 -7, bit Q 0 through respective transfer gates, Q 1, ............, it is outputted as a Q 7. Therefore, at the timing when the system clock signal of the stage H becomes “0” level, the counter 7 is initialized to “00H”.

【0015】このように、カウンタ7においては、カウ
ントしたい数“n”から1を減じた数“n−1”をコン
ペアレジスタ4に書き込んでおくことにより、外部クロ
ック信号が入力されるたびに、0、1、2、…………、
(n−1)、0、1、2、…………という具合にnの周
期でカウントアップ/クリアという計数動作が繰返して
行われる。
As described above, in the counter 7, the number "n-1" obtained by subtracting 1 from the number "n" to be counted is written in the compare register 4, so that each time an external clock signal is input, 0, 1, 2, ...
(N-1), 0, 1, 2,..., Etc., the counting operation of counting up / clearing is repeatedly performed at a cycle of n.

【0016】一方、ステージFにおいてコンペアレジス
タ4より一致信号(クリア信号)104が発生すると、
前述のように、割り込み要求信号としてCPU26(図
6参照)に送出される。CPU26においては、外部ク
ロック信号103が所定回数入力されたことが検知され
ると、外付け機器(図6参照)28に対して所定の制御
作用が行われる。例えば、HDDサーボ制御において
は、セクタ数を外部クロックにより認識し、所定のセク
タ数をカウントした時にモータを停止させる等の処理が
行なわれている。
On the other hand, when a match signal (clear signal) 104 is generated from the compare register 4 in the stage F,
As described above, it is sent to the CPU 26 (see FIG. 6) as an interrupt request signal. When the CPU 26 detects that the external clock signal 103 has been input a predetermined number of times, a predetermined control action is performed on the external device (see FIG. 6) 28. For example, in the HDD servo control, processes such as recognizing the number of sectors by an external clock and stopping the motor when a predetermined number of sectors are counted are performed.

【0017】[0017]

【発明が解決しようとする課題】上述した従来のワンチ
ップマイクロコンピュータに内蔵されるカウンタ回路に
おいては、カウンタ7における値が、コンペアレジスタ
4の設定値と一致すると、その度ごとに、次のカウント
アップ・タイミングにおいてカウンタ7の値が“00
H”に戻されている。従って、この場合におけるカウン
タ7の値の“00H”は、外部クロック信号103が1
回入力されたことを意味している。また、システムリセ
ット信号102により、カウンタ7の値は“00H”に
初期化される。この場合におけるカウンタ7の値“00
H”は、外部クロック信号103の入力がないことを意
味している。
In the above-described counter circuit built in the one-chip microcomputer, when the value of the counter 7 matches the set value of the compare register 4, the next count is performed each time. At the up timing, the value of the counter 7 becomes “00”.
Therefore, in this case, the value of the counter 7 “00H” is “1” when the external clock signal 103 is “1”.
This means that it has been entered twice. Further, the value of the counter 7 is initialized to “00H” by the system reset signal 102. In this case, the value of the counter 7 “00”
H ”means that the external clock signal 103 is not input.

【0018】このために、カウンタ7の値をCPU26
においてリードする際に、当該リード値が“00H”で
ある場合には、一致発生後において外部クロック信号1
03が入力された場合による値であるのか、またはシス
テムリセット信号102による初期化直後において、外
部クロック信号が未だ入力されていない場合による値で
あるのか、ソフト処理のみにてはその判別が不可能であ
るという欠点がある。
For this purpose, the value of the counter 7 is
When the read value is “00H” when the read is performed, the external clock signal 1
It is impossible to determine whether the value is a value obtained when 03 is input or a value obtained when an external clock signal has not yet been input immediately after initialization by the system reset signal 102, by only software processing. There is a disadvantage that it is.

【0019】[0019]

【課題を解決するための手段】本発明のカウンタ回路
は、ワンチップマイクロコンピュータに内蔵されるカウ
ンタ回路において、供給されるクロック信号に基づいて
計数が行われ、当該計数を介して保持データの値が逐次
更新される単数または複数個のカウンタと、前記カウン
タより出力される更新された保持データの値を受けて、
自己の保持データの値との比較照合を行い、両データの
値が一致する場合に、所定の一致信号を出力するコンペ
アレジスタと、前記一致信号を受けて、前記コンペアレ
ジスタにおける当該両データの値の一致発生直後に、最
初に供給される前記クロック信号の入力に対応して、前
記カウンタにおける保持データの値を初期状態の値より
も1カウント進める状態に初期化するように制御作用を
行う初期化制御回路と、を少くとも備えることを特徴と
している。
According to a counter circuit of the present invention, in a counter circuit incorporated in a one-chip microcomputer, counting is performed based on a supplied clock signal, and the value of the held data is determined through the counting. Receiving one or more counters that are sequentially updated, and the value of the updated held data output from the counter,
Performs comparison and comparison with the value of its own held data, and when the values of both data match, a compare register that outputs a predetermined match signal; and receives the match signal and receives the value of both data in the compare register. Immediately after the occurrence of a match, an initial control operation is performed such that the value of the data held in the counter is initialized to a state where it is advanced by one count from the value of the initial state in response to the input of the clock signal supplied first. And a conversion control circuit.

【0020】[0020]

【実施例】次に、本発明について図面を参照して説明す
る。
Next, the present invention will be described with reference to the drawings.

【0021】図1は本発明の一実施例を示すブロック図
である。図1に示されるように、本実施例は、データバ
ス201、バス202およびカウンタバス203に対応
して、OR回路1と、ぞれぞれバス202およびカウン
タバス203に対するバス接続機能を有するトランスフ
ァゲート2および6と、コンペアレジスタ3および4
と、インバータ5と、カウンタ7と、初期化制御回路8
と、インクリメンタ9と、リード/ライト制御回路10
とを備えて構成される。また、図2は本従来例における
インクリメンタ9および初期化制御回路(第1の実施
例)8の内部構成を示す図であり、インクリメンタ9
は、8ビット値に対応する加算器22-0、22-1、……
…、22-7により構成され、初期化制御回路8は、8ビ
ット値に対応するAND回路19-0、19-1、………、
19-7および18と、同様に、それぞれ8ビット値に対
応するトランスファゲート20-0、20-1、………、2
-7ならびに21-0、20-1、………、21-7と、イン
バータ11、12、16および17と、Dラッチ13お
よび14と、NOR回路15とを備えて構成される。な
お、インクリメンタ9を構成する加算器22-0および加
算器22-1は、従来例の場合と同様に、それぞれ最下位
ビットおよび次の上位ビットに対応する加算器であり、
加算器22-7は最上位ビットに対応する加算器である。
その他のビットに対応する加算器は、全て記載が省略さ
れている。また、図3(a)、(b)、(c)、
(d)、(e)、(f)、(g)、(h)、(i)およ
び(j)は、本実施例の動作状態を示すタイミング図で
ある。
FIG. 1 is a block diagram showing one embodiment of the present invention. As shown in FIG. 1, the present embodiment corresponds to a data bus 201, a bus 202, and a counter bus 203, and an OR circuit 1 and a transfer circuit having a bus connection function for the bus 202 and the counter bus 203, respectively. Gates 2 and 6 and compare registers 3 and 4
, An inverter 5, a counter 7, and an initialization control circuit 8
, Incrementer 9 and read / write control circuit 10
And is provided. FIG. 2 is a diagram showing the internal configuration of an incrementer 9 and an initialization control circuit (first embodiment) 8 in the conventional example.
Are the adders 22 -0 , 22 -1 ,... Corresponding to the 8-bit value.
, 22 -7 , and the initialization control circuit 8 outputs AND circuits 19 -0 , 19 -1 ,...
Transfer gates 20 -0 , 20 −1 ,..., 2 corresponding to 8-bit values, similarly to 19 -7 and 18
0 -7 and 21 -0, 20 -1, ........., 21 -7, and inverters 11, 12, and 16 and 17, and includes a D latch 13 and 14, a NOR circuit 15. Incidentally, the adder 22 -0 and the adder 22 -1 constituting the incrementer 9, as in the case of the conventional example, are each adder corresponding to the least significant bit and the next higher-order bit,
The adder 22-7 is an adder corresponding to the most significant bit.
The description of the adders corresponding to the other bits is omitted. 3 (a), (b), (c),
(D), (e), (f), (g), (h), (i) and (j) are timing charts showing the operating state of the present embodiment.

【0022】図1において、従来例の場合と同様に、C
PU26(図6参照)より出力されるアドレス信号10
6、リード信号107およびライト信号108は、周辺
制御回路27に含まれる当該カウンタ回路のOR回路1
およびリード/ライト制御回路10に入力される。リー
ド/ライト制御回路10においては、これらのアドレス
信号106、リード信号107およびライト信号108
の入力を受けて、選択信号109、110、111およ
び112が生成されて出力され、選択信号109および
110はコンペアレジスタ3に入力され、選択信号11
1および112はコンペアレジスタ4に入力される。ま
た、OR回路1においては、リード信号107およびラ
イト信号108の入力を受けて、リード時およびライト
時の何れの場合においても、それぞれ“1”レベルが出
力され、トランスファゲート2のゲートに入力される。
これによりトランスファゲート2はオンの状態となり、
データバス201はトランスファゲート2およびバス2
02を介してコンペアレジスタ3および4に連結され
る。この状態においては、当該データバス201を介し
て、各コンペアレジスタの値の読み出しが行われ、或は
また、データバス201上のデータの各コンペアレジス
タに対する書き込みが行われる。
In FIG. 1, as in the case of the conventional example, C
Address signal 10 output from PU 26 (see FIG. 6)
6, the read signal 107 and the write signal 108 are output to the OR circuit 1 of the counter circuit included in the peripheral control circuit 27.
And input to the read / write control circuit 10. In the read / write control circuit 10, these address signal 106, read signal 107 and write signal 108
, The selection signals 109, 110, 111 and 112 are generated and output. The selection signals 109 and 110 are input to the compare register 3 and the selection signals 11 and
1 and 112 are input to the compare register 4. In addition, the OR circuit 1 receives the input of the read signal 107 and the write signal 108, and outputs a “1” level in both cases of reading and writing, and inputs the “1” level to the gate of the transfer gate 2. You.
As a result, the transfer gate 2 is turned on,
Data bus 201 includes transfer gate 2 and bus 2
02 is connected to the compare registers 3 and 4. In this state, the value of each compare register is read out via the data bus 201, or the data on the data bus 201 is written to each compare register.

【0023】システムクロック101が“0”レベルの
時にはインバータ5を介して“1”レベルがトランスフ
ァゲート6のゲートに入力され、これによりオン状態と
なるトランスファゲート6およびカウンタバス203を
介して、カウンタ7における計数値がコンペアレジスタ
3および4に入力され、これらのコンペアレジスタ3お
よび4においては、書き込まれているデータとカウンタ
7における計数値とが比較される。コンペアレジスタ3
および4における比較結果が一致する場合には、それぞ
れ一致信号105および104が出力され、それぞれ割
り込み要求信号としてCPU26(図6参照)に出力さ
れる。また一致信号104はクリア信号として初期化制
御回路8にも入力される。
When the system clock 101 is at the "0" level, the "1" level is input to the gate of the transfer gate 6 via the inverter 5 and thereby turned on, so that the counter is supplied via the transfer gate 6 and the counter bus 203. The count value at 7 is input to compare registers 3 and 4, where the written data is compared with the count value at counter 7. Compare register 3
When the comparison results in steps 4 and 4 match, match signals 105 and 104 are output, respectively, and output to the CPU 26 (see FIG. 6) as interrupt request signals. The coincidence signal 104 is also input to the initialization control circuit 8 as a clear signal.

【0024】図2において、コンペアレジスタ4より出
力される一致信号(クリア信号)104が“0”レベル
の時には、Dラッチ13および14とインバータ16を
介して“1”レベルの信号がAND回路18に入力さ
れ、またシステムクロック信号101が“1”レベルで
入力されると、トランスファゲート21-0はオンの状態
となる。これにより、ビットQ0 は、トランスファゲー
ト21-0を介してAND回路18に入力され、AND回
路18の出力信号115としてビットQ0 が出力され
て、加算器22-0のB端子に入力される。一方加算器2
-0のA端子には、外部クロック信号103が入力され
ており、加算器22-0においては、これらの外部クロッ
ク信号103とビットQ0 とが加算されて、加算結果は
Q端子出力信号として出力されAND回路19-0に入力
される。なお加算結果に桁上げがある場合には、CY端
子より“1”レベルが出力されて、次の上位ビットに対
応する加算器22-1のA端子に入力される。他方システ
ムリセット信号102が“0”レベルにて入力される
と、インバータ12により反転されて“1”レベルの信
号がAND回路19-0に入力され、AND回路19-0
らは上記のQ端子出力信号が出力される。またシステム
クロック信号101が“0”レベルの時には、インバー
タ17により反転されて、“1”レベルの信号がトラン
スファゲート20-0のゲートに入力され、これによりト
ランスファゲート20-0はオンの状態となって、加算器
22-0の加算出力はあビットQ0 として出力される。
In FIG. 2, when the match signal (clear signal) 104 output from the compare register 4 is at "0" level, a "1" level signal is output to the AND circuit 18 via the D-latches 13 and 14 and the inverter 16. When the system clock signal 101 is input at the “1” level, the transfer gate 21-0 is turned on. As a result, the bit Q 0 is input to the AND circuit 18 via the transfer gate 21-0 , the bit Q 0 is output as the output signal 115 of the AND circuit 18, and is input to the B terminal of the adder 22-0. You. On the other hand, adder 2
The 2 -0 A terminal, which is input an external clock signal 103, the adder 22 -0 are summed and these external clock signal 103 and the bit Q 0 is the addition result is Q terminal output signal And input to the AND circuit 19-0 . Note that if the addition result is Carry "1" from the CY pin level is output, is input to the A terminal of the adder 22 -1 corresponding to the next higher-order bit. If the other system reset signal 102 is input at "0" level is inverted by "1" level signal is inputted to the AND circuit 19 -0 by the inverter 12, the above-mentioned Q terminal of the AND circuit 19 -0 An output signal is output. Also when the system clock signal 101 is "0" level is inverted by the inverter 17, "1" level signal is input to the gate of the transfer gate 20 -0, and thereby the transfer gate 20 -0 on state It is to be outputted as an addition output Ha bit Q 0 of the adder 22 -0.

【0025】また、システムリセット信号102はNO
R回路15にも入力されており、クリア信号104は、
Dラッチ13および14を介して同様にNOR回路15
に入力されている。従って、システムリセット信号10
2またはクリア信号104の何れか一方が“1”レベル
になると、NOR回路15の出力は“0”レベルとな
り、また双方ともに“0”レベルになると、NOR回路
15の出力は“1”レベルとなる。
The system reset signal 102 is set to NO
The clear signal 104 is also input to the R circuit 15,
Similarly, NOR circuit 15 is provided via D latches 13 and 14.
Has been entered. Therefore, the system reset signal 10
When either one of the clear signal 104 and the clear signal 104 becomes "1" level, the output of the NOR circuit 15 becomes "0" level, and when both become "0" level, the output of the NOR circuit 15 becomes "1" level. Become.

【0026】次に、図2のインクリメンタ9および初期
化制御回路8の内部構成図と、図3(a)、(b)、
(c)、(d)、(e)、(f)、(g)、(h)、
(i)のタイミング図を参照して、カウンタ値のインク
リメントとクリアに関する動作について説明する。な
お、インクリメンタ9および初期化制御回路8における
各ビットに対応する部分の回路構成はそれぞれ同一であ
り、全て同様の動作が行われるため、以下の説明におい
ては、最下位ビットに対応する部分の回路についてのみ
動作説明を行うものとする。
Next, the internal structure of the incrementer 9 and the initialization control circuit 8 in FIG. 2 and FIGS.
(C), (d), (e), (f), (g), (h),
The operation related to increment and clear of the counter value will be described with reference to the timing chart of (i). Note that the circuit configuration of the part corresponding to each bit in the incrementer 9 and the initialization control circuit 8 is the same, and all the same operations are performed. Therefore, in the following description, the part corresponding to the least significant bit will be described. The operation will be described only for the circuit.

【0027】図3(a)のステージPまでは、システム
リセット信号102は“1”レベルの状態にあるため、
NOR回路15の出力信号は“0”レベルにて出力さ
れ、AND回路19-1、………、19-7に入力される。
また、システムリセット信号102が“1”レベルであ
るため、インバータ12の反転出力は“0”レベルにて
AND回路19-0に入力される。従って、この場合にお
いては、各加算器22-0、22-1、………、22-7から
の加算出力は、それぞれ対応するAND回路19-0、1
-1、………、19-7において遮断される。従って、シ
ステムリセット期間中においては、ビットQ0 、Q1 、
………、Q7 としては全て“00H”が出力され、カウ
ンタ7は“00H”に初期化される。
Up to the stage P in FIG. 3A, the system reset signal 102 is at "1" level.
The output signal of the NOR circuit 15 is output at the “0” level and input to the AND circuits 19 -1 ,..., 19 -7 .
Further, since the system reset signal 102 is at the “1” level, the inverted output of the inverter 12 is input to the AND circuit 19-0 at the “0” level. Therefore, in this case, the added outputs from the adders 22-0 , 22-1 ,..., 22-7 are output to the corresponding AND circuits 19-0 , 1
Blocked at 9 -1 ,..., 19 -7 . Therefore, during the system reset period, bits Q0, Q1,.
.., Q7 are all output "00H", and the counter 7 is initialized to "00H".

【0028】今、ステージPにおいて、システムリセッ
ト信号102が“1”レベルから“0”レベルに変化し
たものとする。この場合には、システムリセット信号1
02およびクリア信号104は、双方ともに“0”レベ
ルであるため、Dラッチ13および14を介して出力さ
れる信号114も“0”レベルとなり、NOR回路15
からは“1”レベルの信号が出力されて、AND回路1
-1、………、19-7に入力される。また、一方システ
ムリセット信号102のインバータ12による反転出力
が、“1”レベルにてAND回路19-0に入力される。
従って、この場合には、加算器22-0、22-1、……
…、22-7の加算出力は、そのままAND回路19-0
19-1、………、19-7およびトランスファゲート20
-0、20-1、………、20-7を介して、それぞれビット
0 、Q1 、………、Q7 として出力される。そして、
ステージQにおいては、外部クロック信号103が
“1”レベルとなるために、加算器22ー0の出力は
“1”レベルとなり、カウンタ7には“01H”が書き
戻される。即ち、本実施例においては、システムリセッ
ト後における最初の外部クロック信号103の入力に対
応して、カウンタ7においてはカウンタアップが行われ
る。以下、同様にして、カウンタ7においては、カウン
トアップが逐次行われてゆく。
Now, it is assumed that in the stage P, the system reset signal 102 has changed from "1" level to "0" level. In this case, the system reset signal 1
02 and the clear signal 104 are both at the “0” level, so that the signal 114 output via the D latches 13 and 14 is also at the “0” level, and the NOR circuit 15
Outputs a signal of “1” level from the AND circuit 1
9 -1 ,..., 19 -7 are input. On the other hand, the inverted output of the system reset signal 102 by the inverter 12 is input to the AND circuit 19-0 at "1" level.
Therefore, in this case, the adders 22 -0 , 22 -1 ,...
.., 22 -7 are directly output from the AND circuit 19 -0 ,
19 -1 ,..., 19 -7 and transfer gate 20
-0, 20 -1, ........., via 20 -7, respectively bits Q 0, Q 1, ........., is outputted as Q 7. And
In stage Q, to the external clock signal 103 becomes "1" level, the output of the adder 22-1 0 becomes "1" level, the counter 7 is written back is "01H". That is, in the present embodiment, the counter 7 counts up in response to the input of the first external clock signal 103 after the system reset. Hereinafter, in the same manner, the counter 7 sequentially counts up.

【0029】ステージUにおいてカウンタ7の値が“0
3H”になった時点において、システムクロックが
“0”のタイミングでコンペアレジスタ4からは一致信
号(クリア信号)104が出力されて、Dラッチ13に
よりラッチされ、ステージVにおいて、外部クロック信
号103の立ち下がりのタイミングでDラッチ14にラ
ッチされる。Dラッチ14の出力信号114は“1”レ
ベルで出力されて、NOR回路15に入力される。従っ
て、NOR回路15よりは“0”レベルの信号が出力さ
れて、AND回路19-1、…………、19-7の出力も全
て“0”レベルとなる。これにより、ステージWにおい
ては、システムクロック信号101が“0”レベルの期
間において、“0”レベルがビットQ1、………、Q7
として出力される。
At the stage U, the value of the counter 7 becomes "0".
When the system clock becomes 3H, the match signal (clear signal) 104 is output from the compare register 4 at the timing when the system clock is "0", latched by the D latch 13, and the stage V receives the external clock signal 103 at the stage V. At the falling timing, the signal is latched by the D latch 14. The output signal 114 of the D latch 14 is output at "1" level and input to the NOR circuit 15. Therefore, the NOR circuit 15 outputs "0" level. The signals are output, and the outputs of the AND circuits 19 -1 ,..., 19 -7 are all at the "0" level. , The “0” level corresponds to bits Q 1 ,..., Q 7
Is output as

【0030】また、ステージWにおいては、Dラッチ1
4の“1”レベルの出力信号114は、インバータ16
により反転されてAND回路18に入力される。これに
よりAND回路18からは“0”レベルが出力されて、
加算器22-0のB端子に入力される。加算器22-0にお
いては、A端子に入力されている外部クロック信号10
3とB端子に入力される“0”レベルとが加算されて、
Q端子からは“1”レベルが出力される。この場合にお
いて、システムリセット信号102は“0”レベルであ
り、またシステムクロック信号101も“0”レベルで
あるため、加算器22-0のQ端子より出力される“1”
レベルは、AND回路19-0およびトランスファゲート
20-0を介して、ビットQ0 として出力される。また、
カウンタ7に対しては、ステージWにおけるシステムク
ロック信号101の立ち下がりにおいて“01H”が書
き戻される。
In the stage W, the D latch 1
4 is output from the inverter 16
And input to the AND circuit 18. As a result, the "0" level is output from the AND circuit 18, and
It is input to the B terminal of the adder 22-0 . In the adder 22-0 , the external clock signal 10 input to the A terminal is output.
3 and the “0” level input to the B terminal are added,
The “1” level is output from the Q terminal. In this case, since the system reset signal 102 is at the “0” level and the system clock signal 101 is also at the “0” level, “1” output from the Q terminal of the adder 22-0 is output.
Level through the AND circuit 19 -0 and the transfer gate 20 -0, is outputted as the bit Q 0. Also,
“01H” is written back to the counter 7 at the falling edge of the system clock signal 101 in the stage W.

【0031】即ち、システムリセット解除後、またはコ
ンペアレジスタ4の値とカウンタ7の計数値の一致後に
おいては、最初の外部クロック信号103の入力の時点
から、カウンタ7におけるカウンタアップが開始され
る。そして、以後、外部クロック信号103が入力され
る度ごとに、カウンタ7においてはカウントアップが継
続して行われる。このように、カウントしたい数“n”
をコンペアレジスタ4に書き込んでおくことにより、外
部クロック信号103が入力される度ごとに、カウンタ
7においては、1、2、3、………という具合に、nの
周期でカウントアップおよびクリアが繰返して行われ
る。この場合、カウンタ7においては、システムリセッ
ト解除後においてのみ、“00H”で外部クロック信号
103が入力されると必らず“01H”以上の値とな
る。これにより、カウンタ7において読み出しが“0”
であれば、外部クロック信号103が一度も入力されて
いないもと判断される。
That is, after the system reset is released or after the value of the compare register 4 matches the count value of the counter 7, the counter 7 starts counting up from the first input of the external clock signal 103. Thereafter, each time the external clock signal 103 is input, the counter 7 continues counting up. Thus, the number "n" to be counted
Is written in the compare register 4 so that the counter 7 counts up and clears in the cycle of n every time the external clock signal 103 is input, such as 1, 2, 3,... It is performed repeatedly. In this case, when the external clock signal 103 is input at “00H” only after the system reset is released, the counter 7 always has a value of “01H” or more. As a result, the counter 7 reads “0”.
If so, it is determined that the external clock signal 103 has never been input.

【0032】次に、本発明の第2の実施例について説明
する。なお本実施例の構成を示すブロック図は、前述の
第1の実施例の場合と同様であり、図1に示されるとう
りである。本実施例の第1の実施例との相違点は、図1
に示される初期化制御回路の内部構成の差異、ならびに
これに伴なう動作の差異にある。
Next, a second embodiment of the present invention will be described. A block diagram showing the configuration of this embodiment is the same as that of the first embodiment, and is as shown in FIG. This embodiment is different from the first embodiment in that FIG.
In the internal configuration of the initialization control circuit shown in FIG.

【0033】図4は本実施例におけるインクリメンタ
(第1の実施例と同一構成)9および初期化制御回路
(第2の実施例)8の内部構成を示す図であり、インク
リメンタ9は、8ビット値に対応する加算器22-0、2
-1、………、22-7により構成され、初期化制御回路
8は、8ビット値に対応するAND回路19-0、1
-1、………、19-7と、同様に、それぞれ8ビット値
に対応するトランスファゲート20-0、20-1、……
…、20-7ならびに21-0、20-1、………、21
-7と、ビットQ0 に対応するOR回路23と、インバー
タ11および17と、Dラッチ13および14と、NO
R回路15とを備えて構成される。また、図5(a)、
(b)、(c)、(d)、(e)、(f)、(g)、
(h)、(i)、(j)および(k)は、本実施例の動
作状態を示すタイミング図である。
FIG. 4 is a diagram showing the internal configuration of an incrementer 9 (same configuration as in the first embodiment) 9 and an initialization control circuit (second embodiment) 8 in this embodiment. Adder 22-0 corresponding to the 8-bit value, 2
2 -1, ........., is composed of 22 -7, the initialization control circuit 8, the AND circuit 19 -0 corresponding to 8-bit values, 1
9-1, ........., 19 -7, likewise, the transfer gate 20 -0 corresponding to each 8-bit value, 20 -1, ...
…, 20 -7 and 21 −0 , 20 −1 , ………, 21
-7 , OR circuit 23 corresponding to bit Q 0 , inverters 11 and 17, D latches 13 and 14, NO
An R circuit 15 is provided. FIG. 5A,
(B), (c), (d), (e), (f), (g),
(H), (i), (j) and (k) are timing charts showing the operating state of the present embodiment.

【0034】図4に示される本実施例の初期化制御回路
8においては、システムリセット信号102および一致
信号(クリア信号)104を取込む論理回路構成に若干
の差異はあるものの、各ステージにおいて、当該初期化
制御回路8に入力されるシステムクロック信号101、
システムリセット信号102、外部クロック信号103
および一致信号104の各入力レベルにより、インクリ
メンタ9に対応する初期化制御回路8の動作機能は、前
述の第1の実施例の場合と同様である。
In the initialization control circuit 8 of this embodiment shown in FIG. 4, although there is a slight difference in the logic circuit configuration for taking in the system reset signal 102 and the coincidence signal (clear signal) 104, each stage has A system clock signal 101 input to the initialization control circuit 8,
System reset signal 102, external clock signal 103
The operation function of the initialization control circuit 8 corresponding to the incrementer 9 according to each input level of the coincidence signal 104 is the same as that of the first embodiment.

【0035】例えば、図1、図4および図5において、
ビットQ0 について考えると(他のビットについても同
様であるので省略する)、ステージjにおいて、コンペ
アレジスタ4に“03H”という値が保持されており、
カウンタ7より、計数値として“03H”という値が入
力される場合には、コンペアレジスタ4からは一致信号
(クリア信号)104が“1”レベルで出力され、初期
化制御回路8に入力される。この場合、ステージjにお
いては、Dラッチ14の出力信号114は“0”レベル
であり、OR回路23およびNOR回路15に入力され
る。従って、NOR回路15の出力レベルは未だ“1”
レベルの状態にあって、当該“1”レベルの信号はAN
D回路19-0に入力される。このステージjにおいて、
システムクロック信号101が“0”レベルとなる期間
においては、トランスファゲート20-0はオンの状態と
なり、加算器22-0の加算出力は、AND回路19-0
OR回路23およびトランスファゲート20-0を介し
て、ビットQ0 として出力され、これにより、図5
(k)に示されるように、カウンタ7に対しては、ステ
ージlにおけるシステムクロック信号101の立ち下が
りにおいて“01H”が書き戻される。
For example, in FIGS. 1, 4 and 5,
Considering bit Q 0 (the same applies to the other bits, the description is omitted). In stage j, the value “03H” is held in the compare register 4, and
When a value of “03H” is input as a count value from the counter 7, the match signal (clear signal) 104 is output at the “1” level from the compare register 4 and input to the initialization control circuit 8. . In this case, in stage j, the output signal 114 of the D latch 14 is at the “0” level, and is input to the OR circuit 23 and the NOR circuit 15. Therefore, the output level of the NOR circuit 15 is still "1".
In the state of the level, the signal of the “1” level is AN
It is input to the D circuit 19-0 . In this stage j,
During a period in which the system clock signal 101 is at the “0” level, the transfer gate 20-0 is turned on, and the addition output of the adder 22-0 is output to the AND circuit 19-0 ,
It is output as a bit Q 0 via the OR circuit 23 and the transfer gate 20-0 .
As shown in (k), “01H” is written back to the counter 7 at the fall of the system clock signal 101 in the stage 1.

【0036】即ち、前述の第1の実施例の場合と同様
に、システムリセット解除後、またはコンペアレジスタ
4の値とカウンタ7の計数値の一致後においては、最初
の外部クロック信号103の入力の時点から、カウンタ
7におけるカウンタアップが開始される。そして、以
後、外部クロック信号103が入力される度ごとに、カ
ウンタ7においてはカウントアップが継続して行われ
る。このように、カウントしたい数“n”をコンペアレ
ジスタ4に書き込んでおくことにより、外部クロック信
号103が入力される度ごとに、カウンタ7において
は、1、2、3、………という具合に、nの周期でカウ
ントアップおよびクリアが繰返して行われる。この場
合、カウンタ7においては、システムリセット解除後に
おいてのみ、“00H”で外部クロック信号103が入
力されると必らず“01H”以上の値となる。これによ
り、カウンタ7において読み出しが“0”であれば、外
部クロック信号103が一度も入力されていないものと
判断される。
That is, as in the case of the first embodiment, after the system reset is released or after the value of the compare register 4 matches the count value of the counter 7, the input of the first external clock signal 103 is performed. From the time point, the counter 7 starts counting up. Thereafter, each time the external clock signal 103 is input, the counter 7 continues counting up. By writing the number “n” to be counted in the compare register 4 in this way, every time the external clock signal 103 is input, the counter 7 outputs 1, 2, 3,... , N, the count up and the clear are repeated. In this case, when the external clock signal 103 is input at “00H” only after the system reset is released, the counter 7 always has a value of “01H” or more. As a result, if the reading is “0” in the counter 7, it is determined that the external clock signal 103 has never been input.

【0037】なお、上記の本発明の第1および第2の実
施例の動作説明においては、システムリセットにより
“00H”に初期化され、外部クロック信号の入力によ
りカウンタ7の内容に“01H”が加算されるカウンタ
回路についての説明を行っているが、システムリセット
により“n”に初期化され、外部クロック信号入力によ
ってカウンタの内容から“01H”を減算するカウンタ
回路についても、本発明の適用を介して、一致発生時
に、次のカウントタイミングにおいて“n−1”に初期
化することにより、同様の効果が得られることは云うま
でもない。
In the above description of the operation of the first and second embodiments of the present invention, the contents of the counter 7 are initialized to "00H" by a system reset and "01H" is input by the input of an external clock signal. Although the counter circuit to be added is described, the present invention is also applied to a counter circuit which is initialized to “n” by a system reset and subtracts “01H” from the counter content by an external clock signal input. It is needless to say that the same effect can be obtained by initializing to "n-1" at the next count timing when a match occurs.

【0038】[0038]

【発明の効果】以上説明したように、本発明は、従来の
ワンチップマイクロコンピュータに内蔵されるカウンタ
回路に適用されて、外部クロック信号の入力に対応し
て、必らずカウントアップ動作が行われるように制御す
る初期化制御回路を備えることにより、当該カウンタ値
の読み取りを行う極めて簡易なソフトウェア処理によ
り、前記外部クロック信号の入力の有無を判定すること
ができるという効果がある。
As described above, the present invention is applied to the counter circuit built in the conventional one-chip microcomputer, and the count-up operation is necessarily performed in response to the input of the external clock signal. By providing the initialization control circuit for controlling the external clock signal, the presence or absence of the input of the external clock signal can be determined by extremely simple software processing for reading the counter value.

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

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

【図2】前記一実施例に含まれるインクリメンタならび
に初期化制御回路の第1の実施例を示す回路図である。
FIG. 2 is a circuit diagram showing a first embodiment of an incrementer and an initialization control circuit included in the embodiment.

【図3】前記初期化制御回路の第1の実施例を含む前記
一実施例の動作タイミング図である。
FIG. 3 is an operation timing chart of the one embodiment including the first embodiment of the initialization control circuit.

【図4】前記一実施例に含まれるインクリメンタならび
に初期化制御回路の第2の実施例を示す回路図である。
FIG. 4 is a circuit diagram showing a second embodiment of an incrementer and an initialization control circuit included in the one embodiment.

【図5】前記初期化制御回路の第2の実施例を含む前記
一実施例の動作タイミング図である。
FIG. 5 is an operation timing chart of the one embodiment including the second embodiment of the initialization control circuit.

【図6】一般的なマイクロコンピュータのシステム構成
図である。
FIG. 6 is a system configuration diagram of a general microcomputer.

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

【図8】前記従来例に含まれるインクリメンタならびに
クリア回路を示す回路図である。
FIG. 8 is a circuit diagram showing an incrementer and a clear circuit included in the conventional example.

【図9】前記従来例の動作タイミング図である。FIG. 9 is an operation timing chart of the conventional example.

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

1、23 OR回路 2、6、20-0〜20-7、21-0〜20-7 トランス
ファゲート 3、4 コンペアレジスタ 5、11、12、16、17、32 インバータ 7 カウンタ 8 初期化制御回路 9 インクリメンタ 10 リード/ライト制御回路 13、14、34 Dラッチ 15 NOR回路 18、19-0〜19-7、30 AND回路 22-0〜22-7 加算器 23、31 OR回路 24 マイクロコンピュータ 25 メモリ 26 CPU 27 周辺制御回路 28 外付け機器 29 クリア回路 33 RSフリップフロップ
1, 23 OR circuit 2,6,20 -0 to 20 -7, 21 -0 to 20 -7 transfer gates 3 and 4 compare register 5,11,12,16,17,32 inverter 7 counter 8 initialization control circuit REFERENCE SIGNS LIST 9 incrementer 10 read / write control circuit 13, 14, 34 D latch 15 NOR circuit 18, 19 −0 to 19 −7 , 30 AND circuit 22 −0 to 22 −7 adder 23, 31 OR circuit 24 microcomputer 25 Memory 26 CPU 27 Peripheral control circuit 28 External device 29 Clear circuit 33 RS flip-flop

Claims (1)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 ワンチップマイクロコンピュータに内蔵
されるカウンタ回路において、 供給されるクロック信号に基づいて計数が行われ、当該
計数を介して保持データの値が逐次更新される単数また
は複数個のカウンタと、 前記カウンタより出力される更新された保持データの値
を受けて、自己の保持データの値との比較照合を行い、
両データの値が一致する場合に、所定の一致信号を出力
するコンペアレジスタと、 前記一致信号を受けて、前記コンペアレジスタにおける
当該両データの値の一致発生直後に、最初に供給される
前記クロック信号の入力に対応して、前記カウンタにお
ける保持データの値を初期状態の値よりも1カウント進
める状態に初期化するように制御作用を行う初期化制御
回路と、 を少くとも備えることを特徴とするカウンタ回路。
1. A counter circuit incorporated in a one-chip microcomputer, wherein counting is performed based on a supplied clock signal, and a value of a single or a plurality of counters is sequentially updated through the counting. And receiving the updated value of the retained data output from the counter, performing comparison and collation with the value of the retained data,
A compare register that outputs a predetermined coincidence signal when the values of both data coincide with each other; and receiving the coincidence signal, the clock supplied first after the occurrence of the coincidence of the values of both data in the compare register. And an initialization control circuit that performs a control operation so as to initialize the value of the data held in the counter by one count from the value of the initial state in response to the input of the signal. Counter circuit.
JP22627593A 1993-09-13 1993-09-13 Counter circuit Expired - Fee Related JP3338722B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP22627593A JP3338722B2 (en) 1993-09-13 1993-09-13 Counter circuit

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP22627593A JP3338722B2 (en) 1993-09-13 1993-09-13 Counter circuit

Publications (2)

Publication Number Publication Date
JPH0786922A JPH0786922A (en) 1995-03-31
JP3338722B2 true JP3338722B2 (en) 2002-10-28

Family

ID=16842662

Family Applications (1)

Application Number Title Priority Date Filing Date
JP22627593A Expired - Fee Related JP3338722B2 (en) 1993-09-13 1993-09-13 Counter circuit

Country Status (1)

Country Link
JP (1) JP3338722B2 (en)

Also Published As

Publication number Publication date
JPH0786922A (en) 1995-03-31

Similar Documents

Publication Publication Date Title
US4758945A (en) Method for reducing power consumed by a static microprocessor
EP0632370B1 (en) A hardware arrangement of expanding data processing time in the pipeline stages of a microcomputer system and a method thereof
US4748559A (en) Apparatus for reducing power consumed by a static microprocessor
US5311475A (en) High speed full and empty flag generators for first-in first-out memory
JPH07295687A (en) Resetting circuit and resetting method
US5402368A (en) Computing unit and digital signal processor using the same
JP3338722B2 (en) Counter circuit
JPH0573268A (en) Adder
US4802089A (en) Status flag handling in a digital data processing system
EP0469543A2 (en) Multiple interrupt handling circuit
US5001629A (en) Central processing unit with improved stack register operation
EP0462622B1 (en) Microprocessor capable of ensuring flexible recovery time for I/O device
US4723258A (en) Counter circuit
US5623648A (en) Controller for initiating insertion of wait states on a signal bus
US5566322A (en) Method and apparatus for performing read accesses from a counter which avoid large rollover error when multiple read access cycles are used
US5018092A (en) Stack-type arithmetic circuit
JPH02126321A (en) Decoder for instruction code
JP2806849B2 (en) Memory address controller
US5142636A (en) Memory bank address calculation with reduced instruction execution cycles
SU1205142A1 (en) Device for controlling access to scratch-pad memory
JP2859921B2 (en) Instruction queue controller
US6360295B1 (en) Serially loadable digital electronic memory and method of loading the same
JPH04100150A (en) Register circuit
JP3036590B2 (en) External device control circuit
SU1166109A2 (en) Microprogram control unit

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: 20020716

LAPS Cancellation because of no payment of annual fees