JPS6152725A - Timer counter - Google Patents

Timer counter

Info

Publication number
JPS6152725A
JPS6152725A JP59174001A JP17400184A JPS6152725A JP S6152725 A JPS6152725 A JP S6152725A JP 59174001 A JP59174001 A JP 59174001A JP 17400184 A JP17400184 A JP 17400184A JP S6152725 A JPS6152725 A JP S6152725A
Authority
JP
Japan
Prior art keywords
counter
value
down counter
counting
dcnt21
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP59174001A
Other languages
Japanese (ja)
Inventor
Yasuhiro Wakimoto
康裕 脇本
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.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP59174001A priority Critical patent/JPS6152725A/en
Publication of JPS6152725A publication Critical patent/JPS6152725A/en
Pending legal-status Critical Current

Links

Landscapes

  • Electronic Switches (AREA)

Abstract

PURPOSE:To obtain a free running timer counter for which the overhead of a CPU is small, by using two comparator registers for switching between up- counting and down-counting of an up/down counter (U/DCNT). CONSTITUTION:An upper limit value alpha and a lower limit value beta are written on comparator registers 22 and 23 respectively by a CPU1. When an U/DCNT21 starts counting at a time t0 in the up-counting mode, the value alpha of the comparator register 22 and the value of the U/DCNT21 coincide with each other at a time t1, and an AND24 outputs the output to set a flip flop 26, and the U/ DCNT21 is st to the down-counting mode. When the counted value is reduced to reach the value beta of the comparator register 23, the flip flop 26 is reset to set the U/DCNT21 to the up-counting mode. During this period, the U/DCNT21 passes counted value ''0'', and the output signal is inverted at each time.

Description

【発明の詳細な説明】 産業上の利用分野 本発明はシングルチップマイクロコンピュータに用いら
れるフリーランニング方式タイマカウンタに関する。
DETAILED DESCRIPTION OF THE INVENTION Field of the Invention The present invention relates to a free-running timer counter used in a single-chip microcomputer.

従来の技術および発明が解決しようとする問題点シング
ルチップマイクロコンピュータにおいては、タイムイン
ターバルの発生任意デユーティ、任意周波数のパルスの
発生、外部エベントの監視、パルス幅(周波数)の監視
等のために、タイマカウンタは必要不可欠でちる。この
ようなタイマカウンタとしては、カウンタ方式とフリー
ランニンダカウンタ方式とがある。
Problems to be Solved by the Prior Art and the Invention In single-chip microcomputers, in order to generate time intervals at arbitrary duties, generate pulses at arbitrary frequencies, monitor external events, monitor pulse width (frequency), etc. A timer counter is essential. As such timer counters, there are a counter type and a free running counter type.

カウンタ方式のタイマカウンタは、ダウンカウンタ(も
しくはアップカウンタ)、リロードレジスタ等を具備し
ている。たとえば、この場合、ダウンカウンタが所定ク
ロックを計数してアンダフローしたときにキャリアウド
係号を割込み信号としてCPUに発生すると共に、リロ
ードレジスタの内容が再びダウンカウンタに設定されて
同様の動作が継続することになる。従って、上述のキャ
リアウト信号によってフリップ70ソfをリセット(も
しくはセット)することによシ、任意のデユーティの信
号を発生できる。この場合、フリップフロップのセット
(もしくはリセット) i、j: CPUもしくは他の
手段によって行われる。しかしながら、このようなカウ
ンタ方式のタイムカウンタは一使用目的に占有されるの
で、異なる2種の任意のデユーティの信号が必要とすれ
ば2つのタイマカウンタを必要とし、つまり、使用目的
の数が増加すればタイムカウンタを増加しなければなら
ず、製造コストの点で不利である。
The counter-type timer counter includes a down counter (or up counter), a reload register, and the like. For example, in this case, when the down counter underflows after counting a predetermined clock, the carried coefficient is generated as an interrupt signal to the CPU, and the contents of the reload register are set to the down counter again and the same operation continues. I will do it. Therefore, by resetting (or setting) the flip 70 sof using the above-mentioned carry-out signal, a signal of any duty can be generated. In this case, setting (or resetting) of flip-flops i, j: is performed by the CPU or other means. However, such counter-type time counters are used for one purpose, so if two different arbitrary duty signals are required, two timer counters are required, which means that the number of purposes increases. In this case, the time counter must be increased, which is disadvantageous in terms of manufacturing costs.

これに対し、フリーランニング方式タイムカウンタハ、
フリーランニングカウンタ、コンパレータレジスタ、一
致回路等によシ構成されておシ、使用目的が増加しても
フリーランニングカウンタは共通に用いることができる
ので、製造コストの点でカウンタ方式タイムカウンタに
比べて有利である。しかしながら、このフリーランニン
グ方式のタイムカウンタにおいて、任意のデユーティあ
るい社任意の周波数の信号たとえば/4ルス幅Δtの信
号を発生する場合、コンパレータレジスタに、7リーラ
ンニングカウンタの現在値tにパルス幅Δtを加算した
値t+Δtを設定しなければならず、つまシ、タイムカ
ウンタの割込み信号発生毎に上述の加′n、を行った上
でその値をコンパレータレジスタに設定しなければなら
ず、この結果、CPUのオーバヘッドが増加するという
問題点かあった0 問題点を酢決するだめの手段 本発明は、上述の問題点に鑑み、CPUのオーバヘッド
が少ないフリーランニング方式タイムカウンタを提供す
るもので、その手段は、所定クロックを計数してカウン
トアツプもしくはカウントダウンするアップ/ダウンカ
ウンタと、該アップ/ダウンカウンタの計数値の上限値
が設定される第1のコンパレータレジスタと、前記アッ
プ/ダウンカウンタの計数値の下限値が設定される第2
の      1コンパレータレジスタと、前記アップ
/ダウンカウンタの計数値が前記第1のコンパレータレ
ジスタの設定値に一致したときに前記アップ/ダウンカ
ウンタをダウン計数モードにし、前記アップ/ダウンカ
ウンタの5士数値が前記第2のコンパレータレジスタの
設定値に一致したとぎに前記アップ/ダウンカウンタを
アップ計数モードにする手段とを具備し、前記アップ/
ダウンカウンタの正負符号を示すビットに応じた信号を
出力するタイマカウンタによって達成される。
On the other hand, a free running time counter,
It is composed of a free-running counter, a comparator register, a matching circuit, etc., and even if the purpose of use increases, the free-running counter can be used in common, so it is cheaper than a counter-type time counter in terms of manufacturing cost. It's advantageous. However, in this free-running time counter, when generating a signal of any duty or company with any frequency, for example, a signal with /4 pulse width Δt, the current value t of the 7-leaving running counter is set to pulse width Δt in the comparator register. The value t + Δt must be set by adding Δt, and the above addition must be performed every time an interrupt signal of the time counter is generated, and then the value must be set in the comparator register. As a result, there was a problem that the CPU overhead increased.Means for resolving the problem In view of the above-mentioned problems, the present invention provides a free-running time counter with less CPU overhead. The means includes an up/down counter that counts up or down by counting a predetermined clock, a first comparator register in which an upper limit value of the count value of the up/down counter is set, and a counter of the up/down counter. The second, where the lower limit of the numerical value is set.
When the count value of the first comparator register and the up/down counter match the set value of the first comparator register, the up/down counter is put into the down counting mode, and the 5th value of the up/down counter is set. means for setting the up/down counter to an up counting mode when the set value of the second comparator register matches the set value of the second comparator register;
This is achieved by a timer counter that outputs a signal according to the bit indicating the sign of the down counter.

作用   。Effect.

上述の纏成において、一旦w、1・第2のコンパレータ
レジスタに所望の値がたとえばCPUによシ設定される
と、タイムカウンタはCPUの介在なしに上記所望の値
に応じたデユーティもしくは周波数の信号を発生するこ
とになる。
In the above arrangement, once desired values are set in w, the first and second comparator registers by, for example, the CPU, the time counter changes the duty or frequency according to the desired values without the intervention of the CPU. It will generate a signal.

実施例 以下、図面によυ本発明の詳細な説明する。Example Hereinafter, the present invention will be explained in detail with reference to the drawings.

第1図は本発明に糸るタイマカウンタを含むシングルチ
ップマイクロコンピュータを示すブロック回路図である
。第1し1において、1はCPU、 2はタイマカウン
タ、3はプログラム、固定データ等を記憶するROM、
 4は一時的なデータを記憶する湿M、5は外部機器た
とえばブデー6との接続を行う入出力(ilo)インタ
ーフェイスであシ、これらの各要素間はパス7によって
接続されている。内部クロック発生回路8は種々の内部
クロックを必要な内部機器たとえばCPU 1 、タイ
マカウンタ2に供給するものである。
FIG. 1 is a block circuit diagram showing a single-chip microcomputer including a timer counter according to the present invention. In the first part, 1 is a CPU, 2 is a timer counter, 3 is a ROM that stores programs, fixed data, etc.
Reference numeral 4 indicates an input/output (ILO) interface for connecting to an external device such as a memory M for storing temporary data, and an input/output (ILO) interface for connecting with an external device such as a computer 6. A path 7 connects each of these elements. The internal clock generation circuit 8 supplies various internal clocks to necessary internal devices such as the CPU 1 and the timer counter 2.

第2図は第1図のタイマカウンタ2の詳細なブロック回
路図である。第2図において、21はアップ/ダウンカ
ウンタであって、内部クロック発生回路8のクロック信
号CLKを計数してカウントアツプもしくはカウントダ
ウンされる。22゜23はコンパレータレジスタであっ
て、それぞれには、アップ/ダウンカウンタ21の上限
値α、および下限値βがCPU 1によって設定される
。一致回路24はアップ/ダウンカウンタ21の内容(
全ビット)とコンパレータレジスタ22の内容(全ビ2
ット)との一致を監視するものであって、これらの内容
が完全に一致したときに7リツプフロツプ26にセット
信号を発生してそれをセットする。また、一致回路25
はアップ/ダウンヵクンタ21の内容(全ビット)とコ
ンパレータレジスタ23の内容(全ビット)との一致を
監視するものであって、これらの内容が先金に一致しプ
cときにフリップフロップ26にリセット信号を発生し
てそれをリセットする。タイマカウンタ2の出力OUT
はアップ/ダウンカウンタ21の正負符号を示すピッi
−によって行う。
FIG. 2 is a detailed block circuit diagram of the timer counter 2 of FIG. 1. In FIG. 2, 21 is an up/down counter which counts the clock signal CLK of the internal clock generating circuit 8 and counts up or down. 22 and 23 are comparator registers in which the CPU 1 sets an upper limit value α and a lower limit value β of the up/down counter 21, respectively. The coincidence circuit 24 inputs the contents of the up/down counter 21 (
all bits) and the contents of the comparator register 22 (all bits 2)
When these contents completely match, a set signal is generated to the 7 lip-flop 26 to set it. In addition, the matching circuit 25
monitors whether the contents of the up/down counter 21 (all bits) and the contents of the comparator register 23 (all bits) match, and when these contents match the prepayment, the flip-flop 26 is reset. Generate a signal to reset it. Timer counter 2 output OUT
is a pitch i indicating the positive/negative sign of the up/down counter 21
− is done.

第3図は第2図のタイマカウンタ2の動作を説明するだ
めのタイミング図である。アップ/ダウンカウンタ21
の内容は、アップ計数モードであれは、時刻t0から増
加し、時刻t、においてアップ/ダウンカウンタ21の
内容がコンパレータレジスタ22の上限値α(正の値)
と一致する。
FIG. 3 is a timing diagram for explaining the operation of the timer counter 2 of FIG. 2. Up/down counter 21
In the up counting mode, the contents of are increased from time t0, and at time t, the contents of the up/down counter 21 reach the upper limit value α (positive value) of the comparator register 22.
matches.

この結果、一致回路24は7リツグフロツプ2Gをセッ
トするのでへアップ/ダウンカウンタ21はアップ計数
モードからダウン計数モードに切替わる。従って、時刻
t8以降は、アップ/ダウンカウンタ21の内容が減少
する。
As a result, the coincidence circuit 24 sets the 7-lig flop 2G, so that the up/down counter 21 is switched from the up counting mode to the down counting mode. Therefore, after time t8, the content of the up/down counter 21 decreases.

時刻t2において、アップ/ダウンカウンタ21の内容
が零交差すると、出力信号OUTは”1″からOnとな
シ、さらに、時刻t3において、アップ/ダウンカウン
タ21の内容がコンパレータレジスタ23の下限値β(
柄の値)と一致する。
At time t2, when the content of the up/down counter 21 crosses zero, the output signal OUT changes from "1" to On. Furthermore, at time t3, the content of the up/down counter 21 reaches the lower limit value β of the comparator register 23. (
pattern value).

この結果、一致回路25はフリ、fフロップ26をリセ
ットするので、アップ/ダウンカウンタ21はダウン計
数モードからアップ計数モードに切替わる。従って、時
刻t、以降はアップ/ダウンカウンタ21の内容が増加
する。
As a result, the coincidence circuit 25 resets the F-flop 26, so that the up/down counter 21 is switched from the down counting mode to the up counting mode. Therefore, after time t, the contents of the up/down counter 21 increase.

そして、時刻t4において、アップ/ダウンカウンタ2
1の内容が零交差すると、出力信号OUTは′0″から
1sとなる。
Then, at time t4, the up/down counter 2
When the content of 1 crosses zero, the output signal OUT changes from '0' to 1s.

以後同様の動作が続く。つまり、rニーティ比α/(α
+β)の信号OUTが発生することになる。
The same behavior continues thereafter. In other words, rneeti ratio α/(α
+β) signal OUT is generated.

なお、上述の実施例においては、タイマカウンタ2の出
力信号OUTをI10インターフェイス5を介して外部
に送出しているが、この信号OUT’1CPU 1に割
込みとして作用させ、割込みルーテン      トを
実行させることも可能である。
In the above embodiment, the output signal OUT of the timer counter 2 is sent to the outside via the I10 interface 5, but this signal OUT'1 can act as an interrupt to execute the interrupt route. is also possible.

発明の詳細 な説明したように本発明によれば、コンパレータレジス
タに一旦設定した後は、自動的にD[望のデ′ニーティ
もしくは周波数の信号を発生できるので、本発明に係る
タイマカウンタをシングルチップマイクロコンピュータ
に適用すれはCPUのオーバヘッドをZ減少できる。
As described in detail, according to the present invention, once set in the comparator register, it is possible to automatically generate a signal with a desired density or frequency. When applied to a chip microcomputer, the CPU overhead can be reduced by Z.

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

第1図は本発明に係るタイマカウンタを含むシングルチ
ップマイクロコンピュータを示すブロック回路図、第2
図は第1図のタイマカウンタ2の肝油1なブロック回路
図、第3図は第2図のタイマカウンタ2の動作を説明す
るためのタイミング図である。 1 : CPtJ、 2 :タイマカウンタ、3 :R
OM14: RAM、 5 : I10インターフェイ
ス、8:内部クロック発生回路、21:アップ/ダウン
カウンタ、22,23:コン7ぐレータレジスタ、24
゜25ニ一致回路、26:フリップフロップ、α:上限
館、β:下限値。
FIG. 1 is a block circuit diagram showing a single-chip microcomputer including a timer counter according to the present invention, and FIG.
This figure is a basic block circuit diagram of the timer counter 2 of FIG. 1, and FIG. 3 is a timing diagram for explaining the operation of the timer counter 2 of FIG. 2. 1: CPtJ, 2: timer counter, 3: R
OM14: RAM, 5: I10 interface, 8: Internal clock generation circuit, 21: Up/down counter, 22, 23: Controller register, 24
゜25 matching circuit, 26: flip-flop, α: upper limit, β: lower limit.

Claims (1)

【特許請求の範囲】[Claims] 1、所定クロックを計数してカウントアップもしくはカ
ウントダウンするアップ/ダウンカウンタと、該アップ
/ダウンカウンタの計数値の上限値が設定される第1の
コンパレータレジスタと、前記アップ/ダウンカウンタ
の計数値の下限値が設定される第2のコンパレータレジ
スタと、前記アップ/ダウンカウンタの計数値が前記第
1のコンパレータレジスタの設定値に一致したときに前
記アップ/ダウンカウンタをダウン計数モードし、前記
アップ/ダウンカウンタの計数値が前記第2のコンパレ
ータレジスタの設定値に一致したときに前記アップ/ダ
ウンカウンタをアップ計数モードにする手段とを具備し
、前記アップ/ダウンカウンタの正負符号を示すビット
に応じた信号を出力するタイマカウンタ。
1. An up/down counter that counts up or down by counting a predetermined clock, a first comparator register in which an upper limit value of the count value of the up/down counter is set, and an upper limit value of the count value of the up/down counter. When the count value of the second comparator register in which the lower limit value is set and the up/down counter match the set value of the first comparator register, the up/down counter is put into the down counting mode, and the up/down counter and means for setting the up/down counter to an up counting mode when the counted value of the down counter matches the set value of the second comparator register, and according to a bit indicating a positive or negative sign of the up/down counter. A timer counter that outputs a signal.
JP59174001A 1984-08-23 1984-08-23 Timer counter Pending JPS6152725A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP59174001A JPS6152725A (en) 1984-08-23 1984-08-23 Timer counter

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP59174001A JPS6152725A (en) 1984-08-23 1984-08-23 Timer counter

Publications (1)

Publication Number Publication Date
JPS6152725A true JPS6152725A (en) 1986-03-15

Family

ID=15970910

Family Applications (1)

Application Number Title Priority Date Filing Date
JP59174001A Pending JPS6152725A (en) 1984-08-23 1984-08-23 Timer counter

Country Status (1)

Country Link
JP (1) JPS6152725A (en)

Similar Documents

Publication Publication Date Title
EP0388131A2 (en) Random number generator
US5012435A (en) Multiple event timer circuit
JPH04336308A (en) Single-chip microcomputer
US6263450B1 (en) Programmable and resettable multifunction processor timer
JPS5829197A (en) Dynamic memory refleshing circuit
JPS6152725A (en) Timer counter
JPS6316711A (en) Timing device
JPH0464431B2 (en)
JPS5811340U (en) Arbitrary frequency generator
US5566322A (en) Method and apparatus for performing read accesses from a counter which avoid large rollover error when multiple read access cycles are used
JP2946606B2 (en) Counter circuit
JP2023151392A (en) Timer circuit, semiconductor device, and interruption control method
JPS5965356A (en) Single-chip microcomputer
JP2663482B2 (en) Measurement circuit
JPS6010355A (en) Measuring system of activity ratio of central processing unit
JPS59100926A (en) Timer circuit
JP2517943B2 (en) Timer device
JPH0632049B2 (en) Microcomputer equipment
SU655073A1 (en) Multifunction counter
Georgopoulos et al. μP Timing and Synchronization Interfaces
JPH01280918A (en) Interval timer
JPH06318157A (en) Semiconductor integrated circuit
JPH03188514A (en) Counting circuit
Goldband Real-time clocks for microcomputers in behavioral research
JPS6266165A (en) Pulse period input device