JP4127934B2 - Microcontroller and rewriting method thereof - Google Patents

Microcontroller and rewriting method thereof Download PDF

Info

Publication number
JP4127934B2
JP4127934B2 JP21419799A JP21419799A JP4127934B2 JP 4127934 B2 JP4127934 B2 JP 4127934B2 JP 21419799 A JP21419799 A JP 21419799A JP 21419799 A JP21419799 A JP 21419799A JP 4127934 B2 JP4127934 B2 JP 4127934B2
Authority
JP
Japan
Prior art keywords
interrupt
interrupt request
signal
request signal
rewrite
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
JP21419799A
Other languages
Japanese (ja)
Other versions
JP2001043206A (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.)
NEC Electronics Corp
Original Assignee
NEC Electronics 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 NEC Electronics Corp filed Critical NEC Electronics Corp
Priority to JP21419799A priority Critical patent/JP4127934B2/en
Publication of JP2001043206A publication Critical patent/JP2001043206A/en
Application granted granted Critical
Publication of JP4127934B2 publication Critical patent/JP4127934B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Description

【0001】
【発明の属する技術分野】
本発明はマイクロコントローラ及びそのプログラムの書き換え方法に関し、特にプログラムの格納用に電気的に一括消去及び書き換え可能な不揮発性メモリ(フラッシュメモリ)を内蔵したマイクロコントローラ及びそのプログラムの書き換え方法に関する。
【0002】
【従来の技術】
近年、内部にマイクロプロセッサシステム(以下マイクロコントローラ)を持ったテレビジョン受像機,VTR,DVDプレーヤ,オーディオコンポ,衛星放送受信機,CATV端末等のいわゆるAV機器や家電製品、自動車エレクトロニクス等の電子機器が一般化している。これらは電子機器の内部に、電子機器を構成する各種回路・装置を制御するためのCPU、並びにこのCPUのプログラムを格納するPROM等のプログラムメモリを内蔵し、上記CPUにより、CPU及びプログラムメモリの接続されたパスを介して電子機器内部に設けられた各種の回路・装置を制御するようになっている。
【0003】
また、電子機器の高機能化に伴って仕様が複雑化し、年々マイクロコントローラに求められる上記各種の回路・装置の制御も複雑化の一途をたどっている。これにより、電子機器が市場へ出荷後あるいは出荷直前にマイクロコントローラソフトウェアに起因する不具合(いわゆるバグ)が発見されたり、機能仕様の変更も度々発生し、これにより、電子機器の機能を統合的に管理・制御しているマイクロコントローラCPUのプログラムを変更する必要が頻繁に発生する事態が生じている。
【0004】
また、最近は、マイクロコントローラのプログラムを記憶するプログラムメモリとして、マスクROM等の固定メモリに代わり電気的に書き換え可能なEEPROMあるいはフラッシュメモリ等が用いられるようになり、メモリを物理的に交換せずに、電子機器に実装したままの状態でプログラム修正できるようになっている。
【0005】
プログラムメモリとしてフラッシュメモリを用い、このフラッシュメモリに格納したプログラムの書き換え制御を行う特開平8−6919号公報(文献1)記載の従来のマイクロコントローラは、単一の半導体チップ上に、少なくとも中央処理装置(CPU)と、このCPUが処理すべき情報(データ)を電気的な消去書き込みたよって書き換え可能な不揮発性のフラッシュメモリとを搭載し、フラッシュメモリ内のデータの書き換えに対しシリアルコミュニケーションの一種である調歩同期式通信を用いて書き換える書き換え動作モードを備え、この調歩同期式通信のボーレート(ビットレート)を転送元のビットレートに自動的に合わせ込む。
【0006】
この場合に、上記書き換え動作モードにおいて、フラッシュメモリのデータ書き換え及びシリアルコミュニケーションの制御を行うのはCPUであり、このCPUを制御するプログラムであるファームウェアをフラッシュメモリ又はマスクROMが保有する。
【0007】
また、前記書き換え動作モードを起動すると、制御プログラムを保有しているエリア以外のフラッシュメモリのデータを確認し、既に書き込まれたデータがあればこの制御プログラムを保有しているエリア以外を消去する。
【0008】
この種のプログラム書き換えの制御は、一般に割込により行われる。割込とは、コンピュータがプログラム実行中に発生した非同期的な、又は例外的な事象に応答するために、実行中のプログラムを強制的に一時中断し、指定されたルーチン、すなわち、割込処理ルーチンに自動的に制御を移すことである。その際割込時点で実行中のプログラムを後刻再起動できるように、CPU状態を自動的に保存する。
【0009】
割込発生の要因として、割込発生時点で実行中のプログラムと関連があるか否かによって分類し、関連がある場合の内部要因によるものを割出しと呼び、実行中のプログラムと関連がない外部要因によるものを割込と呼ぶことが一般的である。ここでは、この定義による、すなわち、シリアルコミュニケーション等通信デバイスを経由した外部要因による割込を考える。
【0010】
この割込は、上記の通信デバイス経由のほか、入出力関係、タイマ関係、他機器関係等、複数存在するのが一般的であり、これら複数の割込のうちから、所定の優先順位及び割込レベルに従って、最高位の割込要求を選択し、CPUに対して割込要求を行うための割込コントローラが設けられる。
【0011】
割込の優先順位と優先レベルについては、複数の割込原因が同時に発生した場合に、どの割込を先に起こすかという優先度の問題と、ある割込の処理中にほかの割込原因が発生した場合、より高い緊急度を認めて、重ねて割込を起こすか否かのレベルの問題がある。一般的な方法は、原因(のグループ)毎に割込の優先度及びレベルを定め、割込処理以外の通常のプログラムを最低位レベルとして、高位の割込レベルに属する割込は、低位のレベルの処理中に割り込めるようにする方法である。以下の説明においては、上記優先度を割込順位と呼び、上記レベルを割込レベルと呼ぶことにする。
【0012】
文献1記載の従来のマイクロコントローラ(以下マイクロコンピュータ)をブロックで示す図7を参照すると、この従来のマイクロコントローラは、内部バスに結合される中央処理装置(CPU)3と、CPU3を制御する制御プログラムを格納したフラッシュメモリ1と、後述するホストコンピュータ8との通信データ速度(ビットレート)を測定するタイマ30と、ホストコンピュータ8とのインタフェースを調歩同期式通信で行うためのシリアルコミュニケーションインタフェース(SCI)60と、フラッシュメモリ1からのデータを一時格納するバッフアとして機能するランダムアクセスメモリ(RAM)9と、モード端子から入力される動作モード信号を解読し例えば書き換え動作モードが指示されているかを判定するデコーダ7とを備え、例えば、外部のパーソナルコンピュータなどのホストコンピュータ8にSCI60を通じて接続されている。なお、上記制御プログラムの格納には、フラッシュメモリ1の代わりに点線で示したマスクROM10を用いても良い。
【0013】
次に、図7及び処理をフローチャートで示す図8を参照して、従来のマイクロコントローラのプログラムの書き換え方法について説明すると、文献1では特に明記されていないが、割込により、マイクロコンピュータを外部からの書き換え動作モードに設定する動作モード信号MDO〜MD2の供給を受け、デコーダ7で動作モード信号MDO〜MD2をデコードした結果、上記設定での書き換え動作モードの指示であることを判定すると、CPU3はリセット(REST)スタートによりフラッシュメモリ1に格納された制御プログラムを実行する(ステップP1)。これは、動作モード信号MDO〜MD2によるCPU3への割込により書き換えモードに設定することに相当する。
【0014】
さらに、制御プログラムが起動されると、ホストコンピュータ8から所定のビットレートでデータが連続送信され(ステップP2)、CPU3はタイマ30のインプットキャブチャ機能でホストコンピュータ8が送信するデータのLOW期間を内部クロック信号CKにより測定する(ステップP3:測定処理)。この場合に、RXD端子にタイマ30のインプットキャブチャの端子を割り付けておく。そして、データのLOW期間の測定値よりSCI60内のビットレートレジスタに設定する値を計算する(ステップP3:計算処理)。この計算処理はCPU3で行い、求めた値をSCI60内のビットレートレジスタに設定する(ステップP3:設定処理)。
【0015】
続いて、ホストコンピュータ8が転送するビットレートと同じビットレートに調整が終わると、マイクロコンピュータは調整終了の合図を送信線SLを介してホストコンピュータ8に送信し(ステップP5:通知処理)、この調整終了の合図をホストコンピュータ8は正常に受信したことを示す信号を受信線RLを介してマイクロコンピュータに出力する(ステップP5:確認処理)。
【0016】
さらに、ホストコンピュータ8は、次に転送するユーザのプログラムの転送バイト数Nを通知し(ステップP5:通知処理)、以降は順次ユーザの設定したプログラムを送信する。このとき、マイクロコンピュータはホストコンピュータが送信したユーザプログラムを受信し(ステップP5:受信処理)、さらにRAM9に転送する(ステップP6:転送処理)。そして、CPU3は、上記転送の残りバイト数を計算し(ステップP6:残りバイト数計算処理)、ユーザプログラムの転送が終了するまで繰り返して行う(ステップP7)。
【0017】
そして、転送したユーザプログラムを実行する前に、フラッシュメモリ1に書き込まれたデータが存在するか否かを確認し(ステップP8、P9)、既にデータが書き込まれている場合には(ステップP9)、全メモリブロックのデータを消去する(ステップP10)。
【0018】
一方、データが書き込まれていない場合にはフラッシュメモリ1内のテストエリア中にあるプログラム中の最終命令を実行することによりRAM9のエリアに分岐し、RAM9内に転送されたユーザプログラムを実行する(ステップP11)。これにより、フラッシュメモリ1の書き換えを行うことができる。
【0019】
このように、従来のマイクロコントローラは、動作モード信号MDO〜MD2によりによりフラッシュメモリ書き換えモードへの割込が設定され、この割込の認識結果、フラッシュメモリ書き換えモードと判定すると、CPU3はリセットスタートによりフラッシュメモリ1に格納された制御プログラム(ファームウェア)を実行し、このファームウェアの指示に従い、専用の通信端末であるSCII60にフラッシュメモリ書き換えデータの送受信データレートや信号フォーマット等のデータ転送条件の設定を含むイニシャライズを行い、その後設定したデータ転送条件でフラッシュメモリ書き換えデータを受信し、フラッシュメモリ1の書き換えを行う。
【0020】
以上述べたように、従来のマイクロコントローラ及びそのプログラムの書き換え方法は、内蔵するフラッシュメモリの書き換えるための割込が発生すると、専用の通信端末にその都度データ転送レート等のデータ転送条件の設定を含むイニシャライズの実施から、フラッシュメモリの書き換えを開始している。
【0021】
一方、上記割込発生時の割込処理を設定するための割込要求信号のフォーマットである割込ベクタ(上述の従来例では動作モード信号MDO〜MD2の組み合わせ)は、マイクロコンピュータの用途に応じて各種のシリアルもしくはパラレルコミニュケーションデバイス(以下通信デバイス)の割込優先順位あるいは割込レベルが一定ではなく異なるため、マイクロコンピュータの品種毎に異なっている。例えば、ある品種では通信デバイスの割込優先順位が最高位であり、また、別の品種では通信デバイスの割込優先順位が最下位に設定されている。
【0022】
一般に、内蔵フラッシュメモリの書き換えを必要とする場合は、この書き換えのための割込発生原因が他の割込発生原因に比較して優先度が高く、また、この割込による上記書き換え処理実行中は他の割込を受け付けない最高割込レベルに設定する必要がある。
【0023】
このため、マイクロコンピュータ内蔵のフラッシュメモリ又はマスクROM内のファームウェアは、内蔵されるマイクロコンピュータの品種毎に、通信デバイスの割込優先順位をフラッシュメモリの書き換えるための割込発生に対応して一定の割込順位及び割込レベル、例えば最高位の割込順位及び最高割込レベルに割込ベクタを変更するよう専用設計しなければならず、設計のTAT(ターンアラウンドタイム)が長期化するという問題があった。
【0024】
また、マイクロコンピュータの品種毎にファームウェアを変更することによりバグの増大等、設計品質が低下するという問題があった。
【0025】
ここでベクタとは、公知のように、個々の項目が単一の索引や添字に従って順序良く並んでいるデータの配列をいう。従って割込みベクタとは、所定の順序で並んでいる割込に関連する命令及びデータの配列をいう。
【0026】
【発明が解決しようとする課題】
上述した従来のマイクロコントローラ及びそのプログラムの書き換え方法は、内蔵するフラッシュメモリの書き換えるための割込が発生すると、専用の通信端末にその都度データ転送レート等のデータ転送条件の設定を含むイニシャライズの実施から、フラッシュメモリの書き換えを開始するが、上記割込発生時の割込処理を設定するための割込要求信号のフォーマットである割込ベクタは、マイクロコンピュータの用途に応じた品種毎に通信デバイスの割込優先レベルが異なるため、上記書き換え制御のための書き換え制御ソフトウェアであるファームウェアは、内蔵されるマイクロコンピュータの品種毎に通信デバイスの割込優先レベルを元の割込優先レベルとは無関係にフラッシュメモリの書き換えるための割込発生に対応して一定のレベル、例えば最高位レベルに変更するよう専用設計しなければならず、設計のTATが長期化するという欠点があった。
【0027】
また、マイクロコンピュータの品種毎にファームウェアを変更することにより設計品質が低下するという欠点があった。
【0028】
本発明の目的は、マイクロコンピュータの品種とは無関係に、内蔵フラッシュメモリの書き換えのための割込が発生すると通信デバイスの割込優先レベルを予め定めたレベルに自動的に設定することにより、ファームウェアの専用化設計を不要とし、設計のTATの短縮及び設計品質の低下要因を除去したマイクロコントローラ及びそのプログラムの書き換え方法を提供することにある。
【0029】
【課題を解決するための手段】
本発明のマイクロコントローラは、プログラムの格納用に電気的に一括消去及び書き換え可能な不揮発性メモリであるフラッシュメモリを内蔵し、このフラッシュメモリのプログラム修正を行う書き換え動作モードを割込により設定されるマイクロコントローラにおいて、
前記フラッシュメモリを書き換えるための一連の動作のプログラムであるファームウェアと後述の通信手段の動作の制御プログラム又は少なくともこの制御プログラムを設定する割込ベクタを格納したROMと、
前記ROMから読み出したファームウェアに従い前記フラッシュメモリの書き換え手順を制御する中央演算処理装置であるCPUと、
前記フラッシュメモリの書き換えを行わない通常動作モードのとき内蔵する複数の周辺回路から送られてくる割込要求信号の優先順序を制御して前記CPUに通知するとともに、前記フラッシュメモリの書き換えを行う場合である書き換えモードのときこの書き換えモード設定に連動した書き換えモード信号の供給に応答して入力された後述の通信手段からの割込要求信号を予め定めた割込順位に変更して前記CPUに通知する割込コントローラと、
入力/出力(I/O)回路及びタイマを含む複数の前記周辺回路と、
外部のホストコンピュータからの前記フラッシュメモリの書き換えデータの受信、及び前記ホストコンピュータへの受信準備完了通知を含む送信を行う通信手段と、
を備えて構成されている。
【0030】
また、前記割込コントローラが、前記書き換えモード信号の供給に応答して入力された前記通信手段からの割込要求信号である通信割込要求信号を予め定めた基準に基づく割込順位に変更し前記CPUに割込実行を要求する割込実行要求信号を発生する割込レベル変換回路を備えてもよい。
【0031】
さらに、前記割込レベル変換回路が、予め定めたN(Nは正の整数)個の割込要求信号の優先順位に応じて同時発生した複数の割込のうちの最高優先順位のものを選択し選択割込要求信号を出力する割込順位決定回路と、
前記書き換えモード信号の論理レベルに応答して前記割込順位決定回路から出力される前記選択割込要求信号と前記通信手段からの前記通信割込要求信号とのいずれか一方を前記割込実行要求信号として選択し出力する書き換えモード優先化回路と、を備えてもよい。
【0032】
また、前記割込レベル変換回路が、前記書き換えモード信号の不活性化時の論理レベルに応答して予め定めたN(Nは正の整数)個の割込要求信号の優先順位に応じて同時発生した複数の割込のうちの最高優先順位のものを選択して前記割込実行要求信号を出力し、前記書き換えモード信号の活性化時の論理レベルに応答して前記最高優先順位の割込要求信号の割込順位を強制的に下位順位に変更する割込順位決定回路と、
前記書き換えモード信号を反転して反転書き換えモード信号を生成するとともに前記書き換えモード信号の活性化時の前記反転書き換えモード信号の論理レベルに応答して前記通信手段からの割込要求信号である通信割込信号の順位を最高順位に設定する書き換えモード優先化回路と、を備えてもよい。
【0033】
本発明のマイクロコントローラのプログラムの書き換え方法は、プログラムの格納用に電気的に一括消去及び書き換え可能な不揮発性メモリであるフラッシュメモリを内蔵し、このフラッシュメモリのプログラム修正を行う書き換え動作モードを割込により設定されるマイクロコントローラのフラッシュメモリの書き換え方法において、
前記フラッシュメモリの書き換えを行う書き換えモードのときこの書き換えモード設定に連動した書き換えモード信号の論理レベルをLレベルからHレベルに設定する第1のステップと、
前記書き換えモード信号のHレベルへの遷移に応答して、外部のホストコンピュータからの前記フラッシュメモリの書き換えデータの受信、及び前記ホストコンピュータへの受信準備完了通知を含む送信を行う通信手段の割込要求信号の優先順位を最上位の順位に変更する第2のステップと、
前記通信手段の割込要求信号から生成した割込実行要求信号の供給に応答して書き換え動作プログラムを読み出し、CPUの初期化を行う第3のステップと、前記通信手段を経由して前記ホストコンピュータから供給される前記フラッシュメモリの書き換えデータの受信を行うための割込を待つ第4のステップと、
前記通信手段が前記ホストコンピュータが送信した割込データである前記書き換えデータを受信する第5のステップと、
前記CPUが、前記通信手段における前記書き換えデータの受信を認識し、この書き換えデータを基に前記フラッシュメモリの書き換え処理を行う第6のステップと、
全ての前記書き換えデータを受信するまで前記書き換えデータの受信及び前記フラッシュメモリへの書き換えの処理を繰り返す第7のステップと、
を含むことを特徴とするを特徴とするものである。
【0034】
【発明の実施の形態】
以下本発明の実施の形態を図面に基づいて詳細に説明する。
【0035】
本実施の形態のマイクロプロセッサシステム(以下マイクロコントローラ)は、AV機器や家電製品、自動車エレクトロニクス等の電子機器に備えられ、電子機器を構成する各種回路・装置を制御するためのCPU、並びにこのCPUのプログラムを格納するプログラムメモリとして電気的な消去書き込みたよって書き換え可能な不揮発性のフラッシュメモリを内蔵し、上記CPUにより、CPU及びプログラムメモリの接続されたパスを介して電子機器内部に設けられた各種の回路・装置を制御するようになっている。また、上記フラッシュメモリは、物理的に交換せずに、電子機器に実装したままの状態でプログラム修正できるようになっている。
【0036】
このプログラム修正を行う書き換え動作モードは、外部からの書き換え動作モード設定により設定され、この書き換え動作モードにおいて、この書き換え動作モードに対応した割込により、フラッシュメモリのデータ書き換え及びシリアルコミュニケーションの制御を行うのはCPUであり、このCPUを制御するプログラムであるファームウェアをファームウェア格納用のROMが保有する。
【0037】
また、前記書き換え動作モードを起動すると、フラッシュメモリのデータを確認し、既に書き込まれたデータがあればこれを消去する。
【0038】
次に、本発明の第1の実施の形態を図7と共通の構成要素には共通の参照文字/数字を付して同様にブロックで示す図1を参照すると、この図に示す本実施の形態のマイクロコントローラは、後述のCPU3のプログラムを格納した電気的に一括消去及び書き換え可能な不揮発性メモリであるフラッシュメモリ1と、フラッシュメモリ1の所定領域を書き換えるための一連の動作のプログラム(ファームウェア)と後述のCSI6の制御プログラムに対応する割込ベクタを格納しているROM(リードオンリーメモリ)2と、ファームウェアに従いフラッシュメモリ1の書き換え手順を制御する中央演算処理装置(CPU)3と、フラッシュメモリ1の書き換えを行わない通常動作モードのときマイクロコントローラが内蔵する後述する複数の周辺回路5から送られてくる割込要求信号(割込ベクタ)の優先順序を制御してCPU3に通知するとともに、フラッシュメモリ1の書き換えを行う場合の書き換えモードのときこの書き換えモード設定に連動した書き換えモード信号MSの供給に応答して入力された後述のCSI6からの割込要求信号をある一定の基準に基づく割込順位及び割込レベルに変更してCPU3に通知する割込コントローラ4と、マイクロコントローラに内蔵される入力/出力(I/O)回路やタイマ等の様々なユニットである複数の周辺回路5と、マイクロコントローラの外部のホストコンピュータ8からのフラッシュメモリ1の書き換えデータDWの受信、もしくはホストコンピュータ8へのアクノリッジ(受信準備完了通知・受信確認)等の送信DAに使用する通信デバイスとして、シリアルコミュニケーションの一種であるクロック同期式通信方式に対応するクロック同期シリアルインタフェース(CSI:Clocked Sirial Interface)6とを備える。
【0039】
なお、図1では、本発明と直接関係しないデータ、制御信号及びアドレス伝送用の内部バス、入力/出力(I/O)回路、タイマ、クロック発生回路及びフラッシュメモリ1やROM2あるいはCPU3からのデータを一時的に保持するRAM及びレジスタ等のこの種のマイクロコンピュータが通常備える共通的な構成要素については割込要求信号を出力するものを周辺回路5として示したほかは図示を省略している。
【0040】
フラッシュメモリ1は、電気的な一括消去及び書き込みによって情報の書き換えが可能な全面フラッシュメモリであり、マイクロコントローラがその上位システムに実装されている状態で、CPU3の制御に基づいて、指定した領域の記憶情報を書き換えられるようになっている。上記指定以外の書き換え対象でない領域は、書き換えを実施しない。
【0041】
フラッシュメモリ1のメモリセルは、典型的には2層ゲート構造の絶縁ゲート型電界効果トランジスタにより構成されている。P型シリコン基板に形成されたP型拡散層と、上記P型シリコン基板に形成された低濃度のN型拡散層と、上記P型拡散層及びN型拡散層の各々に形成されたN型拡散層を有し、薄い絶縁膜(例えば10nm)を介して上記P型シリコン基板に形成されたフローティングゲートと、酸化膜を介してフローティングゲート上に形成されたコントロールゲートと、ソース及びドレインから成る。
【0042】
このメモリセルに記憶される情報は実質的にしきい値電圧の変化としてトランジスタに保持される。以下、特に述べない限り、メモリセルにおいて、情報を記憶するトランジスタ(以下、記憶トランジスタと称する)がNチャンネル型の場合について述べる。
【0043】
メモリセルへの情報の書き込み動作は、コントロールゲート及びドレインに高圧を印加して、アバランシェ注入によりドレイン側からフローティングゲートに電子を注入することで実現される。この書き込み動作により記憶トランジスタはそのコントロールゲートからみたしきい値電圧が、書き込み動作を行わなかった消去状態の記憶トランジスタに比べて高くなる。
【0044】
一方、消去動作は、ソースに高圧を印加して、トンネル現象によりフローティングゲートからソース側に電子を引き抜くことによって実現される。消去動作により記憶トランジスタはそのコントロールゲートからみたしきい値電圧が低くされる。
【0045】
書き込みならびに消去状態のいずれにおいても記憶トランジスタのしきい値は正の電圧レベルにされる。すなわち、ワード線からコントロールゲートに与えられるワード線選択レベルに対して、書き込み状態のしきい値電圧は高くされ、消去状態のしきい値電圧は低くされる。双方のしきい値電圧とワード線選択レベルとがそのような関係を持つことによって、選択トランジスタを採用することなく1個のトランジスタでメモリセルを構成することができる。
【0046】
上記メモリセルを用いるメモリセルアレイは、X,Y方向にマトリクス配置されたメモリセルにおいて、同一行の記憶トランジスタのコントロールゲートはそれぞれ対応するワード線に接続され、同一列に配置された記憶トランジスタのドレイン領域(メモリセルの入出力ノード)はそれぞれ対応するデータ線に接続され、ソース領域はソース線に結合される。このソース線に消去対応の上記高圧を印加することにより、このソース線に接続されたメモリセル、すなわち、この行全体のメモリセルが一括して消去される。従って、少なくともソース線を介してソースが共通接続されたメモリセルに対して一括消去できる。よって、共通接続するソース線の数と同一ソース線に接続するメモリセルの数を変えることにより、一括消去対象のメモリブロックのサイズを任意に設定できる。
【0047】
ROM2には、上記ファームウェアに加えて、ファームウェア設計時に設定した少なくとも1つの通信デバイス、ここでは、上述のクロック同期式通信方式に対応するCSI6に対する制御プログラムに対応する割込ベクタを格納してある。この割込ベクタは、CSI6への割込発生に対し、このCSI6の通信手順を制御する制御プログラムのアドレスを指定する。この制御プログラムは、ROM2自身又はフラッシュメモリ1の書き換え対象外の領域に格納する。
【0048】
CPU3は、フラッシュメモリ1の書き換えモードではない、通常動作モードでは、このマイクロコントローラを実装した上位システムである電子機器を構成する各種回路・装置を制御し、上記書き換えモードでは、上記ファームウェアに従いフラッシュメモリ1の書き換え手順を制御する。
【0049】
割込コントローラ4は、フラッシュメモリ1の書き換えモード信号MSの供給に応答して入力されたCSI6の割込要求信号INT3をある一定の基準に基づく後述の割込順位及び割込レベル、ここでは説明の便宜上、最高位及び最優先レベルに変更し、割込実行要求信号IMを発生する割込レベル変換回路41を備える。
【0050】
割込レベル変換回路41の構成をブロックで示す図2を参照すると、この割込レベル変換回路41は、予め定めた複数の割込要求信号INT0〜INTNの優先順位に応じて同時発生した複数の割込のうちの最高優先順位のものを選択し選択割込要求信号VIを出力する割込順位決定回路411と、外部から供給される書き換えモード信号MSの論理レベルに応答して割込順位決定回路411からの選択割込要求信号VIとCSI6からの割込信号VCとのいずれか一方を割込実行要求信号IMとして選択し出力する書き換えモード優先化回路412とを備える。
【0051】
本実施の形態では、説明の便宜上、割込要求信号の数N(正の整数)、すなわち、優先順位のレベル数を上位から下降順にINT0〜INT3の4レベルとし、通常動作時、すなわち、フラッシュメモリの書き換えを行わないとき、通信デバイスであるCSI6の割込レベルを、最下位レベルであるINT3とする。
【0052】
割込順位決定回路411は、例えば、図3に示すように、NAND回路やNOR回路等の論理回路の組み合わせによって実現できる。
【0053】
論理回路の組み合わせによる割込順位決定回路411の構成例を回路図で示す図3を参照すると、割込要求信号INT0B(Bはローアクティブ又は信号反転を表す)を反転するインバータG411と、このインバータG411の出力信号と割込要求信号INT1Bとの否定論理和(以下NOR論理)を得る2入力のNOR回路G412と、割込要求信号INT0B,INT1Bの否定論理積(以下NAND論理)を得る2入力のNAND回路G413と、NAND回路G413の出力信号と割込要求信号INT2BとのNOR論理を得る2入力のNOR回路G414と、割込要求信号INT0B,INT1B,INT2BのNAND論理を得る3入力のNAND回路G415と、NAND回路G415の出力信号と割込要求信号INT3BとのNOR論理を得る2入力のNOR回路G416と、インバータG411,NOR回路G412,G414,G416の出力のOR論理を得て出力である選択割込要求信号VIを出力する4入力のOR回路G417とを備える。
【0054】
また、マスクROM等から成るテーブルに複数の周辺回路5の各々が発生する割込要求の情報に、予め設定した個々の割込優先度に基づく重み付け情報を付加した割込優先順位情報を格納し、この割込優先順位情報を参照することにより入力した割込要求信号の割込優先レベルを決定するものを用いても良い。
【0055】
図2を再度参照すると、書き換えモード優先化回路412は、書き換えモード信号MSの論理レベルに応答して割込要求信号INT3を導通遮断するトランスファゲートM41と、書き換えモード信号MSを反転するインバータG41と、インバータG41の出力である書き換えモード信号MSの反転信号の論理レベルに応答して割込順位決定回路411から供給を受けた選択割込要求信号VIを導通遮断するトランスファゲートM42とを備え、これらトランスファゲートM41,M42の各々の出力端を共通接続して出力である割込実行要求信号IMを出力する。トランスファゲートM41,M42は、例えば各々のドレイン・ソースを伝送対象の割込要求信号の入力・出力にそれぞれ接続し、各々のゲートに書き換えモード信号MS/書き換えモード信号MSの反転信号の供給を受けるMOSトランジスタで構成しても良い。
【0056】
次に、本実施の形態のマイクロコントローラの動作について説明する。本実施の形態のフラッシュメモリ1のプログラムの書き換えの制御は、従来技術で説明した割込により行われる。割込とは、コンピュータがプログラム実行中に発生した非同期的な、又は例外的な事象に応答するために、実行中のプログラムを強制的に一時中断し、指定されたルーチン、すなわち、割込処理ルーチンに自動的に制御を移すことである。その際割込時点で実行中のプログラムを後刻再起動できるように、CPU状態を自動的に保存する。
【0057】
割込発生の要因として、割込発生時点で実行中のプログラムと関連があるか否かによって分類し、関連がある場合の内部要因によるものを割出しと呼び、実行中のプログラムと関連がない外部要因によるものを割込と呼ぶことが一般的である。本実施の形態では、この定義による、すなわち、シリアルコミュニケーション等通信デバイスを経由した外部要因による割込を考える。
【0058】
割込の優先順位と優先レベルについては、複数の割込原因が同時に発生した場合に、どの割込を先に起こすかという優先度の問題と、ある割込の処理中にほかの割込原因が発生した場合、より高い緊急度を認めて、重ねて割込を起こすか否かのレベルの問題がある。一般的な方法は、原因(のグループ)毎に割込の優先度及びレベルを定め、割込処理以外の通常のプログラムを最低位レベルとして、高位の割込レベルに属する割込は、低位のレベルの処理中に割り込めるようにする方法である。本実施の形態においても、この方法を用いるものとする。また、本実施の形態の動作の説明においては、上記優先度を割込順位と呼び、上記レベルを割込レベルと呼ぶことにする。
【0059】
次に、図1、図2、及び図3を参照して本実施の形態の動作について説明すると、まず、フラッシュメモリ1の書き換えを行わない通常動作の場合は、書き換えモード信号MSを不活性化に対応するLレベルとする。これにより、CPU3は、通常動作モードとなる。同時に、割込コントローラ4の割込レベル変換回路41は、割込優先順位が最高位の割込要求信号INT0から、最低のINT3すなわち、CSI6からの割込要求信号VCまでの割込優先順位に応じて、同時発生した複数の割込のうちの最高位のものを選択し、対応する割込実行要求信号IMを発生する。
【0060】
割込レベル変換回路41の割込順位決定回路411は、上述したように、複数の割込要求信号INT0〜INTNの優先順位に応じて同時発生した複数の割込のうちの最高位のものを選択し選択割込要求信号VIを出力する。
【0061】
説明の便宜上、割込順位決定回路411の全ての入力端には図示しないインバータを介して割込要求信号INT0〜INT3の反転信号である反転割込要求信号INT0B〜INT3Bが供給されるものとする。これら反転割込要求信号INT0B〜INT3BはLレベルのとき活性状態すなわちローアクティブであるとする。
【0062】
割込順位決定回路411にLレベルの反転割込要求信号(以下割込要求信号と省略)INT0Bが供給されると、この割込要求信号INT0BはインバータG411,NAND回路G413,G415にそれぞれ入力する。インバータG411は、Hレベルの出力信号をNOR回路G412の一方の入力端及びOR回路G417の第1入力端にそれぞれ供給する。このときNOR回路G412は、他方の入力端に供給される割込要求信号INT1Bの入力の有無すなわち、Hレベル/Lレベルに関係なく、NOR回路G412はLレベルの出力信号を出力する。割込要求信号INT0BがHレベルのときは、NOR回路G412は割込要求信号INT1BがLレベルのときHレベルの出力信号を、割込要求信号INT1BがHレベルのときLレベルの出力信号をそれぞれ出力し、OR回路G417に供給する。すなわち、割込要求信号INT0Bの方が割込要求信号INT1Bより優先順位が高い。
【0063】
割込要求信号INT1Bは、NOR回路G412,NAND回路G413,G415にそれぞれ入力する。割込要求信号INT2Bは、NOR回路G414,NAND回路G415にそれぞれ入力する。割込要求信号INT3Bは、NOR回路G416のみに入力する。
【0064】
NAND回路G413は、割込要求信号INT0B,INT1Bの両方がHレベルのときのみ出力信号をLレベルとし、他の場合は出力信号をHレベルとするので、NOR回路G414は、割込要求信号INT0B,INT1Bの両方がHレベルのとき、すなわち不活性化状態のときのみ割込要求信号INT2Bのレベルに対応する出力信号を出力する。すなわち、割込要求信号INT2Bは、割込要求信号INT0B,INT1Bより優先順位が低い。
【0065】
NAND回路G415は、割込要求信号INT0B,INT1B,INT2Bの3者がHレベルのときのみ出力信号をLレベルとし、他の場合は出力信号をHレベルとするので、NOR回路G416は、割込要求信号INT0B,INT1B,INT2Bの3者がHレベルのとき、すなわち不活性化状態のときのみ割込要求信号INT3Bのレベルに対応する出力信号、すなわち、割込要求信号INT3BがLレベルのときはHレベルの出力信号、割込要求信号INT3BがHレベルのときはLレベルの出力信号をそれぞれ出力する。すなわち、割込要求信号INT3Bは、割込要求信号INT0B,INT1B,INT2Bより優先順位が低い。
【0066】
従って、割込優先順位は、INT0B,INT1B,INT2B,INT3Bの順番で低下する。
【0067】
例えば、割込順位決定回路411に、割込要求信号INT3Bと割込要求信号INT0Bとが同時に入力(すなわちLレベルとする)した場合、割込要求信号INT0Bの方が優先順位が高いので、この割込要求信号INT0B対応のインバータG411の出力がHレベルとなり、一方、割込要求信号INT3B対応のNOR回路G416の出力はLレベルのままである。また、割込要求信号INT2Bは、割込要求がなくHレベルのままであるので、対応するNOR回路G414の出力はLレベルとなる。
【0068】
OR回路G417は、インバータG411,NOR回路G412,G413,G416の各出力信号のOR論理を取り、従って、この場合は、インバータG411のHレベルに対応して選択割込要求信号VIを出力する。よって、割込要求信号INT0Bが選択割込要求信号VIとして出力されることになる。
【0069】
書き換えモード優先化回路412では、トランスファゲートM42に割込順位決定回路411から供給を受けた選択割込要求信号VIが入力する。また、トランスファゲートM41に割込要求信号INT3が入力する。書き換えモード信号MSの論理レベルは、Lレベルであるので、制御端子(MOSトランジスタの場合はゲート)にこの書き換えモード信号MSの供給を受けるトランスファゲートM41は遮断状態となり、一方、制御端子に書き換えモード信号MSをインバータG41で反転した反転書き換えモード信号MSBの供給を受けるトランスファゲートM42は導通状態となる。従って、割込要求信号INT3はトランスファゲートM41により阻止され、トランスファゲートM42を通過した選択割込要求信号VIが割込実行要求信号IMとして出力される。
【0070】
CPU3は、割込実行要求信号IMの供給に応答した割込動作を含む通常の動作を行う。
【0071】
次に、割込切り替えを自動的に行う場合の処理をフローチャートで示す図4を併せて参照してフラッシュメモリ1の書き換えを行う場合の動作について説明すると、フラッシュメモリ1の書き換えを行う場合は、まず、書き換えモード信号MSをLレベル(非供給状態又は不活性化状態)からHレベル(供給状態又は活性化状態)に設定する。書き換えモード信号MSがHレベル(ステップS1)となると、割込コントローラ4の割込レベル変換回路41は、割込優先順位が最下位、すなわちINT3のCSI6の割込要求信号VCの割込優先順位を最上位の順位に変更する(ステップS2)。
【0072】
同時にCPU3は、書き換えモードとなり、また、CSI6からの割込要求信号VCは最優先で扱われ、割込コントローラ4の割込レベル変換回路41は、割込実行要求信号IMを発生する状態となる。
【0073】
割込レベル変換回路41の書き換えモード優先化回路412では、トランスファゲートM42に割込順位決定回路411から供給を受けた選択割込要求信号VIが入力する。また、トランスファゲートM41に割込要求信号INT3、すなわち、CSI6からの割込要求信号VCが入力する。書き換えモード信号MSの論理レベルは、Hレベルであるので、制御端子にこの書き換えモード信号MSの供給を受けるトランスファゲートM41は導通状態となり、一方、制御端子に反転書き換えモード信号MSBの供給を受けるトランスファゲートM42は遮断状態となる。従って、選択割込要求信号VIはトランスファゲートM42により阻止され、トランスファゲートM41を通過した割込要求信号INT3、すなわち、CSI6からの割込要求信号VCが割込実行要求信号IMとして出力される。
【0074】
次に、CPU3は、割込コントローラ4が出力する、CSI6の割込要求信号VCから生成した割込実行要求信号IMの供給に応答して書き換え動作プログラムPRをROM2から読み出し、CPU3の初期化ルーチン(ステップS3)を経て、CSI6を経由して外部のホストコンピュータ8から供給される割込データ、すなわち、フラッシュメモリ1の書き換えデータDWを待つ状態、すなわち割込待ち状態(ステップS4)となる。
【0075】
また、CPU3は、CSI6を経由してこの割込待ち状態、すなわち、受信準備が完了したことを、ホストコンピュータ8に通知する(アクノリッジ)。ホストコンピュータ8は、この受信準備完了通知のアクノリッジに応答して、書き換えデータDWを送信する。次に、CSI6は、ホストコンピュータ8から割込データであるフラッシュメモリ1の書き換えデータDWを受信する(ステップS5)。
【0076】
CSI6は、クロック同期シリアルインタフェースであるので、送信側、ここでは、ホストコンピュータ8で発生した通信クロック信号に同期してデータ及びこの通信クロックの送信が行われ、受信側、すなわち、CSI6では受信した通信クロックに同期してデータを受信する。従って、調歩同期式のようなビットレート調整等のイニシャライズは不要であり、上記受信準備完了後、直ちにデータ転送処理を行うことが可能である。
【0077】
CPU3は、割り込みコントローラ4経由でCSI6での書き換えデータDWの受信を認識し、CSI6から書き換えデータDWを読み出した後、この書き換えデータを基にフラッシュメモリ1の書き換え処理を行う(ステップS6)。
【0078】
全ての書き換えデータDWを受信するまで書き換えデータDWの受信及びフラッシュメモリ1への書き換えの処理を繰り返す(ステップS7)。
【0079】
全てのフラッシュメモリ1の書き換え処理が終わった時点で終了となる。
【0080】
次に、フラッシュメモリ1の書き換え処理の最初の処理である消去処理をフローチャートで示す図5を参照して、このフラッシュメモリ1の消去処理について説明すると、まず、CPU3はフラッシュメモリ1の消去対象とするブロック(領域)を指定する(ステップS11)。さらに、CPU3はフラッシュメモリ1をイレースモードに設定する(ステップS12)。
【0081】
続いて、CPU3は消去時間Tの期間、ソフトウェアタイマで所定サイクル数待ち(ステップS13)、T時間経過後フラッシュメモリ1のイレースモードを解除する(ステップS14)。
【0082】
さらに、フラッシュメモリ1をイレーズベリファイモードに設定し(ステップS15)、消去対象のブロックをリードする(ステップS16)。
【0083】
そして、全アドレスをリードし、“1”の状態に消去されていると(ステップS17)、CPU3はイレーズベリファイモードを解除し(ステップS18)、さらに消去ブロックの指定を解除し(ステップS19)、消去完了となる。
【0084】
一方、ステップS17において、全アドレスをリードしていない場合にはアドレスをインクリメントした後(ステップS20)、ステップS16のブロックのリードからの処理を繰り返して実行する。
【0085】
この場合の消去時間Tは、メモリセルの書き込み状態(高しきい値領域VthH)から消去状態(低しきい値領域VthL)に変化させるための時間である。
【0086】
この消去時間Tはメモリセルのプロセス技術によって変動する。例えば、高しきい値領域VthHは4.5V以上であり、低しきい値領域VthLは2.5V以下であり、高しきい値領域VthHから低しきい値領域VthLに変化するまで10msかかる。
【0087】
消去処理完了後、CPU3は書き換えデータDWをCSI6からフラッシュメモリ1に転送し、フラッシュメモリ1はこの書き換えデータDWの転送を受け、消去完了後の領域への書き込み処理を行う。
【0088】
本実施の形態では、通信デバイスとしてクロック同期シリアルインタフェース(CSI)を用いたが、通信デバイスとしてこのCSIに限ることなく従来技術で説明したような調歩同期式通信(UART:Universal asynchronous Receiver/Transmitter)や2線式双方向シリアル通信方式のI2 C(Inter−IC)等のシリアル通信方式、あるいは一般的なパラレルデータの伝送によるパラレル通信方式を用いても良い。また、これらのうちの2種以上の通信方式に対応し、通信相手によりそのうちの1つの方式を選択使用するものでも良い。
【0089】
また、本実施の形態の割込コントローラの割込要求信号の数が4の場合について説明したが、これに限ることなく割込要求信号の数を任意に設定できることは明らかである。
【0090】
次に、本発明の第2の実施の形態を特徴付ける割込レベル変換回路41Aを図3と共通の構成要素には共通の参照文字/数字を付して同様に回路図で示す図6を参照すると、この図に示す本実施の形態の割込レベル変換回路41Aの前述の第1の実施の形態との相違点は、割込順位決定回路411及び書き換えモード優先化回路412の各々の代わりに、書き換えモード信号MSの活性化時の論理レベル(Hレベル)に応答して割込順位を強制的に下位順位に変更する割込順位決定回路411Aと、書き換えモード信号MSを反転して反転書き換えモード信号MSBを生成するとともにこの反転書き換えモード信号MSBの論理レベルに応答してCSI6からの割込信号VCに対応する割込要求信号INT3の順位を最高順位に設定する書き換えモード優先化回路412Aをそれぞれ備えることである。
【0091】
割込順位決定回路411Aの割込順位決定回路411との相違点は、インバータG411の代わりに割込要求信号INT0Bと書き換えモード信号MSとのNAND論理を得る2入力のNAND回路G11Aを、NAND回路G413の代わりに割込要求信号INT0B,INT1Bに加えて書き換えモード信号MSとのNAND論理を得る3入力のNAND回路G413Aを、割込要求信号INT0B,INT1B,INT2Bに加えて書き換えモード信号MSとのNAND論理を得る4入力のNAND回路G415Aを、NOR回路G412,G414,G416及び後述のNOR回路G419の各出力のOR論理を得て出力である割込実行要求信号IMを出力する5入力のOR回路G417Aをそれぞれ備えることである。
【0092】
書き換えモード優先化回路412Aは、書き換えモード信号MSを反転して反転書き換えモード信号MSBを生成するインバータG418と、割込要求信号INT3Bと反転書き換えモード信号MSBとのNOR論理を得る2入力のNOR回路G419とを備える。
【0093】
また、第1の実施の形態と同様に、本実施の形態の割込順位決定回路411Aの全ての入力端には図示しないインバータを介して割込要求信号INT0〜INT3の反転信号である反転割込要求信号INT0B〜INT3Bが供給されるものとする。反転割込要求信号INT0B〜INT3BはLレベルのとき活性状態すなわちローアクティブであるとする。
【0094】
本実施の形態の動作について説明すると、まず、書き換えモード信号MSの不活性化に対応してLレベルである通常動作モードでは、書き換えモード優先化回路412Aは論理レベルがHレベルの反転書き換えモード信号MSBを出力する。従って、NOR回路G419は割込要求信号INT3Bの論理レベルと無関係にLレベルを出力する。
【0095】
一方、割込順位決定回路411AのNAND回路G411A,G413A,G415AはそれぞれLレベルの書き換えモード信号MSが入力されるので、割込順位決定回路411Aは、第1の実施の形態の割込順位決定回路411と同一の動作を行い、従って、上位から割込要求信号INT0B,INT1B,INT2B,INT3Bの優先順序で選択し、OR回路G417Aから割込実行要求信号IMを出力する。
【0096】
すなわち、NAND回路G411Aは割込要求信号INT0Bの論理レベルがLの場合はHレベルを出力し、これは、第1の実施の形態におけるインバータG411と同一動作である。同様にNAND回路G413A,G415AもそれぞれNAND回路G413,G415と同一動作を行う。
【0097】
次に、フラッシュメモリの書き換えモードに対応して、書き換えモード信号MSが活性化しHレベルとなると、書き換えモード優先化回路412Aは論理レベルがLレベルの反転書き換えモード信号MSBを出力する。従って、NOR回路G419は割込要求信号INT3Bの論理レベルに応じてその出力論理レベルが変わり、割込要求信号INT3Bの論理レベルがLレベルの場合論理レベルがHレベルの出力信号を出力する。
【0098】
一方、割込順位決定回路411AのNAND回路G411A,G413A,G415AはそれぞれHレベルの書き換えモード信号MSが入力されるので、これらNAND回路G411A,G413A,G415Aの出力論理レベルは割込要求信号INT0B,INT1B,INT2B,INT3Bの論理レベルと無関係にLレベルを出力する。この結果、割込要求信号INT0B,INT1B,INT2B,INT3Bの論理レベルと無関係にNOR回路G412,G414,G416の各々の出力論理レベルはLレベルとなる。従って、OR回路G417Aは、割込要求信号INT3Bの論理レベルがLレベル、すなわち割込要求がある場合に対応の割込実行要求信号IMを出力する。
【0099】
【発明の効果】
以上説明したように、本発明のマイクロコントローラ及びそのプログラムの書き換え方法は、フラッシュメモリを書き換えるためのファームウェアと通信手段の動作の制御プログラム又は少なくともこの制御プログラムを設定する割込ベクタを格納したROMと、通常動作モードのとき内蔵する複数の周辺回路から送られてくる割込要求信号の優先順序を制御してCPUに通知するとともに、フラッシュメモリの書き換えモードのときこの書き換えモード設定に連動した書き換えモード信号の供給に応答して入力された通信手段からの割込要求信号を予め定めた割込順位に変更して上記CPUに通知する割込コントローラを備え、書き換えモードのとき通信手段からのデータの割込優先順位を上記予め定めた割込順位、例えば最高優先順位に自動的に設定し、上記割込ベクタ対応の制御プログラムにより通信手段を制御するので、マイクロコントローラの品種とは無関係に、ファームウェアの専用化設計を不要とすることにより、設計のTATを短縮できるという効果がある。
【0100】
また、マイクロコントローラの品種毎にファームウェアを変更する必要がないので、バグ等を十分除去した標準化設計を適用できることにより、設計品質の低下要因を除去できるという効果がある。
【図面の簡単な説明】
【図1】本発明のマイクロコントローラの第1の実施の形態を示すブロック図である。
【図2】図1の割込レベル変換回路の構成の一例を示すブロック図である。
【図3】図2の割込順位決定回路の構成の一例を示す回路図である。
【図4】本実施の形態のマイクロコントローラ及びそのプログラムの書き換え方法における動作の一例を示すフローチャートである。
【図5】本実施の形態のプログラムの書き換え方法における消去動作の一例を示すフローチャートである。
【図6】本発明のマイクロコントローラの第2の実施の形態を特徴付ける割込レベル変換回路の構成の一例を示す回路図である。
【図7】従来のマイクロコントローラ及びそのプログラムの書き換え方法の一例を示すブロック図である。
【図8】従来のマイクロコントローラ及びそのプログラムの書き換え方法における動作の一例を示すフローチャートである。
【符号の説明】
1 フラッシュメモリ
2 ROM
3 CPU
4 割込コントローラ
5 周辺回路
6 CSI
7 デコーダ
8 ホストコンピュータ
9 RAM
30 タイマ
60 SCI
41,41A 割込レベル変換回路
411,411A 割込順位決定回路
412,412A 書き換えモード優先化回路
G41,G411,G418 インバータ
G412,G414,G416,G419 NOR回路
G413,G415,G411A,G413A,G415A NAND回路
G417,G417A OR回路
M41,M42 トランスファゲート
[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a microcontroller and a method for rewriting the program, and more particularly to a microcontroller incorporating a nonvolatile memory (flash memory) that can be electrically erased and rewritten for storing programs and a method for rewriting the program.
[0002]
[Prior art]
In recent years, so-called AV devices such as television receivers, VTRs, DVD players, audio components, satellite broadcast receivers, CATV terminals, etc., which have an internal microprocessor system (hereinafter referred to as a microcontroller), home appliances, and electronic devices such as automobile electronics Is generalized. These include a CPU for controlling various circuits and devices constituting the electronic device and a program memory such as a PROM for storing the program of the CPU inside the electronic device. Various circuits / devices provided inside the electronic device are controlled through the connected paths.
[0003]
In addition, as electronic devices become more sophisticated, the specifications become more complex, and the control of the various circuits and devices required for microcontrollers is becoming more complex every year. As a result, defects (so-called bugs) caused by the microcontroller software are discovered after electronic devices are shipped to the market or immediately before shipment, and functional specification changes frequently occur, thereby integrating the functions of electronic devices. There is a situation in which it is frequently necessary to change the program of the microcontroller CPU that is managed and controlled.
[0004]
Recently, an electrically rewritable EEPROM or flash memory has been used instead of a fixed memory such as a mask ROM as a program memory for storing a program of the microcontroller, and the memory is not physically exchanged. In addition, the program can be modified while being mounted on the electronic device.
[0005]
A conventional microcontroller described in Japanese Patent Laid-Open No. 8-6919 (Document 1), which uses a flash memory as a program memory and controls rewriting of a program stored in the flash memory, has at least a central processing on a single semiconductor chip. A device (CPU) and a nonvolatile flash memory that can be rewritten by electrically erasing and writing information (data) to be processed by the CPU are mounted, and a kind of serial communication for rewriting data in the flash memory A rewrite operation mode for rewriting using asynchronous communication is provided, and the baud rate (bit rate) of the asynchronous communication is automatically adjusted to the bit rate of the transfer source.
[0006]
In this case, in the rewrite operation mode, the CPU rewrites the data in the flash memory and controls the serial communication, and the flash memory or the mask ROM holds firmware that is a program for controlling the CPU.
[0007]
When the rewrite operation mode is activated, data in the flash memory other than the area holding the control program is confirmed, and if there is already written data, the area other than the area holding the control program is erased.
[0008]
This type of program rewrite control is generally performed by interruption. An interrupt is a program that forcibly suspends a running program in order to respond to an asynchronous or exceptional event that occurs during program execution. It is to automatically transfer control to the routine. At that time, the CPU state is automatically saved so that the program being executed at the time of interruption can be restarted later.
[0009]
The cause of interrupt generation is classified according to whether or not it is related to the program being executed at the time of the interrupt occurrence. If there is a relation, it is called indexing and is not related to the program being executed. It is common to call an external factor an interrupt. Here, an interrupt caused by this definition, that is, an external factor via a communication device such as serial communication is considered.
[0010]
In general, there are a plurality of interrupts, such as input / output relations, timer relations, and other equipment relations, in addition to the communication device described above. An interrupt controller is provided for selecting the highest level interrupt request according to the interrupt level and making an interrupt request to the CPU.
[0011]
Regarding the priority level and priority level of interrupts, when multiple interrupt causes occur at the same time, the priority issue of which interrupt will occur first and other interrupt causes during the processing of an interrupt When this occurs, there is a problem of whether or not to cause a higher level of urgency and cause another interruption. The general method is to determine the priority and level of interrupts for each cause (group), set the normal program other than interrupt processing as the lowest level, and interrupts belonging to higher interrupt levels are lower. This is a method that allows interrupts during level processing. In the following description, the priority is referred to as an interrupt order, and the level is referred to as an interrupt level.
[0012]
Referring to FIG. 7 showing a block diagram of a conventional microcontroller (hereinafter referred to as a microcomputer) described in Document 1, this conventional microcontroller includes a central processing unit (CPU) 3 coupled to an internal bus and a control for controlling the CPU 3. A serial communication interface (SCI) for performing asynchronous communication between the flash memory 1 storing the program, a timer 30 for measuring a communication data rate (bit rate) between the host computer 8 to be described later, and the host computer 8. ) 60, a random access memory (RAM) 9 functioning as a buffer for temporarily storing data from the flash memory 1, and an operation mode signal input from the mode terminal to determine whether, for example, a rewrite operation mode is instructed Decoder With the door, for example, it is connected through SCI60 to a host computer 8 such as an external personal computer. For storing the control program, a mask ROM 10 indicated by a dotted line may be used instead of the flash memory 1.
[0013]
Next, with reference to FIG. 7 and FIG. 8 showing the process in a flowchart, the rewriting method of the program of the conventional microcontroller will be described. Although not particularly specified in Reference 1, the microcomputer is externally inserted by interruption. When the operation mode signals MDO to MD2 to be set to the rewrite operation mode are received and the operation mode signals MDO to MD2 are decoded by the decoder 7, it is determined that the instruction is the rewrite operation mode with the above settings. The control program stored in the flash memory 1 is executed by reset (REST) start (step P1). This corresponds to setting the rewrite mode by interrupting the CPU 3 with the operation mode signals MDO to MD2.
[0014]
Further, when the control program is started, data is continuously transmitted from the host computer 8 at a predetermined bit rate (step P2), and the CPU 3 sets the LOW period of the data transmitted by the host computer 8 by the input carburetor function of the timer 30. Measurement is performed using the internal clock signal CK (step P3: measurement process). In this case, the input cab terminal of the timer 30 is allocated to the RXD terminal. Then, a value to be set in the bit rate register in the SCI 60 is calculated from the measured value of the data LOW period (step P3: calculation process). This calculation process is performed by the CPU 3, and the obtained value is set in the bit rate register in the SCI 60 (step P3: setting process).
[0015]
Subsequently, when the adjustment is completed to the same bit rate as the bit rate transferred by the host computer 8, the microcomputer transmits a signal of completion of adjustment to the host computer 8 via the transmission line SL (step P5: notification process). The host computer 8 outputs a signal indicating that the adjustment completion signal has been normally received to the microcomputer via the reception line RL (step P5: confirmation process).
[0016]
Further, the host computer 8 notifies the transfer byte number N of the user program to be transferred next (step P5: notification process), and thereafter sequentially transmits the program set by the user. At this time, the microcomputer receives the user program transmitted by the host computer (step P5: reception process) and further transfers it to the RAM 9 (step P6: transfer process). Then, the CPU 3 calculates the number of remaining bytes of the transfer (step P6: remaining byte number calculation process), and repeats it until the transfer of the user program is completed (step P7).
[0017]
Before executing the transferred user program, it is confirmed whether or not the data written in the flash memory 1 exists (steps P8 and P9). If the data has already been written (step P9). The data in all memory blocks is erased (step P10).
[0018]
On the other hand, if no data has been written, the last instruction in the program in the test area in the flash memory 1 is executed to branch to the RAM 9 area, and the user program transferred into the RAM 9 is executed ( Step P11). Thereby, the flash memory 1 can be rewritten.
[0019]
As described above, in the conventional microcontroller, the interrupt to the flash memory rewrite mode is set by the operation mode signals MDO to MD2, and when the flash memory rewrite mode is determined as a result of the recognition of the interrupt, the CPU 3 performs a reset start. The control program (firmware) stored in the flash memory 1 is executed, and data transfer conditions such as the flash memory rewrite data transmission / reception data rate and signal format are set in the dedicated communication terminal SCSI 60 according to the instructions of the firmware. After initialization, the flash memory rewrite data is received under the set data transfer conditions, and the flash memory 1 is rewritten.
[0020]
As described above, in the conventional microcontroller and its program rewriting method, when an interrupt for rewriting the built-in flash memory occurs, data transfer conditions such as a data transfer rate are set in a dedicated communication terminal each time. Rewriting of the flash memory has started from the implementation of initialization.
[0021]
On the other hand, the interrupt vector (combination of the operation mode signals MDO to MD2 in the above-described conventional example), which is the format of the interrupt request signal for setting the interrupt process when the interrupt occurs, depends on the use of the microcomputer. Since the interrupt priority or interrupt level of various serial or parallel communication devices (hereinafter referred to as communication devices) is not constant and varies, it differs depending on the type of microcomputer. For example, the interrupt priority of a communication device is the highest in a certain product, and the interrupt priority of a communication device is set to the lowest in another product.
[0022]
Generally, when the internal flash memory needs to be rewritten, the cause of the interrupt for this rewrite has a higher priority than the cause of other interrupts, and the above rewrite processing is being executed by this interrupt. Must be set to the highest interrupt level that does not accept other interrupts.
[0023]
For this reason, the firmware in the microcomputer's built-in flash memory or mask ROM has a fixed communication device interrupt priority for each type of built-in microcomputer corresponding to the occurrence of an interrupt for rewriting the flash memory. There is a problem that the interrupt design and the interrupt level, for example, the interrupt vector must be changed to the highest interrupt priority and the highest interrupt level, and the design TAT (turnaround time) is prolonged. was there.
[0024]
In addition, there is a problem that design quality is deteriorated due to an increase in bugs and the like by changing firmware for each kind of microcomputer.
[0025]
Here, as is well known, a vector refers to an array of data in which individual items are arranged in order according to a single index or subscript. Therefore, the interrupt vector refers to an instruction and data array related to interrupts arranged in a predetermined order.
[0026]
[Problems to be solved by the invention]
The above-described conventional microcontroller and its program rewriting method perform initialization including setting of data transfer conditions such as a data transfer rate in a dedicated communication terminal each time an interrupt for rewriting the built-in flash memory occurs. The interrupt vector, which is the format of the interrupt request signal for setting the interrupt processing when an interrupt occurs, is a communication device for each product type depending on the application of the microcomputer. The firmware, which is the rewrite control software for the above rewrite control, does not depend on the original interrupt priority level for each type of built-in microcomputer. In response to the occurrence of an interrupt to rewrite the flash memory Bell, must only be designed to change for example the highest level, TAT of the design has a drawback that prolonged.
[0027]
In addition, there is a drawback that the design quality is lowered by changing the firmware for each kind of microcomputer.
[0028]
The object of the present invention is to automatically set the interrupt priority level of a communication device to a predetermined level when an interrupt for rewriting the internal flash memory occurs regardless of the type of microcomputer. It is an object of the present invention to provide a microcontroller and a program rewriting method that eliminates the need for specialized design, eliminates the TAT of the design, and eliminates the cause of the deterioration of the design quality.
[0029]
[Means for Solving the Problems]
The microcontroller according to the present invention has a built-in flash memory that is a nonvolatile memory that can be electrically erased and rewritten for storing programs, and a rewrite operation mode for correcting the program of the flash memory is set by an interrupt. In the microcontroller
A ROM that stores firmware that is a program of a series of operations for rewriting the flash memory and a control program for the operation of the communication means described later, or at least an interrupt vector for setting the control program,
A CPU that is a central processing unit that controls the rewrite procedure of the flash memory in accordance with the firmware read from the ROM;
Controlling the priority order of interrupt request signals sent from a plurality of built-in peripheral circuits in the normal operation mode in which the flash memory is not rewritten and notifying the CPU, and rewriting the flash memory In the rewrite mode, the interrupt request signal from the communication means, which will be described later, input in response to the supply of the rewrite mode signal linked to the rewrite mode setting is changed to a predetermined interrupt order and notified to the CPU. An interrupt controller to
A plurality of said peripheral circuits including input / output (I / O) circuits and timers;
Communication means for performing transmission including reception of rewrite data of the flash memory from an external host computer and reception preparation completion notification to the host computer;
It is configured with.
[0030]
Further, the interrupt controller changes the communication interrupt request signal, which is an interrupt request signal from the communication means input in response to the supply of the rewrite mode signal, to an interrupt order based on a predetermined criterion. An interrupt level conversion circuit for generating an interrupt execution request signal for requesting the CPU to execute interrupt may be provided.
[0031]
Further, the interrupt level conversion circuit selects the one having the highest priority among a plurality of interrupts simultaneously generated according to the priority of predetermined N (N is a positive integer) interrupt request signals. An interrupt priority determination circuit for outputting a selection interrupt request signal;
One of the selected interrupt request signal output from the interrupt priority determination circuit and the communication interrupt request signal from the communication means in response to the logic level of the rewrite mode signal is the interrupt execution request. A rewrite mode prioritizing circuit which selects and outputs as a signal.
[0032]
In addition, the interrupt level conversion circuit simultaneously responds according to the priority of N (N is a positive integer) predetermined interrupt request signals in response to the logic level when the rewrite mode signal is inactivated. Select the highest priority among a plurality of generated interrupts, output the interrupt execution request signal, and respond to the logic level at the time of activation of the rewrite mode signal. An interrupt priority determination circuit for forcibly changing the interrupt priority of a request signal to a lower priority;
Inverting the rewrite mode signal to generate an inverted rewrite mode signal, and in response to a logic level of the inverted rewrite mode signal when the rewrite mode signal is activated, a communication interrupt which is an interrupt request signal from the communication means A rewrite mode prioritizing circuit that sets the order of the embedded signals to the highest order.
[0033]
The program rewriting method of the microcontroller of the present invention incorporates a flash memory which is a nonvolatile memory that can be electrically erased and rewritten electrically for storing programs, and assigns a rewriting operation mode for correcting the program of the flash memory. In the microcontroller flash memory rewrite method set by
A first step of setting a logic level of a rewrite mode signal linked to the rewrite mode setting from L level to H level in a rewrite mode for rewriting the flash memory;
In response to the transition of the rewrite mode signal to the H level, an interrupt of communication means for performing transmission including reception of rewrite data of the flash memory from an external host computer and reception preparation completion notification to the host computer A second step of changing the priority of the request signal to the highest order;
A third step of reading a rewrite operation program in response to the supply of the interrupt execution request signal generated from the interrupt request signal of the communication means and initializing the CPU; and the host computer via the communication means A fourth step of waiting for an interrupt to receive the rewrite data of the flash memory supplied from
A fifth step in which the communication means receives the rewrite data which is interrupt data transmitted by the host computer;
A sixth step in which the CPU recognizes reception of the rewrite data in the communication means and performs rewrite processing of the flash memory based on the rewrite data;
A seventh step of repeating the process of receiving the rewrite data and rewriting the flash memory until receiving all the rewrite data;
It is characterized by including.
[0034]
DETAILED DESCRIPTION OF THE INVENTION
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
[0035]
A microprocessor system (hereinafter referred to as a “microcontroller”) according to the present embodiment is provided in electronic equipment such as AV equipment, home appliances, and automobile electronics, and a CPU for controlling various circuits and devices constituting the electronic equipment. A non-volatile flash memory that is rewritable by electrical erasing and writing is built in as a program memory for storing the program, and is provided inside the electronic device by the CPU via a path connected to the CPU and the program memory. Various circuits and devices are controlled. Further, the flash memory can be modified in a state where it is mounted on an electronic device without being physically replaced.
[0036]
The rewrite operation mode for correcting the program is set by the external rewrite operation mode setting. In this rewrite operation mode, the flash memory data rewrite and serial communication are controlled by an interrupt corresponding to the rewrite operation mode. Is a CPU, and a firmware storing ROM holds firmware which is a program for controlling the CPU.
[0037]
When the rewrite operation mode is activated, the data in the flash memory is confirmed, and any data already written is erased.
[0038]
Next, referring to FIG. 1 in which the first embodiment of the present invention is shown in the same block by adding common reference characters / numerals to the same components as in FIG. 7, the present embodiment shown in FIG. The microcontroller of the embodiment includes a flash memory 1 that is an electrically erasable and erasable nonvolatile memory storing a program of a CPU 3 to be described later, and a series of operation programs (firmware for rewriting a predetermined area of the flash memory 1 ) And an ROM (Read Only Memory) 2 storing an interrupt vector corresponding to a CSI 6 control program, which will be described later, a central processing unit (CPU) 3 that controls the rewrite procedure of the flash memory 1 according to the firmware, and a flash In the normal operation mode in which the memory 1 is not rewritten, a plurality of later-described microcontrollers are incorporated The priority order of the interrupt request signal (interrupt vector) sent from the peripheral circuit 5 is controlled and notified to the CPU 3, and the rewrite mode setting when rewriting the flash memory 1 is linked to the rewrite mode setting. An interrupt controller 4 for changing an interrupt request signal from a CSI 6 (to be described later) input in response to the supply of the rewrite mode signal MS to an interrupt rank and an interrupt level based on a certain standard and notifying the CPU 3; Receiving rewrite data DW of flash memory 1 from a plurality of peripheral circuits 5 which are various units such as input / output (I / O) circuits and timers incorporated in the microcontroller and a host computer 8 outside the microcontroller. Or to send DA for acknowledgment (reception preparation completion notification / reception confirmation) to the host computer 8 As a communication device for use, the clock synchronous serial interface corresponding to the clocked communication system is a type of serial communication (CSI: Clocked Sirial Interface) and a 6.
[0039]
In FIG. 1, data not directly related to the present invention, control signal and address transmission internal bus, input / output (I / O) circuit, timer, clock generation circuit, and data from the flash memory 1, ROM 2 or CPU 3 are shown. As for the common components normally provided in this type of microcomputer such as a RAM and a register for temporarily holding the memory, the output of the interrupt request signal is shown as the peripheral circuit 5 and is not shown.
[0040]
The flash memory 1 is a full-face flash memory in which information can be rewritten by electrical batch erasure and writing, and in a state where a microcontroller is mounted on the host system, a specified area is controlled based on the control of the CPU 3. The stored information can be rewritten. Rewriting is not performed for areas other than those specified above that are not subject to rewriting.
[0041]
The memory cell of the flash memory 1 is typically composed of an insulated gate field effect transistor having a two-layer gate structure. A P-type diffusion layer formed on the P-type silicon substrate, a low-concentration N-type diffusion layer formed on the P-type silicon substrate, and an N-type formed on each of the P-type diffusion layer and the N-type diffusion layer A floating gate having a diffusion layer and formed on the P-type silicon substrate through a thin insulating film (for example, 10 nm), a control gate formed on the floating gate through an oxide film, and a source and a drain .
[0042]
Information stored in the memory cell is substantially held in the transistor as a change in threshold voltage. Unless otherwise specified, a case where a transistor for storing information (hereinafter referred to as a storage transistor) is an N-channel type in a memory cell will be described below.
[0043]
The operation of writing information to the memory cell is realized by applying a high voltage to the control gate and drain and injecting electrons from the drain side to the floating gate by avalanche injection. By this writing operation, the threshold voltage of the memory transistor as viewed from its control gate becomes higher than that of the memory transistor in the erased state where the programming operation is not performed.
[0044]
On the other hand, the erase operation is realized by applying a high voltage to the source and extracting electrons from the floating gate to the source side by a tunnel phenomenon. The threshold voltage seen from the control gate of the memory transistor is lowered by the erase operation.
[0045]
In both the write and erase states, the threshold value of the storage transistor is set to a positive voltage level. That is, the threshold voltage in the write state is increased and the threshold voltage in the erase state is decreased with respect to the word line selection level applied from the word line to the control gate. Since both the threshold voltages and the word line selection level have such a relationship, a memory cell can be configured with a single transistor without employing a selection transistor.
[0046]
In the memory cell array using the memory cell, in the memory cells arranged in a matrix in the X and Y directions, the control gates of the storage transistors in the same row are respectively connected to the corresponding word lines, and the drains of the storage transistors arranged in the same column. Each region (input / output node of the memory cell) is connected to a corresponding data line, and the source region is coupled to the source line. By applying the high voltage corresponding to erasure to the source line, the memory cells connected to the source line, that is, the memory cells in the entire row are erased collectively. Therefore, it is possible to erase the memory cells whose sources are commonly connected via at least the source line. Therefore, the size of the memory block to be collectively erased can be arbitrarily set by changing the number of source lines connected in common and the number of memory cells connected to the same source line.
[0047]
In addition to the above firmware, the ROM 2 stores an interrupt vector corresponding to a control program for the CSI 6 corresponding to at least one communication device set at the time of firmware design, here, the clock synchronous communication method. This interrupt vector designates the address of a control program that controls the communication procedure of CSI6 when an interrupt is generated in CSI6. This control program is stored in the ROM 2 itself or an area not to be rewritten in the flash memory 1.
[0048]
In the normal operation mode, which is not the rewrite mode of the flash memory 1, the CPU 3 controls various circuits and devices that constitute an electronic device that is a host system on which the microcontroller is mounted. In the rewrite mode, the flash memory is in accordance with the firmware. 1 rewrite procedure is controlled.
[0049]
The interrupt controller 4 uses an interrupt request signal INT3 of CSI6 inputted in response to the supply of the rewrite mode signal MS of the flash memory 1 as will be described later based on an interrupt rank and an interrupt level based on certain criteria. For convenience, an interrupt level conversion circuit 41 that changes to the highest and highest priority levels and generates an interrupt execution request signal IM is provided.
[0050]
Referring to FIG. 2 showing the configuration of the interrupt level conversion circuit 41 in block form, the interrupt level conversion circuit 41 has a plurality of simultaneous generations according to the priority order of a plurality of predetermined interrupt request signals INT0 to INTN. Interrupt priority determination circuit 411 for selecting the highest priority among the interrupts and outputting the selected interrupt request signal VI, and interrupt priority determination in response to the logic level of the rewrite mode signal MS supplied from the outside A rewrite mode prioritizing circuit 412 is provided which selects and outputs either the selected interrupt request signal VI from the circuit 411 or the interrupt signal VC from the CSI 6 as the interrupt execution request signal IM.
[0051]
In the present embodiment, for convenience of explanation, the number N of interrupt request signals (positive integer), that is, the number of priority levels is set to four levels INT0 to INT3 in descending order from the top, and during normal operation, that is, flash When the memory is not rewritten, the interrupt level of the communication device CSI6 is set to INT3 which is the lowest level.
[0052]
For example, as shown in FIG. 3, the interrupt order determination circuit 411 can be realized by a combination of logic circuits such as a NAND circuit and a NOR circuit.
[0053]
Referring to FIG. 3 which is a circuit diagram showing a configuration example of an interrupt priority determination circuit 411 based on a combination of logic circuits, an inverter G411 for inverting an interrupt request signal INT0B (B represents low active or signal inversion), and this inverter A 2-input NOR circuit G412 that obtains a negative OR (hereinafter referred to as NOR logic) of the output signal of G411 and the interrupt request signal INT1B, and a 2-input that obtains a negative logical product (hereinafter referred to as NAND logic) of the interrupt request signals INT0B and INT1B. NAND circuit G413, a 2-input NOR circuit G414 for obtaining the NOR logic of the output signal of the NAND circuit G413 and the interrupt request signal INT2B, and a 3-input NAND for obtaining the NAND logic of the interrupt request signals INT0B, INT1B, INT2B Circuit G415, output signal of NAND circuit G415 and interrupt request signal INT3B A two-input NOR circuit G416 that obtains the NOR logic of the inverter, a four-input OR circuit G417 that obtains an OR logic of the outputs of the inverters G411, NOR circuits G412, G414, and G416 and outputs a selection interrupt request signal VI that is an output; Is provided.
[0054]
Also, interrupt priority information obtained by adding weighting information based on each preset interrupt priority to information of interrupt requests generated by each of the plurality of peripheral circuits 5 is stored in a table composed of a mask ROM or the like. Alternatively, the interrupt priority level of the input interrupt request signal may be determined by referring to this interrupt priority information.
[0055]
Referring to FIG. 2 again, the rewrite mode prioritizing circuit 412 includes a transfer gate M41 that cuts off the interrupt request signal INT3 in response to the logic level of the rewrite mode signal MS, and an inverter G41 that inverts the rewrite mode signal MS. And a transfer gate M42 for turning off the selected interrupt request signal VI supplied from the interrupt priority determination circuit 411 in response to the logic level of the inverted signal of the rewrite mode signal MS which is the output of the inverter G41. The output terminals of the transfer gates M41 and M42 are connected in common to output an interrupt execution request signal IM as an output. The transfer gates M41 and M42, for example, connect each drain and source to the input and output of the interrupt request signal to be transmitted, respectively, and receive supply of the rewrite mode signal MS / inversion signal of the rewrite mode signal MS to each gate. You may comprise by a MOS transistor.
[0056]
Next, the operation of the microcontroller of this embodiment will be described. Control of program rewriting of the flash memory 1 of the present embodiment is performed by the interrupt described in the related art. An interrupt is a program that forcibly suspends a running program in order to respond to an asynchronous or exceptional event that occurs during program execution. It is to automatically transfer control to the routine. At that time, the CPU state is automatically saved so that the program being executed at the time of interruption can be restarted later.
[0057]
The cause of interrupt generation is classified according to whether or not it is related to the program being executed at the time of the interrupt occurrence. If there is a relation, it is called indexing and is not related to the program being executed. It is common to call an external factor an interrupt. In the present embodiment, an interrupt caused by this definition, that is, an external factor via a communication device such as serial communication is considered.
[0058]
Regarding the priority level and priority level of interrupts, when multiple interrupt causes occur at the same time, the priority issue of which interrupt will occur first and other interrupt causes during the processing of an interrupt When this occurs, there is a problem of whether or not to cause a higher level of urgency and cause another interruption. The general method is to determine the priority and level of interrupts for each cause (group), set the normal program other than interrupt processing as the lowest level, and interrupts belonging to higher interrupt levels are lower. This is a method that allows interrupts during level processing. This method is also used in this embodiment. In the description of the operation of the present embodiment, the priority is referred to as an interrupt order, and the level is referred to as an interrupt level.
[0059]
Next, the operation of the present embodiment will be described with reference to FIGS. 1, 2, and 3. First, in the normal operation in which the flash memory 1 is not rewritten, the rewrite mode signal MS is inactivated. L level corresponding to. As a result, the CPU 3 enters the normal operation mode. At the same time, the interrupt level conversion circuit 41 of the interrupt controller 4 changes the interrupt priority from the interrupt request signal INT0 having the highest interrupt priority to the lowest INT3, that is, the interrupt request signal VC from the CSI6. In response, the highest one of a plurality of simultaneously generated interrupts is selected and a corresponding interrupt execution request signal IM is generated.
[0060]
As described above, the interrupt level determination circuit 411 of the interrupt level conversion circuit 41 selects the highest one among a plurality of interrupts simultaneously generated according to the priority levels of the plurality of interrupt request signals INT0 to INTN. Select and output a selection interrupt request signal VI.
[0061]
For convenience of explanation, it is assumed that inverted interrupt request signals INT0B to INT3B, which are inverted signals of the interrupt request signals INT0 to INT3, are supplied to all input terminals of the interrupt priority determination circuit 411 via an inverter (not shown). . These inversion interrupt request signals INT0B to INT3B are assumed to be in an active state, that is, low active when they are at the L level.
[0062]
When an L-level inverted interrupt request signal (hereinafter abbreviated as interrupt request signal) INT0B is supplied to the interrupt priority determination circuit 411, the interrupt request signal INT0B is input to the inverter G411, NAND circuits G413, and G415, respectively. . The inverter G411 supplies an H level output signal to one input terminal of the NOR circuit G412 and the first input terminal of the OR circuit G417. At this time, the NOR circuit G412 outputs an L level output signal regardless of whether or not the interrupt request signal INT1B supplied to the other input terminal is input, that is, regardless of the H level / L level. When the interrupt request signal INT0B is at the H level, the NOR circuit G412 outputs an H level output signal when the interrupt request signal INT1B is at the L level, and an L level output signal when the interrupt request signal INT1B is at the H level. To output to the OR circuit G417. That is, the interrupt request signal INT0B has a higher priority than the interrupt request signal INT1B.
[0063]
The interrupt request signal INT1B is input to the NOR circuit G412, NAND circuits G413 and G415, respectively. The interrupt request signal INT2B is input to the NOR circuit G414 and NAND circuit G415, respectively. The interrupt request signal INT3B is input only to the NOR circuit G416.
[0064]
Since the NAND circuit G413 sets the output signal to the L level only when both of the interrupt request signals INT0B and INT1B are at the H level, and the output signal is set to the H level in the other cases, the NOR circuit G414 has the interrupt request signal INT0B. , INT1B outputs an output signal corresponding to the level of the interrupt request signal INT2B only when both are in the H level, that is, in the inactive state. That is, the interrupt request signal INT2B has a lower priority than the interrupt request signals INT0B and INT1B.
[0065]
Since the NAND circuit G415 sets the output signal to the L level only when the interrupt request signals INT0B, INT1B, and INT2B are at the H level, and the output signal is set to the H level in the other cases, the NOR circuit G416 When the three request signals INT0B, INT1B, and INT2B are at the H level, that is, in the inactive state, the output signal corresponding to the level of the interrupt request signal INT3B, that is, when the interrupt request signal INT3B is at the L level. When the H level output signal and the interrupt request signal INT3B are at the H level, the L level output signal is output. That is, the interrupt request signal INT3B has a lower priority than the interrupt request signals INT0B, INT1B, and INT2B.
[0066]
Therefore, the interrupt priority order decreases in the order of INT0B, INT1B, INT2B, INT3B.
[0067]
For example, when the interrupt request signal INT3B and the interrupt request signal INT0B are simultaneously input to the interrupt priority determination circuit 411 (that is, set to L level), the interrupt request signal INT0B has a higher priority. The output of the inverter G411 corresponding to the interrupt request signal INT0B becomes H level, while the output of the NOR circuit G416 corresponding to the interrupt request signal INT3B remains at L level. Further, since the interrupt request signal INT2B does not have an interrupt request and remains at the H level, the output of the corresponding NOR circuit G414 becomes the L level.
[0068]
The OR circuit G417 takes the OR logic of the output signals of the inverter G411, NOR circuits G412, G413, and G416. Therefore, in this case, the selection interrupt request signal VI is output corresponding to the H level of the inverter G411. Therefore, the interrupt request signal INT0B is output as the selected interrupt request signal VI.
[0069]
In the rewrite mode prioritization circuit 412, the selection interrupt request signal VI received from the interrupt priority determination circuit 411 is input to the transfer gate M42. Further, the interrupt request signal INT3 is input to the transfer gate M41. Since the logic level of the rewrite mode signal MS is L level, the transfer gate M41 receiving the supply of the rewrite mode signal MS to the control terminal (in the case of a MOS transistor) is cut off, while the rewrite mode signal is applied to the control terminal. The transfer gate M42 that receives the inverted rewrite mode signal MSB obtained by inverting the signal MS by the inverter G41 becomes conductive. Therefore, the interrupt request signal INT3 is blocked by the transfer gate M41, and the selected interrupt request signal VI that has passed through the transfer gate M42 is output as the interrupt execution request signal IM.
[0070]
The CPU 3 performs a normal operation including an interrupt operation in response to the supply of the interrupt execution request signal IM.
[0071]
Next, a description will be given of an operation when rewriting the flash memory 1 with reference to FIG. 4 showing a process in the case of automatically performing interrupt switching. When rewriting the flash memory 1, First, the rewrite mode signal MS is set from L level (non-supply state or inactive state) to H level (supply state or active state). When the rewrite mode signal MS becomes H level (step S1), the interrupt level conversion circuit 41 of the interrupt controller 4 has the lowest interrupt priority, that is, the interrupt priority of the interrupt request signal VC of CSI6 of INT3. Is changed to the highest rank (step S2).
[0072]
At the same time, the CPU 3 enters the rewrite mode, the interrupt request signal VC from the CSI 6 is handled with the highest priority, and the interrupt level conversion circuit 41 of the interrupt controller 4 enters a state for generating the interrupt execution request signal IM. .
[0073]
In the rewrite mode priority circuit 412 of the interrupt level conversion circuit 41, the selected interrupt request signal VI received from the interrupt priority determination circuit 411 is input to the transfer gate M42. Further, the interrupt request signal INT3, that is, the interrupt request signal VC from the CSI 6 is input to the transfer gate M41. Since the logic level of the rewrite mode signal MS is H level, the transfer gate M41 that receives the supply of the rewrite mode signal MS to the control terminal becomes conductive, while the transfer gate M41 receives the supply of the inverted rewrite mode signal MSB to the control terminal. The gate M42 is cut off. Therefore, the selected interrupt request signal VI is blocked by the transfer gate M42, and the interrupt request signal INT3 that has passed through the transfer gate M41, that is, the interrupt request signal VC from the CSI 6 is output as the interrupt execution request signal IM.
[0074]
Next, the CPU 3 reads the rewrite operation program PR from the ROM 2 in response to the supply of the interrupt execution request signal IM generated from the interrupt request signal VC of the CSI 6 output from the interrupt controller 4, and initializes the CPU 3. After going through (Step S3), it enters a state of waiting for interrupt data supplied from the external host computer 8 via the CSI 6, that is, rewrite data DW of the flash memory 1, that is, an interrupt wait state (Step S4).
[0075]
Further, the CPU 3 notifies the host computer 8 via the CSI 6 of this interrupt waiting state, that is, that reception preparation is completed (acknowledgement). The host computer 8 transmits the rewrite data DW in response to the acknowledgment of the reception preparation completion notification. Next, the CSI 6 receives rewrite data DW of the flash memory 1 which is interrupt data from the host computer 8 (step S5).
[0076]
Since the CSI 6 is a clock synchronous serial interface, data and this communication clock are transmitted in synchronization with the communication clock signal generated on the transmission side, here, the host computer 8, and received on the reception side, ie, the CSI 6. Data is received in synchronization with the communication clock. Accordingly, initialization such as bit rate adjustment as in the asynchronous mode is unnecessary, and data transfer processing can be performed immediately after the completion of the reception preparation.
[0077]
The CPU 3 recognizes the reception of the rewrite data DW at the CSI 6 via the interrupt controller 4, reads the rewrite data DW from the CSI 6, and performs the rewrite processing of the flash memory 1 based on this rewrite data (step S6).
[0078]
The process of receiving the rewrite data DW and rewriting the flash memory 1 is repeated until all the rewrite data DW is received (step S7).
[0079]
The process ends when all the flash memory 1 has been rewritten.
[0080]
Next, referring to FIG. 5 showing a flowchart of the erasing process that is the first process of the rewriting process of the flash memory 1, the erasing process of the flash memory 1 will be described. A block (area) to be designated is designated (step S11). Further, the CPU 3 sets the flash memory 1 to the erase mode (step S12).
[0081]
Subsequently, the CPU 3 waits for a predetermined number of cycles with the software timer during the erasure time T (step S13), and releases the erase mode of the flash memory 1 after the lapse of T time (step S14).
[0082]
Further, the flash memory 1 is set to the erase verify mode (step S15), and the block to be erased is read (step S16).
[0083]
When all addresses are read and erased to the state of “1” (step S17), the CPU 3 cancels the erase verify mode (step S18), and further cancels the designation of the erase block (step S19). Erasing is complete.
[0084]
On the other hand, if all addresses have not been read in step S17, the address is incremented (step S20), and then the processing from reading the block in step S16 is repeated.
[0085]
In this case, the erasing time T is a time for changing the memory cell from the written state (high threshold region VthH) to the erased state (low threshold region VthL).
[0086]
This erase time T varies depending on the process technology of the memory cell. For example, the high threshold region VthH is 4.5 V or more, the low threshold region VthL is 2.5 V or less, and it takes 10 ms to change from the high threshold region VthH to the low threshold region VthL.
[0087]
After completion of the erase process, the CPU 3 transfers the rewrite data DW from the CSI 6 to the flash memory 1, and the flash memory 1 receives the transfer of the rewrite data DW and performs a write process to the area after the erase is completed.
[0088]
In the present embodiment, a clock synchronous serial interface (CSI) is used as a communication device. However, the communication device is not limited to this CSI, and the asynchronous communication (UART: Universal Asynchronous Receiver / Transmitter) as described in the related art. I and 2-wire bidirectional serial communication system 2 A serial communication system such as C (Inter-IC) or a parallel communication system by transmission of general parallel data may be used. Further, two or more of these communication methods may be supported, and one of them may be selectively used depending on the communication partner.
[0089]
Further, although the case where the number of interrupt request signals of the interrupt controller of the present embodiment is four has been described, it is obvious that the number of interrupt request signals can be arbitrarily set without being limited to this.
[0090]
Next, the interrupt level conversion circuit 41A, which characterizes the second embodiment of the present invention, is referred to FIG. Then, the difference of the interrupt level conversion circuit 41A of the present embodiment shown in this figure from the first embodiment described above is that each of the interrupt rank determination circuit 411 and the rewrite mode prioritization circuit 412 is replaced with each other. In response to the logic level (H level) at the time of activation of the rewrite mode signal MS, the interrupt order determination circuit 411A forcibly changes the interrupt order to a lower order, and the rewrite mode signal MS is inverted and inverted rewrite Write that generates the mode signal MSB and sets the order of the interrupt request signal INT3 corresponding to the interrupt signal VC from the CSI 6 in response to the logic level of the inverted rewrite mode signal MSB It is to comprise each example mode priority circuit 412A.
[0091]
The difference between the interrupt priority determination circuit 411A and the interrupt priority determination circuit 411 is that a two-input NAND circuit G11A for obtaining the NAND logic of the interrupt request signal INT0B and the rewrite mode signal MS is replaced by a NAND circuit instead of the inverter G411. Instead of G413, a 3-input NAND circuit G413A for obtaining NAND logic with the rewrite mode signal MS in addition to the interrupt request signals INT0B and INT1B is added to the rewrite mode signal MS with the interrupt request signals INT0B, INT1B and INT2B. The 4-input NAND circuit G415A for obtaining the NAND logic obtains the OR logic of the outputs of the NOR circuits G412, G414, G416 and the NOR circuit G419, which will be described later, and outputs an interrupt execution request signal IM as an output. Each circuit G417A is provided.
[0092]
The rewrite mode prioritizing circuit 412A is an inverter G418 that inverts the rewrite mode signal MS to generate an inverted rewrite mode signal MSB, and a 2-input NOR circuit that obtains the NOR logic of the interrupt request signal INT3B and the inverted rewrite mode signal MSB. G419.
[0093]
Similarly to the first embodiment, all the input terminals of the interrupt order determination circuit 411A according to the present embodiment are connected to an inverted interrupt that is an inverted signal of the interrupt request signals INT0 to INT3 via an inverter (not shown). Assume that the request signals INT0B to INT3B are supplied. It is assumed that the inversion interrupt request signals INT0B to INT3B are in an active state, that is, low active when they are at the L level.
[0094]
The operation of the present embodiment will be described. First, in the normal operation mode in which the rewrite mode signal MS is at the L level corresponding to the inactivation of the rewrite mode signal MS, the rewrite mode prioritizing circuit 412A has the inverted rewrite mode signal whose logic level is the H level. Output MSB. Therefore, the NOR circuit G419 outputs an L level regardless of the logic level of the interrupt request signal INT3B.
[0095]
On the other hand, the NAND circuit G411A, G413A, G415A of the interrupt order determination circuit 411A receives the L-level rewrite mode signal MS, so that the interrupt order determination circuit 411A determines the interrupt order determination according to the first embodiment. The same operation as that of the circuit 411 is performed. Accordingly, the interrupt request signals INT0B, INT1B, INT2B, and INT3B are selected from the higher order in order of priority, and the interrupt execution request signal IM is output from the OR circuit G417A.
[0096]
That is, the NAND circuit G411A outputs an H level when the logic level of the interrupt request signal INT0B is L, which is the same operation as the inverter G411 in the first embodiment. Similarly, NAND circuits G413A and G415A perform the same operation as NAND circuits G413 and G415, respectively.
[0097]
Next, when the rewrite mode signal MS is activated and becomes H level corresponding to the rewrite mode of the flash memory, the rewrite mode prioritizing circuit 412A outputs the inverted rewrite mode signal MSB whose logic level is L level. Therefore, the NOR circuit G419 changes its output logic level according to the logic level of the interrupt request signal INT3B, and outputs an output signal whose logic level is H level when the logic level of the interrupt request signal INT3B is L level.
[0098]
On the other hand, since the NAND circuit G411A, G413A, G415A of the interrupt order determination circuit 411A receives the H-level rewrite mode signal MS, the output logic levels of these NAND circuits G411A, G413A, G415A are the interrupt request signals INT0B, The L level is output regardless of the logic levels of INT1B, INT2B, and INT3B. As a result, the output logic levels of the NOR circuits G412, G414, and G416 become L level regardless of the logic levels of the interrupt request signals INT0B, INT1B, INT2B, and INT3B. Therefore, the OR circuit G417A outputs the corresponding interrupt execution request signal IM when the logic level of the interrupt request signal INT3B is L level, that is, when there is an interrupt request.
[0099]
【The invention's effect】
As described above, the microcontroller of the present invention and the method for rewriting the program include the firmware for rewriting the flash memory and the ROM storing the control program for the operation of the communication means or at least the interrupt vector for setting the control program. Controls the priority order of interrupt request signals sent from a plurality of built-in peripheral circuits in the normal operation mode, notifies the CPU, and rewrite mode linked to the rewrite mode setting in the flash memory rewrite mode An interrupt controller for changing the interrupt request signal from the communication means input in response to the signal supply to a predetermined interrupt order and notifying the CPU is provided. Set the interrupt priority to the above-mentioned predetermined interrupt priority, for example, the highest priority Since the communication means is controlled dynamically by the control program corresponding to the interrupt vector, the design TAT can be shortened by eliminating the need for a dedicated firmware design regardless of the type of microcontroller. effective.
[0100]
In addition, since there is no need to change the firmware for each type of microcontroller, it is possible to apply a standardized design from which bugs and the like have been sufficiently removed, thereby eliminating the design quality degradation factor.
[Brief description of the drawings]
FIG. 1 is a block diagram showing a first embodiment of a microcontroller of the present invention.
2 is a block diagram showing an example of a configuration of an interrupt level conversion circuit in FIG. 1; FIG.
FIG. 3 is a circuit diagram showing an example of a configuration of an interrupt order determination circuit in FIG. 2;
FIG. 4 is a flowchart showing an example of the operation in the microcontroller of the present embodiment and the program rewriting method thereof.
FIG. 5 is a flowchart showing an example of an erasing operation in the program rewriting method of the present embodiment.
FIG. 6 is a circuit diagram showing an example of a configuration of an interrupt level conversion circuit that characterizes the second embodiment of the microcontroller of the present invention;
FIG. 7 is a block diagram showing an example of a conventional microcontroller and a method for rewriting the program.
FIG. 8 is a flowchart showing an example of operation in a conventional microcontroller and its program rewriting method.
[Explanation of symbols]
1 Flash memory
2 ROM
3 CPU
4 Interrupt controller
5 Peripheral circuits
6 CSI
7 Decoder
8 Host computer
9 RAM
30 timer
60 SCI
41, 41A Interrupt level conversion circuit
411,411A Interrupt ranking determination circuit
412A 412A Rewrite mode priority circuit
G41, G411, G418 inverter
G412, G414, G416, G419 NOR circuit
G413, G415, G411A, G413A, G415A NAND circuit
G417, G417A OR circuit
M41, M42 Transfer gate

Claims (9)

プログラムの格納用に電気的に一括消去および書き換え可能な不揮発性メモリであるフラッシュメモリを内蔵し、このフラッシュメモリのプログラム修正を行う書き換え動作モードを割込により設定されるマイクロコントローラにおいて、
前記フラッシュメモリを書き換えるための一連の動作のプログラムであるファームウェアと後述の通信手段の動作の制御プログラムを設定する割込ベクタを格納したROMと、
前記ROMから読み出したファームウェアに従い前記フラッシュメモリの書き換え手順を制御する中央演算処理装置であるCPUと、
外部のホストコンピュータからの前記フラッシュメモリの書き換えデータの受信、及び前記ホストコンピュータへの受信準備完了通知を含む送信を行う通信手段と、
入力/出力(I/O)回路およびタイマを含む複数の周辺回路と、
前記フラッシュメモリの書き換えを行わない通常モードのとき、前記複数の周辺回路から送られてくる割込要求信号を予め定めた優先順位に従って前記CPUに通知するとともに、前記フラッシュメモリの書き換えを行う場合である書き換えモードのとき、この書き換えモード設定に連動した書き換えモード信号の供給に応答して、前記通信手段の割込要求信号を前記優先順位よって定められた前記通信手段の割込順位よりも上位に変更して前記CPUに通知する割込みコントローラと、を備えることを特徴とするマイクロコントローラ。
In a microcontroller that has a built-in flash memory that is an electrically erasable and rewritable nonvolatile memory for program storage, and a rewrite operation mode for modifying the program of the flash memory is set by an interrupt.
A ROM that stores firmware that is a program of a series of operations for rewriting the flash memory and an interrupt vector that sets a control program for the operation of the communication means described below,
A CPU that is a central processing unit that controls the rewrite procedure of the flash memory in accordance with the firmware read from the ROM;
Communication means for performing transmission including reception of rewrite data of the flash memory from an external host computer and reception preparation completion notification to the host computer;
A plurality of peripheral circuits including input / output (I / O) circuits and timers;
In the normal mode in which the flash memory is not rewritten, an interrupt request signal sent from the plurality of peripheral circuits is notified to the CPU according to a predetermined priority order, and the flash memory is rewritten. In a certain rewrite mode, in response to the supply of the rewrite mode signal linked to the rewrite mode setting, the communication means interrupt request signal is higher than the communication means interrupt order determined by the priority order. A microcontroller comprising: an interrupt controller that changes and notifies the CPU .
前記割込コントローラが、前記書き換えモード信号の供給に応答して入力された前記通信手段からの割込要求信号である通信割込要求信号を予め定めた基準に基づく割込順位に変更し前記CPUに割込実行を要求する割込実行要求信号を発生する割込レベル変換回路を備えることを特徴とする請求項1記載のマイクロコントローラ。  The CPU changes the communication interrupt request signal, which is an interrupt request signal from the communication means input in response to the supply of the rewrite mode signal, to an interrupt order based on a predetermined criterion. 2. The microcontroller according to claim 1, further comprising an interrupt level conversion circuit for generating an interrupt execution request signal for requesting interrupt execution. 前記割込レベル変換回路が、予め定めたN(Nは正の整数)個の割込要求信号の優先順位に応じて同時発生した複数の割込のうちの最高優先順位のものを選択し選択割込要求信号を出力する割込順位決定回路と、
前記書き換えモード信号の論理レベルに応答して前記割込順位決定回路から出力される前記選択割込要求信号と前記通信手段からの前記通信割込要求信号とのいずれか一方を前記割込実行要求信号として選択し出力する書き換えモード優先化回路と、
を備えることを特徴とする請求項2記載のマイクロコントローラ。
The interrupt level conversion circuit selects and selects the highest priority among a plurality of interrupts simultaneously generated according to the priority of predetermined N (N is a positive integer) interrupt request signals. An interrupt order determination circuit for outputting an interrupt request signal;
One of the selected interrupt request signal output from the interrupt priority determination circuit and the communication interrupt request signal from the communication means in response to the logic level of the rewrite mode signal is the interrupt execution request. A rewrite mode prioritizing circuit which selects and outputs as a signal;
The microcontroller according to claim 2, further comprising:
前記Nが4であり、前記割込順位決定回路が、フラッシュメモリの書き換えを行わない通常動作モードのとき前記4個の割込要求信号のうちの最高優先順位の割込要求信号の反転信号である第1の反転割込要求信号を反転するインバータと、
前記インバータの出力信号と前記4個の割込要求信号のうちの第2の優先順位の割込要求信号の反転信号である第2の反転割込要求信号との否定論理和をとる第1のNOR回路と、
前記第1の反転割込要求信号と前記第2の反転割込要求信号との否定論理積をとる第1のNAND回路と、
前記第1のNAND回路の出力と前記4個の割込要求信号のうちの第3の優先順位の割込要求信号の反転信号である第3の反転割込要求信号との否定論理和をとる第2のNOR回路と、
前記第1の反転割込要求信号と前記第2の反転割込要求信号と前記4個の割込要求信号のうちの第3の優先順位の割込要求信号の反転信号である第3の反転割込要求信号との否定論理積をとる第2のNAND回路と、
前記第2のNAND回路の出力と前記4個の割込要求信号のうちの第4の優先順位の割込要求信号の反転信号である第4の反転割込要求信号との否定論理和をとる第3のNOR回路と、
前記インバータの出力と前記第1〜第3のNOR回路の各々の出力との論理和をとり前記選択割込要求信号を発生するOR回路と、
を備えることを特徴とする請求項3記載のマイクロコントローラ。
When N is 4 and the interrupt order determination circuit is in a normal operation mode in which the flash memory is not rewritten, an inverted signal of the highest priority interrupt request signal among the four interrupt request signals. An inverter that inverts a first inversion interrupt request signal;
A first logical OR of the output signal of the inverter and a second inverted interrupt request signal that is an inverted signal of the interrupt request signal of the second priority order among the four interrupt request signals. A NOR circuit;
A first NAND circuit that takes a negative logical product of the first inverted interrupt request signal and the second inverted interrupt request signal;
An OR operation is performed between the output of the first NAND circuit and a third inverted interrupt request signal that is an inverted signal of the interrupt request signal of the third priority among the four interrupt request signals. A second NOR circuit;
A third inversion which is an inverted signal of the interrupt request signal of the third priority among the first inverted interrupt request signal, the second inverted interrupt request signal, and the four interrupt request signals. A second NAND circuit that performs a NAND operation with the interrupt request signal;
An OR operation is performed between the output of the second NAND circuit and a fourth inverted interrupt request signal which is an inverted signal of the interrupt request signal having the fourth priority order among the four interrupt request signals. A third NOR circuit;
An OR circuit that generates the selection interrupt request signal by performing a logical sum of the output of the inverter and the outputs of the first to third NOR circuits;
The microcontroller according to claim 3, further comprising:
前記書き換えモード優先化回路が、前記書き換えモード信の論理レベルに応答して前記通信割込要求信号を導通遮断する第1のトランスファゲートと、
前記書き換えモード信号を反転し反転書き換えモード信号を出力するインバータと、
出力端が前記第1のトランスファゲートの出力端と共通接続され、前記インバータの出力である前記反転書き換えモード信号の論理レベルに応答して前記割込順位決定回路から供給を受けた前記選択割込要求信号を導通遮断する第2のトランスファゲートとを備え、前記出力端から前記割込実行要求信号を出力することを特徴とする請求項3記載のマイクロコントローラ。
A first transfer gate that interrupts the communication interrupt request signal in response to a logic level of the rewrite mode signal;
An inverter that inverts the rewrite mode signal and outputs an inverted rewrite mode signal;
The selected interrupt whose output terminal is connected in common with the output terminal of the first transfer gate and is supplied from the interrupt priority determining circuit in response to the logic level of the inverted rewrite mode signal which is the output of the inverter 4. The microcontroller according to claim 3, further comprising: a second transfer gate that cuts off the request signal, and outputting the interrupt execution request signal from the output terminal.
前記割込レベル変換回路が、前記書き換えモード信号の不活性化時の論理レベルに応答して予め定めたN(Nは正の整数)個の割込要求信号の優先順位に応じて同時発生した複数の割込のうちの最高優先順位のものを選択して前記割込実行要求信号を出力し、前記書き換えモード信号の活性化時の論理レベルに応答して前記最高優先順位の割込要求信号の割込順位を強制的に下位順位に変更する割込順位決定回路と、
前記書き換えモード信号を反転して反転書き換えモード信号を生成するとともに前記書き換えモード信号の活性化時の前記反転書き換えモード信号の論理レベルに応答して前記通信手段からの割込要求信号である通信割込信号の順位を最高順位に設定する書き換えモード優先化回路と、
を備えることを特徴とする請求項2記載のマイクロコントローラ。
The interrupt level conversion circuit is simultaneously generated according to the priority order of N interrupt request signals determined in advance (N is a positive integer) in response to the logic level when the rewrite mode signal is inactivated. Select the highest priority among a plurality of interrupts, output the interrupt execution request signal, and respond to the logic level when the rewrite mode signal is activated, the interrupt request signal with the highest priority An interrupt priority determination circuit for forcibly changing the interrupt priority to a lower priority;
Inverting the rewrite mode signal to generate an inverted rewrite mode signal, and in response to a logic level of the inverted rewrite mode signal when the rewrite mode signal is activated, a communication interrupt which is an interrupt request signal from the communication means Rewrite mode prioritizing circuit that sets the order of the embedded signal to the highest order,
The microcontroller according to claim 2, further comprising:
前記Nが4であり、前記割込順位決定回路が、フラッシュメモリの書き換えを行わない通常動作モードのとき前記4個の割込要求信号のうちの最高優先順位の割込要求信号の反転信号である第1の反転割込要求信号と前記書き換えモード信号との否定論理積をとる第1のNAND回路と、
前記第1のNAND回路の出力信号と前記4個の割込要求信号のうちの第2の優先順位の割込要求信号の反転信号である第2の反転割込要求信号との否定論理和をとる第1のNOR回路と、
前記第1の反転割込要求信号と前記第2の反転割込要求信号と前記書き換えモード信号との否定論理積をとる第2のNAND回路と、
前記第2のNAND回路の出力と前記4個の割込要求信号のうちの第3の優先順位の割込要求信号の反転信号である第3の反転割込要求信号との否定論理和をとる第2のNOR回路と、
前記第1の反転割込要求信号と前記第2の反転割込要求信号と前記4個の割込要求信号のうちの第3の優先順位の割込要求信号の反転信号である第3の反転割込要求信号と前記書き換えモード信号との否定論理積をとる第3のNAND回路と、
前記第3のNAND回路の出力と前記4個の割込要求信号のうちの第4の優先順位の割込要求信号の反転信号である第4の反転割込要求信号との否定論理和をとる第3のNOR回路と、
前記第1のNAND回路の出力と前記第1〜第3のNOR回路の各々の出力と前記書き換えモード優先化回路の出力との論理和をとり前記選択割込要求信号を発生するOR回路と、を備え、
前記書き換えモード優先化回路が、前記書き換えモード信号を反転して反転書き換えモード信号を出力するインバータと、
前記反転書き換えモード信号と前記通信割込要求信号との否定論理和をとる第4のNOR回路と、
を備えることを特徴とする請求項6記載のマイクロコントローラ。
When N is 4 and the interrupt order determination circuit is in a normal operation mode in which the flash memory is not rewritten, an inverted signal of the highest priority interrupt request signal among the four interrupt request signals. A first NAND circuit that performs a NAND operation between a first inversion interrupt request signal and the rewrite mode signal;
A negative logical sum of the output signal of the first NAND circuit and a second inverted interrupt request signal that is an inverted signal of the interrupt request signal of the second priority among the four interrupt request signals. A first NOR circuit to take;
A second NAND circuit that performs a negative logical product of the first inverted interrupt request signal, the second inverted interrupt request signal, and the rewrite mode signal;
An OR operation is performed between the output of the second NAND circuit and a third inverted interrupt request signal that is an inverted signal of the interrupt request signal of the third priority among the four interrupt request signals. A second NOR circuit;
A third inversion which is an inverted signal of the interrupt request signal of the third priority among the first inverted interrupt request signal, the second inverted interrupt request signal, and the four interrupt request signals. A third NAND circuit that takes a negative logical product of an interrupt request signal and the rewrite mode signal;
An OR operation is performed between the output of the third NAND circuit and a fourth inverted interrupt request signal which is an inverted signal of the fourth priority interrupt request signal among the four interrupt request signals. A third NOR circuit;
An OR circuit that generates the selection interrupt request signal by ORing the outputs of the first NAND circuit, the outputs of the first to third NOR circuits, and the output of the rewrite mode priority circuit; With
The rewrite mode prioritizing circuit inverts the rewrite mode signal and outputs an inverted rewrite mode signal; and
A fourth NOR circuit that performs a negative OR of the inverted rewrite mode signal and the communication interrupt request signal;
The microcontroller according to claim 6, further comprising:
前記通信手段が、シリアルコミュニケーションの一種であるクロック同期式通信方式に対応するクロック同期シリアルインタフェースを備えることを特徴とする請求項1記載のマイクロコントローラ。  2. The microcontroller according to claim 1, wherein the communication unit includes a clock synchronous serial interface corresponding to a clock synchronous communication system which is a kind of serial communication. プログラムの格納用に電気的に一括消去および書き換え可能な不揮発性メモリであるフラッシュメモリを内蔵し、このフラッシュメモリのプログラム修正を行う書き換え動作モードを割込により設定されるマイクロコントローラのフラッシュメモリの書き換え方法において、
前記フラッシュメモリの書き換えを行う書き換えモードのときこの書き換えモード設定に連動した書き換えモード信号の論理レベルをLレベルからHレベルに設定する第1のステップと、
前記書き換えモード信号のHレベルへの遷移に応答して、外部のホストコンピュータからの前記フラッシュメモリの書き換えデータの受信、及び前記ホストコンピュータへの受信準備完了通知を含む送信を行う通信手段の割込要求信号の優先順位を予め定められた順位から最上位の順位に変更する第2のステップと、
前記通信手段の割込要求信号から生成した割込み実行要求信号の供給に応答して書き換え動作プログラムを読み出し、CPUの初期化を行う第3のステップと、
前記通信手段を経由して前記ホストコンピュータから供給される前記フラッシュメモリの書き換えデータの受信を行うための割込を待つ第4のステップと、
前記通信手段が前記ホストコンピュータが送信した割込データである前記書き換えデータを受信する第5のステップと、
前記CPUが、前記通信手段における前記書き換えデータの受信を認識し、この書き換えデータを下に前記フラッシュメモリの書き換え処理を行う第6のステップと、
すべての前記書き換えデータを受信するまで前記書き換えデータの受信及び前記フラッシュメモリへの書き換え処理を繰り返す第7のステップと、
を含むことを特徴とするマイクロコントローラのフラッシュメモリの書き換え方法。
Built-in flash memory, which is an electrically erasable and rewritable non-volatile memory for storing programs, and rewriting the flash memory of a microcontroller that is set by an interrupt to rewrite the flash memory program. In the method
A first step of setting a logic level of a rewrite mode signal linked to the rewrite mode setting from L level to H level in a rewrite mode for rewriting the flash memory;
In response to the transition of the rewrite mode signal to the H level, an interrupt of communication means for performing transmission including reception of rewrite data of the flash memory from an external host computer and reception preparation completion notification to the host computer A second step of changing the priority of the request signal from a predetermined rank to the highest rank;
A third step of reading the rewrite operation program in response to the supply of the interrupt execution request signal generated from the interrupt request signal of the communication means and initializing the CPU;
A fourth step of waiting for an interrupt for receiving rewrite data of the flash memory supplied from the host computer via the communication means;
A fifth step in which the communication means receives the rewrite data which is interrupt data transmitted by the host computer;
A sixth step in which the CPU recognizes reception of the rewrite data in the communication means and performs rewrite processing of the flash memory under the rewrite data;
A seventh step of repeating the reception of the rewrite data and the rewrite process to the flash memory until receiving all the rewrite data;
A method of rewriting a flash memory of a microcontroller, comprising:
JP21419799A 1999-07-28 1999-07-28 Microcontroller and rewriting method thereof Expired - Fee Related JP4127934B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP21419799A JP4127934B2 (en) 1999-07-28 1999-07-28 Microcontroller and rewriting method thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP21419799A JP4127934B2 (en) 1999-07-28 1999-07-28 Microcontroller and rewriting method thereof

Publications (2)

Publication Number Publication Date
JP2001043206A JP2001043206A (en) 2001-02-16
JP4127934B2 true JP4127934B2 (en) 2008-07-30

Family

ID=16651847

Family Applications (1)

Application Number Title Priority Date Filing Date
JP21419799A Expired - Fee Related JP4127934B2 (en) 1999-07-28 1999-07-28 Microcontroller and rewriting method thereof

Country Status (1)

Country Link
JP (1) JP4127934B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4828816B2 (en) 2004-10-25 2011-11-30 株式会社東芝 Memory card, semiconductor device, and memory card control method
JP5720206B2 (en) * 2010-11-29 2015-05-20 ミツミ電機株式会社 Microprocessor

Also Published As

Publication number Publication date
JP2001043206A (en) 2001-02-16

Similar Documents

Publication Publication Date Title
US8037358B2 (en) Semiconductor device and boot method for the same
US7440337B2 (en) Nonvolatile semiconductor memory apparatus having buffer memory for storing a program and buffering work data
US9208022B2 (en) Techniques for adaptive moving read references for memory cell read error recovery
KR20020021001A (en) Data processing system and data processing method
JP2006134482A (en) Nonvolatile memory system
KR20140028543A (en) Semiconductor memory device and operating method thereof
US20160232982A1 (en) Semiconductor device control circuit and method thereof
JP2011100518A (en) Semiconductor device and method for controlling the same
KR20090021508A (en) Flash memory device storing data with multi-bit and single-bit form and program method thereof
US6259630B1 (en) Nonvolatile semiconductor memory device equipped with verification circuit for identifying the address of a defective cell
JP2000030475A (en) Semiconductor memory device
US20040240253A1 (en) Flash memory sector tagging for consecutive sector erase or bank erase
JP4127934B2 (en) Microcontroller and rewriting method thereof
US6532529B1 (en) Microcomputer including flash memory overwritable during operation and operating method thereof
US20020141263A1 (en) Semiconductor memory
US5381556A (en) Semiconductor device having externally programmable memory
US20030135702A1 (en) Microcomputer for accessing a replacing block area preset in a nonvolatile memory in place of a replaced block area accessed in the nonvolatile memory
JP5017443B2 (en) Memory system
US9996458B1 (en) Memory sector retirement in a non-volatile memory
US7191323B2 (en) Information processing unit selecting one of reset vector addresses
JP5059524B2 (en) MEMORY CONTROL CIRCUIT, SEMICONDUCTOR INTEGRATED CIRCUIT, AND NONVOLATILE MEMORY VERIFY METHOD
US8477557B2 (en) Input circuit of semiconductor memory apparatus and controlling method thereof
US5307313A (en) Flag circuit for memory
JPH07182899A (en) Semiconductor storage
US7945744B2 (en) Interface circuit

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20040423

A711 Notification of change in applicant

Free format text: JAPANESE INTERMEDIATE CODE: A711

Effective date: 20060303

RD01 Notification of change of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7421

Effective date: 20070703

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20070809

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20070814

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20071012

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

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

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

Free format text: PAYMENT UNTIL: 20110523

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

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

Free format text: PAYMENT UNTIL: 20110523

Year of fee payment: 3

S533 Written request for registration of change of name

Free format text: JAPANESE INTERMEDIATE CODE: R313533

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

Free format text: PAYMENT UNTIL: 20110523

Year of fee payment: 3

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

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

Free format text: PAYMENT UNTIL: 20120523

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20120523

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20130523

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20140523

Year of fee payment: 6

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

LAPS Cancellation because of no payment of annual fees