JP2015049722A - Microcomputer and block control method of non-volatile memory - Google Patents

Microcomputer and block control method of non-volatile memory Download PDF

Info

Publication number
JP2015049722A
JP2015049722A JP2013181245A JP2013181245A JP2015049722A JP 2015049722 A JP2015049722 A JP 2015049722A JP 2013181245 A JP2013181245 A JP 2013181245A JP 2013181245 A JP2013181245 A JP 2013181245A JP 2015049722 A JP2015049722 A JP 2015049722A
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.)
Granted
Application number
JP2013181245A
Other languages
Japanese (ja)
Other versions
JP6040895B2 (en
Inventor
佑樹 堀井
Yuki Horii
佑樹 堀井
伊藤 智康
Tomoyasu Ito
智康 伊藤
瑞穂 石田
Mizuho Ishida
瑞穂 石田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Denso Corp
Original Assignee
Denso Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Denso Corp filed Critical Denso Corp
Priority to JP2013181245A priority Critical patent/JP6040895B2/en
Publication of JP2015049722A publication Critical patent/JP2015049722A/en
Application granted granted Critical
Publication of JP6040895B2 publication Critical patent/JP6040895B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL 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
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE 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/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Power Sources (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide a microcomputer that can efficiently control data for which writing is unsuccessfully performed when it stores a plurality of data in a non-volatile memory while updating them.SOLUTION: A low voltage detection circuit 8 outputs a low voltage detection signal when it detects a voltage reduction of a flash power 7 to a level at which writing to a flash memory cannot be performed. A non-volatile under-writing flag memory 9 W is provided where an under-writing flag is set by the low voltage detection signal. A CPU2 starts writing an ID and data in a block of a flash memory 4 after shifting to a status where the flag can be set by a control logic 10 W. Afterward, the control logic 10 W shifts to a status where the flag cannot be set. When a reset is cancelled, the CPU2 reads out the under-writing flag memory 9 W, and disables the final ID and data for which writing was performed when the flag is set, before deleting the flag memory 9 W.

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, Patent Document 1 discloses a technique for managing data in units of IDs and adding only updated data to reduce the number of erasures.

ここで、フラッシュメモリへのデータの書込み中に、例えば電源の瞬断等によるリセットが発生すると、書込みデータが不正な値となったり、リテンションが長く維持できなくなるといった問題が発生する。例えば大容量のコンデンサを配置することで、瞬断が発生しても書込み可能な電圧を維持する対策も考えられる。しかし、製品のコスト及びサイズの増大というデメリットがあり、実際には採用しがたい。   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 Patent Document 2, when a power interruption occurs during writing of a program to the flash memory, an auxiliary memory such as an EEPROM stores a flag, a position where the writing is interrupted, a program type, etc. A technique is disclosed in which, when the computer is restarted, the information in the EEPROM is read and writing is resumed from the position where it was interrupted.

特開2004−164493号公報JP 2004-164493 A 特開2010−9165号公報JP 2010-9165 A

しかしながら、図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 Patent Document 2, since a write target is a program, it is necessary to store a lot of information corresponding to the program in the EEPROM. If the object to be written is a plurality of types of data, it cannot be applied immediately, and necessary and efficient information cannot be stored.

本発明は上記事情に鑑みてなされたものであり、その目的は、不揮発性メモリに複数のデータを更新しつつ記憶させる際に、書込みが失敗したデータを効率的に管理できるマイクロコンピュータ,及び不揮発性メモリのブロック管理方法を提供する。   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 claim 1, the data record that has been written last is stored. Can be identified. However, it cannot be denied that the writing and erasing of the status area itself may have failed due to a decrease in power supply voltage. Therefore, if the writing flag memory and the control logic are provided corresponding to each block, the writing check can be performed more reliably.

請求項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実施形態であり、リセット解除後にCPUが実行する処理を示すフローチャートThe flowchart which is 1st Embodiment and shows the process which CPU performs after reset cancellation | release フラッシュメモリのブロックへの書込み処理を示すフローチャートFlow chart showing the writing process to the block of the flash memory フラッシュメモリのブロックの消去処理を示すフローチャートA flowchart showing the erase processing of a block of the flash memory マイクロコンピュータの構成を示す機能ブロック図Functional block diagram showing the configuration of the microcomputer フラッシュメモリ内における各ブロック及びフラグメモリを示す図The figure which shows each block and flag memory in flash memory 各フラグメモリに対応した制御ロジックの構成を示す図The figure which shows the structure of the control logic corresponding to each flag memory フラッシュメモリ内における先頭ブロックのアドレスマップの一例を示す図The figure which shows an example of the address map of the head block in flash memory ブロック管理の一例を示す図Diagram showing an example of block management 各データレコードについて有効/無効を判定するための領域を付与した場合で、(a)は第1実施形態、(b)は従来技術の例を示す図When an area for determining validity / invalidity is assigned to each data record, (a) shows the first embodiment, and (b) shows an example of the prior art. 第2実施形態を示す図1相当図FIG. 1 equivalent view showing the second embodiment 従来技術を説明する図Diagram explaining the prior art

(第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 microcomputer 1 includes a CPU 2 (writing processing means, writing checking means, erasing processing means, erasing checking means), a flash memory (FLASH) for program storage 3, and a flash memory 4 for data storage ( A nonvolatile semiconductor memory), a RAM (Random Access Memory) 5, a peripheral circuit 6, a flash power supply 7, and a low voltage detection circuit 8 are provided. The CPU 2 has the function of a memory controller that controls data writing and rewriting (updating) of the flash memory 4, erasing of blocks, switching of blocks to be written, and the like by reading and executing program data from the flash memory 3. Yes.

RAM5はCPU2のメインメモリであり、データの書込みや書き換えなどの際に、データやCPU2の演算結果などを一時的に保持する作業領域として用いられる。フラッシュメモリ4は、内部に記憶部として、複数のブロックに分けられているメモリセルを有している。そして、データの種類を示すIDとデータとをワンセットのレコードとして書き込む。   The RAM 5 is a main memory of the CPU 2, and is used as a work area for temporarily storing data, calculation results of the CPU 2, and the like when data is written or rewritten. The flash memory 4 includes a memory cell divided into a plurality of blocks as a storage unit. Then, the ID indicating the type of data and the data are written as a set of records.

フラッシュ用電源7は、外部より供給される電源を変圧・安定化させてフラッシュメモリ3,4に供給する。低電圧検出回路8は、フラッシュ用電源電圧が低下して、書込みが可能なレベル(例えば14V)を下回ると、低電圧検出信号をフラッシュメモリ4に出力する。その判定閾値は、例えば10Vに設定される。フラッシュメモリ4には、フラグメモリ9(W,E)及び制御ロジック10(W,E)を内蔵されている。低電圧検出信号は、制御ロジック10を介してフラグメモリ9に書込み(フラグのセット)を行うために使用される。   The flash power supply 7 transforms and stabilizes the power supplied from the outside and supplies it to the flash memories 3 and 4. The low voltage detection circuit 8 outputs a low voltage detection signal to the flash memory 4 when the flash power supply voltage decreases and falls below a writable level (for example, 14 V). The determination threshold is set to 10 V, for example. The flash memory 4 includes a flag memory 9 (W, E) and a control logic 10 (W, E). The low voltage detection signal is used to write (set a flag) to the flag memory 9 via the control logic 10.

図5に示すように、フラッシュメモリ4は、複数のブロック4B(1),4B(2),…を備えている。1ブロックの容量は、例えば2kバイト程度である。そして、各ブロック4Bごとに、それぞれ1ビットの書込み中フラグメモリ9W,消去中メモリフラグ9Eが配置されている。これらのフラグメモリ9は、フラッシュメモリ4と同様に不揮発性のメモリである。ただし、フラグメモリ9の書込み可能電圧は、フラッシュメモリ4の通常のメモリセルの書込み可能電圧よりも低く設定されており、例えば8V程度となっている。   As shown in FIG. 5, the flash memory 4 includes a plurality of blocks 4B (1), 4B (2),. The capacity of one block is, for example, about 2 kbytes. A 1-bit writing flag memory 9W and an erasing memory flag 9E are arranged for each block 4B. These flag memories 9 are nonvolatile memories like the flash memory 4. However, the writable voltage of the flag memory 9 is set lower than the writable voltage of a normal memory cell of the flash memory 4, and is about 8V, for example.

書込み中フラグメモリ9W,消去中メモリフラグ9Eに対するデータの書込み(フラグのセット)は、図6に示すように、制御ロジック10(W,E)を介して行われる。制御ロジック10は、ANDゲート10aと、レジスタ10bとで構成されている。ANDゲート10aの一方の入力端子には、低電圧検出信号が与えられており、他方の入力端子には、レジスタ10bの出力端子が接続されている。   Data writing (flag setting) to the flag flag 9W being written and the memory flag 9E being erased is performed via the control logic 10 (W, E) as shown in FIG. The control logic 10 includes an AND gate 10a and a register 10b. A low voltage detection signal is supplied to one input terminal of the AND gate 10a, and the output terminal of the register 10b is connected to the other input terminal.

レジスタ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 flash memory 4 in the registers 10Wb and 10Eb, the data values are held. That is, if a high-level low voltage detection signal is output while “1” is held in the registers 10Wb and 10Eb (start of writing and erasing), the writing flag memory 9W and the erasing memory flag 9E respectively. A flag is set. On the other hand, while “0” is held in the registers 10Wb and 10Eb, the flag is not set in the flag memories 9W and 9E.

制御ロジック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 block 4B. For example, as shown in FIG. 7, if one data record is 16 bytes, the address area is from 0x0000 to 0x001F (first part). However, only the first three bytes are actually used. For example, 0x0000 is assigned to the writing flag memory 9W, and the next 0x0001 is assigned to the erasing flag memory 9E.

例えばアドレス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 flag memory 9W
1: Data “1/0” is written to the register 10b, and bits 2 to 7 are not used. Further, the same functions as described above are assigned to bits 0 and 1 of the address 0x0001 (second byte) corresponding to the erasing flag memory 9E.

また、アドレス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 block 4B (valid block) in which data is currently written. Therefore, a predetermined value (for example, “55”, “AA”, etc.) is written when data is first written in the new block 4B after being erased. As described above, if the capacity of each block 4B is 2 kbytes, the start address of the next block is 0x0400, and the start address of the next block is 0x0800.

次に、本実施形態の作用について図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 CPU 2 writes a data record in the write target block 4B of the flash memory 4, "1" is written and set in the register 10Wb (S1), and ID and data are respectively set in the write target address. Write (S2, S3). Then, “0” is written to the register 10Wb to be cleared (S4). The processing shown in FIG. 2 corresponds to the writing processing means.

また、図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 CPU 2 erases the block 4B to be erased from the flash memory 4, "1" is written and set in the register 10Eb (S11) and erased (S12). Next, “0” is written to the register 10Eb to clear it (S13). Therefore, during the execution of steps S2 and S3, or step S12, if the voltage of the flash power supply 7 drops and a voltage drop detection signal is output due to, for example, a momentary interruption of the power supply, writing to the flag memories 9W and 9E is in progress. Flag and erasing flag are set. The process shown in FIG. 3 corresponds to an erasure processing unit.

図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 CPU 2 reads the erasing flag memory 9E of each block (S21). If the erasing flag memory 9E does not have the erasing flag set (no write, S22: NO), the process proceeds to step S25 to determine a valid block (described later). On the other hand, if the erasing flag is set (S22: YES), the block 4B is erased (S23), and the erasing flag memory 9E is reset (erased) (S24). Steps S21 to S24 correspond to the erasure check means.

続くステップ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” block 4B. FIG. 8 shows an example. There are four types of data, ID0 to ID3, and when they are updated, data is written in the empty area of the block 4B being written. For example, when there is no free space in block 4B (1), writing is performed after erasing block 4B (2) (at this time, a predetermined value is written in the status area of block 4B (2)). It is ID1 data that was last written in 4B (1).

そこで、他の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 other IDs 0, 2, and 3, the data written in the past is picked up and then transferred to the head area of the block 4B (2). It is the data of ID3 that was last written when the free area of the block 4B (2) is exhausted. Therefore, when writing is performed after erasing block 4B (3) next time, the latest data of ID0 to ID3 is transferred to the head area of block 4B (2). If the number of blocks is “3” as shown in FIG. 8, when there is no more free space in the block 4B (3), the next block 4B (1) is erased and writing is performed.

再び図1を参照する。ステップS26において、CPU2は、有効なブロック4Bの書込み中フラグメモリ9Wを読み出して、フラグがセットされているか否かを判断する(S27)。フラグがセットされていなければ(NO)ステップS30に移行し、書込み・消去処理の要求待ちを行う。一方、ステップS27においてフラグがセットされていれば(YES)、そのブロック4B内で最後に書込みが行われたデータレコードをサーチする。   Refer to FIG. 1 again. In step S26, the CPU 2 reads the valid flag memory 9W of the valid block 4B and determines whether or not the flag is set (S27). If the flag is not set (NO), the process proceeds to step S30 to wait for a request for write / erase processing. On the other hand, if the flag is set in step S27 (YES), the last data record written in the block 4B is searched.

一般に、データの書込みはアドレスの昇順で行われるので、当該ブロック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 block 4B. Identify the last data record. Since it is presumed that the power supply voltage has dropped during the writing of the final data record and the writing has become incomplete, the data record is invalidated (S28). Then, the writing flag memory 9W is reset (erased) (S29), and the process proceeds to step S30. Steps S25 to S29 correspond to write check means.

尚、各データレコードについて、データの有効/無効を判別するには、例えば図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 microcomputer 1, when the low voltage detection circuit 8 detects that the voltage of the flash power supply 7 has dropped to a level at which writing to the flash memory 4 becomes impossible, the low voltage detection circuit 8 A detection signal is output. Further, a non-writing flag memory 9W in which a writing flag is set by a low voltage detection signal is provided. Then, when writing to the block 4B to be written, the CPU 2 writes the ID and data to the block 4B after the control logic 10W makes the flag settable.

その後、制御ロジック10Wにより前記フラグをセット不能な状態とする。また、CPU2は、リセットが解除されると、書込み中フラグメモリ9Wを読み出し、当該フラグがセットされていると、最後に書込みが行われていたID及びデータを無効化し、その後に前記フラグメモリ10Wを消去する。   After that, the flag cannot be set by the control logic 10W. When the reset is released, the CPU 2 reads the writing flag memory 9W. If the flag is set, the CPU 2 invalidates the last written ID and data, and then the flag memory 10W. Erase.

そして、ブロック4Bの消去についても同様に不揮発性の消去中フラグメモリ9Eを備え、CPU2は、ブロック4Bを消去する際に、制御ロジック10Eにより消去中フラグをセット可能な状態としてから消去を行い、その後、制御ロジック10Eにより消去中フラグをセット不能な状態とする。そして、リセットが解除されると、消去中フラグメモリ9Eを読み出し、消去中フラグがセットされていると、最後に書込みが行われていたブロックの次に書込み対象となる予定であったブロックを消去して、その後に消去中フラグメモリ9Eを消去する。   Similarly, for erasing the block 4B, a nonvolatile erasing flag memory 9E is provided, and when erasing the block 4B, the CPU 2 erases after the control logic 10E sets the erasing flag in a state that can be set, Thereafter, the erasing flag cannot be set by the control logic 10E. When the reset is released, the erasing flag memory 9E is read, and when the erasing flag is set, the block that was scheduled to be written next to the last written block is erased. Thereafter, the erasing flag memory 9E is erased.

したがって、各ブロック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 block 4B, the write check and the erase check can be performed, so that the storage area of the flash memory 4 can be used efficiently. In addition, since the flag memory 9 and the control logic 10 are provided corresponding to each block 4B included in the flash memory 4, even when the writing and erasing itself into the status area by the CPU 2 has failed due to a decrease in the power supply voltage, Write check and erase check can be performed more reliably.

そして、フラグメモリ9と制御ロジック10とを、フラッシュメモリ4の内部に配置したので、不揮発性のフラグメモリ9をフラッシュメモリ4と同じプロセスで、1つのデバイスとして一括で製造できる。また、フラグメモリ9及び制御ロジック10へのアクセスアドレスが、フラッシュメモリ4と同じ領域のアドレスとなるので、それらに対するアクセスや制御が容易となる。   Since the flag memory 9 and the control logic 10 are arranged inside the flash memory 4, the nonvolatile flag memory 9 can be manufactured as a single device in the same process as the flash memory 4. In addition, since the access addresses to the flag memory 9 and the control logic 10 are addresses in the same area as the flash memory 4, it is easy to access and control them.

更に、フラグメモリ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 flash memory 4, when accessing these bits, the MSB side bit corresponding to the number of blocks 4B is used. You can easily access by simply specifying. In addition, the CPU 2 first performs an erasure check and then performs a write check. As a result, the possibility of erroneously determining 4B as a valid block 4B for a block that has failed to be erased due to a decrease in power supply voltage is reduced as much as possible. Then, with respect to the block 4B that is determined to be valid thereafter, the data record that has been written last is searched, so that the processing can be efficiently performed without searching all the blocks 4B.

(第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 block 4B. However, in the second embodiment, a flag is provided for the flash memory 4. Only one set of the memory 9 (W, E) and the control logic 10 (W, E) is provided. Therefore, even if a write failure or erasure failure occurs in any one of the plurality of blocks 4B due to the voltage drop of the flash power supply 7, a flag is set in the common flag memory 9.

この場合、図10に示すように、CPU2は、ステップS22で「YES」と判断すると、各ブロック4Bのステータス領域をチェックして、リセット解除前に書込み有効であったブロック4Bを特定する(S31)。最後に消去が行われていたブロック4Bは、リセット解除前の有効ブロック4Bの次に書込み対象となるブロック4Bであるから、消去を失敗したブロック4Bが特定できる。そして、続くステップS23’では、ステップS31で特定したブロック4Bを消去する。   In this case, as shown in FIG. 10, when the CPU 2 determines “YES” in step S22, the CPU 2 checks the status area of each block 4B, and identifies the block 4B in which writing was valid before reset release (S31). ). Since the block 4B that has been erased last is the block 4B to be written next to the valid block 4B before reset release, the block 4B that has failed to be erased can be identified. In subsequent step S23 ', the block 4B specified in step S31 is erased.

一方、書込みチェックについては、第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 valid block 4B is identified in step S25 and the writing flag is set, it is the identified valid block 4B that failed to be written. Therefore, the code is invalidated with the final data in the block 4B (S28).

ここで、第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 flash memory 4. The block 4B that has failed to be erased or written can be identified in substantially the same manner as in the first embodiment by using the status area.

しかしながら、CPU2が上記ステータス領域に書込みを行っている途中でフラッシュ電源7の電圧低下が発生し、書込みが失敗している可能性は否定できない。したがって、第1実施形態のように、各ブロック4Bに対応してフラグメモリ9(W,E)及び制御ロジック10(W,E)を設ければ、ステータス領域に依存せずとも、消去或いは書込みを失敗したブロック4Bを確実に特定できる。   However, it cannot be denied that the CPU 2 is writing to the status area and that the voltage drop of the flash power supply 7 has occurred and the writing has failed. Therefore, as in the first embodiment, if the flag memory 9 (W, E) and the control logic 10 (W, E) are provided corresponding to each block 4B, erasing or writing is possible without depending on the status area. It is possible to reliably identify the block 4B that has failed.

すなわち、第1実施形態の書込みチェックにおいて、ステップS25でステータス領域を参照して有効ブロック4Bを特定している。しかし、必ずしもステータス領域を参照する必要はなく、最初から各ブロック4Bのフラグメモリ9Wだけを参照しても、書込みを失敗したブロック4Bの特定は可能である。   That is, in the write check of the first embodiment, the valid block 4B is specified with reference to the status area in step S25. However, it is not always necessary to refer to the status area, and even if only the flag memory 9W of each block 4B is referred to from the beginning, it is possible to identify the block 4B in which writing has failed.

本発明は上記した、又は図面に記載した実施形態にのみ限定されるものではなく、以下のような変形又は拡張が可能である。
ブロック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 block 4B is not limited to 2 kbytes.
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 block 4B.
The flag memory 9 and the control logic 10 may be arranged outside the flash memory 4 as devices independent of the flash memory 4.

消去中フラグメモリ9E,制御ロジック10Eを設けて行う消去処理及び消去チェック処理については、必要に応じて行えば良い。
書込み可能な電圧や低電圧検出のための閾値電圧等は、個別の設計に応じて適宜変更すれば良い。
フラッシュメモリに限ることなく、書き換え可能な不揮発性メモリであれば適用が可能である。
The erasing process and the erasure check process performed by providing the erasing flag memory 9E and the control logic 10E may be performed as necessary.
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)

データを一括して消去可能な単位である所定サイズのブロック(4B)を複数有し、更新された複数種類のデータが、前記種類を示すIDと共に空き領域に書き込まれて記憶される不揮発性メモリ(4)を内蔵するマイクロコンピュータ(1)であって、
電源電圧が、前記不揮発性メモリへの書込みが不能となるレベルに低下したことを検出すると、低電圧検出信号を出力する低電圧検出回路(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).
前記書込み中フラグメモリと、前記制御ロジックとを、前記不揮発性メモリの内部に配置したことを特徴とする請求項1記載のマイクロコンピュータ。   2. The microcomputer according to claim 1, wherein the writing flag memory and the control logic are arranged inside the nonvolatile memory. 前記書込み中フラグメモリ及び前記制御ロジックにアクセスするためのアドレスを、前記不揮発性メモリに割り当てられるアドレスの先頭部分に設定したことを特徴とする請求項2記載のマイクロコンピュータ。   3. The microcomputer according to claim 2, wherein an address for accessing the writing flag memory and the control logic is set at a head portion of an address assigned to the nonvolatile memory. 前記書込み中フラグメモリと、前記制御ロジックとを、前記不揮発性メモリが備える各ブロックに対応して設けたことを特徴とする請求項1から3の何れか一項に記載のマイクロコンピュータ。   The microcomputer according to any one of claims 1 to 3, wherein the writing flag memory and the control logic are provided corresponding to each block included in the nonvolatile memory. 各ブロックに対応する書込み中フラグメモリ及び前記制御ロジックにアクセスするためのアドレスを、それぞれ各ブロックに割り当てられるアドレスの先頭部分に設定したことを特徴とする請求項1又は2を引用する請求項4記載のマイクロコンピュータ。   4. The reference to claim 1 or 2, wherein an address for accessing the flag memory during writing and the control logic corresponding to each block is set at a head portion of an address assigned to each block. The microcomputer as described. 前記低電圧検出信号により消去中フラグがセットされる、不揮発性の消去中フラグメモリ(9E)と、
この消去中フラグメモリに対する前記消去中フラグのセットの可否を制御する制御ロジック(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.
前記消去中フラグメモリと、当該フラグメモリに対応する制御ロジックとを、前記不揮発性メモリの内部に配置したことを特徴とする請求項6記載のマイクロコンピュータ。   7. The microcomputer according to claim 6, wherein the erasing flag memory and a control logic corresponding to the flag memory are arranged in the nonvolatile memory. 前記消去中フラグメモリ及び前記制御ロジックにアクセスするためのアドレスを、前記不揮発性メモリに割り当てられるアドレスの先頭部分に設定したことを特徴とする請求項7記載のマイクロコンピュータ。   8. The microcomputer according to claim 7, wherein an address for accessing the erasing flag memory and the control logic is set at a head portion of an address assigned to the nonvolatile memory. 前記消去中フラグメモリと、当該フラグメモリに対応する制御ロジックとを、前記不揮発性メモリが備える各ブロックに対応して設けたことを特徴とする請求項6又は7記載のマイクロコンピュータ。   8. The microcomputer according to claim 6, wherein the erasing flag memory and a control logic corresponding to the flag memory are provided corresponding to each block included in the nonvolatile memory. 各ブロックに対応する消去中フラグメモリ及び前記制御ロジックにアクセスするためのアドレスを、それぞれ各ブロックに割り当てられるアドレスの先頭部分に設定したことを特徴とする請求項9記載のマイクロコンピュータ。   10. The microcomputer according to claim 9, wherein an address for accessing the erasing flag memory and the control logic corresponding to each block is set at a head portion of an address assigned to each block. 最初に、前記消去チェック手段により消去チェックを行い、続いて、前記書込みチェック手段により書込みチェックを行うことを特徴とする請求項6から10の何れか一項に記載のマイクロコンピュータ。   11. The microcomputer according to claim 6, wherein an erase check is first performed by the erase check unit, and then a write check is performed by the write check unit. データを一括して消去可能な単位である所定サイズのブロックを複数有し、更新された複数種類のデータが、前記種類を示すIDと共に空き領域に書き込まれて記憶される不揮発性メモリのブロック管理方法であって、
前記不揮発性メモリの各ブロックに対応して設けられているステータス領域に、現在データの書込みが行われているブロックを示すために所定値を書込み、
書込み対象とするブロックに書込みを行う際に、不揮発性の書込み中フラグメモリに、電源電圧が、前記不揮発性メモリへの書込みが不能となるレベルに低下したことを検出した際に出力される低電圧検出信号による書込み中フラグのセットを可能な状態としてから、前記ブロックに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.
JP2013181245A 2013-09-02 2013-09-02 Microcomputer and non-volatile memory block management method Expired - Fee Related JP6040895B2 (en)

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 true JP2015049722A (en) 2015-03-16
JP6040895B2 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)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111061427A (en) * 2019-10-22 2020-04-24 安徽力高新能源技术有限公司 Method for preventing task cycle from being blocked due to off-chip flash access
JP2020204921A (en) * 2019-06-18 2020-12-24 株式会社デンソー Data storing control unit and data storing control system

Citations (7)

* Cited by examiner, † Cited by third party
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
JP2008269635A (en) * 2008-06-02 2008-11-06 Renesas Technology Corp Semiconductor processor
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
JP2013003869A (en) * 2011-06-17 2013-01-07 Denso Corp Non-volatile semiconductor memory device and memory management method
JP2013003623A (en) * 2011-06-13 2013-01-07 Panasonic Corp Flash memory control device and flash memory control method
JP2013218371A (en) * 2012-04-04 2013-10-24 Seiko Epson Corp Information processor and data storage processing method in the same

Patent Citations (7)

* Cited by examiner, † Cited by third party
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
JP2008269635A (en) * 2008-06-02 2008-11-06 Renesas Technology Corp Semiconductor processor
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
JP2013003869A (en) * 2011-06-17 2013-01-07 Denso Corp Non-volatile 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

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2020204921A (en) * 2019-06-18 2020-12-24 株式会社デンソー Data storing control unit and data storing control system
JP7279534B2 (en) 2019-06-18 2023-05-23 株式会社デンソー Data storage controller and data storage control system
CN111061427A (en) * 2019-10-22 2020-04-24 安徽力高新能源技术有限公司 Method for preventing task cycle from being blocked due to off-chip flash access
CN111061427B (en) * 2019-10-22 2023-04-07 力高(山东)新能源技术股份有限公司 Method for preventing task cycle from being blocked due to off-chip flash access

Also Published As

Publication number Publication date
JP6040895B2 (en) 2016-12-07

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
JP4524309B2 (en) Memory controller for flash memory
JP4129381B2 (en) Nonvolatile semiconductor memory device
KR100531192B1 (en) Non-volatile memory control 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
US20050033937A1 (en) Non-volatile data storage system and data storaging method
US20100125696A1 (en) Memory Controller For Controlling The Wear In A Non-volatile Memory Device And A Method Of Operation Therefor
KR20110121897A (en) User device and program fail procerssing method thereof
JP4666081B2 (en) MEMORY CONTROLLER, FLASH MEMORY SYSTEM HAVING MEMORY CONTROLLER, AND FLASH MEMORY CONTROL METHOD
US9778862B2 (en) Data storing method for preventing data losing during flush operation, memory control circuit unit and memory storage apparatus
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
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
JP2006107363A (en) Portable electronic device and memory access method used in the same

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