JP6040895B2 - Microcomputer and non-volatile memory block management method - Google Patents
Microcomputer and non-volatile memory block management method Download PDFInfo
- Publication number
- JP6040895B2 JP6040895B2 JP2013181245A JP2013181245A JP6040895B2 JP 6040895 B2 JP6040895 B2 JP 6040895B2 JP 2013181245 A JP2013181245 A JP 2013181245A JP 2013181245 A JP2013181245 A JP 2013181245A JP 6040895 B2 JP6040895 B2 JP 6040895B2
- Authority
- JP
- Japan
- Prior art keywords
- flag
- block
- memory
- writing
- erasing
- 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
Links
Images
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Power Sources (AREA)
- Techniques For Improving Reliability Of Storages (AREA)
Description
本発明は、データを一括して消去可能な単位である所定サイズのブロックを複数有してなる不揮発性メモリを内蔵するマイクロコンピュータ,及び前記不揮発性メモリのブロック管理方法に関する。 The present invention relates to a microcomputer incorporating a nonvolatile memory having a plurality of blocks of a predetermined size, which is a unit capable of erasing data collectively, and a block management method for the nonvolatile memory.
近年、不揮発性半導体メモリの一種であるフラッシュメモリを内蔵したマイクロコンピュータが使用されており、このフラッシュメモリは、例えば、マイクロコンピュータのCPU(Central Processing Unit)が使用するユーザプログラムを格納する用途や、種々のデータを書き込んで格納しておく用途に用いられる。ここで、フラッシュメモリは、1ワード毎の書込みが可能であるが、消去は複数ワードからなるブロックを単位として一括で消去することが必要となる。 In recent years, a microcomputer incorporating a flash memory which is a kind of nonvolatile semiconductor memory has been used. For example, the flash memory can be used for storing a user program used by a CPU (Central Processing Unit) of the microcomputer, Used for writing and storing various data. Here, the flash memory can be written for each word, but erasing needs to be performed in batches in units of blocks of a plurality of words.
ブロック消去回数が増えるとフラッシュメモリの寿命を縮めることになるため、フラッシュメモリに記憶されているデータが更新される場合に、極力消去を行わないようにする
技術が提案されている。例えば、特許文献1には、データをID単位で管理し、更新されたデータのみを追記することで消去回数を低減する技術が開示されている。
When the number of block erase increases, the life of the flash memory is shortened. Therefore, a technique has been proposed in which erasure is not performed as much as possible when data stored in the flash memory is updated. For example,
ここで、フラッシュメモリへのデータの書込み中に、例えば電源の瞬断等によるリセットが発生すると、書込みデータが不正な値となったり、リテンションが長く維持できなくなるといった問題が発生する。例えば大容量のコンデンサを配置することで、瞬断が発生しても書込み可能な電圧を維持する対策も考えられる。しかし、製品のコスト及びサイズの増大というデメリットがあり、実際には採用しがたい。 Here, if a reset occurs due to, for example, a momentary power interruption during the writing of data to the flash memory, there arises a problem that the written data becomes an incorrect value or the retention cannot be maintained for a long time. For example, by arranging a large-capacity capacitor, a measure for maintaining a writable voltage even if an instantaneous interruption occurs can be considered. However, there is a demerit of increasing the cost and size of the product, and it is difficult to adopt it in practice.
一部のフラッシュメモリには、ブランクチェック機能やベリファイ機能を備えているものがあり、それらの機能を利用すれば上記問題に対処できるが、当該機能を備えていないフラッシュメモリには別の対策が必要となる。例えば、図11に示すように、各データの書込みの開始を行う前に所定値を書き込むチェック領域と、ID及びデータを書き込んだ後に所定値を書き込むチェック領域とを設ける。そして、これらのチェック領域にそれぞれ所定値が書き込まれているか否かを確認することで、書込みが適正に行われているかを判定することが考えられる。 Some flash memories have a blank check function and a verify function. If these functions are used, the above problem can be dealt with. However, flash memory that does not have the function has another countermeasure. Necessary. For example, as shown in FIG. 11, a check area in which a predetermined value is written before starting writing of each data and a check area in which a predetermined value is written after writing ID and data are provided. It can be considered to determine whether or not the writing is properly performed by checking whether or not a predetermined value is written in each of these check areas.
また、特許文献2には、フラッシュメモリへのプログラムの書込み中に電源の瞬断が発生すると、EEPROMなどの補助メモリに、フラグや書込み中断した位置,プログラムの種類などを記憶し、電源復旧後に再起動すると、上記EEPROMの情報を読み出して中断した位置から書込みを再開する技術が開示されている。
Further, in
しかしながら、図11に示す方式では、1つのID及びデータ(データレコード)について2つのチェック領域が必要となり、それらにより記憶領域が侵食されるため、フラッシュメモリの使用効率が低下する。また、特許文献2の技術では、書込み対象がプログラムであるため、それに対応した多くの情報をEEPROMに記憶させる必要がある。書込み対象が複数種類のデータである場合には直ちに適用できず、必要かつ効率的な情報を記憶させることができない。
However, in the method shown in FIG. 11, two check areas are required for one ID and data (data record), and the storage area is eroded by them, so that the use efficiency of the flash memory is lowered. Further, in the technique of
本発明は上記事情に鑑みてなされたものであり、その目的は、不揮発性メモリに複数のデータを更新しつつ記憶させる際に、書込みが失敗したデータを効率的に管理できるマイクロコンピュータ,及び不揮発性メモリのブロック管理方法を提供する。 The present invention has been made in view of the above circumstances, and an object of the present invention is to provide a microcomputer capable of efficiently managing data that has failed to be written when a plurality of data is stored in a nonvolatile memory while being updated, and a nonvolatile memory. A block management method for a random memory is provided.
請求項1記載のマイクロコンピュータによれば、低電圧検出回路は、電源電圧が不揮発性メモリへの書込みが不能となるレベルに低下したことを検出すると、低電圧検出信号を出力する。また、低電圧検出信号により書込み中フラグがセットされる、不揮発性の書込み中フラグメモリを備える。このフラッシュメモリは、1ビットの記憶素子であれば良い。 According to the microcomputer of the first aspect, the low voltage detection circuit outputs a low voltage detection signal when detecting that the power supply voltage has dropped to a level at which writing to the nonvolatile memory becomes impossible. In addition, a non-writing flag memory in which a writing flag is set by a low voltage detection signal is provided. The flash memory may be a 1-bit storage element.
そして、書込み処理手段は、書込み対象ブロックに書込みを行う際に、制御ロジックにより前記フラグをセット可能な状態としてから、当該ブロックにID及びデータの書込みを行う。その後、制御ロジックにより前記フラグをセット不能な状態とする。また、書込みチェック手段は、リセットが解除されると、書込み中フラグメモリを読み出し、書込み中フラグがセットされていると、最後に書込みが行われていたID及びデータを無効化し、その後に書込み中フラグメモリを消去する(フラグのリセット)。 Then, when writing to the write target block, the write processing means writes the ID and data to the block after the flag is set by the control logic. Thereafter, the control logic makes the flag unsettable. When the reset is released, the writing check means reads the writing flag memory, and when the writing flag is set, invalidates the ID and data that was written last, and then writes. Erase the flag memory (flag reset).
このように構成すれば、あるブロックに書込みを行っている途中に電源電圧が低下すると書込み中フラグがセットされる。そして、書込みチェック手段は、リセットが解除された際に、書込み中フラグのセットの有無によりチェックを行うことができ、前記フラグがセットされていれば、最後に書込みが行われていたID及びデータを無効化する。 With this configuration, the writing flag is set when the power supply voltage drops while writing to a certain block. Then, when the reset is released, the write check means can check based on whether or not the writing flag is set. If the flag is set, the ID and data that was last written is written. Disable.
ここで、「最後に書込みが行われていたID及びデータ」の特定は、ブロックの有効性を示すステータス領域を参照することで、最後に書込みが行われていたブロックが特定できる。そして、書込みがアドレスの昇順で行われるとすれば、当該ブロックの最大アドレスから降順で、消去状態のデータ値と異なる値のデータが記憶されているレコードをサーチすれば良い。したがって、1ビットの記憶素子である書込み中フラグメモリを用意すれば、書込みチェックを行うことができるので、不揮発性メモリの記憶領域を効率的に使用できる。 Here, the identification of “ID and data that was last written” can be identified by referring to the status area indicating the validity of the block. If writing is performed in ascending order of addresses, a record in which data having a value different from the erased data value is stored in descending order from the maximum address of the block may be searched. Therefore, if a writing flag memory that is a 1-bit storage element is prepared, a write check can be performed, so that the storage area of the nonvolatile memory can be used efficiently.
請求項4記載のマイクロコンピュータによれば、書込み中フラグメモリと、制御ロジックとを、不揮発性メモリが備える各ブロックに対応して設ける。すなわち、書込み中フラグメモリが、不揮発性メモリに対して1つだけ用意されている場合でも、請求項1について述べたようにステータス領域を参照すれば、最後に書込みが行われていたデータレコードを特定できる。しかしながら、前記ステータス領域への書込み,消去自体が、電源電圧の低下により失敗している可能性も否定できない。したがって、書込み中フラグメモリと制御ロジックとを各ブロックに対応して設ければ、書込みチェックをより確実に行うことができる。
According to the microcomputer of the fourth aspect, the writing flag memory and the control logic are provided corresponding to each block provided in the nonvolatile memory. In other words, even when only one writing flag memory is prepared for the non-volatile memory, if the status area is referred to as described in
請求項6記載のマイクロコンピュータによれば、低電圧検出信号により消去中フラグがセットされる、不揮発性の消去中フラグメモリを設ける。消去処理手段は、ブロックを消去する際に、制御ロジックにより前記フラグをセット可能な状態としてから前記ブロックを消去し、その後、制御ロジックによりフラグをセット不能な状態とする。そして、消去チェック手段は、リセットが解除されると、消去中フラグメモリを読み出し、消去中フラグがセットされていると、最後に書込みが行われていたブロックの次に書込み対象となる予定であったブロックを消去して、その後に消去中フラグメモリを消去する。 According to another aspect of the microcomputer of the present invention, there is provided a nonvolatile erasing flag memory in which an erasing flag is set by a low voltage detection signal. When erasing the block, the erasure processing unit erases the block after setting the flag in a state where the flag can be set by the control logic, and then sets the flag in a state where the flag cannot be set by the control logic. When the reset is released, the erasure check means reads the erasing flag memory, and when the erasing flag is set, the erasure check means is scheduled to be the next to be written after the last written block. The erased flag memory is erased after that block is erased.
このように構成すれば、あるブロックを消去している途中に電源電圧が低下すると消去中フラグがセットされるので、消去チェック手段は、リセットが解除された際に、消去中フラグのセットの有無によりチェックを行うことができる。そして、消去されるブロックは、最後に書込みが行われていたブロックの次に書込み対象となるものであるから、ステータス領域を参照すればそのブロックを特定でき、消去が不完全だったブロックを完全に消去できる。 With this configuration, an erasing flag is set when the power supply voltage drops while erasing a certain block, so the erasure check means checks whether the erasing flag is set when the reset is released. Can be checked. And since the block to be erased is the one to be written next to the block that was last written, the block can be identified by referring to the status area, and the block that was incompletely erased is completely Can be deleted.
請求項11記載のマイクロコンピュータによれば、最初に、消去チェック手段により消去チェックを行い、続いて、書込みチェック手段により書込みチェックを行う。このように構成すれば、先に消去チェックを行うことで、電源電圧の低下により消去が失敗したブロックを、有効なブロックと誤判定する可能性を極力低下させる。その後、有効と判断したブロックに対して、最後に書込みが行われていたデータレコードを検索することで、全てのブロックを検索することなく効率的に処理することが可能である。 According to the microcomputer of the eleventh aspect, first, the erasure check unit performs the erasure check, and then the write check unit performs the write check. With this configuration, the possibility of erroneously determining a block that has failed to be erased due to a decrease in power supply voltage as a valid block is reduced as much as possible by performing an erase check first. After that, by searching the data record that has been written last for the block determined to be valid, it is possible to efficiently process without searching all the blocks.
(第1実施形態)
以下、第1実施形態について図1から図9を参照して説明する。図4に示すように、マイクロコンピュータ1は、CPU2(書込み処理手段,書込みチェック手段,消去処理手段,消去チェック手段),プログラム記憶用のフラッシュメモリ(FLASH)3,データ記憶用のフラッシュメモリ4(不揮発性半導体メモリ),RAM(Random Access Memory)5,周辺回路6,フラッシュ用電源7,低電圧検出回路8を備えている。CPU2は、フラッシュメモリ3からプログラムデータを読み出して実行することで、フラッシュメモリ4のデータ書込み及び書き換え(更新)、ブロックの消去及び書込み対象ブロックの切替えなどを制御するメモリコントローラの機能を有している。
(First embodiment)
Hereinafter, the first embodiment will be described with reference to FIGS. 1 to 9. As shown in FIG. 4, the
RAM5はCPU2のメインメモリであり、データの書込みや書き換えなどの際に、データやCPU2の演算結果などを一時的に保持する作業領域として用いられる。フラッシュメモリ4は、内部に記憶部として、複数のブロックに分けられているメモリセルを有している。そして、データの種類を示すIDとデータとをワンセットのレコードとして書き込む。
The
フラッシュ用電源7は、外部より供給される電源を変圧・安定化させてフラッシュメモリ3,4に供給する。低電圧検出回路8は、フラッシュ用電源電圧が低下して、書込みが可能なレベル(例えば14V)を下回ると、低電圧検出信号をフラッシュメモリ4に出力する。その判定閾値は、例えば10Vに設定される。フラッシュメモリ4には、フラグメモリ9(W,E)及び制御ロジック10(W,E)を内蔵されている。低電圧検出信号は、制御ロジック10を介してフラグメモリ9に書込み(フラグのセット)を行うために使用される。
The
図5に示すように、フラッシュメモリ4は、複数のブロック4B(1),4B(2),…を備えている。1ブロックの容量は、例えば2kバイト程度である。そして、各ブロック4Bごとに、それぞれ1ビットの書込み中フラグメモリ9W,消去中メモリフラグ9Eが配置されている。これらのフラグメモリ9は、フラッシュメモリ4と同様に不揮発性のメモリである。ただし、フラグメモリ9の書込み可能電圧は、フラッシュメモリ4の通常のメモリセルの書込み可能電圧よりも低く設定されており、例えば8V程度となっている。
As shown in FIG. 5, the
書込み中フラグメモリ9W,消去中メモリフラグ9Eに対するデータの書込み(フラグのセット)は、図6に示すように、制御ロジック10(W,E)を介して行われる。制御ロジック10は、ANDゲート10aと、レジスタ10bとで構成されている。ANDゲート10aの一方の入力端子には、低電圧検出信号が与えられており、他方の入力端子には、レジスタ10bの出力端子が接続されている。
Data writing (flag setting) to the
レジスタ10Wb,レジスタ10Ebには、それぞれフラッシュメモリ4内に設定されている所定領域に対してデータ「1,0」の書込みが行われると、そのデータ値が保持される。すなわち、レジスタ10Wb,レジスタ10Ebに「1」が保持されている間に(書込み,消去開始)ハイレベルの低電圧検出信号が出力されると、書込み中フラグメモリ9W,消去中メモリフラグ9Eにそれぞれフラグがセットされる。一方、レジスタ10Wb,10Ebに「0」が保持されている間は、フラグメモリ9W,9Eにフラグはセットされない。
When data “1, 0” is written in the predetermined areas set in the
制御ロジック10(W,E)のレジスタ10bに書込みを行うためのアドレス,及びフラグメモリ9(W,E)のフラグをリセットするためのアドレスは、各ブロック4Bの先頭に配置されている。例えば、図7に示すように、1つのデータレコードが16バイトであれば、0x0000〜0x001Fまで(先頭部分)を前記アドレス領域とする。但し、実際に使用するのは、それらのうち先頭の3バイトだけであり、例えば0x0000が書込み中フラグメモリ9Wに、次の0x0001が消去中フラグメモリ9Eに割り当てられている。
An address for writing to the register 10b of the control logic 10 (W, E) and an address for resetting the flag of the flag memory 9 (W, E) are arranged at the head of each
例えばアドレス0x0000(第1バイト)の各ビットには、以下のような機能が割り当てられている。
ビット0:書込み中フラグメモリ9Wのフラグの読み出し/リセット
1:レジスタ10bにデータ「1/0」書込み
そして、ビット2〜7は不使用である。また、アドレス0x0001(第2バイト)のビット0,1には、消去中フラグメモリ9Eに対応して上記と同じ機能が割り当てられている。
For example, the following functions are assigned to each bit of the address 0x0000 (first byte).
Bit 0: Reading / reset of flag in writing
1: Data “1/0” is written to the register 10b, and
また、アドレス0x0002(第3バイト)はステータス領域として使用される。このステータス領域は、本実施形態のように、更新されたデータを各ブロックに順次追記する使用形態において一般的に使用されるもので、現在データの書込みが行われているブロック4B(有効ブロック)を判別するため、消去された後の新たなブロック4Bに最初に書込みを行う際に、所定値(例えば、「55」,「AA」等)が書き込まれる。そして、上述のように各ブロック4Bの容量が2kバイトであれば、次のブロックの先頭アドレスは0x0400,その次のブロックの先頭アドレスは0x0800となる。
The address 0x0002 (third byte) is used as a status area. This status area is generally used in a usage pattern in which updated data is sequentially added to each block as in the present embodiment, and a
次に、本実施形態の作用について図1から図3,図7〜図9を参照して説明する。図2に示すように、CPU2がフラッシュメモリ4の書込み対象のブロック4Bにデータレコードを書き込む場合は、レジスタ10Wbに「1」を書き込んでセットし(S1)、書込み対象アドレスにID及びデータをそれぞれ書き込む(S2,S3)。それから、レジスタ10Wbに「0」を書き込んでクリアする(S4)。図2に示す処理が、書込み処理手段に対応する。
Next, the operation of this embodiment will be described with reference to FIGS. 1 to 3 and FIGS. As shown in FIG. 2, when the
また、図3に示すように、CPU2がフラッシュメモリ4の消去対象のブロック4Bを消去する場合は、レジスタ10Ebに「1」を書き込んでセットしてから(S11)消去する(S12)。次に、レジスタ10Ebに「0」を書き込んでクリアする(S13)。したがって、ステップS2及びS3,又はステップS12の実行中に、例えば電源の瞬断等によりフラッシュ電源7の電圧が低下して電圧低下検出信号が出力されると、フラグメモリ9W,9Eにそれぞれ書込み中フラグ,消去中フラグがセットされる。図3に示す処理が、消去処理手段に対応する。
As shown in FIG. 3, when the
図1に示すように、電源が復帰してリセットが解除されると、CPU2は、各ブロックの消去中フラグメモリ9Eを読み出す(S21)。消去中フラグメモリ9Eに消去中フラグがセットされていなければ(書込み無し,S22:NO)ステップS25に移行して有効ブロック判定を行う(後述)。一方、消去中フラグがセットされていれば(S22:YES)そのブロック4Bを消去し(S23)、消去中フラグメモリ9Eをリセット(消去)する(S24)。尚、ステップS21〜S24が消去チェック手段に対応する。
As shown in FIG. 1, when the power is restored and the reset is released, the
続くステップS25における有効ブロック判定は、上述したステータス領域をチェックして、「書込み有効」なブロック4Bについて以降のステップS26の処理を行う。図8に一例を示すと、ID0〜ID3の4種類のデータがあり、それらが更新されると書込み中のブロック4Bの空き領域に書き込んで行く。例えばブロック4B(1)に空き領域がなくなると、次にブロック4B(2)を消去してから書込みを行うが(この時、ブロック4B(2)のステータス領域に所定値が書き込まれる)、ブロック4B(1)で最後に書込みが行われたのはID1のデータである。
In the subsequent valid block determination in step S25, the above-described status area is checked, and the processing in the subsequent step S26 is performed on the “write valid”
そこで、他のID0,2,3のデータについては、それより過去に書き込まれているデータを拾い、次にブロック4B(2)の先頭領域に転送する。ブロック4B(2)の空き領域がなくなった時点で最後に書込みが行われたのはID3のデータである。したがって、次にブロック4B(3)を消去してから書込みを行う際には、ID0〜ID3の最新のデータをブロック4B(2)の先頭領域に転送する。図8のようにブロック数が「3」であれば、ブロック4B(3)の空き領域がなくなると、次はブロック4B(1)を消去して書込みを行う。
Therefore, with respect to the data of
再び図1を参照する。ステップS26において、CPU2は、有効なブロック4Bの書込み中フラグメモリ9Wを読み出して、フラグがセットされているか否かを判断する(S27)。フラグがセットされていなければ(NO)ステップS30に移行し、書込み・消去処理の要求待ちを行う。一方、ステップS27においてフラグがセットされていれば(YES)、そのブロック4B内で最後に書込みが行われたデータレコードをサーチする。
Refer to FIG. 1 again. In step S26, the
一般に、データの書込みはアドレスの昇順で行われるので、当該ブロック4Bの最大アドレスから降順で、消去状態のデータ値(all「F」)と異なる値のデータ値となっているレコードをサーチして最終データレコードを特定する。この最終データレコードの書込み中に電源電圧の低下が発生して書込みが不完全になったと推定されるので、このデータレコードを無効化する(S28)。それから、書込み中フラグメモリ9Wをリセット(消去)して(S29)、ステップS30に移行する。尚、ステップS25〜S29が書込みチェック手段に対応する。
In general, since data is written in ascending order of addresses, a record having a data value different from the erased data value (all “F”) is searched in descending order from the maximum address of the
尚、各データレコードについて、データの有効/無効を判別するには、例えば図9(a)に示すように、各データレコードに無効化フラグ領域(Invalid)を設ける。そして、ステップS28では、対応するデータレコードの無効化フラグ領域に、例えばデータ値「0」を書き込むようにする。その分だけデータ等の記憶領域は浸食されるが、これは図9(b)に示す従来技術の場合も同様である。 In order to determine the validity / invalidity of data for each data record, for example, as shown in FIG. 9A, an invalidation flag area (Invalid) is provided for each data record. In step S28, for example, a data value “0” is written in the invalidation flag area of the corresponding data record. The storage area for data and the like is eroded accordingly, which is also the case with the prior art shown in FIG.
以上のように本実施形態によれば、マイクロコンピュータ1において、低電圧検出回路8は、フラッシュ電源7の電圧がフラッシュメモリ4への書込みが不能となるレベルに低下したことを検出すると、低電圧検出信号を出力する。また、低電圧検出信号により書込み中フラグがセットされる不揮発性の書込み中フラグメモリ9Wを備える。そして、CPU2は、書込み対象となるブロック4Bに書込みを行う際に、制御ロジック10Wにより前記フラグをセット可能な状態としてから、当該ブロック4BにID及びデータの書込みを行う。
As described above, according to the present embodiment, in the
その後、制御ロジック10Wにより前記フラグをセット不能な状態とする。また、CPU2は、リセットが解除されると、書込み中フラグメモリ9Wを読み出し、当該フラグがセットされていると、最後に書込みが行われていたID及びデータを無効化し、その後に前記フラグメモリ10Wを消去する。
After that, the flag cannot be set by the control logic 10W. When the reset is released, the
そして、ブロック4Bの消去についても同様に不揮発性の消去中フラグメモリ9Eを備え、CPU2は、ブロック4Bを消去する際に、制御ロジック10Eにより消去中フラグをセット可能な状態としてから消去を行い、その後、制御ロジック10Eにより消去中フラグをセット不能な状態とする。そして、リセットが解除されると、消去中フラグメモリ9Eを読み出し、消去中フラグがセットされていると、最後に書込みが行われていたブロックの次に書込み対象となる予定であったブロックを消去して、その後に消去中フラグメモリ9Eを消去する。
Similarly, for erasing the
したがって、各ブロック4Bについてそれぞれ1ビットの記憶素子であるフラグメモリ10W,10Eを用意すれば、書込みチェック及び消去チェックを行うことができるので、フラッシュメモリ4の記憶領域を効率的に使用できる。また、フラグメモリ9及び制御ロジック10を、フラッシュメモリ4が備える各ブロック4Bに対応して設けたので、CPU2によるステータス領域への書込み,消去自体が電源電圧の低下により失敗している場合でも、書込みチェック及び消去チェックをより確実に行うことができる。
Therefore, if the flag memories 10W and 10E, which are 1-bit storage elements, are prepared for each
そして、フラグメモリ9と制御ロジック10とを、フラッシュメモリ4の内部に配置したので、不揮発性のフラグメモリ9をフラッシュメモリ4と同じプロセスで、1つのデバイスとして一括で製造できる。また、フラグメモリ9及び制御ロジック10へのアクセスアドレスが、フラッシュメモリ4と同じ領域のアドレスとなるので、それらに対するアクセスや制御が容易となる。
Since the flag memory 9 and the control logic 10 are arranged inside the
更に、フラグメモリ9及び制御ロジック10にアクセスするためのアドレスを、フラッシュメモリ4に割り当てられるアドレスの先頭部分に設定したので、これらにアクセスする際には、ブロック4B数に応じたMSB側のビットを指定するだけで簡単にアクセスできる。加えて、CPU2は、最初に消去チェックを行い、続いて書込みチェックを行うようにした。これにより、電源電圧が低下したことで消去が失敗したブロックを4Bを、有効なブロック4Bと誤判定する可能性を極力低下させる。そして、その後に有効と判断したブロック4Bに対して、最後に書込みが行われていたデータレコードを検索することで、全てのブロック4Bを検索することなく効率的に処理することができる。
Further, since the address for accessing the flag memory 9 and the control logic 10 is set at the head of the address assigned to the
(第2実施形態)
以下、第2実施形態について図10を参照して説明する。尚、第1実施形態と同一部分には同一符号を付して説明を省略し、以下異なる部分について説明する。第1実施形態では、各ブロック4Bに対応してフラグメモリ9(W,E)及び制御ロジック10(W,E)を個別に設けたが、第2実施形態では、フラッシュメモリ4に対してフラグメモリ9(W,E)及び制御ロジック10(W,E)を1組だけ設ける。したがって、フラッシュ電源7の電圧低下が発生することで、複数のうち何れか1つのブロック4Bに書込み不良や消去不良が生じたとしても、共通のフラグメモリ9にフラグがセットされる。
(Second Embodiment)
Hereinafter, a second embodiment will be described with reference to FIG. In addition, the same code | symbol is attached | subjected to the same part as 1st Embodiment, description is abbreviate | omitted, and a different part is demonstrated below. In the first embodiment, the flag memory 9 (W, E) and the control logic 10 (W, E) are individually provided corresponding to each
この場合、図10に示すように、CPU2は、ステップS22で「YES」と判断すると、各ブロック4Bのステータス領域をチェックして、リセット解除前に書込み有効であったブロック4Bを特定する(S31)。最後に消去が行われていたブロック4Bは、リセット解除前の有効ブロック4Bの次に書込み対象となるブロック4Bであるから、消去を失敗したブロック4Bが特定できる。そして、続くステップS23’では、ステップS31で特定したブロック4Bを消去する。
In this case, as shown in FIG. 10, when the
一方、書込みチェックについては、第1実施形態と全く同様である。すなわち、ステップS25で有効ブロック4Bを特定し、書込み中フラグがセットされていれば、書込みが失敗したのは特定された有効ブロック4Bである。したがって、前記ブロック4B内の最終データでコードを無効化する(S28)。
On the other hand, the write check is exactly the same as in the first embodiment. That is, if the
ここで、第1,第2実施形態の相違について説明する。第2実施形態は、フラッシュメモリ4に対してフラグメモリ9(W,E)及び制御ロジック10(W,E)を1組だけ設けるので、必要なハードウェアのサイズが小さくなるというメリットがある。そして、消去或いは書込みを失敗したブロック4Bの特定も、ステータス領域を利用することで第1実施形態とほぼ同様に行える。
Here, differences between the first and second embodiments will be described. The second embodiment has an advantage that the required hardware size is reduced because only one set of flag memory 9 (W, E) and control logic 10 (W, E) is provided for the
しかしながら、CPU2が上記ステータス領域に書込みを行っている途中でフラッシュ電源7の電圧低下が発生し、書込みが失敗している可能性は否定できない。したがって、第1実施形態のように、各ブロック4Bに対応してフラグメモリ9(W,E)及び制御ロジック10(W,E)を設ければ、ステータス領域に依存せずとも、消去或いは書込みを失敗したブロック4Bを確実に特定できる。
However, it cannot be denied that the
すなわち、第1実施形態の書込みチェックにおいて、ステップS25でステータス領域を参照して有効ブロック4Bを特定している。しかし、必ずしもステータス領域を参照する必要はなく、最初から各ブロック4Bのフラグメモリ9Wだけを参照しても、書込みを失敗したブロック4Bの特定は可能である。
That is, in the write check of the first embodiment, the
本発明は上記した、又は図面に記載した実施形態にのみ限定されるものではなく、以下のような変形又は拡張が可能である。
ブロック4Bの容量は、2kバイトに限らない。
フラグメモリ9や制御ロジック10にアクセスするためのアドレスは、必ずしもブロック4Bのアドレスの先頭部分に配置する必要はない。
フラグメモリ9及び制御ロジック10を、フラッシュメモリ4と独立したデバイスとして、フラッシュメモリ4の外部に配置しても良い。
The present invention is not limited to the embodiments described above or shown in the drawings, and the following modifications or expansions are possible.
The capacity of the
The address for accessing the flag memory 9 and the control logic 10 is not necessarily arranged at the head of the address of the
The flag memory 9 and the control logic 10 may be arranged outside the
消去中フラグメモリ9E,制御ロジック10Eを設けて行う消去処理及び消去チェック処理については、必要に応じて行えば良い。
書込み可能な電圧や低電圧検出のための閾値電圧等は、個別の設計に応じて適宜変更すれば良い。
フラッシュメモリに限ることなく、書き換え可能な不揮発性メモリであれば適用が可能である。
The erasing process and the erasure check process performed by providing the erasing
A writable voltage, a threshold voltage for detecting a low voltage, and the like may be appropriately changed according to individual designs.
The present invention is not limited to a flash memory and can be applied to any rewritable nonvolatile memory.
図面中、1はマイクロコンピュータ、2はCPU(書込み処理手段,書込みチェック手段,消去処理手段,消去チェック手段)、4はフラッシュメモリ(不揮発性メモリ)、4Bはブロック、7はフラッシュ用電源、8は低電圧検出回路、9Wは書込み中フラグメモリ、10Wは制御ロジックを示す。 In the drawings, 1 is a microcomputer, 2 is a CPU (write processing means, write check means, erase processing means, erase check means), 4 is a flash memory (nonvolatile memory), 4B is a block, 7 is a power supply for flash, 8 Is a low voltage detection circuit, 9W is a writing flag memory, and 10W is a control logic.
Claims (16)
電源電圧が、前記不揮発性メモリへの書込みが不能となるレベルに低下したことを検出すると、低電圧検出信号を出力する低電圧検出回路(8)と、
前記低電圧検出信号により書込み中フラグがセットされる、不揮発性の書込み中フラグメモリ(9W)と、
この書込み中フラグメモリに対する前記書込み中フラグのセットの可否を制御する制御ロジック(10W)と、
前記不揮発性メモリの各ブロックに対応して設けられ、現在データの書込みが行われているブロックを示すため、所定値が書き込まれるステータス領域と、
書込み対象とするブロックに書込みを行う際に、前記制御ロジックにより前記フラグをセット可能な状態としてから、前記ブロックにID及びデータの書込みを行い、その後、前記制御ロジックにより前記フラグをセット不能な状態とする書込み処理手段(2)と、
リセットが解除されると、前記書込み中フラグメモリを読み出し、書込み中フラグがセットされていると、最後に書込みが行われていたID及びデータを無効化し、その後に前記書込み中フラグメモリを消去する書込みチェック手段(2)とを備えることを特徴とするマイクロコンピュータ。 Non-volatile memory having a plurality of blocks (4B) of a predetermined size, which is a unit capable of erasing data collectively, and storing a plurality of updated types of data written in an empty area together with an ID indicating the type A microcomputer (1) incorporating (4),
A low voltage detection circuit (8) that outputs a low voltage detection signal when detecting that the power supply voltage has dropped to a level at which writing to the nonvolatile memory becomes impossible;
A non-writing flag memory (9W) in which a writing flag is set by the low voltage detection signal;
Control logic (10 W) for controlling whether or not the writing flag is set to the writing flag memory;
A status area provided corresponding to each block of the non-volatile memory and indicating a block where data is currently written, and a predetermined area to which a predetermined value is written,
When writing to a block to be written, the flag can be set by the control logic, and then the ID and data are written to the block, and then the flag cannot be set by the control logic. Write processing means (2)
When the reset is released, the writing flag memory is read, and if the writing flag is set, the ID and data that were written last are invalidated, and then the writing flag memory is erased. A microcomputer comprising write check means (2).
この消去中フラグメモリに対する前記消去中フラグのセットの可否を制御する制御ロジック(10E)と、
消去対象とするブロックを消去する際に、前記制御ロジックにより前記フラグをセット可能な状態としてから、前記ブロックを消去し、その後、前記制御ロジックにより前記フラグをセット不能な状態とする消去処理手段(2)と、
リセットが解除されると、前記消去中フラグメモリを読み出し、消去中フラグがセットされていると、最後に書込みが行われていたブロックの次に書込み対象となる予定であったブロックを消去して、その後に前記消去中フラグメモリを消去する消去チェック手段(2)とを備えることを特徴とする請求項1から5の何れか一項に記載のマイクロコンピュータ。 A non-erasing flag memory (9E) in which an erasing flag is set by the low voltage detection signal;
Control logic (10E) for controlling whether or not the erasing flag is set to the erasing flag memory;
When erasing a block to be erased, the control logic enables the flag to be set and then erases the block, and then the control logic disables the flag to be set. 2) and
When the reset is released, the erasing flag memory is read, and if the erasing flag is set, the block that was scheduled to be written next to the last written block is erased. The microcomputer according to any one of claims 1 to 5, further comprising an erasure check means (2) for erasing the erasure flag memory thereafter.
前記不揮発性メモリの各ブロックに対応して設けられているステータス領域に、現在データの書込みが行われているブロックを示すために所定値を書込み、
書込み対象とするブロックに書込みを行う際に、不揮発性の書込み中フラグメモリに、電源電圧が、前記不揮発性メモリへの書込みが不能となるレベルに低下したことを検出した際に出力される低電圧検出信号による書込み中フラグのセットを可能な状態としてから、前記ブロックにID及びデータの書込みを行い、その後、前記フラグをセット不能な状態にして、
リセットが解除されると、前記書込み中フラグメモリを読み出し、書込み中フラグがセットされていると、最後に書込みが行われていたID及びデータを無効化し、その後に前記書込み中フラグメモリを消去することを特徴とする不揮発性メモリのブロック管理方法。 Non-volatile memory block management in which a plurality of blocks of a predetermined size, which is a unit capable of erasing data collectively, are stored and a plurality of types of updated data are written and stored in an empty area together with an ID indicating the type A method,
In a status area provided corresponding to each block of the non-volatile memory, a predetermined value is written to indicate a block in which data is currently written,
When writing to a block to be written, a low output is output to the nonvolatile writing flag memory when it is detected that the power supply voltage has dropped to a level at which writing to the nonvolatile memory becomes impossible. After enabling the setting of the flag during writing by the voltage detection signal, ID and data are written to the block, and then the flag cannot be set,
When the reset is released, the writing flag memory is read, and if the writing flag is set, the ID and data that were written last are invalidated, and then the writing flag memory is erased. A block management method for a nonvolatile memory.
リセットが解除されると、各ブロックに対応する書込み中フラグメモリをそれぞれ読み出して、書込み中フラグがセットされているか否かを判断することを特徴とする請求項12記載の不揮発性メモリのブロック管理方法。 The writing flag memory is provided corresponding to each block included in the nonvolatile memory,
13. The non-volatile memory block management according to claim 12, wherein when the reset is released, the in-writing flag memory corresponding to each block is read to determine whether or not the in-writing flag is set. Method.
リセットが解除されると、前記消去中フラグメモリを読み出し、消去中フラグがセットされていると、最後に書込みが行われていたブロックの次に書込み対象となる予定であったブロックを消去して、その後に前記消去中フラグメモリを消去することを特徴とする請求項12又は13記載の不揮発性メモリのブロック管理方法。 When erasing a block to be erased, the non-erasing flag memory is enabled to set the erasing flag by the low voltage detection signal, and then the block is erased, and then the flag cannot be set. In a state
When the reset is released, the erasing flag memory is read, and if the erasing flag is set, the block that was scheduled to be written next to the last written block is erased. 14. The nonvolatile memory block management method according to claim 12, wherein the erasing flag memory is erased thereafter.
リセットが解除されると、各ブロックに対応する消去中フラグメモリをそれぞれ読み出して、消去中フラグがセットされているか否かを判断することを特徴とする請求項14記載の不揮発性メモリのブロック管理方法。 The erasing flag memory is provided corresponding to each block included in the nonvolatile memory,
15. The block management of a non-volatile memory according to claim 14, wherein when the reset is released, each of the erasing flag memories corresponding to each block is read to determine whether or not the erasing flag is set. Method.
続いて、書込み中フラグがセットされているか否かを判断することを特徴とする請求項14又は15記載の不揮発性メモリのブロック管理方法。 First, determine if the erasing flag is set,
16. The non-volatile memory block management method according to claim 14, wherein it is determined whether or not a writing flag is set.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2013181245A JP6040895B2 (en) | 2013-09-02 | 2013-09-02 | Microcomputer and non-volatile memory block management method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2013181245A JP6040895B2 (en) | 2013-09-02 | 2013-09-02 | Microcomputer and non-volatile memory block management method |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2015049722A JP2015049722A (en) | 2015-03-16 |
JP6040895B2 true JP6040895B2 (en) | 2016-12-07 |
Family
ID=52699682
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2013181245A Expired - Fee Related JP6040895B2 (en) | 2013-09-02 | 2013-09-02 | Microcomputer and non-volatile memory block management method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP6040895B2 (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP7279534B2 (en) * | 2019-06-18 | 2023-05-23 | 株式会社デンソー | Data storage controller and data storage control system |
CN111061427B (en) * | 2019-10-22 | 2023-04-07 | 力高(山东)新能源技术股份有限公司 | Method for preventing task cycle from being blocked due to off-chip flash access |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2001051883A (en) * | 1999-08-12 | 2001-02-23 | Nec Corp | Method for self-restoration by nonvolatile memory and novolatile memory device |
JP4803757B2 (en) * | 2008-06-02 | 2011-10-26 | ルネサスエレクトロニクス株式会社 | Semiconductor processing equipment |
JP2010009165A (en) * | 2008-06-25 | 2010-01-14 | Kyocera Mita Corp | Recording apparatus, image forming apparatus, and option apparatus |
JP2011129192A (en) * | 2009-12-16 | 2011-06-30 | Samsung Electronics Co Ltd | Semiconductor memory device |
JP2013003623A (en) * | 2011-06-13 | 2013-01-07 | Panasonic Corp | Flash memory control device and flash memory control method |
JP5660521B2 (en) * | 2011-06-17 | 2015-01-28 | 株式会社デンソー | Nonvolatile semiconductor memory device and memory management method |
JP2013218371A (en) * | 2012-04-04 | 2013-10-24 | Seiko Epson Corp | Information processor and data storage processing method in the same |
-
2013
- 2013-09-02 JP JP2013181245A patent/JP6040895B2/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
JP2015049722A (en) | 2015-03-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6601132B2 (en) | Nonvolatile memory and method of writing data thereto | |
US8452913B2 (en) | Semiconductor memory device and method of processing data for erase operation of semiconductor memory device | |
JP4129381B2 (en) | Nonvolatile semiconductor memory device | |
JP4729062B2 (en) | Memory system | |
JP4524309B2 (en) | Memory controller for flash memory | |
US7117328B2 (en) | Non-volatile data storage system and data storaging method | |
US20170139839A1 (en) | Data storage device and data maintenance method thereof | |
US9431069B2 (en) | Management method for nonvolatile memory system following power-off | |
TWI436369B (en) | Methods for measuring usable lifespan and replacing an in-system programming code of a memory device, and data storage system using the same | |
US20100125696A1 (en) | Memory Controller For Controlling The Wear In A Non-volatile Memory Device And A Method Of Operation Therefor | |
KR20040014971A (en) | Non-volatile memory control method | |
JP4666081B2 (en) | MEMORY CONTROLLER, FLASH MEMORY SYSTEM HAVING MEMORY CONTROLLER, AND FLASH MEMORY CONTROL METHOD | |
JP2008033801A (en) | Memory data management device | |
CN111324549B (en) | Memory and control method and device thereof | |
JP4488048B2 (en) | MEMORY CONTROLLER, FLASH MEMORY SYSTEM HAVING MEMORY CONTROLLER, AND FLASH MEMORY CONTROL METHOD | |
JP6040895B2 (en) | Microcomputer and non-volatile memory block management method | |
US20180052635A1 (en) | Electronic control apparatus and information storage method for the same | |
JP4661369B2 (en) | Memory controller | |
JP3981268B2 (en) | Nonvolatile memory and data updating method thereof | |
JP2008251154A (en) | Nonvolatile semiconductor memory device | |
JP4794530B2 (en) | Semiconductor device and mobile phone | |
JP5983512B2 (en) | Writing device | |
JP6636930B2 (en) | Microcomputer with built-in flash memory, method of writing data to flash memory built in microcontroller, and program for writing data to flash memory | |
US9465730B2 (en) | Flash memory device | |
CN102591738A (en) | Data management method, memory controller and embedded memory storage device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20151215 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20160929 |
|
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: 20161011 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20161024 |
|
R151 | Written notification of patent or utility model registration |
Ref document number: 6040895 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R151 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
LAPS | Cancellation because of no payment of annual fees |