JP4947027B2 - Microcomputer - Google Patents

Microcomputer Download PDF

Info

Publication number
JP4947027B2
JP4947027B2 JP2008261690A JP2008261690A JP4947027B2 JP 4947027 B2 JP4947027 B2 JP 4947027B2 JP 2008261690 A JP2008261690 A JP 2008261690A JP 2008261690 A JP2008261690 A JP 2008261690A JP 4947027 B2 JP4947027 B2 JP 4947027B2
Authority
JP
Japan
Prior art keywords
task
break
switching
address
cpu
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
JP2008261690A
Other languages
Japanese (ja)
Other versions
JP2010092271A (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.)
Denso Corp
Original Assignee
Denso Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Denso Corp filed Critical Denso Corp
Priority to JP2008261690A priority Critical patent/JP4947027B2/en
Publication of JP2010092271A publication Critical patent/JP2010092271A/en
Application granted granted Critical
Publication of JP4947027B2 publication Critical patent/JP4947027B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、CPUが周期タスクと非周期タスクとを時分割並行的に実行可能であると共に、ICEインターフェイス部を備えるマイクロコンピュータに関する。   The present invention relates to a microcomputer in which a CPU can execute a periodic task and an aperiodic task in a time-sharing manner in parallel and has an ICE interface unit.

出願人は、1つのCPUにおいて、制御クロックに同期して2つのタスクを交互に切り換えて実行させ、一方のタスクでは割込み処理を受け付けることなく常に一定の周期で処理を行わせ、他方のタスクで割込み処理を受け付けて処理させるように構成したマイクロコンピュータを提案している(例えば、特許文献1参照)。
そして、上記マイクロコンピュータのタスク処理形態を発展させたものとして、常時一定周期で処理を行う周期タスクの実行をベースとして、その周期内において周期タスクが実行すべき命令の実行が完了した時点で非周期タスクを実行させるように構成したマイクロコンピュータも提案している(特許文献2参照)。
特開平6−250857号公報 特開2008−77294号公報
The applicant causes one CPU to alternately switch and execute two tasks in synchronization with the control clock, and allows one task to always perform processing at a constant cycle without accepting interrupt processing. A microcomputer configured to accept and process interrupt processing has been proposed (see, for example, Patent Document 1).
Then, as a development of the task processing form of the microcomputer, the execution of the instruction to be executed by the periodic task within that period is completed based on the execution of the periodic task that always performs processing at a constant period. A microcomputer configured to execute a periodic task has also been proposed (see Patent Document 2).
JP-A-6-250857 JP 2008-77294 A

ここで、特許文献2に開示されているマイクロコンピュータについて、ICEを用いて開発作業を行うことを想定すると、以下のような問題がある。図5は、非周期タスクであるAタスクを実行している途中で、ブレーク命令が発行された場合のCPUの動作を示すタイミングチャートである。(a)のタスクタイマは、CPUが周期タスクの実行周期を計時するタイマであり、(b)のアドレスは、Aタスクの実行アドレスA0,A2,A4,…を示している。   Here, regarding the microcomputer disclosed in Patent Document 2, assuming that development work is performed using ICE, there are the following problems. FIG. 5 is a timing chart showing the operation of the CPU when a break instruction is issued during the execution of the A task, which is an aperiodic task. The task timer in (a) is a timer for the CPU to measure the execution cycle of the periodic task, and the address in (b) indicates the execution addresses A0, A2, A4,.

ここでは図示されないブレーク処理中において、ユーザがICE上でアドレスA4にブレークポイントを設定したことにより、ICEインターフェイス部によりマイコン上のエミュレーションメモリのデータが、ブレーク命令に対応する特定データ「FA00」に書き換えられている。そのためCPUは、アドレスA4のデータフェッチ時に、上記のデータ「FA00」をフェッチすることで(c)ブレーク命令の発行を認識し(NMI:マスク不能割込みとして取り扱われる)、(a)のタスクタイマはタイマ値「C」で計時を停止する。   Here, during a break process (not shown), when the user sets a breakpoint at address A4 on the ICE, the data in the emulation memory on the microcomputer is rewritten to the specific data “FA00” corresponding to the break instruction by the ICE interface unit. It has been. Therefore, the CPU recognizes the issuance of the break instruction by fetching the data “FA00” at the time of fetching the data of the address A4 (NMI: treated as an unmaskable interrupt), and the task timer of (a) The timer stops at the timer value “C”.

そして、更なるブレークの受付を禁止するため(e)ブレークマスクをアクティブ(ハイ)にすると共に、(f)ブレーク中信号をアクティブにする。加えて、(h)のブレークレジスタには処理が中断したAタスクのアドレスA6が復帰先アドレスとして格納され、(i)ブレーク命令の発行によりブレークが生じたことを示すフラグをセットする。それから、CPUは、アドレスA8の後にブレーク命令を処理するためのベクタに分岐して、ブレーク時処理(ブレーク処理ルーチン)を実行する。   Then, in order to inhibit the acceptance of further breaks, (e) the break mask is activated (high), and (f) the break signal is activated. In addition, the address A6 of the A task where the processing is interrupted is stored as a return destination address in the break register of (h), and (i) a flag indicating that a break has occurred by issuing a break instruction is set. Then, the CPU branches to a vector for processing a break instruction after address A8, and executes a break time process (break processing routine).

図6は、ブレーク時処理からAタスクに復帰する前に行う処理部分のみを示すフローチャートである。AタスクのアドレスA4においてブレーク命令が発行されたため、復帰時には、アドレスA4からAタスクの処理を開始する必要がある。そこで、計時を停止しているタスクタイマのタイマ値に「1」を加算し(ステップS11)、復帰先アドレス(戻りアドレス)をブレークレジスタより「2」を減じて設定する(ステップS12)。すると、復帰時には、タイマ値「D」,アドレスA4から処理が再開される。   FIG. 6 is a flowchart showing only a processing part performed before returning from the break time processing to the A task. Since the break instruction is issued at the address A4 of the A task, it is necessary to start the processing of the A task from the address A4 when returning. Therefore, "1" is added to the timer value of the task timer that has stopped timing (step S11), and the return destination address (return address) is set by subtracting "2" from the break register (step S12). Then, at the time of return, the processing is resumed from the timer value “D” and the address A4.

また、図7は、非周期タスクであるAタスクから周期タスクであるLタスクにタスク切り換えが行われる場合のタイミングチャートである。タスク切換え開始レジスタは「4」に設定されており、タスクタイマの値が「4」に達した時点で(d)のタスク切換え期間信号がアクティブになると共に、(e)のブレーク(NMI)マスク信号をアクティブにしてタスク切換え期間中のブレークの受付を禁止する。この期間に、タスク切換えアドレスレジスタに格納されていたLタスクの処理アドレスL0がLタスクの復帰先アドレスとしてプログラムカウンタに格納されると共に、Aタスクの処理アドレスA6が次回のAタスクの復帰先アドレスとしてタスク切換えアドレスレジスタに格納される(g)。その後、タスクタイマ値が「0」になるのと同時にタスクタイマの計時動作を停止し、Lタスクの実行を開始する。   FIG. 7 is a timing chart when the task is switched from the A task that is an aperiodic task to the L task that is a periodic task. The task switching start register is set to “4”. When the value of the task timer reaches “4”, the task switching period signal in (d) becomes active and the break (NMI) mask in (e). The signal is activated and break acceptance during the task switching period is prohibited. During this period, the L task processing address L0 stored in the task switching address register is stored in the program counter as the L task return destination address, and the A task processing address A6 is the next A task return destination address. Is stored in the task switching address register (g). Thereafter, at the same time as the task timer value becomes “0”, the task timer stops the time counting operation, and the execution of the L task starts.

図8は、図6におけるブレーク命令の受付と、図7における非周期タスクから周期タスクへのタスク切換えとが同時に発生した場合のタイミングチャートである。AタスクからLタスクの切換え期間はブレークの受付が禁止されるため、タスク切換え期間の直前にブレーク命令が発行されると、そのブレーク命令の受付はタスク切換えが完了した後になる。すると、例えば本来はAタスクをブレークの対象としていた場合でも、CPUの実行対象がLタスクに切り換わってしまうため、ブレーク命令からの復帰時に戻り先アドレスが間違ってしまうという問題がある。   FIG. 8 is a timing chart when reception of a break instruction in FIG. 6 and task switching from an aperiodic task to a periodic task in FIG. 7 occur simultaneously. Since the acceptance of a break is prohibited during the switching period from the A task to the L task, if a break instruction is issued immediately before the task switching period, the break instruction is accepted after the task switching is completed. Then, for example, even if the A task is originally targeted for a break, the execution target of the CPU is switched to the L task, so that there is a problem that the return address is wrong when returning from the break instruction.

図5のケースでは、ブレーク命令発行の時点で、ブレークレジスタにはAタスクの処理アドレスA6が格納され、その後「−2」されて戻りアドレスはA4となるが、図8のケースでは、タスク切換えによって実行対象アドレスがL0になった時点でブレーク命令が受付けられて処理されるので、ブレークレジスタにはアドレスL0が格納され((h)参照)、戻りアドレスは(L0−2)になってしまう。   In the case of FIG. 5, when the break instruction is issued, the processing address A6 of the A task is stored in the break register, and after that, it is “−2” and the return address becomes A4. In the case of FIG. When the execution target address becomes L0, the break instruction is accepted and processed, so the address L0 is stored in the break register (see (h)) and the return address becomes (L0-2). .

本発明は上記事情に鑑みてなされたものであり、その目的は、CPUが周期タスクと非周期タスクを並行して実行する場合でも、ICEにより発行されるブレーク命令の受付を適切に処理できるマイクロコンピュータを提供することにある。   The present invention has been made in view of the above circumstances, and a purpose of the present invention is to make it possible to appropriately process reception of a break instruction issued by the ICE even when the CPU executes a periodic task and an aperiodic task in parallel. To provide a computer.

請求項1記載のマイクロコンピュータによれば、CPUに、周期タスクと非周期タスクとの実行を切り換える際に、復帰先のアドレスが格納されるタスク切換えレジスタと、ブレーク命令が発行された場合に、復帰先のアドレスが格納されるブレークレジスタとを備える。そして、同時発生検出手段が、CPUによる周期タスク,非周期タスクの切り換えとブレーク命令の受付とが同時に発生したことを検出すると、アドレス入換え手段は、タスク切換えレジスタに格納されているアドレスとブレークレジスタに格納されているアドレスとを入れ換える。   According to the microcomputer of claim 1, when switching between execution of the periodic task and the non-periodic task, the task switching register for storing the return destination address and the break instruction are issued to the CPU. And a break register for storing a return destination address. When the coincidence detection means detects that the switching of the periodic task and aperiodic task by the CPU and the reception of the break instruction occur at the same time, the address exchange means detects the address and break stored in the task switching register. Replace the address stored in the register.

このように構成すれば、ブレーク命令の実行対象であったタスクが、タスク切換えにより異なるタスクに切り換えられたとしても、タスク切換えレジスタに格納されているアドレスがブレークレジスタに格納される。したがって、ブレーク命令に対応する処理を行った後の復帰先アドレスが、ブレーク命令が発行された時点に実行中であったタスク側のアドレスとなるように設定できる。   With this configuration, even if the task that was the execution target of the break instruction is switched to a different task by task switching, the address stored in the task switching register is stored in the break register. Accordingly, it is possible to set so that the return address after the processing corresponding to the break instruction is the address on the task side that was being executed when the break instruction was issued.

請求項2記載のマイクロコンピュータによれば、アドレス入換え手段は、CPUがブレーク命令を実行した場合のブレーク処理ルーチンにおいて実現されるので、ブレーク処理ルーチンのプログラムを若干追加修正するだけで、アドレス入換えを実行できる。   According to the microcomputer of the second aspect, since the address changing means is realized in the break processing routine when the CPU executes the break instruction, the address input means can be changed by slightly modifying the break processing routine program. Can be replaced.

請求項3記載のマイクロコンピュータによれば、アドレス入換え手段は、CPUに内蔵されるロジック回路によって実現されるので、ソフトウエアを変更することなくアドレス入換えを実行できる。   According to the microcomputer of the third aspect, since the address exchange means is realized by a logic circuit built in the CPU, the address exchange can be executed without changing the software.

請求項4記載のマイクロコンピュータによれば、タスクタイマは、CPUが非周期タスクを実行している期間に計時動作を行い、タスク切換え開始レジスタには、CPUがタスク切り換えを開始するタイミングを示すタスクタイマ値の所定値が格納される。したがって、CPUは、タスクタイマの値がタスク切換え開始レジスタに設定された所定値に一致した場合にタスク切換えを開始することで、周期タスクの周期性を維持できる。また周期タスクではタスクタイマ値は「0」で停止し、計時動作は行わない。   According to the microcomputer of claim 4, the task timer performs a time measuring operation during a period in which the CPU executes the non-periodic task, and the task switching start register indicates a task indicating a timing at which the CPU starts task switching. A predetermined value of the timer value is stored. Therefore, the CPU can maintain the periodicity of the periodic task by starting the task switching when the value of the task timer matches the predetermined value set in the task switching start register. In the periodic task, the task timer value is stopped at “0”, and the timing operation is not performed.

請求項5記載のマイクロコンピュータによれば、タスクタイマ修正手段は、同時発生検出手段によりタスク切換えとブレーク命令発行との同時発生が検出されると、CPUがブレーク命令の処理ルーチンから復帰する前に、タスク切換え開始レジスタに格納されている所定値を修正してタスクタイマに書き戻す。
すなわち、ブレーク命令の受付と非周期タスクから周期タスクへのタスクの切替えとが同時に発生した場合、タスク切替え後にCPUがブレークを受付けるため、ブレーク処理ルーチンではタスクタイマ値が「0」となってしまう。そこで、CPUがブレーク処理ルーチンから非周期タスクに復帰する前に、タスク切換え開始レジスタに格納されている所定値を修正してタスクタイマに書き戻せば、周期タスクの周期性を維持できる。
According to the microcomputer of claim 5, when the simultaneous occurrence of task switching and break instruction issuance is detected by the coincidence detecting means, the task timer correcting means before the CPU returns from the break instruction processing routine. The predetermined value stored in the task switching start register is corrected and written back to the task timer.
In other words, if the acceptance of a break instruction and the switching of a task from an aperiodic task to a periodic task occur simultaneously, the CPU accepts a break after task switching, so the task timer value becomes “0” in the break processing routine. . Therefore, if the predetermined value stored in the task switching start register is corrected and written back to the task timer before the CPU returns from the break processing routine to the non-periodic task, the periodicity of the periodic task can be maintained.

(第1実施例)
以下、本発明の第1実施例について図1乃至図3を参照して説明する。本実施例のマイクロコンピュータは、周期タスクと非周タスクとを実行することで所望の処理を行う。具体的には、周期タスクの実行開始を周期的に行い、ある周期タスクとその次の周期タスクとの間に非周期タスクを実行する。周期タスクは、例えばタイマのカウントや通信処理といった正確な時間管理が必要な処理を行うもので、非周期タスクは、例えば周期的な実行を必要としないアプリケーションを実行するもの(割込み処理など)である。
(First embodiment)
Hereinafter, a first embodiment of the present invention will be described with reference to FIGS. The microcomputer of this embodiment performs a desired process by executing a periodic task and a non-circular task. Specifically, the execution of the periodic task is periodically performed, and the aperiodic task is executed between a certain periodic task and the next periodic task. Periodic tasks are processes that require accurate time management, such as timer counting and communication processing. Non-periodic tasks are applications that execute applications that do not require periodic execution (interrupt processing, for example). is there.

図1は、マイクロコンピュータ(マイコン)1の内部構成を、本発明の要旨に係る部分について示す機能ブロック図である。尚、本発明のマイコン1が周期タスクと非周期タスクとを切り換えながら時分割並行的に実行する制御については、基本的に特許文献2に開示されているマイコンと同様である。マイコン1は、CPU2とICEインターフェイス部3とを備えており、CPU2は、演算部4とタスク切換・ブレーク制御部5とを備えている。尚、演算部4は特許文献2の実行ユニット322に対応し、タスク切換・ブレーク制御部5は、同制御ユニット310とデータパス320の機能に対応している。   FIG. 1 is a functional block diagram showing an internal configuration of a microcomputer 1 with respect to a part according to the gist of the present invention. The control that the microcomputer 1 of the present invention executes in a time-division parallel manner while switching between the periodic task and the non-periodic task is basically the same as the microcomputer disclosed in Patent Document 2. The microcomputer 1 includes a CPU 2 and an ICE interface unit 3, and the CPU 2 includes a calculation unit 4 and a task switching / break control unit 5. The calculation unit 4 corresponds to the execution unit 322 of Patent Document 2, and the task switching / break control unit 5 corresponds to the functions of the control unit 310 and the data path 320.

タスク切換・ブレーク制御部5は、タスクタイマ6,タスク切換えレジスタ7,タスク切換え開始レジスタ8と、これらに基づきタスク切換えを制御するタスク切換え制御部9(図中のタスク切換え制御)と、ICEインターフェイス部3からのブレーク要求に応じてブレーク制御を行うブレーク制御部10(同ブレーク制御),ブレークレジスタ11,統括制御部12(同制御部),同時発生検出部(同時発生検出手段)13を備えている。タスクタイマ6は、CPU2が非周期タスクを実行している期間に計時動作を行うタイマであり、そのタイマ値は、タスク切換え制御部9に出力される。タスク切換えレジスタ7は、上述したように、タスク切換えが実行される場合に、実行中であったタスクの処理に復帰するためのアドレスが制御部12によって格納される。   The task switching / break control unit 5 includes a task timer 6, a task switching register 7, a task switching start register 8, a task switching control unit 9 (task switching control in the figure) for controlling task switching based on these, and an ICE interface. A break control unit 10 (same break control) that performs break control in response to a break request from the unit 3, a break register 11, an overall control unit 12 (same control unit), and a coincidence detection unit (simultaneous occurrence detection unit) 13 are provided. ing. The task timer 6 is a timer that performs a timing operation during the period when the CPU 2 is executing the non-periodic task, and the timer value is output to the task switching control unit 9. In the task switching register 7, as described above, when task switching is executed, an address for returning to the processing of the task being executed is stored by the control unit 12.

タスク切換え開始レジスタ8は、CPU2が、実行対象を非周期タスクから周期タスクに切り換えるための開始タイミングを示すデータが格納され、そのデータは、タスク切換え制御部9に出力される。ブレーク制御部(同時発生検出手段)10は、ブレーク要求が発生した場合に統括制御部12との間でブレーク制御に関する処理を行い、ブレークレジスタ11には、ブレーク処理から復帰する場合の戻りアドレスが統括制御部12によって格納される。   The task switching start register 8 stores data indicating the start timing for the CPU 2 to switch the execution target from the non-periodic task to the periodic task, and the data is output to the task switching control unit 9. The break control unit (simultaneous occurrence detection means) 10 performs processing related to break control with the overall control unit 12 when a break request occurs, and the break register 11 has a return address when returning from break processing. Stored by the overall control unit 12.

タスク切換え制御部(同時発生検出手段)9は、実行対象タスクが非周期タスクから周期タスクに切り換わる場合にタスク切換え信号を同時発生検出部13に出力し、ブレーク制御部10は、ICE14によりブレーク命令が発行されると、同時発生検出部13に対してブレーク命令発生フラグをセットする。そして、同時発生検出部13は、タスク切換え発生とブレーク命令発生フラグのセットとが同時になると、同時発生検出信号をICEインターフェイス部3に出力する。   The task switching control unit (simultaneous occurrence detecting means) 9 outputs a task switching signal to the simultaneous occurrence detecting unit 13 when the execution target task is switched from the non-periodic task to the periodic task. When an instruction is issued, a break instruction generation flag is set for the simultaneous occurrence detection unit 13. The coincidence detection unit 13 outputs a coincidence detection signal to the ICE interface unit 3 when task switching occurs and the break instruction generation flag is set at the same time.

ICEインターフェイス部3は、マイコン1を用いた開発作業を行う場合に使用するICE14と通信処理を行うと共に、CPU2とはマイコン1内部のアドレスバス15及びデータバス16を介して接続されている。また、ICEインターフェイス部3には、CPU2によって実行されるモニタプログラム17が格納されており、そのモニタプログラム17において、アドレス切換え処理(アドレス入換え手段)18及びブレークレジスタ修正処理(タスクタイマ修正手段)19が実行される。そして、同時発生検出部13が同時発生検出信号を出力すると、ICEインターフェイス部3の内部に、タスク切換え中ブレーク同時発生フラグ20がセットされる。   The ICE interface unit 3 performs communication processing with the ICE 14 used when performing development work using the microcomputer 1, and is connected to the CPU 2 via an address bus 15 and a data bus 16 inside the microcomputer 1. The ICE interface unit 3 stores a monitor program 17 executed by the CPU 2. In the monitor program 17, an address switching process (address exchange means) 18 and a break register correction process (task timer correction means) are stored. 19 is executed. When the coincidence detection unit 13 outputs a coincidence detection signal, a task switching break simultaneous occurrence flag 20 is set in the ICE interface unit 3.

また、ICEインターフェイス部3は、ユーザがICE14においてブレークポイントを設定すると、バス15及び16に接続されている図示しないエミュレーションメモリ上の上記ブレークポイントに対応するアドレスのデータを、ブレーク命令である特定データ「FA00」に書き換える。また、ユーザがICE14のブレーク発行スイッチを操作した場合には、ブレーク要求信号をブレーク制御部10に対して直接出力する。   Further, when the user sets a breakpoint in the ICE 14, the ICE interface unit 3 converts the data at the address corresponding to the breakpoint on the emulation memory (not shown) connected to the buses 15 and 16 into the specific data that is a break instruction. Rewrite to “FA00”. When the user operates the break issue switch of the ICE 14, a break request signal is directly output to the break control unit 10.

次に、本実施例の作用について図2及び図3も参照して説明する。図2は図8相当図であり、本発明のマイコン1において、タスク切換えとブレーク命令の発行とが同時に発生した場合の処理を示すタイミングチャートである。ユーザがICE21においてアドレスA4にブレークポイントを設定すると、ICEインターフェイス部3は、エミュレーションメモリ上の対象アドレスのデータを特定データ「FA00」に書き換える。   Next, the operation of this embodiment will be described with reference to FIGS. FIG. 2 is a diagram corresponding to FIG. 8, and is a timing chart showing processing when task switching and issue of a break instruction occur simultaneously in the microcomputer 1 of the present invention. When the user sets a breakpoint at the address A4 in the ICE 21, the ICE interface unit 3 rewrites the data of the target address on the emulation memory to the specific data “FA00”.

その後、ユーザプログラムの実行が開始されるとCPU2が非周期タスク(Aタスク)を実行している場合に、タスク切換えタイミングの直前のアドレスA4でCPU2がその特定データ(ブレーク命令)をフェッチするが(図2(c))、その次のサイクルではタスク切換え開始レジスタ設定値とタスクタイマ値が一致するためタスク切換え処理が開始され、タスク切換え制御部5がタスク切換え区間を示す信号をハイレベルにする(図2(d))。   Thereafter, when the execution of the user program is started, if the CPU 2 is executing an aperiodic task (A task), the CPU 2 fetches the specific data (break instruction) at the address A4 immediately before the task switching timing. (FIG. 2 (c)), in the next cycle, the task switching start register setting value matches the task timer value, so that task switching processing is started, and the task switching control unit 5 sets the signal indicating the task switching interval to the high level. (FIG. 2D).

それと同時に、ブレーク制御部10は、タスク切り替え中のブレークの受付を禁止するためにブレークマスク信号をアクティブにする(図2(e))。そのためブレーク制御部10は、ブレーク命令発生フラグをセットする(図2(i))が、ブレーク命令の処理はペンディング状態となる。それに伴い、同時発生検出部13が、同時発生検出信号をICEインターフェイス部3に出力し、タスク切換中ブレーク発生フラグ20がセットされる(図2(j))。   At the same time, the break control unit 10 activates a break mask signal to prohibit acceptance of breaks during task switching (FIG. 2 (e)). Therefore, the break control unit 10 sets a break instruction generation flag (FIG. 2 (i)), but the break instruction processing is in a pending state. Accordingly, the coincidence detection unit 13 outputs a coincidence detection signal to the ICE interface unit 3, and the task occurrence break occurrence flag 20 is set (FIG. 2 (j)).

この場合、タスク切換えレジスタ7には、図7について前述したように、非周期タスクのアドレスA6が次回のタスク切換え時の復帰先として格納される(図2(g))。そして、CPU2の実行対象は、非周期タスクから周期タスク(Lタスク)に切り換わり、実行アドレスは、それ以前のタスク切り換え時にタスク切換えレジスタ7に格納されていた周期タスクの先頭アドレスL0に切り換わる(図2(b))。   In this case, as described above with reference to FIG. 7, the aperiodic task address A6 is stored in the task switching register 7 as the return destination at the next task switching (FIG. 2 (g)). The execution target of the CPU 2 is switched from the non-periodic task to the periodic task (L task), and the execution address is switched to the start address L0 of the periodic task stored in the task switching register 7 at the previous task switching. (FIG. 2 (b)).

アドレス切り換えが行われた後、アドレスL0でブレーク命令が受け付けられ、ブレークレジスタ11にはアドレスL0が格納され(図2(h))、ブレークマスク信号が再び出力される(図2(e))。そして、アドレスL2の次でブレーク命令に対応したベクタが発行され、モニタプログラム17(ブレーク命令処理ルーチン)による処理が開始される。   After the address is switched, a break instruction is accepted at the address L0, the address L0 is stored in the break register 11 (FIG. 2 (h)), and the break mask signal is output again (FIG. 2 (e)). . Then, after the address L2, a vector corresponding to the break instruction is issued, and processing by the monitor program 17 (break instruction processing routine) is started.

図3は、CPU2がモニタプログラム17の処理から復帰する場合の復帰前処理を示すフローチャートである。先ず、ブレーク要因がブレーク命令によるものであったかを確認し(ステップS1)、ブレーク命令による場合は(YES)、タスク切り換え時にブレークが発生したか否かを、タスク切換中ブレーク発生フラグ20がセットされているか否かによって判断する(ステップS2)。
ここで、上記フラグ20がセットされていない場合は(NO)、タスクタイマ6のタイマ値が「0」ではなく、タイマ動作中にブレークが発生していた場合は(ステップS5:YES)、続くステップS6,S7においてステップS11,S12と同様の処理を行う。また、タイマ値が「0」の場合は(ステップS5:NO)ステップS7だけを実行する。
FIG. 3 is a flowchart showing the pre-return process when the CPU 2 returns from the process of the monitor program 17. First, it is confirmed whether or not the break factor is caused by a break instruction (step S1). If the break instruction is caused by a break instruction (YES), a break occurrence flag 20 during task switching is set to determine whether or not a break has occurred during task switching. Judgment is made based on whether or not (step S2).
Here, if the flag 20 is not set (NO), the timer value of the task timer 6 is not “0”, and if a break occurs during the timer operation (step S5: YES), it continues. In steps S6 and S7, processing similar to that in steps S11 and S12 is performed. If the timer value is “0” (step S5: NO), only step S7 is executed.

一方、ステップS2において上記フラグ20がセットされている場合は(YES)、ステップS3において、モニタプログラム17からの復帰先をブレーク命令が発生したアドレスに設定するための処理を行う。先ず、(1)アドレス切換え処理18により、タスク切換えレジスタ7の内容とブレークレジスタ11の内容とを入れ換えて(図2(g),(h)参照)、タスク切換えレジスタ7にアドレスL0を、ブレークレジスタ11にアドレスA6を格納する。   On the other hand, if the flag 20 is set in step S2 (YES), processing for setting the return destination from the monitor program 17 to the address where the break instruction is generated is performed in step S3. First, (1) the contents of the task switching register 7 and the contents of the break register 11 are exchanged by the address switching process 18 (see FIGS. 2 (g) and (h)), and the address L0 is set in the task switching register 7. The address A6 is stored in the register 11.

次に、(2)ステップS7と同様に、ブレークレジスタ修正処理19によりブレークレジスタ11に格納されたアドレス値を「2」減算し(図2(i)参照)、アドレス値をA4とする。それから、(3)タスク切換え開始レジスタの値に「1」を加えたものをタスクタイマ6に設定する。この場合、タスク切換え開始レジスタ8の値は「4」であるから、「1」を加えた「5」がタスクタイマ6に設定される(図2(a)参照)。
以上のステップS3の処理が終了すると、タスク切換中ブレーク発生フラグ20をクリアして(図2(j)参照)通常処理に復帰する。この場合、図2(b)に示すように、実行対象アドレスは非周期タスクのA4となり、再び周期タスクへの切換え(アドレスL0)が実行されることになる。
Next, (2) “2” is subtracted from the address value stored in the break register 11 by the break register correction process 19 (see FIG. 2 (i)) as in step S7, and the address value is set to A4. Then, (3) a value obtained by adding “1” to the value of the task switching start register is set in the task timer 6. In this case, since the value of the task switching start register 8 is “4”, “5” including “1” is set in the task timer 6 (see FIG. 2A).
When the process of step S3 is completed, the task switching break occurrence flag 20 is cleared (see FIG. 2J), and the process returns to the normal process. In this case, as shown in FIG. 2B, the execution target address is A4 of the non-periodic task, and switching to the periodic task (address L0) is executed again.

以上のように本実施例によれば、CPU2に、周期タスクと非周期タスクとの実行を切り換える際に復帰先アドレスが格納されるタスク切換えレジスタ7と、ICE14によってブレーク命令が発行された場合に復帰先アドレスが格納されるブレークレジスタ11とを備える。そして、同時発生検出部13が、CPU2による周期タスク,非周期タスクの切り換えとブレーク命令の発行とが同時に発生したことを検出すると、モニタプログラム17のアドレス切換え処理18は、タスク切換えレジスタ7に格納されているアドレスとブレークレジスタ11に格納されているアドレスとを入れ換えるようにした。   As described above, according to the present embodiment, when the CPU 2 issues a break instruction by the task switching register 7 in which the return destination address is stored when switching between the execution of the periodic task and the non-periodic task, and the ICE 14. And a break register 11 in which a return destination address is stored. When the coincidence detection unit 13 detects that the switching of the periodic task and the non-periodic task by the CPU 2 and the issue of the break instruction occur simultaneously, the address switching process 18 of the monitor program 17 is stored in the task switching register 7. And the address stored in the break register 11 are interchanged.

したがって、ブレーク命令に対応する処理を行った後の戻りアドレスが、ブレーク命令が発行された時点に実行中であったタスク側のアドレスとなるように設定できる。そして、上記のアドレス切換え処理18を、CPU2がブレーク命令を実行した場合のモニタプログラム17において実行するので、モニタプログラム17を若干追加修正するだけで、アドレス入換えを実行できる。
また、タスクタイマ6は、CPU2が非周期タスクを実行している期間に計時動作を行い、タスク切換え開始レジスタ8には、CPU2がタスク切り換えを行うタイミングを示すタスクタイマ値の所定値が格納されるので、周期タスクの周期性を維持できる。
Therefore, it is possible to set the return address after performing the processing corresponding to the break instruction to be the address on the task side being executed when the break instruction is issued. Since the address switching process 18 is executed in the monitor program 17 when the CPU 2 executes the break instruction, the address change can be executed with only a slight modification of the monitor program 17.
The task timer 6 performs a time measuring operation while the CPU 2 is executing the non-periodic task, and the task switching start register 8 stores a predetermined value of the task timer value indicating the timing at which the CPU 2 performs task switching. Therefore, the periodicity of the periodic task can be maintained.

そして、ブレークレジスタ修正処理19は、同時発生検出部13によりタスク切換えとブレーク命令発行との同時発生が検出されると、CPU2がモニタプログラム17から復帰する前に、タスク切換え開始レジスタ8に格納されている所定値を修正してタスクタイマ6に書き戻す。すなわち、アドレス切換え処理18がアドレス入換え処理に時間を要した分だけ、タスクタイマ6のタイマ値が進んでしまうので、モニタプログラム17から復帰する前に、タスク切換え開始レジスタ8に格納されている所定値を修正してタスクタイマ6に書き戻せば、周期タスクの周期性を維持できる。   The break register correction process 19 is stored in the task switching start register 8 before the CPU 2 returns from the monitor program 17 when the simultaneous detection of the task switching and the break instruction issuance is detected by the simultaneous detection unit 13. The predetermined value is corrected and written back to the task timer 6. That is, the timer value of the task timer 6 advances by an amount corresponding to the time required for the address switching process 18 by the address switching process 18 and is stored in the task switching start register 8 before returning from the monitor program 17. If the predetermined value is corrected and written back to the task timer 6, the periodicity of the periodic task can be maintained.

(第2実施例)
図4は、本発明の第2実施例であり、第1実施例と同一部分には同一符号を付して説明を省略し、以下異なる部分について説明する。第2実施例のマイコン21は、CPU22の内部に、第1実施例のアドレス切換え処理18に対応する機能をハードウエアロジック回路で実現したアドレス切換え部(アドレス入換え手段)23を備えている。このアドレス切換え部23はデータバッファを内蔵しており、同時発生検出部13からの同時発生検出信号を受けて、タスク切換えレジスタ7,ブレークレジスタ11に直接アクセスし、両者にそれぞれ格納されているアドレス値を入れ換える処理を実行する。
(Second embodiment)
FIG. 4 shows a second embodiment of the present invention. The same parts as those of the first embodiment are denoted by the same reference numerals, and the description thereof is omitted. Hereinafter, different parts will be described. The microcomputer 21 of the second embodiment includes an address switching section (address exchange means) 23 that implements a function corresponding to the address switching processing 18 of the first embodiment with a hardware logic circuit inside the CPU 22. The address switching unit 23 has a built-in data buffer, receives the coincidence detection signal from the coincidence detection unit 13 and directly accesses the task switching register 7 and the break register 11, and stores the address values stored in both of them. Execute the process of replacing.

そして、ICEインターフェイス部24のモニタプログラム25は、ブレークレジスタ修正処理19だけを実行するようになっている。
以上のように構成される第2実施例によれば、アドレス切換え部23を、CPU22に内蔵されるロジック回路によって実現するので、ソフトウエアを変更することなくアドレス入換えを実行できる。
The monitor program 25 of the ICE interface unit 24 executes only the break register correction process 19.
According to the second embodiment configured as described above, the address switching unit 23 is realized by the logic circuit built in the CPU 22, so that the address replacement can be executed without changing the software.

本発明は上記し且つ図面に記載した実施例にのみ限定されるものではなく、以下のような変形または拡張が可能である。
第2実施例において、ブレークレジスタ修正処理19に対応する機能についても、CPU22に内蔵されるロジック回路で実現しても良い。
第1実施例および第2実施例において、ユーザがICE14においてブレークポイントを設定した場合、エミュレーションメモリ上の上記ブレークポイントに対応するアドレスのデータを特定データ「FA00」に書換えずに、アドレス比較器によってCPU22のフェッチアドレスと上記ブレークポイントに対応するアドレスを比較し、両者の一致を検出した場合にデータバスの内容を特定データ「FA00」にすり替える方式で実現しても良い。
特定データは「FA00」以外であっても良い。
The present invention is not limited to the embodiments described above and shown in the drawings, and the following modifications or expansions are possible.
In the second embodiment, the function corresponding to the break register correction process 19 may also be realized by a logic circuit built in the CPU 22.
In the first and second embodiments, when the user sets a breakpoint in the ICE 14, the address comparator does not rewrite the address data corresponding to the breakpoint on the emulation memory with the specific data “FA00”. It may be realized by comparing the fetch address of the CPU 22 with the address corresponding to the breakpoint and replacing the content of the data bus with the specific data “FA00” when a match between the two is detected.
The specific data may be other than “FA00”.

本発明の第1実施例であり、マイクロコンピュータの構成を示す機能ブロック図1 is a functional block diagram showing the configuration of a microcomputer according to a first embodiment of the present invention. タスク切換えとブレーク命令の発行とが同時に発生した場合の処理を示すタイミングチャートTiming chart showing processing when task switching and break instruction issuance occur simultaneously モニタプログラムから復帰する場合の復帰前処理を示すフローチャートFlow chart showing pre-return processing when returning from the monitor program 本発明の第2実施例を示す図1相当図FIG. 1 equivalent view showing a second embodiment of the present invention. 従来技術を示す、ブレーク命令が発行された場合のタイミングチャートTiming chart when a break instruction is issued showing conventional technology 図3相当図3 equivalent figure タスク切り換えが行われる場合のタイミングチャートTiming chart for task switching 図2相当図2 equivalent diagram

符号の説明Explanation of symbols

図面中、1はマイクロコンピュータ、2はCPU、3はICEインターフェイス部、6はタスクタイマ、7はタスク切換えレジスタ、8はタスク切換え開始レジスタ、9はタスク切換え制御部(同時発生検出手段)、10はブレーク制御部(同時発生検出手段)、13は同時発生検出部(同時発生検出手段)、14はICE、18はアドレス切換え処理(アドレス入換え手段)、19はブレークレジスタ修正処理(タスクタイマ修正手段)、21はマイクロコンピュータ、22はCPU、23はアドレス切換え部(アドレス入換え手段)、24はICEインターフェイス部を示す。   In the drawings, 1 is a microcomputer, 2 is a CPU, 3 is an ICE interface unit, 6 is a task timer, 7 is a task switching register, 8 is a task switching start register, 9 is a task switching control unit (simultaneous occurrence detection means), 10 Is a break control section (simultaneous occurrence detection means), 13 is a coincidence detection section (simultaneous occurrence detection means), 14 is ICE, 18 is an address switching process (address replacement means), 19 is a break register correction process (task timer correction) Means), 21 is a microcomputer, 22 is a CPU, 23 is an address switching section (address exchange means), and 24 is an ICE interface section.

Claims (5)

CPUが周期タスクと非周期タスクとを時分割並行的に実行可能であり、一定数のサイクル毎に非周期タスクから周期タスクに実行対象を切り換えることで周期タスクのプログラム周期が一定となり、前記切り換えの期間中はブレーク命令の受付を禁止し、前記切り換えの完了後にブレーク命令を受け付けるように構成されると共に、ICE(In Circuit Emulator)との通信を行うICEインターフェイス部を備えるマイクロコンピュータであって、
前記CPUは、前記周期タスクと前記非周期タスクとの実行を切り換える際に、復帰先のアドレスが格納されるタスク切換えレジスタと、前記ICEからのブレーク命令を受け付けた場合に、復帰先のアドレスが格納されるブレークレジスタとを有し、
前記CPUによる前記非周期タスクから前記周期タスクへの切り換えと、ブレーク命令の受付とが同時に発生したことを検出する同時発生検出手段と、
この同時発生検出手段により前記同時発生が検出されると、前記タスク切換えレジスタに格納されているアドレスと前記ブレークレジスタに格納されているアドレスとを入れ換えるアドレス入換え手段とを備えることを特徴とするマイクロコンピュータ。
CPU is time division parallel feasible the periodic tasks and aperiodic tasks, Ri program period of the periodic tasks by switching the execution target periodically task from aperiodic tasks for every predetermined number of cycles Do constant, wherein during the switching prohibits acceptance of the break instruction, together configured so that accepts break instruction after completion of the switching, a microcomputer equipped with ICE interface unit which communicates with the ICE (in Circuit Emulator) There,
When the CPU switches between execution of the periodic task and the non-periodic task, when the CPU receives a break switching instruction from the ICE and a task switching register that stores a return destination address, the return destination address is A break register to be stored,
Simultaneous detection means for detecting that switching from the non-periodic task to the periodic task by the CPU and acceptance of a break instruction have occurred simultaneously;
When the simultaneous occurrence is detected by the simultaneous occurrence detection means, an address exchange means for exchanging the address stored in the task switching register and the address stored in the break register is provided. Microcomputer.
前記アドレス入換え手段は、前記CPUが前記ブレーク命令を実行した場合のブレーク処理ルーチンにおいて実現されることを特徴とする請求項1記載のマイクロコンピュータ。   2. The microcomputer according to claim 1, wherein the address exchange means is realized in a break processing routine when the CPU executes the break instruction. 前記アドレス入換え手段は、前記CPUに内蔵されるロジック回路によって実現されることを特徴とする請求項1記載のマイクロコンピュータ。   2. The microcomputer according to claim 1, wherein the address exchange unit is realized by a logic circuit built in the CPU. 前記CPUが前記非周期タスクを実行している期間に計時動作を行うタスクタイマと、
前記CPUが前記周期タスクと前記非周期タスクとの切り換えを行うタイミングとして、前記タスクタイマにより計時される所定値が格納されるタスク切換え開始レジスタを備えることを特徴とする請求項1乃至3の何れかに記載のマイクロコンピュータ。
A task timer that performs a timekeeping operation during a period in which the CPU executes the non-periodic task;
4. A task switching start register in which a predetermined value measured by the task timer is stored as a timing at which the CPU switches between the periodic task and the non-periodic task. A microcomputer according to any one of the above.
前記同時発生検出手段により前記同時発生が検出されると、前記CPUが前記ブレーク命令の処理ルーチンから復帰する前に、前記タスク切換え開始レジスタに格納されている所定値を修正して前記タスクタイマに書き戻すタスクタイマ修正手段を備えたことを特徴とする請求項4記載のマイクロコンピュータ。   When the coincidence detection unit detects the coincidence, the CPU corrects a predetermined value stored in the task switching start register before returning from the break instruction processing routine to the task timer. 5. The microcomputer according to claim 4, further comprising task timer correction means for writing back.
JP2008261690A 2008-10-08 2008-10-08 Microcomputer Expired - Fee Related JP4947027B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2008261690A JP4947027B2 (en) 2008-10-08 2008-10-08 Microcomputer

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2008261690A JP4947027B2 (en) 2008-10-08 2008-10-08 Microcomputer

Publications (2)

Publication Number Publication Date
JP2010092271A JP2010092271A (en) 2010-04-22
JP4947027B2 true JP4947027B2 (en) 2012-06-06

Family

ID=42254919

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2008261690A Expired - Fee Related JP4947027B2 (en) 2008-10-08 2008-10-08 Microcomputer

Country Status (1)

Country Link
JP (1) JP4947027B2 (en)

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0721036A (en) * 1993-07-02 1995-01-24 Mitsubishi Electric Corp Multitask system testing device
JP2003330751A (en) * 2002-05-16 2003-11-21 Fujitsu Ltd Debug system for micro-processor
JP2007114945A (en) * 2005-10-19 2007-05-10 Kyocera Mita Corp Real-time processor
JP4770664B2 (en) * 2006-09-20 2011-09-14 株式会社デンソー Microprocessor and microcomputer using the same

Also Published As

Publication number Publication date
JP2010092271A (en) 2010-04-22

Similar Documents

Publication Publication Date Title
US5148529A (en) Pipelined multi-stage data processor including an operand bypass mechanism
EP2660713B1 (en) Patch mechanism in embedded controller for memory access
JPH08123514A (en) Programmable controller
JP4947027B2 (en) Microcomputer
JP3872196B2 (en) Microcomputer
JPS6224831B2 (en)
JP5245237B2 (en) Error handling method
JP3260083B2 (en) Debug system and debugging method
JP2011150532A (en) Information processing apparatus
US20160103704A1 (en) Data processing device and method of controlling the same
JP4853390B2 (en) Measuring device
CN110297688B (en) Hardware counting device and method and processor
JP5803721B2 (en) Data processing device
US8176301B2 (en) Millicode assist instructions for millicode store access exception checking
JP2013105388A (en) Interruption circuit and interruption method
JP4305400B2 (en) Microcomputer
JP2015121953A (en) Microcomputer and electronic control device
JP5012562B2 (en) Microcomputer
US9342359B2 (en) Information processing system and information processing method
JP3171615B2 (en) Data transfer retry control method
JP2007122547A (en) Program implementation method and shared memory type multicore processor
JPS595932B2 (en) Data processing method
CN117369870A (en) Sub-real-time processor, real-time processor and system-on-chip
JP2009294823A (en) Data processor and data processing method
JPH0477826A (en) Microprocessor

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20100705

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20111013

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20111025

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20111219

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

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20120220

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20150316

Year of fee payment: 3

R151 Written notification of patent or utility model registration

Ref document number: 4947027

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20150316

Year of fee payment: 3

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

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