JP5331451B2 - Microcontroller - Google Patents

Microcontroller Download PDF

Info

Publication number
JP5331451B2
JP5331451B2 JP2008288805A JP2008288805A JP5331451B2 JP 5331451 B2 JP5331451 B2 JP 5331451B2 JP 2008288805 A JP2008288805 A JP 2008288805A JP 2008288805 A JP2008288805 A JP 2008288805A JP 5331451 B2 JP5331451 B2 JP 5331451B2
Authority
JP
Japan
Prior art keywords
interrupt
cpu
priority
request
signal
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
JP2008288805A
Other languages
Japanese (ja)
Other versions
JP2010117770A (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.)
MegaChips Corp
Original Assignee
MegaChips Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by MegaChips Corp filed Critical MegaChips Corp
Priority to JP2008288805A priority Critical patent/JP5331451B2/en
Publication of JP2010117770A publication Critical patent/JP2010117770A/en
Application granted granted Critical
Publication of JP5331451B2 publication Critical patent/JP5331451B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、CPUを備えたマイクロコントローラに関する。   The present invention relates to a microcontroller including a CPU.

従来より、CPUを備え、要求された割り込み処理を行うとともに、この割り込み処理の実行時間を監視するマイクロコントローラが知られている。   2. Description of the Related Art Conventionally, a microcontroller that includes a CPU and performs requested interrupt processing and monitors the execution time of the interrupt processing is known.

例えば、特許文献1には、割り込み許可信号が‘0’(割り込みディセーブル状態)になったときからタイマ動作を開始し、タイマによる経過時間が監視時間値を超えたときに、監視時間超過信号を発生する技術が提案されている。この技術によれば、割り込み禁止状態が続いていることを感知して、使用者やプログラムに注意を喚起することができる。   For example, in Patent Document 1, a timer operation is started when an interrupt permission signal becomes “0” (interrupt disabled state), and when the elapsed time by the timer exceeds the monitoring time value, the monitoring time excess signal A technique for generating the above has been proposed. According to this technology, it is possible to alert the user and the program by detecting that the interrupt disabled state continues.

また、特許文献2には、実行優先順位とともに実行時間が設定された各アプリケーションタスクの実行時間を実行時間監視部が監視し、実行時間が超過したことを検出したならば、優先順位変更部を起動して現在実行中のアプリケーションタスクの実行優先順位を下げる技術が提案されている。この技術によれば、障害が発生したタスクは優先順位が下げられるため、他の正常なタスクの実行周期に影響を与えずにシステムを正常に稼働することができる。
特開平2−18626号公報 特開平5−241906号公報
In Patent Document 2, the execution time monitoring unit monitors the execution time of each application task whose execution time is set together with the execution priority, and if it detects that the execution time has been exceeded, the priority order changing unit is A technique for lowering the execution priority of an application task that has been started and is currently being executed has been proposed. According to this technique, since the priority of a task in which a failure has occurred is lowered, the system can be operated normally without affecting the execution cycle of other normal tasks.
Japanese Patent Laid-Open No. 2-18626 Japanese Patent Laid-Open No. 5-241906

一般に、CPUを備えたマイクロコントローラにおいて、割り込みイネーブル状態で割り込み要求信号が受け付けられると、割り込みルーチンが起動されて割り込み処理が行なわれる。この割り込みルーチン実行時に、割り込みイネーブル状態であれば、さらに他の割り込みが受け付け可能であり(これを多重割り込みと称する)、一方割り込みディセーブル状態であれば、さらなる他の割り込みは受け付け不可となる。   In general, in a microcontroller provided with a CPU, when an interrupt request signal is accepted in an interrupt enabled state, an interrupt routine is started and interrupt processing is performed. When this interrupt routine is executed, if another interrupt is enabled, another interrupt can be accepted (this is referred to as a multiple interrupt). On the other hand, if another interrupt is disabled, no other interrupt can be accepted.

一般的なマイクロコントローラでは、割り込みイネーブル状態で割り込みを受け付けた場合、自動的に割り込みディセーブルの状態となるため、多重割り込みを許可するためには、明示的にソフトウェアにより割り込みルーチン内で割り込みイネーブル操作を行なう必要がある。   In general microcontrollers, when an interrupt is accepted in the interrupt enable state, the interrupt is automatically disabled. Therefore, to enable multiple interrupts, the interrupt enable operation must be performed explicitly in the interrupt routine by software. It is necessary to do.

ここで、多重割り込みを許可しない場合であって、予定以上に長時間にわたり処理が実行されている場合(割り込みルーチンから処理が抜け出せない状態に陥った場合等)、他の割り込み処理を行なうことはできず、その結果システム全体のパフォーマンスに支障が生じるという問題が発生する。換言すれば、ある処理に許される応答時間が規定されている場合、ある割り込みが発生した後に、その規定されている応答時間以内でその処理が開始されないと、システム全体が破綻してしまうという問題が発生する。   Here, when multiple interrupts are not permitted and processing has been executed for a longer time than planned (for example, when processing cannot escape from the interrupt routine), other interrupt processing is performed. This results in a problem that the performance of the entire system is hindered. In other words, if a response time allowed for a certain process is specified, the entire system will fail if the process is not started within the specified response time after an interrupt occurs. Will occur.

そこで、前記特許文献1では、タイマによる経過時間が監視時間値を超えたときに注意を喚起することが提案されている。しかし、特許文献1では、使用者やプログラムによる対処を求めるために注意を喚起するのみであり、マイクロコントローラが割り込みディセーブル状態を解除することは無い。   Therefore, in Patent Document 1, it is proposed to call attention when the elapsed time by the timer exceeds the monitoring time value. However, in Patent Document 1, attention is only given to request a countermeasure by the user or a program, and the microcontroller does not release the interrupt disabled state.

また、マイクロコントローラの中には、要因ごとに優先順位が設定された割り込み処理の要求を受信し、そのマイクロコントローラに備えられたCPUで実行中の割り込み処理よりも高い優先順位を有する割り込み処理の要求を受信したときに、その要求を受け付け、CPUに対してその受け付けた割り込み処理の起動を要求する割り込みコントローラを備えたものがある。この割り込みコントローラでは、優先順位の高い割り込み要因による割り込みサービスを実行している場合、この割り込み要因よりも低い優先順位の割り込みを受け付けることはない。このため、優先順位の低い割り込み要因は、優先順位の高い割り込み処理が完了するまで、待たなければならない。   Also, some microcontrollers receive interrupt processing requests with priorities set for each factor, and interrupt processing having higher priority than interrupt processing being executed by the CPU provided in the microcontroller. Some have an interrupt controller that receives the request and requests the CPU to start the accepted interrupt process when the request is received. In this interrupt controller, when an interrupt service is executed by an interrupt factor having a higher priority, an interrupt having a lower priority than the interrupt factor is not accepted. For this reason, an interrupt factor with a low priority must wait until the interrupt process with a high priority is completed.

従って、例えば、優先順位の高い割り込みルーチン内で何らかの問題が発生し、想定以上の長時問、CPUで実行されている処理がこのルーチンから抜け出せない状態に陥った場合、優先順位の低い割り込み処理を行なうことができず、その結果システム全体のパフォーマンスに支障が生じるという問題がある。   Therefore, for example, if a problem occurs in an interrupt routine with a high priority, and if the problem is longer than expected, or if the processing being executed by the CPU is not able to escape from this routine, the interrupt process with a low priority is performed. As a result, there is a problem that the performance of the entire system is hindered.

前記特許文献2では、実行時間が超過したときに、現在実行中のアプリケーションタスクの実行優先順位を下げる技術が提案されている。しかしながら、現在実行中に割り込みルーチンの優先順位を下げたとしても、割り込みディセーブル状態が継続している限りは、他の割込処理を行うことはできない。   Patent Document 2 proposes a technique for lowering the execution priority of an application task that is currently being executed when the execution time has exceeded. However, even if the priority of the interrupt routine is lowered during the current execution, other interrupt processing cannot be performed as long as the interrupt disabled state continues.

本発明は、上記事情に鑑み、システム全体のパフォーマンスを高めることができるマイクロコントローラを提供することを目的とする。   In view of the above circumstances, an object of the present invention is to provide a microcontroller that can improve the performance of the entire system.

上記目的を達成する本発明のマイクロコントローラは、
CPUを備えたマイクロコントローラであって、
要求された割り込み処理の起動が禁止された割り込みディセーブル状態と、要求された割り込み処理の起動が許可された割り込みイネーブル状態とを有し、
上記CPUにおいて実行中の割り込み処理の継続時間を計測するタイマと、そのタイマが計測した継続時間が所定値を超えたときに、上記CPUを割り込みディセーブル状態から割り込みイネーブル状態に変化させる割り込みイネーブル変更信号を生成する割り込み制御部を備えたことを特徴とする。
The microcontroller of the present invention that achieves the above object provides:
A microcontroller with a CPU,
An interrupt disabled state in which activation of the requested interrupt processing is prohibited, and an interrupt enable state in which activation of the requested interrupt processing is permitted,
A timer that measures the duration of interrupt processing being executed in the CPU, and an interrupt enable change that changes the CPU from an interrupt disabled state to an interrupt enabled state when the duration measured by the timer exceeds a predetermined value An interrupt control unit for generating a signal is provided.

本発明のマイクロコントローラは、CPUにおいて実行中の割り込み処理の継続時間が所定値を超えたときに、上記CPUを割り込みディセーブル状態から割り込みイネーブル状態に変化させる構成である。この構成によれば、CPUが割り込みディセーブル状態であるか割り込みイネーブル状態であるかに拘わらず、CPUを割り込みイネーブル状態に変化させることができる。従って、例えば、多重割り込みを許可しない割り込みルーチン内で何らかの問題が発生し、長時間にわたりCPUがこの割り込みルーチンから抜け出せない状態に陥った場合に、他の割り込みを強制的に許可することができる。従って、システム全体のパフォーマンスを高めることができる。   The microcontroller of the present invention is configured to change the CPU from the interrupt disabled state to the interrupt enabled state when the duration of interrupt processing being executed in the CPU exceeds a predetermined value. According to this configuration, the CPU can be changed to the interrupt enable state regardless of whether the CPU is in the interrupt disable state or the interrupt enable state. Therefore, for example, when a problem occurs in an interrupt routine that does not permit multiple interrupts, and the CPU enters a state in which it cannot escape from this interrupt routine for a long time, other interrupts can be forcibly permitted. Therefore, the performance of the entire system can be improved.

ここで、上記CPUで実行するソフトウエアが参照可能な履歴フラグ記録部をさらに備え、上記割り込みイネーブル変更信号が生成されたときにその履歴フラグ記録部にフラグを設定することが好ましい。   Here, it is preferable that a history flag recording unit that can be referred to by software executed by the CPU is further provided, and a flag is set in the history flag recording unit when the interrupt enable change signal is generated.

このようにすると、割り込みディセーブル状態から割り込みイネーブル状態に変化した場合、その変化をソフトウェアで確認することができる。従って、長時間にわたり割り込み処理が行なわれていた場合、その処理が有効か否か(その処理において何らかの問題が発生しているか否か)を判断することができる。   In this way, when the interrupt disable state changes to the interrupt enable state, the change can be confirmed by software. Therefore, if interrupt processing has been performed for a long time, it can be determined whether the processing is valid (whether any problem has occurred in the processing).

また、要因ごとに優先順位が設定された割り込み処理の要求を受信し、上記CPUにおいて実行中の割り込み処理よりも高い優先順位を有する割り込み処理の要求を受信したときに、その要求を受け付け、上記CPUに対してその受け付けた割り込み処理の起動を要求する割り込みコントローラであって、
上記タイマが計測した継続時間が上記所定値を超えたときに、その起動された割り込み処理の優先順位が低くなるように上記優先順位を設定する優先順位設定部を備える割り込みコントローラをさらに備えたことが好ましい。
Also, when receiving a request for interrupt processing having a priority set for each factor and receiving a request for interrupt processing having a higher priority than the interrupt processing being executed in the CPU, the request is accepted, An interrupt controller that requests the CPU to start the accepted interrupt process,
And further comprising an interrupt controller including a priority setting unit that sets the priority so that the priority of the activated interrupt processing is lowered when the duration measured by the timer exceeds the predetermined value. Is preferred.

このような割り込みコントローラを備えると、優先順位の高い割り込みルーチン内で何らかの問題が発生し、想定以上の長時問、CPUで実行されている処理がこのルーチンから抜け出せない状態に陥った場合であっても、優先順位の低い割り込み処理を行なうことができる。   When such an interrupt controller is provided, there is a problem in an interrupt routine with a high priority, a problem that is longer than expected, and a process that is being executed by the CPU cannot be escaped from this routine. However, interrupt processing with a low priority can be performed.

本発明によれば、システム全体のパフォーマンスを高めることができるマイクロコントローラが提供される。   According to the present invention, a microcontroller that can improve the performance of the entire system is provided.

以下、図面を参照して本発明の実施の形態を説明する。   Embodiments of the present invention will be described below with reference to the drawings.

図1は、本発明の一実施形態のマイクロコントローラの構成を示す図である。   FIG. 1 is a diagram showing a configuration of a microcontroller according to an embodiment of the present invention.

図1に示すマイクロコントローラ1には、割り込みコントローラ10と、CPU20が備えられている。   The microcontroller 1 shown in FIG. 1 includes an interrupt controller 10 and a CPU 20.

割り込みコントローラ10には、要因ごとに優先順位が設定された割り込み処理の要求を示す割り込み要因信号IR0,IR1,IR2,IR3が入力される。ここでは、割り込み要因信号IR0,IR1,IR2,IR3の順に優先順位が高くなっているものとする。割り込みコントローラ10の構成については後述するが、この割り込みコントローラ10は、CPU20で実行中の割り込み処理よりも高い優先順位を有する割り込み処理の要求を示す割り込み要因信号を入力したときに、その要求を受け付け、CPU20に対して受け付けた割り込み処理の起動を要求する割り込み要求信号INT_を出力する。また、割り込みコントローラ10は、データバスを経由して外部にデータDOを出力する。   The interrupt controller 10 receives interrupt factor signals IR0, IR1, IR2, and IR3 indicating requests for interrupt processing with priorities set for respective factors. Here, it is assumed that the priority order is higher in the order of the interrupt factor signals IR0, IR1, IR2, and IR3. Although the configuration of the interrupt controller 10 will be described later, the interrupt controller 10 accepts the request when an interrupt factor signal indicating a request for an interrupt process having a higher priority than the interrupt process being executed by the CPU 20 is input. Then, an interrupt request signal INT_ for requesting the CPU 20 to start the accepted interrupt process is output. The interrupt controller 10 outputs data DO to the outside via the data bus.

CPU20は、アドレス信号ADR,リード信号RD,ライト信号WDを外部に出力する。また、CPU20は、データバスを経由して外部からのデータDIを入力するとともに、データバスを経由して外部にデータDOを出力する。さらに、CPU20の詳細について図2を参照して説明する。   The CPU 20 outputs an address signal ADR, a read signal RD, and a write signal WD to the outside. Further, the CPU 20 inputs data DI from the outside via the data bus and outputs data DO to the outside via the data bus. Details of the CPU 20 will be described with reference to FIG.

図2は、図1に示すCPUの内部構成を示す図である。   FIG. 2 is a diagram showing an internal configuration of the CPU shown in FIG.

図2に示すCPU20には、割り込み処理部21と、制御回路部22と、レジスタ部23と、演算部24とが備えられている。割り込み処理部21,制御回路部22,レジスタ部23,演算部24には、リード信号RD,ライト信号WD等の制御信号CNTが入力される。   The CPU 20 shown in FIG. 2 includes an interrupt processing unit 21, a control circuit unit 22, a register unit 23, and a calculation unit 24. Control signals CNT such as a read signal RD and a write signal WD are input to the interrupt processing unit 21, the control circuit unit 22, the register unit 23, and the calculation unit 24.

割り込み処理部21は、図1に示す割り込みコントローラ10からの割り込み要求信号INT_の入力を受け、CPU20全体の制御を司る制御回路部22へ割り込み要求を伝達する。   The interrupt processing unit 21 receives an interrupt request signal INT_ from the interrupt controller 10 shown in FIG. 1 and transmits an interrupt request to the control circuit unit 22 that controls the entire CPU 20.

制御回路部22は、CPU20が動作する期間のうちの割り込み処理を受け付けることが可能な期間になった時点で、割り込み処理部21へ割り込み許可を与える。割り込み処理部21は、この割り込み許可を受けて、割り込み許可信号INTA_を割り込みコントローラ10に出力する。   The control circuit unit 22 gives an interrupt permission to the interrupt processing unit 21 when it becomes a period during which the interrupt processing can be accepted during the period in which the CPU 20 operates. The interrupt processing unit 21 receives this interrupt permission and outputs an interrupt permission signal INTA_ to the interrupt controller 10.

レジスタ部23は、データを保持する記憶用のラッチ回路から構成されており、このレジスタ部23からは、あらかじめ読み込まれたプログラムコードによるデータが演算部24へ出力される。   The register unit 23 is configured by a storage latch circuit that holds data, and the register unit 23 outputs data according to a program code read in advance to the arithmetic unit 24.

演算部24は、レジスタ部23からのデータを用いて論理演算や算術演算を行ない、その結果をレジスタ部23へ書き戻す。   The arithmetic unit 24 performs a logical operation or an arithmetic operation using the data from the register unit 23 and writes the result back to the register unit 23.

尚、CPU20が外部のメモリや1/0に対して、データの読み出しやデータの書き込みを行なう際に必要なアドレス信号ADRSとデータDATAは、レジスタ部23から出力されるようになっている。さらに、CPU20の内部構成について、図3を参照して詳細に説明する。   Note that the address signal ADRS and data DATA required when the CPU 20 reads data from or writes data to an external memory or 1/0 is output from the register unit 23. Further, the internal configuration of the CPU 20 will be described in detail with reference to FIG.

図3は、図2に示す割り込み処理部およびレジスタ部の構成を示す図である。   FIG. 3 is a diagram showing the configuration of the interrupt processing unit and the register unit shown in FIG.

図3に示す割り込み処理部21には、フリップフロップ21_1と、アンドゲート21_2と、計測タイマ21_3(本発明にいうタイマの一例に相当)と、比較器21_4と、アンドゲート21_5,21_6と、オアゲート21_7とが備えられている。   The interrupt processing unit 21 shown in FIG. 3 includes a flip-flop 21_1, an AND gate 21_2, a measurement timer 21_3 (corresponding to an example of a timer according to the present invention), a comparator 21_4, AND gates 21_5 and 21_6, and an OR gate. 21_7.

一方、レジスタ部23には、フリップフロップ23_1と、割り込みイネーブルレジスタ23_2と、設定値レジスタ23_3とが備えられている。   On the other hand, the register unit 23 includes a flip-flop 23_1, an interrupt enable register 23_2, and a set value register 23_3.

ここで、図3に示す割り込み許可信号INTA_は、割り込み処理部21の図示しない部分で生成され、この割り込み処理部21を構成するフリップフロップ21_1に、割り込み許可信号INTA_とクロック信号CLKが入力される。このフリップフロップ21_1と、次段のアンドゲート21_2とから、割り込み許可信号INTA_の立ち下がりエッジを検出する回路が構成される。この回路からの、割り込み許可信号INTA_の立ち下がりエッジが、計測タイマ21_3ヘのカウント開始信号COUNTとなり、この計測タイマ21_3でクロック信号CLKのクロックをカウントすることにより割り込みサービスの継続時間が測定される。   Here, the interrupt permission signal INTA_ shown in FIG. 3 is generated at a portion (not shown) of the interrupt processing unit 21, and the interrupt permission signal INTA_ and the clock signal CLK are input to the flip-flop 21 </ b> _ 1 constituting the interrupt processing unit 21. . The flip-flop 21_1 and the AND gate 21_2 at the next stage constitute a circuit that detects the falling edge of the interrupt permission signal INTA_. The falling edge of the interrupt enable signal INTA_ from this circuit becomes the count start signal COUNT to the measurement timer 21_3, and the duration of the interrupt service is measured by counting the clock of the clock signal CLK by the measurement timer 21_3. .

一方、レジスタ部23を構成する設定値レジスタ23_3には、CPU20が実行する命令により、任意の値がセットされる。また、割り込み処理部21を構成する比較器21_4は、この設定値レジスタ23_3の値と計測タイマ21_3の値を比較する回路である。両者が一致した時点で比較器21_4から割り込みイネーブル変更信号IECとして論理‘1’(‘H’レベル)が出力される。   On the other hand, an arbitrary value is set in the set value register 23_3 constituting the register unit 23 by an instruction executed by the CPU 20. The comparator 21_4 constituting the interrupt processing unit 21 is a circuit that compares the value of the set value register 23_3 with the value of the measurement timer 21_3. When the two match, the comparator 21_4 outputs a logic “1” (“H” level) as the interrupt enable change signal IEC.

レジスタ部23を構成する割り込みイネーブルレジスタ23_2は、その値が、図2に示す制御回路部22において、割り込み要求信号INT_を受け付けるか否かの判断に使用される。詳細には、この図3に示す割り込みイネーブルレジスタ23_2は、割り込み許可信号INTA_の立ち下がりエッジに基づいて生成されるカウント開始信号COUNTによってディセーブル状態になり、割り込みイネーブル信号IEとして‘L’レベルを出力する。また、割り込みイネーブル変更信号IECによってイネーブル状態になり、割り込みイネーブル信号IEとして‘H’レベルを出力する。即ち、CPU20は、‘H’レベルの割り込みイネーブル信号IEが出力されているときには、割り込みイネーブルの状態になっている。   The interrupt enable register 23_2 constituting the register unit 23 is used to determine whether or not the control circuit unit 22 shown in FIG. 2 accepts the interrupt request signal INT_. Specifically, the interrupt enable register 23_2 shown in FIG. 3 is disabled by the count start signal COUNT generated based on the falling edge of the interrupt enable signal INTA_, and sets the 'L' level as the interrupt enable signal IE. Output. Further, it is enabled by the interrupt enable change signal IEC, and outputs the “H” level as the interrupt enable signal IE. That is, the CPU 20 is in an interrupt enable state when the interrupt enable signal IE of “H” level is output.

一方、割り込みイネーブル変更信号IECは、割り込みコントローラ10(図1参照)ヘ‘優先順位変更要求信号PCR’として出力される。また、この割り込みイネーブル変更信号IECは、アンドゲート21_5,21_6,オアゲート21_7からなる回路に入力される。この回路からの出力はフリップフロップ23_1に入力され、このフリップフロップ23_1から履歴フラグF(割り込みイネーブル変更履歴フラグ)が出力される。尚、このフリップフロップ23_1が、本発明にいう履歴フラグ記録部の一例に相当する。この履歴フラグFは、割り込み許可信号INTA_がアクティブ(‘L’レベル)になった時点でクリア(‘0’)され、計測タイマ21_3の値が設定値レジスタ23_3の値と同じになった時点でセット(‘1’)される。ソフトウェアでは、この履歴フラグFを参照することで、そのルーチンでの処理が途中で問題が生じたものか否かを判定することが可能となる。   On the other hand, the interrupt enable change signal IEC is output as a “priority change request signal PCR” to the interrupt controller 10 (see FIG. 1). The interrupt enable change signal IEC is input to a circuit composed of AND gates 21_5, 21_6 and OR gate 21_7. An output from this circuit is input to the flip-flop 23_1, and a history flag F (interrupt enable change history flag) is output from the flip-flop 23_1. The flip-flop 23_1 corresponds to an example of a history flag recording unit referred to in the present invention. This history flag F is cleared ('0') when the interrupt permission signal INTA_ becomes active ('L' level), and when the value of the measurement timer 21_3 becomes the same as the value of the set value register 23_3. Set ('1'). By referring to the history flag F, the software can determine whether or not a problem has occurred during the processing in the routine.

図4は、図1に示す割り込みコントローラの構成を示す図である。   FIG. 4 is a diagram showing a configuration of the interrupt controller shown in FIG.

図4に示す割り込みコントローラ10には、割り込み要求レジスタ(IRR)11と、制御回路12と、優先順位割当回路13と、割り込みサービスレジスタ(ISR)14とが備えられている。   The interrupt controller 10 shown in FIG. 4 includes an interrupt request register (IRR) 11, a control circuit 12, a priority order assignment circuit 13, and an interrupt service register (ISR) 14.

割り込み要求レジスタ11には、割り込み処理の要求を示す割り込み要因信号IR0,IR1,IR2,IR3が入力される。尚、これら割り込み要因信号IR0,IR1,IR2,IR3の優先順位は、前述したように、割り込み要因信号IR0,IR1,IR2,IR3の順に高くなっている。この割り込み要求レジスタ11では、割り込み要因信号IR0,IR1,IR2,IR3のいずれかの割り込み要因信号による割り込み要求が発生すると、その割り込み要因信号に該当するビットが‘1’にセットされる。その後、制御回路12が、CPU20から割り込み許可信号INTA_を受信すると、その該当ビットは‘0’にリセットされる。   The interrupt request register 11 receives interrupt factor signals IR0, IR1, IR2 and IR3 indicating interrupt processing requests. Note that the priority order of the interrupt factor signals IR0, IR1, IR2, and IR3 is higher in the order of the interrupt factor signals IR0, IR1, IR2, and IR3, as described above. In the interrupt request register 11, when an interrupt request is generated by any one of the interrupt factor signals IR0, IR1, IR2, and IR3, the bit corresponding to the interrupt factor signal is set to '1'. Thereafter, when the control circuit 12 receives the interrupt permission signal INTA_ from the CPU 20, the corresponding bit is reset to '0'.

割り込みサービスレジスタ14では、割り込みコントローラ10が割り込みサービスを行なっていると、その割り込みサービスの該当ビットが‘1’にセットされる。また、そのサービスが終了すると該当ビットが‘0’にリセットされる。   In the interrupt service register 14, when the interrupt controller 10 performs an interrupt service, the corresponding bit of the interrupt service is set to “1”. When the service is completed, the corresponding bit is reset to “0”.

優先順位割当回路13は、本発明にいう優先順位設定部の一例に相当し、割り込み要因の優先順位の設定および割り当てを行なう。   The priority assignment circuit 13 corresponds to an example of a priority setting unit according to the present invention, and sets and assigns priority of interrupt factors.

制御回路12は、割り込みの受け付け、割り込み要求のマスク、および割り込みサービスの割り当てを行なう。また、CPU20からの優先順位変更要求信号PCRを受けて、優先順位割当回路13の優先順位の設定を、現在サービス中の割り込み要因に対応する優先順位が相対的に低下させるように変更する機能を有する。   The control circuit 12 accepts interrupts, masks interrupt requests, and assigns interrupt services. Also, a function of receiving a priority change request signal PCR from the CPU 20 and changing the priority setting of the priority assignment circuit 13 so that the priority corresponding to the interrupt factor currently in service is relatively lowered. Have.

さらに、制御回路12は、いわゆる割り込みベクタ方式に要求される割り込みルーチンの開始アドレス(割り込みベクタ)を、データバス上に出力する機能を有する。   Further, the control circuit 12 has a function of outputting the start address (interrupt vector) of the interrupt routine required for the so-called interrupt vector method on the data bus.

この制御回路12は、割り込み要求レジスタ11からの割り込み要求を受けると、割り込みサービスレジスタ14を参照してCPU20において実行中の割り込み処理(サービス)を把握するとともに、優先順位割当回路13を利用して、割り込み要求レジスタ11から受けた要求の割り込み要因の優先順位が、実行中の割り込み処理を要求する割り込み要因の優先順位に比較して高いか否かを(言い換えると、割り込み要求レジスタ11から受けた要求の割り込み要因による割り込みサービスの優先順位が、実行中の割り込みサービスの優先順位に比較して高いか否かを)判断する。そして、実行中の割り込みサービスよりも高い優先順位を有する割り込みサービスの要求を受けたと判断したときには、その要求を受け付け、サービスの割り当てを実施し、CPU20に向けて割り込み要求信号INT_を出力する。これにより、CPU20に対して割り込みの要求を行なう。CPU20は、この割り込み要求信号INT_を受けて、割り込みが受け付け可能となった時点で割り込み許可信号INTA_を、この制卸回路12に出力する。これを受けて、制御回路12は、データバス上に割り込み要因に対応する割り込みベクタを出力し、さらにサービスを割り当てた要因に対応するビットについて、割り込みサービスレジスタ14の該当ビットを‘1’に設定する。このようにして、割り込みサービスレジスタ14の値を更新する。すなわち、割り込みサービスレジスタ14の値が更新された時点で割り込みサービスが開始される。   When receiving an interrupt request from the interrupt request register 11, the control circuit 12 refers to the interrupt service register 14 to grasp the interrupt processing (service) being executed in the CPU 20 and uses the priority assignment circuit 13. Whether the priority of the interrupt factor of the request received from the interrupt request register 11 is higher than the priority of the interrupt factor requesting the interrupt processing being executed (in other words, from the interrupt request register 11 It is determined whether or not the priority of the interrupt service due to the interrupt factor of the request is higher than the priority of the interrupt service being executed. When it is determined that an interrupt service request having a higher priority than the interrupt service being executed has been received, the request is accepted, the service is allocated, and an interrupt request signal INT_ is output to the CPU 20. Thereby, an interrupt request is made to the CPU 20. The CPU 20 receives the interrupt request signal INT_, and outputs an interrupt permission signal INTA_ to the control circuit 12 when the interrupt becomes acceptable. In response to this, the control circuit 12 outputs an interrupt vector corresponding to the interrupt factor on the data bus, and sets the corresponding bit of the interrupt service register 14 to “1” for the bit corresponding to the factor to which the service is assigned. To do. In this way, the value of the interrupt service register 14 is updated. In other words, the interrupt service is started when the value of the interrupt service register 14 is updated.

図5は、図4に示す割り込みコントローラの、割り込み要求を受けてから割り込みサービスが開始されるまでのタイミングを示す図である。   FIG. 5 is a diagram showing the timing from when the interrupt controller shown in FIG. 4 receives an interrupt request until the interrupt service is started.

最初の時点では、制御回路12から出力される割り込み要求信号INT_、およびCPU20から出力される割り込み許可信号INTA_は、ともに‘H’レベルにある。   At the first time point, the interrupt request signal INT_ output from the control circuit 12 and the interrupt permission signal INTA_ output from the CPU 20 are both at the ‘H’ level.

ここで、制御回路12が割り込み要求レジスタ11からの割り込み要求を受けると、この制御回路12は、クロック信号CLKの最初のクロックの立ち上がりエッジで、割り込み要求信号INT_を‘H’レベルから‘L’レベルに変化させる。この‘L’レベルの割り込み要求信号INT_はCPU20に入力される。   When the control circuit 12 receives an interrupt request from the interrupt request register 11, the control circuit 12 changes the interrupt request signal INT_ from the “H” level to the “L” at the rising edge of the first clock of the clock signal CLK. Change to level. The 'L' level interrupt request signal INT_ is input to the CPU 20.

すると、CPU20は、次のクロックの立ち上がりエッジで、この‘L’レベルの割り込み要求信号INT_を取り込む。さらに、CPU20は、その時点で割り込みが受け付け可能であった場合には、次のクロックの立ち上がりエッジで、割り込み許可信号INTA_を‘H’レベルから‘L’レベルに変化させる。   Then, the CPU 20 captures the 'L' level interrupt request signal INT_ at the rising edge of the next clock. Further, when the interrupt can be accepted at that time, the CPU 20 changes the interrupt permission signal INTA_ from the ‘H’ level to the ‘L’ level at the rising edge of the next clock.

制卸回路12では、これを受けて、さらに2つ目のクロックの立ち上がりエッジで、データバス上に割り込みベクタを出力する。   In response to this, the control circuit 12 outputs an interrupt vector on the data bus at the rising edge of the second clock.

さらに次のクロックの立ち上がりエッジで、割り込みサービスレジスタ14は、生成した割り込みベクタに対応する割込要因に基づいて該当ビットを「1」に設定する。これにより、割り込みサービスレジスタ14の値を更新する。また、CPU20は、所定の時間の後に、割り込み許可信号INTA_を‘L’レベルから‘H’レベルに変化させる。   Further, at the next rising edge of the clock, the interrupt service register 14 sets the corresponding bit to “1” based on the interrupt factor corresponding to the generated interrupt vector. As a result, the value of the interrupt service register 14 is updated. Further, after a predetermined time, the CPU 20 changes the interrupt permission signal INTA_ from the “L” level to the “H” level.

さらに、次のクロックの立ち上がりエッジで、割り込みサービスが開始される。また、制御回路12は、割り込み許可信号INTA_が‘H’レベルになったことを受けて、さらに次のクロックの立ち上がりエッジで、割り込み要求信号INT_を‘L’レベルから‘H’レベルに変化させる。   Furthermore, the interrupt service is started at the next rising edge of the clock. Further, the control circuit 12 changes the interrupt request signal INT_ from the “L” level to the “H” level at the next rising edge of the clock in response to the interrupt permission signal INTA_ becoming the “H” level. .

図6は、図1に示すマイクロコントローラの割り込みシーケンスの一例を示す図である。   FIG. 6 is a diagram showing an example of an interrupt sequence of the microcontroller shown in FIG.

ここでは、前述したように、割り込み要因信号IR0,IR1,IR2,IR3の順に優先順位が高くなっている。先ず、割り込み要因信号IR1が発生し、この割り込み要因信号IR1による割り込み処理が行なわれる。即ち、この割り込み要因信号IR1によるサービス状態になる。この割り込み処理中に、割り込み要因信号IR0が発生するが、この割り込み要因信号IR0の優先順位は、割り込み要因信号IR1よりも低いため、割り込み要因信号IR0による割り込み要求は受け付けられず、サービスは行なわれない。尚、この例では、割り込み要因信号IR2,IR3は発生しないものとする。また、割り込み要因信号IR1は長期化するものとする。   Here, as described above, the priority order is higher in the order of the interrupt factor signals IR0, IR1, IR2, and IR3. First, an interrupt factor signal IR1 is generated, and an interrupt process by the interrupt factor signal IR1 is performed. That is, the service state is established by the interrupt factor signal IR1. During this interrupt processing, the interrupt factor signal IR0 is generated. Since the priority of the interrupt factor signal IR0 is lower than that of the interrupt factor signal IR1, the interrupt request by the interrupt factor signal IR0 is not accepted and the service is performed. Absent. In this example, interrupt factor signals IR2 and IR3 are not generated. The interrupt factor signal IR1 is assumed to be long.

ここで、計測タイマ21_3(図3参照)の値が設定値レジスタ23_3の値と一致する。この時、優先順位変更要求信号PCRが有効となり、割り込み要因信号IR1,IR2,IR3,IR0の順に優先順位が高くなるように変更される。これに伴い、割り込み要因信号IR1によるサービスが中断され、割り込み要因信号IR0による割り込み処理が開始される。   Here, the value of the measurement timer 21_3 (see FIG. 3) matches the value of the set value register 23_3. At this time, the priority change request signal PCR becomes valid, and the priority is changed in the order of the interrupt factor signals IR1, IR2, IR3, IR0. Along with this, service by the interrupt factor signal IR1 is interrupted, and interrupt processing by the interrupt factor signal IR0 is started.

尚、割り込みイネーブルレジスタ23_2は、割り込み要因信号IR1,IR0によるサービス開始直前まではイネーブル状態にある。このため、CPU20では、割り込み要求信号INT_が受け付けられる。割り込み要求信号INT_が受け付けられて、割り込み要因信号IR1,IR0によるサービスが開始されると、割り込みイネーブルレジスタ23_2はディセーブル状態になる。さらに、割り込みイネーブルレジスタ23_2は、計測タイマ21_3の値と設定値レジスタ23_3の値とが一致した時点でイネーブル状態となる。その後、割り込み要因信号IR0による割り込み処理が開始された時点でディセーブル状態となる。   The interrupt enable register 23_2 is in an enabled state until immediately before the service is started by the interrupt factor signals IR1 and IR0. Therefore, the CPU 20 accepts the interrupt request signal INT_. When the interrupt request signal INT_ is accepted and service by the interrupt factor signals IR1 and IR0 is started, the interrupt enable register 23_2 is disabled. Furthermore, the interrupt enable register 23_2 is enabled when the value of the measurement timer 21_3 matches the value of the set value register 23_3. Thereafter, the interrupt state is disabled when the interrupt processing by the interrupt factor signal IR0 is started.

以上説明したように、本実施形態のマイクロコントローラ1では、例えば多重割り込みを許可しない割り込みルーチン内で何らかの問題が発生し、長時間にわたりCPU20が割り込みルーチンから抜け出せない状態に陥った場合に、低い優先順位の割り込みを許可することができる。従って、システム全体のパフォーマンスを高めることができる。   As described above, in the microcontroller 1 of this embodiment, for example, when a problem occurs in an interrupt routine that does not permit multiple interrupts, and the CPU 20 falls into a state where it cannot escape from the interrupt routine for a long time, low priority is given. Ranking interrupts can be allowed. Therefore, the performance of the entire system can be improved.

尚、本実施形態では、CPU内に計測タイマを備えた例で説明したが、これに限られるものではなく、割り込みコントローラ内に計測タイマを備えてもよく、本発明は、CPUにおいて実行中の割り込み処理の継続時間を計測するタイマを、CPU内と割り込みコントローラ内とのいずれに備えてもよい。   In the present embodiment, the example in which the measurement timer is provided in the CPU has been described. However, the present invention is not limited to this, and the measurement timer may be provided in the interrupt controller. A timer for measuring the duration of interrupt processing may be provided in either the CPU or the interrupt controller.

本発明の一実施形態のマイクロコントローラの構成を示す図である。It is a figure which shows the structure of the microcontroller of one Embodiment of this invention. 図1に示すCPUの内部構成を示す図である。It is a figure which shows the internal structure of CPU shown in FIG. 図2に示す割り込み処理部およびレジスタ部の構成を示す図である。FIG. 3 is a diagram illustrating a configuration of an interrupt processing unit and a register unit illustrated in FIG. 2. 図1に示す割り込みコントローラの構成を示す図である。It is a figure which shows the structure of the interrupt controller shown in FIG. 図4に示す割り込みコントローラの、割り込み要求を受けてから割り込みサービスが開始されるまでのタイミングを示す図である。FIG. 5 is a diagram illustrating timings from when an interrupt request is received until an interrupt service is started by the interrupt controller shown in FIG. 4. 図1に示すマイクロコントローラの割り込みシーケンスの一例を示す図である。It is a figure which shows an example of the interruption sequence of the microcontroller shown in FIG.

符号の説明Explanation of symbols

1 マイクロコントローラ
10 割り込みコントローラ
11 割り込み要求レジスタ
12 制御回路
13 優先順位割当回路
14 割り込みサービスレジスタ
20 CPU
21 割り込み処理部
21_1,23_1 フリップフロップ
21_2,21_5,21_6 アンドゲート
21_3 計測タイマ
21_4 比較器
21_7 オアゲート
22 制御回路部
23 レジスタ部
23_2 割り込みイネーブルレジスタ
23_3 設定値レジスタ
24 演算部
1 Microcontroller 10 Interrupt Controller 11 Interrupt Request Register 12 Control Circuit 13 Priority Assignment Circuit 14 Interrupt Service Register 20 CPU
DESCRIPTION OF SYMBOLS 21 Interrupt processing part 21_1, 23_1 Flip-flop 21_2, 21_5, 21_6 AND gate 21_3 Measurement timer 21_4 Comparator 21_7 OR gate 22 Control circuit part 23 Register part 23_2 Interrupt enable register 23_3 Setting value register 24 Calculation part

Claims (2)

CPUを備えたマイクロコントローラであって、
要求された割り込み処理の起動が禁止された割り込みディセーブル状態と、要求された割り込み処理の起動が許可された割り込みイネーブル状態とを有し、
前記CPUにおいて実行中の割り込み処理の継続時間を計測するタイマと、該タイマが計測した継続時間が所定値を超えたときに、前記CPUを割り込みディセーブル状態から割り込みイネーブル状態に変化させる割り込みイネーブル変更信号を生成する割り込み制御部と、前記CPUで実行するソフトウエアが参照可能な履歴フラグ記録部とを備え、前記割り込みイネーブル変更信号が生成されたときに該履歴フラグ記録部にフラグを設定することを特徴とするマイクロコントローラ。
A microcontroller with a CPU,
An interrupt disabled state in which activation of the requested interrupt processing is prohibited, and an interrupt enable state in which activation of the requested interrupt processing is permitted,
A timer that measures the duration of interrupt processing being executed in the CPU, and an interrupt enable change that changes the CPU from an interrupt disable state to an interrupt enable state when the duration measured by the timer exceeds a predetermined value An interrupt control unit that generates a signal, and a history flag recording unit that can be referred to by software executed by the CPU, and sets a flag in the history flag recording unit when the interrupt enable change signal is generated A microcontroller characterized by
要因ごとに優先順位が設定された割り込み処理の要求を受信し、前記CPUにおいて実行中の割り込み処理よりも高い優先順位を有する割り込み処理の要求を受信したときに、該要求を受け付け、前記CPUに対して該受け付けた割り込み処理の起動を要求する割り込みコントローラであって、
前記タイマが計測した継続時間が前記所定値を超えたときに、該起動された割り込み処理の優先順位が低くなるように前記優先順位を設定する優先順位設定部を備える割り込みコントローラをさらに備えたことを特徴とする請求項1記載のマイクロコントローラ。
When receiving a request for an interrupt process having a priority set for each factor and receiving a request for an interrupt process having a higher priority than the interrupt process being executed in the CPU, the request is accepted and the CPU receives the request. An interrupt controller that requests activation of the accepted interrupt processing,
And further comprising an interrupt controller including a priority setting unit for setting the priority so that the priority of the activated interrupt processing is lowered when the duration measured by the timer exceeds the predetermined value. The microcontroller according to claim 1.
JP2008288805A 2008-11-11 2008-11-11 Microcontroller Expired - Fee Related JP5331451B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2008288805A JP5331451B2 (en) 2008-11-11 2008-11-11 Microcontroller

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2008288805A JP5331451B2 (en) 2008-11-11 2008-11-11 Microcontroller

Publications (2)

Publication Number Publication Date
JP2010117770A JP2010117770A (en) 2010-05-27
JP5331451B2 true JP5331451B2 (en) 2013-10-30

Family

ID=42305428

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2008288805A Expired - Fee Related JP5331451B2 (en) 2008-11-11 2008-11-11 Microcontroller

Country Status (1)

Country Link
JP (1) JP5331451B2 (en)

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS5295133A (en) * 1976-02-06 1977-08-10 Mitsubishi Electric Corp Buss occupation demand adjusting system
JPH06103467B2 (en) * 1985-01-31 1994-12-14 富士重工業株式会社 Preventing malfunction of automobile computer
JPS6214235A (en) * 1985-07-10 1987-01-22 Nec Corp Information processor
JPH0218626A (en) * 1988-07-06 1990-01-22 Hokuriku Nippon Denki Software Kk Interruption inhibition monitoring system
JPH02310629A (en) * 1989-05-26 1990-12-26 Hitachi Ltd Interruption controller, common resource exclusive method and assembler program processing method
JPH03102430A (en) * 1989-09-14 1991-04-26 Nippon Telegr & Teleph Corp <Ntt> Interruption control system
JPH04225432A (en) * 1990-12-27 1992-08-14 Nec Eng Ltd Interruption processing time control system for one-chip microcomputer
JPH05241906A (en) * 1991-10-21 1993-09-21 Mitsubishi Electric Corp Programmable controller
JP3572650B2 (en) * 1994-01-24 2004-10-06 株式会社リコー Interrupt controller and control method thereof
JP3512603B2 (en) * 1997-09-11 2004-03-31 富士通株式会社 Data processing device

Also Published As

Publication number Publication date
JP2010117770A (en) 2010-05-27

Similar Documents

Publication Publication Date Title
EP2315113A1 (en) Multi-threaded processors and multi-processor systems comprising shared resources
EP1685486B1 (en) Interrupt handling in an embedded multi-threaded processor to avoid priority inversion and maintain real-time operation
JP2010277303A (en) Semiconductor device and failure detection method
US10229077B2 (en) Method for data transfer between real-time tasks using a DMA memory controller
JP2009110156A (en) Log output device and log output program
JP4523910B2 (en) Parallel processing device, parallel processing method, and parallel processing program
CN109933549B (en) Interrupt controller suitable for RISC-V treater
JP2006244382A (en) Microprocessor
JP2011134162A (en) System and method for controlling switching of task
JP5331451B2 (en) Microcontroller
JP2006201948A (en) Interrupt signal accepting device and method
JP2004127163A (en) Multiprocessor system
US20220415405A1 (en) Memory-control circuit and method for controlling erasing operation of flash memory
JP2007299126A (en) Controller and program for controller
JP4647276B2 (en) Semiconductor circuit device
JP2009098972A (en) Interruption control method and interruption system
JP2010140440A (en) Bus arbitration device
JP2010113414A (en) Multicore system, thread scheduling method, program, and storage medium
JP2011107939A (en) Redundant system information processor
JPH09167117A (en) Microcomputer and real time system using the microcomputer
JP2007128396A (en) Interrupt control method and information processor
KR100930009B1 (en) Method of interrupt processing
JP2009093393A (en) Data processing device, and self-diagnosis method for data processing device
WO2008062508A1 (en) Multiprocessor system
JP2009086908A (en) Microcomputer device

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20111011

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20130426

A711 Notification of change in applicant

Free format text: JAPANESE INTERMEDIATE CODE: A712

Effective date: 20130430

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20130514

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A821

Effective date: 20130516

RD04 Notification of resignation of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7424

Effective date: 20130516

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A821

Effective date: 20130620

RD04 Notification of resignation of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7424

Effective date: 20130620

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20130708

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20130723

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20130729

R150 Certificate of patent or registration of utility model

Ref document number: 5331451

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

LAPS Cancellation because of no payment of annual fees