JP5366159B2 - Semiconductor device and microcomputer - Google Patents

Semiconductor device and microcomputer Download PDF

Info

Publication number
JP5366159B2
JP5366159B2 JP2011194380A JP2011194380A JP5366159B2 JP 5366159 B2 JP5366159 B2 JP 5366159B2 JP 2011194380 A JP2011194380 A JP 2011194380A JP 2011194380 A JP2011194380 A JP 2011194380A JP 5366159 B2 JP5366159 B2 JP 5366159B2
Authority
JP
Japan
Prior art keywords
data
address
additional bit
flash memory
read
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
JP2011194380A
Other languages
Japanese (ja)
Other versions
JP2011243230A (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.)
Renesas Electronics Corp
Original Assignee
Renesas 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 Renesas Electronics Corp filed Critical Renesas Electronics Corp
Priority to JP2011194380A priority Critical patent/JP5366159B2/en
Publication of JP2011243230A publication Critical patent/JP2011243230A/en
Application granted granted Critical
Publication of JP5366159B2 publication Critical patent/JP5366159B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To allow the number of data items constituting an emulation writing unit (data group) in EEPROM emulation to be freely set not using a common value (fixed value) among data groups. <P>SOLUTION: In the present invention, when a first data item is written to a flash memory 4, a first additional bit for identifying the first data item is written. When a second data item is written to the flash memory 4, a second additional bit for identifying the second data item, which is different from the first additional bit, is written. <P>COPYRIGHT: (C)2012,JPO&amp;INPIT

Description

本発明は、フラッシュメモリ、メモリ制御回路、マイクロコンピュータおよびメモリ制御方法に関し、特に、付加ビットを用いてデータの書き込みおよび読み出しを実行するフラッシュメモリ、メモリ制御回路、マイクロコンピュータおよびメモリ制御方法に関する。   The present invention relates to a flash memory, a memory control circuit, a microcomputer, and a memory control method, and more particularly to a flash memory, a memory control circuit, a microcomputer, and a memory control method that execute data writing and reading using additional bits.

近年、フラッシュメモリとEEPROM(Electrically Erasable Programmable Read Only Memory)の両方の不揮発性メモリを備える半導体装置が使用されている。同じ不揮発性メモリであってもフラッシュメモリとEEPROMとでは、データの消去単位、書き換え回数、回路面積等、その特徴が異なる。   2. Description of the Related Art In recent years, a semiconductor device including both a flash memory and an EEPROM (Electrically Erasable Programmable Read Only Memory) has been used. Even in the same nonvolatile memory, flash memory and EEPROM have different characteristics such as data erasing unit, number of rewrites, circuit area, and the like.

フラッシュメモリやEEPROMにデータの書き込みを行うためには、フラッシュメモリやEEPROMを構成する記憶素子であるメモリセルに記憶されているデータを消去してからでないと新しいデータの書き込みを行うことができないが、この消去を行う単位が、フラッシュメモリとEEPROMとで異なる。フラッシュメモリは、ブロック単位での消去となるが、EEPROMはワード線とビット線とで選択可能な単位での消去となる。(以下、この単位を最小書き込み単位という。)このため、ブロック単位での消去に制約されるフラッシュメモリは、EEPROMに対しその使い方に制限を受ける。   In order to write data to the flash memory or the EEPROM, new data cannot be written unless the data stored in the memory cells that are storage elements constituting the flash memory or the EEPROM is erased. The unit for erasing is different between the flash memory and the EEPROM. The flash memory is erased in units of blocks, while the EEPROM is erased in units selectable by word lines and bit lines. (Hereinafter, this unit is referred to as a minimum writing unit.) For this reason, the flash memory that is restricted to erasing in units of blocks is limited in its use with respect to EEPROM.

また、フラッシュメモリとEEPROMとでは、その書き換え(消去)回数も異なる。例えば、マイコンに搭載されるメモリでは、フラッシュメモリが100〜1000回程度の書き換え回数が保証されるのに対し、EEPROMは1万〜10万回程度の書き換え回数が保証される。   Further, the number of rewriting (erasing) is different between the flash memory and the EEPROM. For example, in a memory mounted on a microcomputer, a flash memory is guaranteed a rewrite count of about 100 to 1000 times, whereas an EEPROM is guaranteed a rewrite count of about 10,000 to 100,000 times.

このように消去単位や書き換え(消去)回数の観点からみると、EEPROMはフラッシュメモリに比べ技術的に優位であると考えられるが、最小書き込み単位での消去を可能にするための回路構成や、フラッシュメモリに対して10〜1000倍の書き換え回数を保証するために消去の際に印加する高電界の影響に耐えることが可能なデバイス構造が必要となり、その結果、回路規模が増大する。回路規模の増大は、製造コストのアップにつながるため、このような観点では、逆に、フラッシュメモリはEEPROMに比べ有利であるといえる。   Thus, from the viewpoint of the erase unit and the number of rewrites (erase), the EEPROM is considered to be technically superior to the flash memory, but the circuit configuration for enabling the erase in the minimum write unit, A device structure that can withstand the influence of a high electric field applied at the time of erasing is required to guarantee a rewrite frequency of 10 to 1000 times that of a flash memory, resulting in an increase in circuit scale. Since an increase in circuit scale leads to an increase in manufacturing cost, from this point of view, it can be said that a flash memory is more advantageous than an EEPROM.

そこで、フラッシュメモリとEEPROMの両方の不揮発性メモリを半導体装置に搭載し、大量のデータを記憶する必要があるが書き換えを行う頻度が少ないデータに対してはフラッシュメモリを使用し、一方、記憶するデータ量は少量であるが頻繁に書き換えを行う必要があるデータに対してはEEPROMを使用するようにして、フラッシュメモリとEEPROM双方の長所を活かすように、使い分けを行って使用されている。   Therefore, both the flash memory and the EEPROM are mounted on the semiconductor device, and a large amount of data needs to be stored, but the flash memory is used for data that needs to be rewritten less frequently and is stored. For data that has a small amount of data but needs to be rewritten frequently, an EEPROM is used, and the data is used properly so as to take advantage of both the flash memory and the EEPROM.

しかし、このように異なる構造を有する複数種類のメモリの両方を搭載する半導体装置の製造プロセスは混載プロセスとなり、どちらか一方のみのメモリを搭載する半導体装置の製造プロセスに比べると、非常に多くのプロセス工程を追加しなくてはならず、製造コストが増大する要因となってしまう。   However, the manufacturing process of a semiconductor device having both of a plurality of types of memories having different structures as described above is a mixed mounting process, which is much larger than the manufacturing process of a semiconductor device having only one of the memories. Process steps must be added, which increases manufacturing costs.

そこで、使用する不揮発性メモリはフラッシュメモリだけにし、その代わりにそのフラッシュメモリの一部をEEPROMのように扱うことによって、混載プロセスを回避する技術が考え出されている。このようなフラッシュメモリをあたかもEEPROMのように使用する技術は、一般的には、EEPROMエミュレーションと呼ばれている。   In view of this, a technique has been devised that avoids a mixed process by using only a flash memory as a non-volatile memory and using a part of the flash memory like an EEPROM instead. A technique of using such a flash memory as if it is an EEPROM is generally called EEPROM emulation.

EEPROMエミュレーションは、フラッシュメモリ内の記憶領域において、まだ使用されていない領域、すなわち、データの書き込みが行われていない空き(ブランク)領域を最大限活用し、全ての領域が使用されてからブロック単位での消去を行うことで、データ更新時に付属する消去の回数を減らし、その結果、見かけ上の書き換え回数をEEPROMのように増加させる技術である。   EEPROM emulation makes full use of an area that is not yet used in the storage area in the flash memory, that is, an empty (blank) area in which no data is written, and blocks are used after all areas have been used. This is a technique for reducing the number of times of erasure attached at the time of data update, and as a result, increasing the apparent number of times of rewriting as in the case of EEPROM.

図11に、(a)EEPROMに記憶されたデータAをデータA’に書き換える(更新する)場合と、(b)フラッシュメモリに記憶されたデータAをEEPROMエミュレーションを使用してデータA’に書き換える(更新する)場合を示す。   In FIG. 11, (a) data A stored in the EEPROM is rewritten (updated) to data A ′, and (b) data A stored in the flash memory is rewritten to data A ′ using EEPROM emulation. Indicates (updating) case.

データAをデータA’に書き換える場合、通常はデータAをデータA’に上書すればよい。しかしながら、フラッシュメモリやEEPROMにおいては、消去してからでないと書き込みができない構成であるため、具体的には、ブロック単位或いは最小書き込み単位に存在する全てのメモリセルの浮遊ゲートから電荷を引き抜いた(消去した)状態にし、その後、書き込みデータに基づいて、任意のメモリセルの浮遊ゲートに電荷を注入する(書き込む)ことで、書き換えを行う。   When data A is rewritten to data A ′, data A is usually overwritten on data A ′. However, since the flash memory and the EEPROM cannot be written unless they are erased, specifically, the charge is extracted from the floating gates of all the memory cells existing in the block unit or the minimum write unit ( Rewriting is performed by injecting (writing) a charge into a floating gate of an arbitrary memory cell based on write data.

EEPROMの消去単位は、最小書き込み単位であるため、図11(a)のように書き換え対象のデータAを消去して、その場所にデータA’を書き込むことで、データAのデータA’へのEEPROMおける書き換えが完了する。   Since the erase unit of the EEPROM is the minimum write unit, the data A to be rewritten is erased as shown in FIG. Rewriting in EEPROM is completed.

一方、フラッシュメモリの書き換え単位は、ブロック単位であるため、図11(b)のようにデータA、B、Cが1ブロックの中に書き込まれている場合には、データAの上書きするためにブロック全体を消去してしまうと、データB、Cも同時に消去してしまうことになる。そこで、データB、Cを別領域に一時的に退避し、ブロック単位での消去後に、データA’、B、Cを書き込む方法を取ることによって、フラッシュメモリにおけるデータAのデータA’への書き換えを完了する。   On the other hand, the rewrite unit of the flash memory is a block unit. Therefore, when data A, B, and C are written in one block as shown in FIG. If the entire block is erased, the data B and C are also erased at the same time. Therefore, the data B and C are temporarily saved in another area, and the data A ′, B and C are rewritten to the data A ′ in the flash memory by erasing the data in blocks and then writing the data A ′, B and C. To complete.

しかし、EEPROMエミュレーションでは、図11(b)のように、ブロック内にデータA’を書き込むことができる未使用(ブランク)領域があれば、データA’をそのブランク領域に書き込む。そして、データAとA’が併存することになるので、所定の方法で、データAは既に無効となったデータであるとしてデータAの無効化を行う。   However, in the EEPROM emulation, if there is an unused (blank) area where data A 'can be written in the block as shown in FIG. 11B, the data A' is written in the blank area. Since the data A and A 'coexist, the data A is invalidated by a predetermined method, assuming that the data A is already invalidated data.

このように、EEPROMエミュレーションを使用すれば、新しいデータを書き込むためのブランク領域さえあれば、ブロック単位での消去を不要とすることができ、また、ブロック消去に伴う他のデータ(図12ではデータB、Cに相当)の一時的な退避および再度の書き込みの作業を回避することができる。すなわち、書き換え(消去)回数を削減できることから、見かけ上の書き換え回数をEEPROMのように増加することができ、また、EEPROMのように他のデータに対する保護を考慮しなくてもデータの書き換えを可能にする。   In this way, if EEPROM emulation is used, erasing in units of blocks can be made unnecessary as long as there is a blank area for writing new data, and other data (data in FIG. (Equivalent to B, C)) can be avoided. In other words, since the number of times of rewriting (erasing) can be reduced, the apparent number of times of rewriting can be increased as in the case of EEPROM, and data can be rewritten without considering protection for other data as in the case of EEPROM. To.

次に、図12〜図17を用いて、EEPROMエミュレーションについて詳細に説明する。   Next, EEPROM emulation will be described in detail with reference to FIGS.

図12に、従来のEEPROMエミュレーションの際のデータ書き込み単位(以下、エミュレーション書き込み単位という)を示す。   FIG. 12 shows a data writing unit (hereinafter referred to as an emulation writing unit) in the conventional EEPROM emulation.

エミュレーション書き込み単位に含まれるデータは、DATA_0〜DATA_nのn+1個のDATAと、そのn+1個のDATAグループの名称であるデータ番号(ID)から構成される(つまり、IDは複数のDATAと関連付けが行われたデータである)。但し、IDの値は、消去状態、つまり、未使用領域から読み出される値以外の値でなければならない。また、各データ群に含まれるDATAの数(n)は、ID毎に同じ(共通)でなければならず、異なった値であってはならない。例えば、ID=0の識別番号が付されているデータ群0に含まれるDATA数が5個であれば、ID=1の識別番号が付されているデータ群1に含まれるDATA数も5でなければならない。また、このエミュレーション書き込み単位を構成する複数のデータをまとめてデータ群と呼ぶ。   The data included in the emulation write unit is composed of n + 1 DATA_0 to DATA_n and a data number (ID) which is the name of the n + 1 DATA group (that is, the ID is associated with a plurality of DATA). Data). However, the ID value must be a value other than the erased state, that is, the value read from the unused area. The number (n) of DATA included in each data group must be the same (common) for each ID, and cannot be different. For example, if the number of DATA included in the data group 0 assigned with the identification number ID = 0 is 5, the number of DATA included in the data group 1 assigned the identification number ID = 1 is also 5. There must be. A plurality of data constituting the emulation writing unit are collectively referred to as a data group.

図13に、従来のEEPROMエミュレーション時の書き込み処理を示す動作フローチャートを示す。また、図14,図15,図16に、データ群0〜データ群2が格納されたフラッシュメモリを示す。図14,図15,図16のフラッシュメモリは、1ブロックから構成(つまり、消去単位は、フラッシュメモリ全体)され、0000H番地〜FFFFH番地の最小書き込み単位領域(番地)を持ち、それぞれの番地が格納できるデータの大きさは、8ビット(00H〜FFH)である。また、0000H番地〜0011H番地にはデータ群0〜データ群2が書き込まれており、書き込まれているデータ群0〜データ群2の各々は、DATA_0〜DATA_4とID(ID=0〜2)で構成されている。なお、図17のフラッシュメモリの消去状態をFFHであるとすると、前述の通り、IDは、消去状態のデータ領域から読み出される値とは異なる値としなければならないため、IDの取り得る値は、00H〜FEHである。また、図12に示すように、DATAやIDが格納される場所をデータ領域とする。   FIG. 13 shows an operation flowchart showing a writing process at the time of conventional EEPROM emulation. FIGS. 14, 15 and 16 show flash memories in which data group 0 to data group 2 are stored. The flash memory shown in FIGS. 14, 15 and 16 is composed of one block (that is, the erase unit is the entire flash memory) and has a minimum write unit area (address) from address 0000H to address FFFFH. The size of data that can be stored is 8 bits (00H to FFH). Data group 0 to data group 2 are written at addresses 0000H to 0011H, and each of the written data group 0 to data group 2 is DATA_0 to DATA_4 and ID (ID = 0 to 2). It is configured. If the erase state of the flash memory in FIG. 17 is FFH, as described above, the ID must be different from the value read from the data area in the erase state. 00H to FEH. Also, as shown in FIG. 12, a data area is a place where DATA and ID are stored.

図13および図14,図15,図16を用いて、EEPROMエミュレーションの時の書き込み処理について、データ群1を書き込む処理具体例と共に説明する。なお、図13に示すように、書き込み処理においては、新しいデータを書き込む領域を特定するためのブランクサーチの工程(S13−1〜S13−4)と、特定したブランク領域にDATA_0〜IDまで順次書き込む工程(S13−5〜S13−6)の2段階の処理で行われる。   The writing process at the time of EEPROM emulation will be described together with a specific example of the process of writing the data group 1 with reference to FIGS. 13, 14, 15, and 16. As shown in FIG. 13, in the writing process, blank search steps (S13-1 to S13-4) for specifying an area in which new data is to be written, and DATA_0 to ID are sequentially written in the specified blank area. This is performed in two stages of processes (S13-5 to S13-6).

(S13−1)フラッシュメモリの最終番地であるFFFFH番地からスタートし、FFFFH番地→FFFEH番地→FFFDH番地→・・・→0001H番地→0000H番地の検索方向で、データの読み出しを行う。すなわち、図12におけるフラッシュメモリのブランク領域側から読み出し処理を行っていく。   (S13-1) Data is read in the search direction starting from the FFFFH address, which is the final address of the flash memory, and starting from FFFFH address → FFFEH address → FFFFDH address →... → 0001H address → 0000H address. That is, the reading process is performed from the blank area side of the flash memory in FIG.

(S13−2)読み出した値がFFH以外の値(FFHは消去状態(未使用状態)を示す値)であるか否かを判定する。FFH以外の値が読み出された場合には、S13−4に遷移する。一方、FFHが読み出された場合には、S13−3に遷移する。   (S13-2) It is determined whether or not the read value is a value other than FFH (FFH is a value indicating an erased state (unused state)). When a value other than FFH is read, the process proceeds to S13-4. On the other hand, when FFH is read, the process proceeds to S13-3.

(S13−3)読み出し先の番地を+1ディクリメント(検索方向は最終番地から開始番地の方向なので、読み出し先の番地は、−1番地分加算する。以下、同様。)して、再度読み出しを行う。図14では、FFFFH番地〜0012H番地は、未使用(ブランク)領域なので、0012H番地までは、S13−2とS13−3の処理を繰り返すことになる。   (S13-3) Decrement the address of the read destination by +1 (the search direction is the direction from the last address to the start address, so the address of the read destination is incremented by -1 address, and so on). Do. In FIG. 14, the addresses FFFFH to 0012H are unused (blank) areas, and thus the processes of S13-2 and S13-3 are repeated up to address 0012H.

(S13−4)S13−2において、FFH以外の値が読み出された場合には、当該FFH以外の値が読み出された番地の直前に読み出した番地をブランク領域の先頭番地(書き込みを開始する番地)であると特定する。FFH以外のデータが読み出されたということは、使用領域と未使用(ブランク)領域の境界を特定することができるので、最後にFFHが読み出された番地がブランク領域の先頭番地であると判断することができる。   (S13-4) In S13-2, when a value other than FFH is read, the address read immediately before the address from which the value other than FFH is read is set to the head address of the blank area (writing starts. Specified address). When data other than FFH is read, the boundary between the used area and the unused (blank) area can be specified, so that the address at which FFH is read last is the head address of the blank area. Judgment can be made.

図14では、0011H番地においてID=2(FFH以外の値)が読み出されるので、0011H番地が使用領域の最終番地(境界)であると判断され、直前に読み出しを行った番地である0012H番地がブランク領域の先頭番地であると判断できる。なお、IDが取り得る値は00H〜FEHであると前述したが、もしIDの値がFFHであるすれば、ブランク領域との区別がつかなくなってしまうため、IDの値としてのFFHを禁止したものである。   In FIG. 14, since ID = 2 (value other than FFH) is read at address 0011H, it is determined that address 0011H is the last address (boundary) of the use area, and address 0012H, which is the address read immediately before, is determined. It can be determined that it is the head address of the blank area. It should be noted that the values that can be taken by the ID are 00H to FEH. However, if the ID value is FFH, it cannot be distinguished from the blank area, so FFH as the ID value is prohibited. Is.

(S13−5)DATA(DATA_0〜DATA_n)の書き込みを行う。書き込みは、DATA_0→DATA_1→・・・→DATA_nの順で行う。図15では、データ群0のDATA_0〜DATA_4の書き込みが行われている。   (S13-5) Data (DATA_0 to DATA_n) is written. Writing is performed in the order of DATA_0 → DATA_1 →... → DATA_n. In FIG. 15, DATA_0 to DATA_4 of data group 0 are written.

(S13−6)IDの書き込みを行う。IDの書き込みは、エミュレーション書き込み単位の最後に行われるで、IDの書き込み終了をもって、複数のデータを有するデータ群の一連の書き込み処理は完了する。   (S13-6) ID is written. Since ID writing is performed at the end of the emulation writing unit, a series of writing processing of a data group having a plurality of data is completed upon completion of ID writing.

図16では、データ群0のID=1の書き込みが終了し、DATA_0〜DATA_4およびID=1から構成されるデータ群1の書き込みが完了している。   In FIG. 16, the writing of ID = 1 in the data group 0 is completed, and the writing of the data group 1 composed of DATA_0 to DATA_4 and ID = 1 is completed.

従来のEEPROMエミュレーション時の書き込み処理は、このようなステップをもって行われ、その後新規のデータ群を書き込む際には、同様のステップで追記書き込み処理が行われる。図16では、0018H番地から新規データ群の書き込みが行われる。   The writing process at the time of conventional EEPROM emulation is performed by such steps, and when a new data group is written thereafter, the additional writing process is performed by the same steps. In FIG. 16, a new data group is written from address 0018H.

また、図14では、既に書き込まれているデータ群0〜データ群2が存在していたが、書き込まれているデータ群が全くない場合には、データの書き込みは0000H番地から行われる。また、ブランクサーチの結果、これから書き込もうとするデータ群に含まれる全てのデータを書き込むブランク領域がない場合には、消去が必要となり、その場合には前述した通り、必要なデータを保護しつつ消去を行う必要がある。   In FIG. 14, there are already written data group 0 to data group 2. However, when there is no written data group, data is written from address 0000H. As a result of the blank search, if there is no blank area in which all data included in the data group to be written is not written, erasing is necessary. In this case, erasing while protecting the necessary data as described above. Need to do.

続いて、従来のEEPROMエミュレーション時の読み出し動作について説明する。   Subsequently, a read operation during conventional EEPROM emulation will be described.

図17に、従来の読み出し処理を示す動作フローチャートを示す。図17に示すように、読み出し処理においては、読み出し対象のデータ群に含まれる複数のDATAに関連付けされたIDを検索することで読み出し対象データ群を特定するIDサーチの工程(S17−1〜S17−6)と、特定した読み出し対象データ群をフラッシュメモリから読み出す工程(S17−7)の2段階の処理で行われる。   FIG. 17 is an operation flowchart showing a conventional reading process. As shown in FIG. 17, in the read process, ID search steps (S17-1 to S17) for specifying a read target data group by searching for IDs associated with a plurality of DATA included in the read target data group. -6) and a process of reading the specified read target data group from the flash memory (S17-7).

また、具体的な事例として、図16のフラッシュメモリからデータ群0および1を読み出す事例をあげて説明する。但し、図16のフラッシュメモリは、2度目のデータ群1の書き込み(データの更新)が行われているため、最後に書き込まれたデータ群1(0012H番地〜0017H番地)が有効なデータ群であり、以前に書き込まれたデータ群1(0006H番地〜000BH番地)は、無効なデータ群として取り扱われる。   As a specific example, a case will be described in which data groups 0 and 1 are read from the flash memory of FIG. However, in the flash memory of FIG. 16, since the data group 1 is written (updated) for the second time, the last written data group 1 (addresses 0012H to 0017H) is an effective data group. Yes, previously written data group 1 (addresses 0006H to 000BH) is treated as an invalid data group.

(S17−1)フラッシュメモリの最終番地であるFFFFH番地からスタートし、FFFFH番地→FFFEH番地→FFFDH番地→・・・→0001H番地→0000H
番地の検索方向で、データの読み出しを行う。すなわち、図16のフラッシュメモリのブランク領域側から読み出し処理を行っていく。これは、前述した書き込み処理のS13−1と同じである。
(S17-1) Start from the FFFFH address which is the last address of the flash memory, and the FFFFH address → FFFEH address → FFFFH address →... → 0001H address → 0000H
Data is read in the address search direction. That is, the reading process is performed from the blank area side of the flash memory of FIG. This is the same as S13-1 of the writing process described above.

(S17−2)読み出した値がFFH(消去状態を示す値)以外の値であるか否かを判定する。FFH以外の値が読み出された場合には、S17−4に遷移し、一方、FFHが読み出された場合には、S17−3に遷移する。   (S17-2) It is determined whether or not the read value is a value other than FFH (value indicating the erased state). When a value other than FFH is read, the process proceeds to S17-4. On the other hand, when FFH is read, the process proceeds to S17-3.

(S17−3)読み出し先の番地を+1ディクリメントして、再度読み出しを行う。図16では、FFFFH番地〜0018H番地は、未使用(ブランク)領域なので、0018H番地までは、S17−2とS17−3の処理を繰り返すことになる。   (S17-3) The read destination address is decremented by +1 and read again. In FIG. 16, the addresses FFFFH to 0018H are unused (blank) areas, so the processes of S17-2 and S17-3 are repeated up to address 0018H.

(S17−4)S17−2において、FFH以外の値が読み出された場合には、その読み出した値が、読み出し対象データ群のDATAに関連付けされたID(目的のID)であるか否かを判定する。   (S17-4) When a value other than FFH is read in S17-2, whether or not the read value is an ID (target ID) associated with DATA of the read target data group. Determine.

図16において、読み出し対象のデータ群をデータ群0とすると、読み出した値がID=0であれば、目的のIDであると判断できる。S17−2で、FFH以外の値が検出されるのは、0017H番地であり、0017H番地に格納されている値は、ID=1である。従って、読み出し対象のデータ群はデータ群0であるため、読み出した値は、目的のIDではないと判断できる。一方、読み出し対象データ群をデータ群1とすると、0017H番地に格納されているデータはID=1であるため、読み出した値は、目的のIDであると判断できる。   In FIG. 16, when the data group to be read is data group 0, if the read value is ID = 0, it can be determined that the target ID is the target ID. In S17-2, a value other than FFH is detected at address 0017H, and the value stored at address 0017H is ID = 1. Therefore, since the data group to be read is the data group 0, it can be determined that the read value is not the target ID. On the other hand, assuming that the data group to be read is data group 1, since the data stored at address 0017H is ID = 1, it can be determined that the read value is the target ID.

(S17−5)読み出した値が目的のIDでない場合には、読み出し先の番地から+6ディクリメントした番地に対し、再度読み出し処理を行う。そして再度読み出した値に対して、S17−4での判定が行われる。   (S17-5) If the read value is not the target ID, the read process is performed again for the address decremented by +6 from the read address. Then, the determination in S17-4 is performed on the value read again.

図16において、読み出し対象のデータ群がデータ群0である場合には、0017H番地から+6ディクリメントした番地は0011H番地となり、この0011番地から読み出した値はID=2であるため、目的のID(ID=0)ではない。そのため、再び読み出し先の番地を+6ディクリメントする。   In FIG. 16, when the data group to be read is data group 0, the address decremented by +6 from address 0017H becomes address 0011H, and the value read from this address 0011 is ID = 2. It is not (ID = 0). Therefore, the read address is decremented by +6 again.

(S17−6)S17−4で、読み出した値が目的のIDであった場合には、当該目的のIDを読み出した番地から+5ディクリメントした番地を、読み出し対象データ群の先頭番地であると特定する。   (S17-6) If the value read in S17-4 is the target ID, the address decremented by +5 from the address from which the target ID is read is the head address of the read target data group. Identify.

図16において、データ群0を読み出す場合には、S17−4で、0005H番地に目的のIDが格納されていると判断できるので、0005H番地から+5ディクリメントした0000H番地を、読み出し対象データ群の先頭番地であると特定する。また、データ群1を読み出す場合には、S17−4で、0017H番地に目的のIDが格納されていると判断できるので、0017H番地から+5ディクリメントした0012H番地を、読み出し対象データ群の先頭番地であると特定する。   In FIG. 16, when reading the data group 0, it can be determined in S17-4 that the target ID is stored at the address 0005H, so the address 0000H decremented by +5 from the address 0005H is set as the read target data group. Specify the first address. When data group 1 is read, it can be determined in S17-4 that the target ID is stored at address 0017H. Therefore, address 0012H decremented by +5 from address 0017H is read as the first address of the data group to be read. To be identified.

(S17−7)S17−6で特定した読み出し対象データ群の先頭番地からDATA_0を読み出し、順に番地を+1インクリメントしながらDATA_1〜DATA_nを読み出す。図16において、0000H番地〜0004H番地よりDATA_0〜DATA_4を読み出すことによって、データ群0の読み出しを完了する。また、0012H番地〜0016H番地よりDATA_0〜DATA_4を読み出すことによって、データ群1の読み出しを完了する。   (S17-7) DATA_0 is read from the head address of the read target data group specified in S17-6, and DATA_1 to DATA_n are read while sequentially incrementing the address by +1. In FIG. 16, the reading of data group 0 is completed by reading DATA_0 to DATA_4 from addresses 0000H to 0004H. Further, the reading of data group 1 is completed by reading DATA_0 to DATA_4 from addresses 0012H to 0016H.

図16のフラッシュメモリでは、データ群1は更新されていて、フラッシュメモリ内にデータ群1に関するデータが2箇所に格納されているが、有効なデータ群は最後に書かれた方、すなわち、ブランク領域側に近い方である。S17−1〜S17−6で説明した方式では、ブランク領域側からIDの検索を行い、読み出した値が目的のIDと同じとなった時点で、読み出し対象データ群の検索を終了するため、フラッシュメモリ内に同じIDを有する複数のデータ群が格納されていたとしても、適切に、一番新しいデータ群、つまり、有効なデータ群を読み出すことができる。   In the flash memory of FIG. 16, the data group 1 has been updated, and the data related to the data group 1 is stored in two locations in the flash memory, but the valid data group is the last written one, that is, a blank. The one closer to the region side. In the method described in S17-1 to S17-6, the ID is searched from the blank area side, and when the read value becomes the same as the target ID, the search of the data group to be read is terminated. Even if a plurality of data groups having the same ID are stored in the memory, the newest data group, that is, an effective data group can be read out appropriately.

図16における読み出し対象データ群をデータ群1とした読み出し処理の例においても、無効なデータ群1(0006H番地〜000BH番地)を選択せずに、有効なデータ群1(0012H番地〜0017H番地)を選択している。   In the example of the reading process in which the data group to be read in FIG. 16 is the data group 1, the valid data group 1 (address 0012H to address 0017H) is selected without selecting the invalid data group 1 (address 0006H to 000BH). Is selected.

なお、図13および図17の書き込み処理フローおよび読み出し処理フローにおいて、ブランクサーチおよびIDサーチの方向をFFFFH番地(最終番地)から行うと説明したが、逆に0000H番地(開始番地)から行ってもよい。但し、その場合には、書き込み処理フローにおいては、最後にFFH以外の値が読み出された番地に+1インクリメントした番地が未使用(ブランク)領域の先頭番地となり、また、読み出し処理フローにおいては、読み出し先の番地を+6インクリメントすることでIDだけを読み出し、読み出した値がFFHになった時点でその直前に読み出したIDから順に遡って目的のIDであるかを探索する方法で、目的のIDの特定をすることができる。   In the write processing flow and the read processing flow of FIGS. 13 and 17, it has been described that the direction of blank search and ID search is performed from the address FFFFH (final address), but conversely, it may be performed from address 0000H (start address). Good. However, in that case, in the write processing flow, the address incremented by +1 to the address where the value other than FFH was read last becomes the start address of the unused (blank) area, and in the read processing flow, In this method, only the ID is read by incrementing the address of the reading destination by +6, and when the read value becomes FFH, the ID is read back in order from the ID read immediately before, and the target ID is searched. Can be specified.

また、このようなEEPROMエミュレーションに関する技術が非特許文献1に記載されている。非特許文献1では、エミュレーション書き込み単位は、データ番号、データ1、デリミタ、データ2から構成されており、データ番号としてFFH(消去状態)を禁止している。データ番号はフラッシュメモリに4バイト毎に格納される。ブロックの先頭から4バイト毎にインクリメントしながらデータ番号を読み出すことで、最新のデータの検索を行い、同一番号を持つデータ番号が複数見つかった場合には、データの終端に近いデータを最新のデータとして取り扱うことが記載されている。   Further, Non-Patent Document 1 describes a technique related to such EEPROM emulation. In Non-Patent Document 1, the emulation write unit is composed of data number, data 1, delimiter, and data 2, and FFH (erased state) is prohibited as the data number. The data number is stored in the flash memory every 4 bytes. The latest data is searched by reading the data number while incrementing every 4 bytes from the beginning of the block. If multiple data numbers with the same number are found, the data near the end of the data is updated to the latest data. It is described that it is handled as.

「アプリケーションノート U17057JJ3V0AN00」、第3版、NECエレクトロニクス株式会社、2004年11月、p.25−27“Application Note U17057JJ3V0AN00”, 3rd edition, NEC Electronics Corporation, November 2004, p. 25-27

前述のように、EEPROMエミュレーションを使用して書き込まれたデータ群の読み出し処理は、エミュレーション書き込み単位(データ群)毎に関連付けされたデータ番号(ID)の検索を行い、検索したIDが読み出し対象データのIDであるか否かを判断することで行われる。このとき、フラッシュメモリに書き込まれたデータのどこにIDが格納されているかがわからないと、IDの検索をすることができない。そのため、従来では、エミュレーション書き込み単位(データ群)に含まれるデータの個数を各エミュレーション書き込み単位(データ群)で共通とすることにより、フラッシュメモリの各番地にIDを規則的に格納することで、IDの検索を可能としている。図15では、データ群0〜データ群2において、エミュレーション書き込み単位(データ群)を、ID、DATA_0〜DATA_4からなる6個のデータから構成されるものとし、フラッシュメモリにIDを6番地ごとに規則的に配置して書き込む構成としている。   As described above, the data group written using EEPROM emulation is read out by searching for the data number (ID) associated with each emulation writing unit (data group), and the retrieved ID is read target data. This is done by determining whether or not the ID is the same. At this time, the ID cannot be searched unless the ID stored in the data written in the flash memory is known. Therefore, conventionally, by making the number of data included in an emulation write unit (data group) common to each emulation write unit (data group), by regularly storing IDs in each address of the flash memory, ID search is possible. In FIG. 15, in data group 0 to data group 2, the emulation write unit (data group) is composed of six data consisting of ID and DATA_0 to DATA_4, and the ID is assigned to the flash memory every six addresses. In this configuration, the data is arranged and written.

しかしながら、エミュレーション書き込み単位を構成するデータ数がエミュレーション書き込み単位(データ群)で共通(固定値)にしなくてはならないのは、ユーザの観点からみると、製品設計に制限がかかることとなり、大きなディメリットになってしまう。   However, the number of data composing the emulation write unit must be common (fixed value) in the emulation write unit (data group) from the user's point of view. It becomes merit.

なお、IDとして使用する値を、DATA_0〜DATA_nの値としては使わないと禁止するならば、エミュレーション書き込み単位(データ群)を構成するデータ数は、各エミュレーション書き込み単位(データ群)で共通(固定値)にしなくても、IDの検索を行うことが可能となる。但し、この場合には、ユーザが使用するDATA_0〜DATA_nそのものの値に制限を課すことになり、これはユーザによって非常に都合が悪く、実用的ではない。   If the value used as the ID is prohibited from being used as the value of DATA_0 to DATA_n, the number of data constituting the emulation write unit (data group) is common (fixed) to each emulation write unit (data group). Even if it is not set to (value), the ID can be searched. However, in this case, a limit is imposed on the value of DATA_0 to DATA_n used by the user, which is very inconvenient for the user and is not practical.

本発明のフラッシュメモリは、l(l>0)ビットの第1および第2のデータを格納するデータ領域と、前記第1のデータを識別するためのmビットの第1の付加ビットおよび前記第2のデータを識別するためのm(m>0)ビットの第2の付加ビットを格納する付加ビット領域と、を備え、前記第1の付加ビットは、前記第2の付加ビットとは異なる値を有する、ことを特徴とする。   The flash memory according to the present invention includes a data area for storing 1 (1> 0) bits of first and second data, a first additional bit of m bits for identifying the first data, and the first data And an additional bit area for storing a second additional bit of m (m> 0) bits for identifying two data, wherein the first additional bit is a value different from the second additional bit. It is characterized by having.

また、本発明のメモリ制御回路は、第1のデータおよび第2のデータから構成されるデータ単位でフラッシュメモリへのアクセスを行うメモリ制御回路であって、前記メモリ制御回路は、前記第1のデータを前記フラッシュメモリ書き込むときには、前記第1のデータを識別するための第1の付加ビットを書き込み、前記第2のデータを前記フラッシュメモリに書き込むときには、前記第2のデータを識別するための前記第1の付加ビットとは異なる第2の付加ビットを書き込む、ことを特徴とする。   The memory control circuit of the present invention is a memory control circuit that accesses the flash memory in units of data composed of first data and second data, and the memory control circuit includes the first data When writing data to the flash memory, a first additional bit for identifying the first data is written, and when writing the second data to the flash memory, the second data is identified. A second additional bit different from the first additional bit is written.

また、本発明のマイクロコンピュータは、フラッシュメモリと、中央演算装置と、第1のデータおよび第2のデータから構成されるデータ単位で、前記中央演算装置の命令に従って前記フラッシュメモリへのアクセスを行うメモリ制御回路と、を備えるマイクロコンピュータであって、前記メモリ制御回路は、前記第1のデータを前記フラッシュメモリ書き込むときには、前記第1のデータを識別するための第1の付加ビットを書き込み、前記第2のデータを前記フラッシュメモリに書き込むときには、前記第2のデータを識別するための前記第1の付加ビットとは異なる第2の付加ビットを書き込む、ことを特徴とする。   The microcomputer according to the present invention accesses the flash memory in accordance with an instruction from the central processing unit in a data unit composed of a flash memory, a central processing unit, and first data and second data. A memory control circuit, wherein the memory control circuit writes a first additional bit for identifying the first data when writing the first data to the flash memory, When writing the second data to the flash memory, a second additional bit different from the first additional bit for identifying the second data is written.

また、本発明のメモリ制御方法は、第1のデータおよび前記第1のデータから構成されるデータ単位でフラッシュメモリへのアクセスを行うメモリ制御方法であって、前記第1のデータおよび前記第1のデータを識別するための第1の付加ビットを前記フラッシュメモリに書き込む第1の工程と、前記第2のデータおよび前記第2のデータを識別するための前記第1の付加ビットとは異なる第2の付加ビットを前記フラッシュメモリに書き込む第2の工程と、を備えることを特徴とする。   The memory control method of the present invention is a memory control method for accessing a flash memory in units of data composed of first data and the first data, wherein the first data and the first data A first step of writing a first additional bit for identifying the data to the flash memory and a first additional bit different from the first additional bit for identifying the second data and the second data And a second step of writing two additional bits to the flash memory.

本発明によれば、エミュレーション書き込み単位のデータ数、すなわち、DATA_0〜DATA_nのnの値は、各データ群で共通にしなくてもよく、データ群毎に自由に設定することが可能となり、ユーザの設計自由度が向上する。   According to the present invention, the number of data in the emulation writing unit, that is, the value n of DATA_0 to DATA_n does not have to be common to each data group, and can be freely set for each data group. Design freedom is improved.

本発明の実施の形態1に係るマイクロコンピュータの構成を示すブロック図である。It is a block diagram which shows the structure of the microcomputer which concerns on Embodiment 1 of this invention. 本発明の実施の形態1のマイクロコンピュータが備えるフラッシュメモリの構成を示す概念図である。It is a conceptual diagram which shows the structure of the flash memory with which the microcomputer of Embodiment 1 of this invention is provided. 本発明の実施の形態1に係る書き込みデータ(エミュレーション書き込み単 位)のデータ構造を示す図である。It is a figure which shows the data structure of the write data (emulation write unit) which concerns on Embodiment 1 of this invention. 本発明の実施の形態1に係る書き込み処理フローを示す動作フローチャートである。It is an operation | movement flowchart which shows the write-in processing flow which concerns on Embodiment 1 of this invention. 本発明の実施の形態1に係る書き込み処理を示す図(フラッシュメモリ)である。It is a figure (flash memory) which shows the write-in process based on Embodiment 1 of this invention. 本発明の実施の形態1に係る書き込み処理を示す図(フラッシュメモリ)である。It is a figure (flash memory) which shows the write-in process based on Embodiment 1 of this invention. 本発明の実施の形態1に係るフラッシュメモリの番地の割り当ての変形例を示す図である。It is a figure which shows the modification of allocation of the address of the flash memory which concerns on Embodiment 1 of this invention. 本発明の実施の形態1に係るフラッシュメモリの番地の割り当ての変形例を示す図である。It is a figure which shows the modification of allocation of the address of the flash memory which concerns on Embodiment 1 of this invention. 本発明の実施の形態1に係る読み出し処理フローを示す動作フローチャートである。It is an operation | movement flowchart which shows the read-out process flow which concerns on Embodiment 1 of this invention. 本発明の実施の形態2に係るデータ書き込み順序を示す図である。It is a figure which shows the data write order which concerns on Embodiment 2 of this invention. 従来のEEPROMおよびフラッシュメモリ(EEPROMエミュレーション使用)に対するデータの書き換え(更新)を示す図である。It is a figure which shows the rewriting (update) of the data with respect to the conventional EEPROM and flash memory (EEPROM emulation use). 従来の書き込みデータ(エミュレション書き込み単位)のデータ構造を示す図である。It is a figure which shows the data structure of the conventional write data (emulation write unit). 従来の書き込み処理フローを示す動作フローチャートである。It is an operation | movement flowchart which shows the conventional write-in processing flow. 従来の書き込み処理を示す図(フラッシュメモリ)である。It is a figure (flash memory) which shows the conventional write processing. 従来の書き込み処理を示す図(フラッシュメモリ)である。It is a figure (flash memory) which shows the conventional write processing. 従来の書き込み処理を示す図(フラッシュメモリ)である。It is a figure (flash memory) which shows the conventional write processing. 従来の読み出し処理フローを示す動作フローチャートである。It is an operation | movement flowchart which shows the conventional read-out processing flow.

以下、本発明の好ましい実施例について、図面を参照して詳細に説明する。   Hereinafter, preferred embodiments of the present invention will be described in detail with reference to the drawings.

実施の形態1
図1は、実施の形態1に係るマイクロコンピュータの構成を示すブロック図である。マイクロコンピュータ1は、中央演算装置(CPU)2、メモリ制御回路3およびフラッシュメモリ4を備えている。CPU2は、バス5、6を介して、それぞれメモリ制御回路3およびフラッシュメモリ4に接続されている。CPU2は、メモリ制御回路3に対し、書き込み/読み出し命令、書き込み/読み出し先のアドレス(番地)および書き込みデータを出力する。また、フラッシュメモリ4から読み出されたデータを取得する。メモリ制御回路3は、フラッシュメモリ4と配線7を介して接続されており、フラッシュメモリ対し、書き込み/読み出しの制御信号(ライト/リードモードの制御信号)、書き込み/読み出し先のアドレス(番地)および書き込みデータを出力する。フラッシュメモリ4は、メモリ制御回路3からの制御信号等に基づいて、書き込み/読み出しの動作を行い、読み出しの場合には、読み出したデータをCPUに出力する。
Embodiment 1
FIG. 1 is a block diagram showing the configuration of the microcomputer according to the first embodiment. The microcomputer 1 includes a central processing unit (CPU) 2, a memory control circuit 3, and a flash memory 4. The CPU 2 is connected to the memory control circuit 3 and the flash memory 4 via buses 5 and 6, respectively. The CPU 2 outputs a write / read command, a write / read destination address (address), and write data to the memory control circuit 3. Further, data read from the flash memory 4 is acquired. The memory control circuit 3 is connected to the flash memory 4 via the wiring 7, and for the flash memory, a write / read control signal (write / read mode control signal), a write / read destination address (address), and Write data is output. The flash memory 4 performs a write / read operation based on a control signal from the memory control circuit 3, and outputs the read data to the CPU in the case of reading.

図2は、実施の形態1に係るマイクロコンピュータ1に搭載されたフラッシュメモリ4の構成を示す概念図である。図2に示すフラッシュメモリ4は、1つのブロックから構成(つまり、消去単位はフラッシュメモリ4全体)され、0000H番地〜FFFFH番地の最小書き込み単位領域(番地)を持ち、それぞれの番地が格納できるデータの大きさは9ビット長(000H〜1FFH)である。すなわち、図17等の従来のフラッシュメモリに対し、実施の形態1に係るフラッシュメモリ4は、それぞれの番地に対してメモリセルを1ビット追加した構成になっている。   FIG. 2 is a conceptual diagram showing a configuration of the flash memory 4 mounted on the microcomputer 1 according to the first embodiment. The flash memory 4 shown in FIG. 2 is composed of one block (that is, the erase unit is the entire flash memory 4), has a minimum write unit area (address) from addresses 0000H to FFFFH, and can store each address. Is 9 bits long (000H to 1FFH). That is, the flash memory 4 according to the first embodiment has a configuration in which one bit of a memory cell is added to each address with respect to the conventional flash memory of FIG.

9ビット長のデータは、本来取り扱う8ビット長のデータに1ビット長の付加ビット(後述する)を加えて構成される。本説明においては、本来取り扱うデータを8ビット長のデータとしているが、8ビット長に関わらず、lビット(但し、l>0)であればよく、また、付加ビットに関しても、1ビット長に関わらず、mビット(但し、m>0)であればよい。但し、フラッシュメモリ4に対し、lビット長のデータとmビット長の付加ビットを同時に書き込み/読み出し処理を行う場合には、配線7は、少なくともl+mビット幅を有する必要があり、フラッシュメモリ4についても、l+mビット幅の信号が入力できる端子が必要になる。なお、8ビット長のデータが格納される領域をデータ領域とし、また付加ビットが格納される領域を付加ビット領域とする。   The 9-bit data is constituted by adding an additional bit (described later) to the 8-bit data originally handled. In this description, the data to be handled is assumed to be 8-bit length data. However, regardless of the 8-bit length, it may be 1 bit (where l> 0), and the additional bits are also 1-bit length. Regardless, m bits (where m> 0) are sufficient. However, when writing / reading data of 1-bit length and additional bits of m-bit length to the flash memory 4 at the same time, the wiring 7 needs to have at least l + m-bit width. However, a terminal capable of inputting a signal having a width of 1 + m bits is required. An area where 8-bit data is stored is a data area, and an area where additional bits are stored is an additional bit area.

また、フラッシュメモリ4の0000H番地〜000EH番地には、データ群0〜データ群2が既に書き込まれているものとし、未使用領域の読み出し値、すなわち、消去状態の読み出し値を1FFH(1Hの付加ビット+FFHのデータ)とする。   Further, it is assumed that data group 0 to data group 2 have already been written in addresses 0000H to 000EH of the flash memory 4, and the read value of the unused area, that is, the read value in the erased state is set to 1FFH (addition of 1H). Bit + FFH data).

図3(a)〜(d)に、実施の形態1に係るエミュレーション書き込み単位(データ群)の一般的なデータ構造および図2のフラッシュメモリ4に書き込まれたデータ群0〜データ群2を示す。   3A to 3D show a general data structure of the emulation write unit (data group) according to the first embodiment and data group 0 to data group 2 written in the flash memory 4 of FIG. .

図3(a)には、エミュレーション書き込み単位(データ群)の一般的なデータ構造を示す。従来と同様、エミュレーション書き込み単位(データ群)8は、DATA_0〜DATA_nのn個のDATA9と、そのn+1個のDATAグループの名称であるデータ番号(ID)10から構成される(つまり、IDは複数のDATAと関連付けが行われたデータである)。   FIG. 3A shows a general data structure of an emulation write unit (data group). As in the prior art, the emulation write unit (data group) 8 is composed of n DATA9 of DATA_0 to DATA_n and a data number (ID) 10 which is the name of the n + 1 DATA group (that is, there are a plurality of IDs). Data associated with the other DATA).

しかし、従来と比較して、2点の相違がある。1点目は、データ群を構成する複数のデータのそれぞれに対して、付加ビットと呼ばれる1ビット長のデータが付加されることである。図3(a)に示す通り、DATA_0〜DATA_nには、1Hの付加ビット10が付加され、IDには、0Hの付加ビット11が付加される。これらの付加ビットは、DATA_0〜DATA_nやIDの識別を可能とするために、付加されるものである。   However, there are two differences compared to the conventional case. The first point is that 1-bit data called additional bits is added to each of a plurality of data constituting the data group. As shown in FIG. 3A, an additional bit 10 of 1H is added to DATA_0 to DATA_n, and an additional bit 11 of 0H is added to ID. These additional bits are added to enable identification of DATA_0 to DATA_n and ID.

2点目は、nの値は、各データ群で共通の値を取らず、自由に設定できる点である。(b)〜(d)に示すデータ群0〜データ群2のデータ構造が示されているが、それぞれのデータ群は、データ群0が5個、データ群1が3個、データ群2が7個のデータで構成されている。なお、n=1、つまり、DATA_0とIDから構成されるデータ群であってもよい。   The second point is that the value of n can be freely set without taking a common value in each data group. Although the data structures of data group 0 to data group 2 shown in (b) to (d) are shown, each data group has five data groups 0, three data groups 1, and two data groups 2. It consists of 7 pieces of data. Note that n = 1, that is, a data group composed of DATA_0 and ID may be used.

次に、本発明の実施形態1に係るEEPROMエミュレーション時の書き込み動作について説明する。   Next, a write operation during EEPROM emulation according to the first embodiment of the present invention will be described.

図4に、実施の形態1に係る書き込み処理を示す動作フローチャートを示す。   FIG. 4 shows an operation flowchart showing the writing process according to the first embodiment.

図1、図2および4を用いて、図4の書き込み処理フローに従い、図1に示すマイクロコンピュータ1が、図2に示すフラッシュメモリ4の未使用(ブランク)領域に、データ群1(図3(b)参照)を書き込む処理についての具体例と共に説明する。なお、図4に示すように、書き込み処理は、書き込み先を特定するためのブランクサーチの工程(S4−1〜S4−4)と、特定したブランク領域に1H+DATA_0〜1H+DATA_n、0H+IDを順次書き込む工程(S4−5〜S4−6)の2段階の処理で行われる。   1, 2, and 4, according to the write processing flow of FIG. 4, the microcomputer 1 shown in FIG. 1 stores data group 1 (FIG. 3) in an unused (blank) area of the flash memory 4 shown in FIG. 2. (B) will be described together with a specific example of the process of writing. As shown in FIG. 4, in the writing process, a blank search process (S4-1 to S4-4) for specifying a writing destination and 1H + DATA_0 to 1H + DATA_n and 0H + ID are sequentially written in the specified blank area. This is performed in two stages of processes (S4-5 to S4-6).

(S4−1)CPU2は、フラッシュメモリ4の最終番地であるFFFFH番地からスタートし、FFFFH番地→FFFEH番地→FFFDH番地→・・・→0001H番地→0000H番地の検索方向で、付加ビットの読み出しを行う。   (S4-1) The CPU 2 starts from the FFFFH address which is the last address of the flash memory 4, and reads the additional bits in the search direction of FFFFH address → FFFEH address → FFFFDH address →... → 0001H address → 0000H address. Do.

具体的には、CPU2は、メモリ制御回路3に対し、読み出し命令および読み出し先の番地(最初の読み出し先はFFFFH番地)を出力する。CPU2の読み出し命令を受けたメモリ制御回路3は、フラッシュメモリ4に対し、読み出し先として指定された番地に格納されている9ビット長のデータの読み出し制御を行う。フラッシュメモリ4は、読み出した9ビット長のデータをCPU2に出力する。CPU2は、フラッシュメモリ4から読み出した9ビット長のデータの中から付加ビットを判別し取得する。   Specifically, the CPU 2 outputs a read command and a read destination address (the first read destination is an FFFFH address) to the memory control circuit 3. The memory control circuit 3 that has received the read command from the CPU 2 controls the flash memory 4 to read out the 9-bit data stored at the address designated as the read destination. The flash memory 4 outputs the read 9-bit data to the CPU 2. The CPU 2 determines and acquires additional bits from the 9-bit data read from the flash memory 4.

(S4−2)CPU2は、読み出した付加ビットが0Hであるか否かを判定する。0Hの付加ビットが読み出された場合には、S4−4に遷移する。一方、1Hの付加ビットが読み出された場合には、S4−3に遷移する。   (S4-2) The CPU 2 determines whether or not the read additional bit is 0H. When the additional bit of 0H is read, the process proceeds to S4-4. On the other hand, when the additional bit of 1H is read, the process proceeds to S4-3.

(S4−3)CPU2は、読み出し先の番地を+1ディクリメント(検索方向は最終番地から開始番地の方向であるため、読み出し先の番地は、−1番地分加算する。以下、同様。)して、再度付加ビットの読み出しを行う。   (S4-3) The CPU 2 decrements the address of the reading destination by +1 (since the search direction is the direction from the last address to the starting address, the address of the reading destination is added by -1 address. The same applies hereinafter). Then, the additional bit is read again.

図2では、FFFFH番地〜000FH番地まで未使用(ブランク)領域であり、付加ビット領域の読み出し値は、消去状態の1Hであるため、000FH番地までは、S4−2とS4−3の処理を繰り返すことになる。   In FIG. 2, since it is an unused (blank) area from address FFFFH to address 000FH and the read value of the additional bit area is 1H in the erased state, the processing of S4-2 and S4-3 is performed until address 000FH. Will repeat.

(S4−4)CPU2は、S4−2において、0Hの付加ビットを読み出した場合には、当該0Hの付加ビットを読み出した番地の直前に読み出し処理を行った番地をブランク領域の先頭番地(書き込みを開始する番地)であると特定する。0Hの付加ビットが読み出されたということは、その番地から開始番地まではデータが書き込まれていることになり、当該番地は、使用領域と未使用(ブランク)領域の境界であると判断することができる。従って、最後に1Hの付加ビットが読み出された番地がブランク領域の先頭番地であると特定することができる。   (S4-4) When the CPU 2 reads the additional bit of 0H in S4-2, the CPU 2 sets the address where the reading process was performed immediately before the address where the additional bit of 0H was read out (the write address of the blank area) Is specified). When the additional bit of 0H is read, data is written from the address to the start address, and it is determined that the address is a boundary between the used area and the unused (blank) area. be able to. Therefore, it is possible to specify that the address from which the 1H additional bit is read last is the head address of the blank area.

図2では、000EH番地において0Hの付加ビットが読み出されるので、000EH番地が使用領域の最終番地(境界)であると判断され、直前に読み出し処理を行った番地である000FH番地がブランク領域の先頭番地、つまり、これから新しいデータの書き込みを開始する番地であると特定できる。   In FIG. 2, since an additional bit of 0H is read at the address 000EH, it is determined that the address 000EH is the last address (boundary) of the use area, and the address 000FH which is the address where the read process was performed immediately before is the head of the blank area. It is possible to specify the address, that is, the address from which new data writing is started.

(S4−5)CPU2は、DATA(DATA_0〜DATA_n)および付加ビットの書き込みを行う。   (S4-5) The CPU 2 writes DATA (DATA_0 to DATA_n) and additional bits.

具体的には、CPU2は、S4−4において特定したブランク領域の先頭番地を書き込み先の番地として指定し、書き込みデータを1H+DATA_0として、メモリ制御回路3に出力する。メモリ制御回路3は、フラッシュメモリ4の指定された番地に対し、1H+DATA_0の書き込み制御を行う。続いて、CPU2は、書き込み先の番地を+1インクリメントし、当該番地を指定して、書き込みデータを1H+DATA_1として、メモリ制御回路3に出力する。メモリ制御回路3は、フラッシュメモリ4の指定された番地に対し、1H+DATA_1の書き込み制御を行う。同様に、1H+DATA_2〜1H+DATA_nまで、フラッシュメモリ4に対する書き込み処理を行う。図2のフラッシュメモリ4にデータ群1(DATA_0、DATA_1、IDから構成)を書き込む処理では、000FH番地に1H+DATA_0を、0010H番地に1H+DATA_1をそれぞれ書き込む(図5)。   Specifically, the CPU 2 designates the head address of the blank area identified in S4-4 as the write destination address, and outputs the write data to the memory control circuit 3 as 1H + DATA_0. The memory control circuit 3 controls writing of 1H + DATA_0 to the designated address of the flash memory 4. Subsequently, the CPU 2 increments the write destination address by +1, designates the address, and outputs the write data to the memory control circuit 3 as 1H + DATA_1. The memory control circuit 3 controls writing of 1H + DATA_1 to the designated address of the flash memory 4. Similarly, the writing process to the flash memory 4 is performed from 1H + DATA_2 to 1H + DATA_n. In the process of writing the data group 1 (consisting of DATA_0, DATA_1, and ID) to the flash memory 4 of FIG. 2, 1H + DATA_0 is written to address 000FH and 1H + DATA_1 is written to address 0010H (FIG. 5).

(S4−6)CPU2は、メモリ制御回路3を介して、付加ビット(0H)およびIDの書き込みを行う。IDに付加される付加ビットは0Hであるので、S4−5で最後に書き込みを行った番地に+1インクリメントし、当該番地を指定して、0H+IDを書き込む。IDの書き込みは、エミュレーション書き込み単位の最後に行われるで、IDの書き込み終了をもって、エミュレーション書き込み単位での一連の書き込み処理は完了する。図6では、0011H番地に0H+IDを書き込む。   (S4-6) The CPU 2 writes the additional bit (0H) and ID via the memory control circuit 3. Since the additional bit added to the ID is 0H, the address that was last written in S4-5 is incremented by +1, the address is designated, and 0H + ID is written. Since the ID writing is performed at the end of the emulation writing unit, the series of writing processes in the emulation writing unit is completed upon completion of the ID writing. In FIG. 6, 0H + ID is written at address 0011H.

本発明の実施の形態1のEEPROMエミュレーション時の書き込み処理は、このようなステップを持って行われ、その後新規のデータ群の書き込みを行う際には、同様のステップを持って追記書き込みが行われる。図6では、0012H番地から新規データの書き込み処理が行われる。   The writing process at the time of EEPROM emulation according to the first embodiment of the present invention is performed with such steps. When a new data group is subsequently written, additional writing is performed with the same steps. . In FIG. 6, new data is written from address 0012H.

また、S4−1において、フラッシュメモリ4から付加ビットの読み出しを行う際に、同じ番地内のデータ領域に格納されている8ビット長のデータも同時に読み出しているが、付加ビットの1ビットのみを読み出す構成にしてもよい。その場合には、例えば、図7に示すように、付加ビットが格納される付加ビット領域とDATAやIDが格納されるデータ領域のそれぞれに対し番地を割り当て(従って、フラッシュメモリ4に割り当てられる番地は、00000000H番地〜FFFFFFFFH番地となり、それぞれが最小書き込み単位となる)、CPU2がメモリ制御回路3に対し、付加ビット領域に割り当てられた番地のみを指定する形式にする。具体的には、S4−1における読み出し先の番地は、FFFFFFFEH番地→FFFFFFFCH番地→FFFFFFFA番地→・・・→00000001H番地→00000000H番地となる。   In S4-1, when reading additional bits from the flash memory 4, 8-bit data stored in the data area in the same address is simultaneously read, but only one additional bit is read. It may be configured to read. In this case, for example, as shown in FIG. 7, an address is assigned to each of the additional bit area in which the additional bits are stored and the data area in which DATA and ID are stored (therefore, the address assigned to the flash memory 4). Are addresses 00000000H to FFFFFFFFH, each of which is a minimum writing unit), and the CPU 2 instructs the memory control circuit 3 to specify only the address assigned to the additional bit area. Specifically, the address of the reading destination in S4-1 is FFFFFFFEH address → FFFFFFFCH address → FFFFFFFA address → ... → 00000001H address → 00000000H address.

また、図8に示す通り、付加ビット領域を指定する0H番地とデータ領域を指定する1H番地をそれぞれ示す追加の番地を作成し、2つの番地を用いて、付加ビットのみを読み出せるようにしてもよい。   Further, as shown in FIG. 8, an additional address indicating 0H address specifying the additional bit area and 1H address specifying the data area is created, and only the additional bits can be read using the two addresses. Also good.

なお、従来と同様、既に書き込まれているデータ群がなければ、データの書き込みは、0000H番地からとなる。また、S4−1〜S4−4のブランクサーチの工程での説明では省いたが、ブランク領域があっても、これから書き込もうとするデータ群に含まれる全てのデータが書き込むだけのブランク領域が存在しない場合には、フラッシュメモリ4にブランク領域がないものと判断し、必要なデータ群(今回の書き込みに関係ないデータ群)を保護しつつ、フラッシュメモリ4全体の消去を行い、消去後のフラッシュメモリ4に必要なデータの書き戻し処理と新しいデータ群の書き込み処理をそれぞれ行う。   As in the prior art, if there is no data group already written, data is written from address 0000H. Although omitted in the description of the blank search process of S4-1 to S4-4, even if there is a blank area, there is no blank area for writing all the data included in the data group to be written. In this case, it is determined that there is no blank area in the flash memory 4, and the entire flash memory 4 is erased while protecting a necessary data group (data group not related to the current writing), and the flash memory after erasure is performed. 4 performs a data write-back process and a new data group write process.

続いて、本発明の実施の形態1に係るEEPROMエミュレーション時の読み出し動作について説明する。   Next, a read operation during EEPROM emulation according to Embodiment 1 of the present invention will be described.

図9に、実施の形態1に係る読み出し処理を示す動作フローチャートを示す。読み出し処理においては、0Hの付加ビットを検索し、検索により見つかった0Hの付加ビットと同じ番地に格納されているデータ領域のIDを読み出し、読み出したIDが読み出す対象のデータ群に含まれる複数のDATAに関連付けられたIDか否かを判定することで、読み出し対象データを特定するIDサーチの工程(S9−1〜S9−5)と、特定した読み出し対象データを読み出す工程(S9−6)の2段階の処理で行われる。   FIG. 9 shows an operation flowchart showing the read processing according to the first embodiment. In the reading process, the 0H additional bit is searched, the ID of the data area stored at the same address as the 0H additional bit found by the search is read, and the read ID is included in a plurality of data groups to be read. By determining whether or not the ID is associated with DATA, an ID search process (S9-1 to S9-5) for specifying read target data and a process for reading the specified read target data (S9-6) This is done in two stages.

また、具体例として、図6のフラッシュメモリ4からデータ群0および1を読み出す事例をあげて説明する。なお、図6のフラッシュメモリ4は、2度目のデータ群1の書き込み(データの更新)が行われているため、最後に書き込まれたデータ群1(000FH番地〜0011H番地)が有効なデータ群であり、以前に書き込まれたデータ群1(0005H番地〜0007H番地)は、無効なデータ群として取り扱われる。   As a specific example, a case where data groups 0 and 1 are read from the flash memory 4 of FIG. 6 will be described. In the flash memory 4 in FIG. 6, since the data group 1 is written (updated) for the second time, the last written data group 1 (addresses 000FH to 0011H) is an effective data group. The previously written data group 1 (addresses 0005H to 0007H) is treated as an invalid data group.

(S9−1)CPU2は、フラッシュメモリ4の最終番地であるFFFFH番地からスタートし、FFFFH番地→FFFEH番地→FFFDH番地→・・・→0001H番地→0000H番地の検索方向で、付加ビットの読み出しを行う。   (S9-1) The CPU 2 starts from the FFFFH address which is the final address of the flash memory 4, and reads the additional bits in the search direction of FFFFH address → FFFEH address → FFFFDH address → ... → 0001H address → 0000H address. Do.

具体的には、CPU2は、メモリ制御回路3に対し、読み出し命令および読み出し先の番地(最初の読み出し先はFFFFH番地)を出力する。CPU2の読み出し命令を受けたメモリ制御回路3は、フラッシュメモリ4に対し、読み出し先として指定された番地に格納されている9ビット長のデータの読み出し制御を行う。フラッシュメモリ4は、読み出した9ビット長のデータをCPU2に出力する。CPU2は、フラッシュメモリ4から読み出した9ビット長のデータの中から付加ビットを判別し取得する。本ステップは、書き込み処理のS4−1と同様の処理となる。   Specifically, the CPU 2 outputs a read command and a read destination address (the first read destination is an FFFFH address) to the memory control circuit 3. The memory control circuit 3 that has received the read command from the CPU 2 controls the flash memory 4 to read out the 9-bit data stored at the address designated as the read destination. The flash memory 4 outputs the read 9-bit data to the CPU 2. The CPU 2 determines and acquires additional bits from the 9-bit data read from the flash memory 4. This step is the same process as S4-1 of the writing process.

(S9−2)CPU2は、取得した付加ビットが0Hであるか否かを判定する。0Hであった場合には、S9−4に遷移し、1Hであった場合には、S9−3に遷移する。   (S9-2) The CPU 2 determines whether or not the acquired additional bit is 0H. If it is 0H, the process proceeds to S9-4, and if it is 1H, the process proceeds to S9-3.

(S9−3)S9−2で、CPU2が取得した付加ビットが1Hであった場合には、読み出し先の番地を+1ディクリメントして、再度読み出しを行いS9−2に遷移する。
図6では、FFFFH番地〜0012H番地まで未使用(ブランク)領域であり、付加ビット領域の読み出し値は消去状態の1Hであるため、0012H番地までは、S9−2とS9−3の処理を繰り返すことになる。
(S9-3) If the additional bit acquired by the CPU 2 is 1H in S9-2, the address of the read destination is decremented by +1, read again, and the process proceeds to S9-2.
In FIG. 6, since it is an unused (blank) area from address FFFFH to address 0012H and the read value of the additional bit area is 1H in the erased state, the processes of S9-2 and S9-3 are repeated until address 0012H. It will be.

(S9−4)CPU2は、S9−2において、付加ビットの値として0Hを取得した場合には、当該0Hの付加ビットが格納された同じ番地から読み出した8ビット長のデータ(ID)が、読み出し対象データ群のDATAに関連付けされたID(目的のID)であるか否かを判定する。読み出したIDが目的のIDであった場合には、S9−5に遷移する。一方、読み出したIDが目的のIDでなかった場合には、S9−3に遷移し、再び0Hの付加ビットを見つけるまで、S9−2とS9−3の処理を繰り返す。   (S9-4) When CPU 2 acquires 0H as the value of the additional bit in S9-2, the 8-bit data (ID) read from the same address where the additional bit of 0H is stored is It is determined whether or not the ID (target ID) associated with DATA of the read target data group. If the read ID is the target ID, the process proceeds to S9-5. On the other hand, if the read ID is not the target ID, the process proceeds to S9-3, and the processes of S9-2 and S9-3 are repeated until an additional bit of 0H is found again.

図6において、読み出し対象をデータ群0とすると、読み出したIDがID=0であれば、読み出し対象データに関連付けされたIDであると判断できる。S9−2で、IDが読み出されるのは、0011H番地であり、0011H番地に格納されている値は、ID=1である。従って、読み出し対象はデータ群0であるため、このIDは、目的のIDではないと判断できる。そのため、S9−3に遷移し、読み出し先の番地を+1ディクリメントし、再び0Hの付加ビットをフラッシュメモリ4から読み出すまで、S9−2とS9−3の処理を繰り返し、0Hの付加ビットが読み出された場合には、同じ番地のデータ領域に格納されたIDが目的のIDか否かを判定する。0Hの付加ビットが読み出されるのは、000EH番地、0007H番地、0004H番地であるが、目的のID(ID=0)が格納されているのは、0004H番地であるので、0004H番地まで、S9−2〜S9−4の処理を繰り返す。一方、読み出し対象をデータ群1とすると、0011H番地に格納されているデータはID=1であるため、このIDは、目的のIDであると判断でき、S9−5に遷移する。   In FIG. 6, when the read target is a data group 0, if the read ID is ID = 0, it can be determined that the ID is associated with the read target data. In S9-2, the ID is read out at address 0011H, and the value stored at address 0011H is ID = 1. Therefore, since the read target is the data group 0, it can be determined that this ID is not the target ID. Therefore, the process proceeds to S9-3, the address of the read destination is decremented by +1, and the processing of S9-2 and S9-3 is repeated until the additional bit of 0H is read from the flash memory 4 again, and the additional bit of 0H is read. If issued, it is determined whether or not the ID stored in the data area of the same address is the target ID. The additional bits of 0H are read out at addresses 000EH, 0007H, and 0004H, but since the target ID (ID = 0) is stored at address 0004H, up to address 0004H, S9− The processing of 2 to S9-4 is repeated. On the other hand, if the read target is the data group 1, since the data stored at address 0011H is ID = 1, it can be determined that this ID is the target ID, and the process proceeds to S9-5.

(S9−5)S9−4で、目的のIDを特定することができた場合には、当該目的のIDを読み出した番地から+5ディクリメントした番地を、読み出し対象データ群の先頭番地であると特定する。   (S9-5) If the target ID can be specified in S9-4, the address decremented by +5 from the address from which the target ID is read is the head address of the read target data group. Identify.

図6において、データ群0を読み出す場合には、S9−4で、0004H番地が目的のIDであると判定されるので、0004H番地から+4ディクリメントした番地は0000H番地となり、この0000H番地を、読み出し対象のデータ群0の先頭番地であると特定する。+4ディリメントするのは、データ群0は、DATA_0〜DATA_3、IDの5個のデータから構成されていることがわかっているので、DATA_0が格納されている番地は、IDが格納されている番地から+4ディクリメントした番地となるからである。   In FIG. 6, when the data group 0 is read, it is determined in S9-4 that the address 0004H is the target ID, so the address decremented by +4 from the address 0004H becomes the address 0000H, and this address 0000H is It identifies that it is the head address of the data group 0 to be read. Since it is known that the data group 0 is composed of five data items DATA_0 to DATA_3 and ID, the address where DATA_0 is stored is from the address where the ID is stored. This is because the address is decremented by +4.

また、データ群1を読み出す場合には、0011H番地が目的のIDであるので、0011H番地から+2ディクリメント(データ群1は3個のデータから構成されている)した番地は000FH番地となり、この000FH番地を、読み出し対象データのデータ群1の先頭番地であると特定する。   When data group 1 is read, since address 0011H is the target ID, the address decremented by +2 from address 0011H (data group 1 is composed of three data) becomes address 000FH. The address 000FH is specified as the head address of the data group 1 of the read target data.

(S9−6)S9−5で特定した読み出し対象データの先頭番地からDATA_0を読み出し、順に番地を+1インクリメントしながらDATA_1〜DATA_nを読み出す

図6において、0000H番地〜0003H番地よりDATA_0〜DATA_3を読み出すことによって、データ群0の読み出しを行う。また、000FH番地〜0010H番地よりDATA_0、DATA_1を読み出すことによって、データ群1の読み出しを行う。
(S9-6) DATA_0 is read from the head address of the read target data specified in S9-5, and DATA_1 to DATA_n are read while sequentially incrementing the address by +1.
In FIG. 6, data group 0 is read by reading DATA_0 to DATA_3 from addresses 0000H to 0003H. Data group 1 is read by reading DATA_0 and DATA_1 from addresses 000FH to 0010H.

図6のフラッシュメモリ4では、データ群1が更新されていて、そのためデータ群1に関するデータ群が2箇所に格納されているが、有効なデータ群は最後に書かれた方、すなわち、ブランク領域側に近い方である。S9−1〜S9−6で説明した方式では、ブランク領域側から0Hの付加ビット(ID)の検索を行い、目的のIDが特定された時点で読み出し対象データの検索を終了するため、フラッシュメモリ4内に同じIDを有する複数のデータ群が格納されていたとしても、適切に一番新しいデータ群、つまり、有効なデータ群を読み出すことができる。図6におけるデータ群1の読み出しの例においても、無効なデータ群1(0005H番地〜0007H番地)を選択せずに、有効なデータ群1(000FH番地〜0011H番地)を選択している。   In the flash memory 4 of FIG. 6, the data group 1 is updated, and therefore the data group related to the data group 1 is stored in two places, but the valid data group is the last written one, that is, a blank area. Closer to the side. In the method described in S9-1 to S9-6, a search is performed for an additional bit (ID) of 0H from the blank area side, and the search for data to be read is terminated when a target ID is specified. Even if a plurality of data groups having the same ID are stored in 4, the most recent data group, that is, an effective data group can be read out appropriately. In the example of reading data group 1 in FIG. 6, valid data group 1 (address 000FH to address 0011H) is selected without selecting invalid data group 1 (address 0005H to address 0007H).

また、S9−5において、読み出し対象のデータ群のIDが格納された番地を基準にして、読み出し対象のデータ群のDATA_0が格納された番地を特定する方法を説明したが、目的のIDが読み出された番地から順次+1ディリメントして1Hの付加ビット+DATAを読み出していき、0Hの付加ビット+IDが読み出された時点で、読み出し対象のデータ群の読み出しを終了する方法をとってもよい。この方式では、事前にデータ群が何個のデータ数で構成されているか否かわからない場合に有効である。   In S9-5, the method of specifying the address where DATA_0 of the data group to be read is stored is described with reference to the address where the ID of the data group to be read is stored. A method may be used in which 1H is sequentially decremented from the issued address, 1H additional bit + DATA is read, and when the 0H additional bit + ID is read, reading of the data group to be read is terminated. This method is effective when it is not known in advance whether or not the data group is composed of the number of data.

なお、図4および9の書き込み処理フローおよび読み出し処理フローにおいて、ブランクサーチおよびIDサーチの方向をFFFFH番地(最終番地)から行うと説明したが、従来の説明でも記載したように、逆に0000H番地(開始番地)から行ってもよい。但し、その場合には、書き込み処理フローにおいては、最後に0Hの付加ビットを読み出した番地に+1インクリメントした番地が未使用(ブランク)領域の先頭番地となり、また、読み出し処理フローにおいても、最後に目的のIDを読み出した番地が有効なデータ群のIDであると特定することになる。   In the write processing flow and the read processing flow of FIGS. 4 and 9, it has been described that the direction of blank search and ID search is performed from the address FFFFH (last address). However, as described in the conventional description, address 0000H is reversed. You may go from (start address). However, in that case, in the write processing flow, the address incremented by +1 to the address from which the 0H additional bit was read last becomes the first address of the unused (blank) area. The address from which the target ID is read out is specified as the ID of a valid data group.

このように、本実施の形態によれば、EEPROMエミュレーション時のエミュレーション書き込み単位を構成するデータ数は、IDが異なるエミュレーション書き込み単位間、つまり、データ群間において、共通の値でなくてもよい。そのため、ユーザは、自由にデータ群に含まれるデータ数を設定することができるようになり、その結果、ユーザの設計自由度が向上することになる。   As described above, according to the present embodiment, the number of data constituting an emulation write unit at the time of EEPROM emulation does not have to be a common value between emulation write units with different IDs, that is, between data groups. Therefore, the user can freely set the number of data included in the data group, and as a result, the user's design freedom is improved.

また、書き込み処理におけるブランクサーチの工程および読み出し処理におけるIDサーチの工程において、IDを検索するのに付加ビットのみを確認すればよいことから、従来に比べ、IDの検出手段が容易となる。   In addition, in the blank search process in the writing process and the ID search process in the reading process, only the additional bits need to be checked to search for the ID.

実施の形態2
図10は、本発明の実施の形態2に関するデータの書き込み順序を示したものである。実施の形態2では、書き込み処理における0H+IDを書き込む際の書き込み順序に実施の形態1と異なる特徴がある。従って、これ以外の点においては、実施の形態1と同じであるので説明は省略する。
Embodiment 2
FIG. 10 shows the data writing order according to the second embodiment of the present invention. The second embodiment is different from the first embodiment in the writing order when writing 0H + ID in the writing process. Accordingly, since the other points are the same as those in the first embodiment, description thereof will be omitted.

EEPROMエミュレーションの書き込み処理では、エミュレーション書き込み単位毎に複数のデータ(DATA_0〜DATA_n、ID)および付加ビットをフラッシュメモリ4に書き込む(S4−4およびS4−5)。実施の形態1では、最後に0H+IDを書き込むと説明したが(S4−5)、実施の形態2では、1H+ID→0H+FFHという2ステップに分けて書き込みを行う。   In the EEPROM emulation writing process, a plurality of data (DATA_0 to DATA_n, ID) and additional bits are written to the flash memory 4 for each emulation writing unit (S4-4 and S4-5). In the first embodiment, it has been described that 0H + ID is written last (S4-5), but in the second embodiment, writing is performed in two steps of 1H + ID → 0H + FFH.

フラッシュメモリ4は、消去状態(例えば、フラッシュメモリ4を構成する複数のメモリセルの浮遊ゲートに電荷がない状態)を1Hとしているため、1Hの付加ビットの書き込み、或いは、FFH(11111111B)のデータの書き込みは、フラッシュメモリ4構成するメモリセルに対して、実際には何ら動作を行わない。すなわち、1ステップ目の1H+IDは、フラッシュメモリ4内のデータ領域のみに対して書き込みを行う処理であり、付加ビット領域に対する書き込み処理は行われない。また逆に、2ステップ目の0H+FFHは、フラッシュメモリ4内の付加ビット領域にのみに対して書き込みを行う処理であり、データ領域に対する書き込み処理は行われない。換言すれば、1ステップ目にIDを書き込み、2ステップ目、つまり、一連の書き込み処理の最後に0Hの付加ビットが書き込まれることになる。   Since the flash memory 4 has an erased state (for example, a state in which there is no charge in the floating gates of a plurality of memory cells constituting the flash memory 4) as 1H, 1H additional bit write or FFH (11111111B) data Is actually not performed on the memory cells constituting the flash memory 4. That is, 1H + ID in the first step is a process of writing only to the data area in the flash memory 4, and the writing process to the additional bit area is not performed. Conversely, 0H + FFH in the second step is a process of writing only to the additional bit area in the flash memory 4, and the writing process to the data area is not performed. In other words, the ID is written in the first step, and the additional bit of 0H is written in the second step, that is, at the end of a series of writing processes.

図10に示す通り、まず1H+DATA_0の書き込みを行う(S10−1)。次に1H+DATA_1の書き込みを行う(S10−2)。同様に、1H+DATA_2〜1H+DATA_nまでの書き込みを行う(S10−3〜S10−5)。   As shown in FIG. 10, first, 1H + DATA_0 is written (S10-1). Next, 1H + DATA_1 is written (S10-2). Similarly, writing is performed from 1H + DATA_2 to 1H + DATA_n (S10-3 to S10-5).

DATAの書込みが終了後、0H+IDの書き込みを行う。まずIDだけの書き込みを行うため、1H+IDの書き込みを行う(S10−6)。最後に0Hの付加ビットの書き込みを行うため、0H+FFHの書き込みを行う(S10−7)。以上で、付加ビットおよびDATA_0〜DATA_n、IDからなる1個のデータ群の書き込みが完了する。   After writing DATA, 0H + ID is written. First, since only ID is written, 1H + ID is written (S10-6). Finally, in order to write an additional bit of 0H, writing of 0H + FFH is performed (S10-7). Thus, writing of one data group including the additional bits, DATA_0 to DATA_n, and ID is completed.

このように、本実施の形態によれば、0Hの付加ビットを最後に書くことにより、電源瞬停等に起因する書き込みエラーが発生していないことを確認することができる。すなわち、最後に書き込まれた0Hの付加ビットが正しく読み出せたとすると、その前に書かれたDATA_0〜DATA_n、IDの書き込みは正常に実行されたと判断することができるからである。   As described above, according to the present embodiment, it is possible to confirm that no write error due to a momentary power interruption or the like has occurred by writing the additional bit of 0H last. That is, if the last 0H additional bit written can be read correctly, it can be determined that the previous writing of DATA_0 to DATA_n and ID has been executed normally.

以上、本発明の実施の形態に基づいて詳細に説明したが、本発明は、上述のような実施の形態に限定されるものでなく種々の変形が可能である。例えば、付加ビットは1ビット長に限定されるわけではなく、2ビット長以上であってもよい。また、図面では、付加ビットは、識別する8ビット長のデータと同じ番地に、9ビット長のデータの最上位ビットの位置に配置されるように書かれているが、それに限られるわけではない。さらに、図8において、付加ビット領域と、データ領域が交互に配置されているが、どのように配置されていてもかまわない。また、実施の形態の説明では、CPU2が、メモリ制御回路3に対する書き込み/読み出し命令や、書き込みデータの生成、読み出した値の判定を行っているが、この機能の全て、或いは、一部をメモリ制御回路3が実行しても構わない。逆に、メモリ制御回路3が担うフラッシュメモリ4に対する直接的なアクセス制御機能を、メモリ制御回路3を介さずに、CPU2が実行してもよい。さらには、実施の形態1と実施の形態2を組み合わせることなども可能である。   As mentioned above, although it demonstrated in detail based on embodiment of this invention, this invention is not limited to the above embodiment, A various deformation | transformation is possible. For example, the additional bits are not limited to 1-bit length and may be 2 bits or more. In the drawing, the additional bits are written to be arranged at the same address as the 8-bit data to be identified at the most significant bit position of the 9-bit data. However, the present invention is not limited to this. . Further, in FIG. 8, the additional bit areas and the data areas are alternately arranged, but they may be arranged in any way. In the description of the embodiment, the CPU 2 performs write / read commands for the memory control circuit 3, generation of write data, and determination of read values, but all or part of this function is stored in the memory. The control circuit 3 may execute it. Conversely, the CPU 2 may execute a direct access control function for the flash memory 4, which the memory control circuit 3 performs, without using the memory control circuit 3. Furthermore, the first embodiment and the second embodiment can be combined.

1 マイクロコンピュータ
2 CPU
3 メモリ制御回路
4 フラッシュメモリ
5、6 バス
7 信号配線
8 エミュレーション書き込み単位(データ群)
9 DATA
10 データ番号(ID)
11、12 付加ビット
1 Microcomputer 2 CPU
3 Memory control circuit 4 Flash memory 5 and 6 Bus 7 Signal wiring 8 Emulation write unit (data group)
9 DATA
10 Data number (ID)
11, 12 Additional bits

Claims (15)

フラッシュメモリと、
データ群の単位で前記フラッシュメモリへアクセスするメモリ制御回路と
を備えた半導体装置であって、
前記データ群は、
データと前記データに関連づけられた付加情報である付加ビットデータとの組を複数備え、
前記フラッシュメモリは、
前記データを複数格納するデータ領域と
前記付加ビットデータを複数格納する付加ビット領域と
を備え、
前記メモリ制御回路は、
前記フラッシュメモリへの前記データ群の書き込み時は、
前記データが前記データ群の識別情報である第1のデータの場合、前記第1のデータに関連付けられた第1の付加ビットデータを前記付加ビット領域に書き込み、
前記データが前記データ群の識別情報でない第2のデータの場合、前記第2のデータに関連付けられ前記第1の付加ビットデータとは異なる第2の付加ビットデータを前記付加ビット領域に書き込み、
前記データ群の読み出し時は、
アドレスを昇順または降順のいずれか一方の第1の方向または前記第1の方向とは逆の第2の方向のいずれか一方の方向に、前記フラッシュメモリのアドレスを変えて、前記付加ビット領域の各アドレスに格納された値を読み出し、
読み出した値が第1の値と同じ値であるアドレスに格納された前記付加ビットデータに関連付けられた前記第1のデータを抽出し、
抽出された第1のデータが読み出すべき識別情報であるデータ群を読み出す
ことを特徴とする半導体装置。
Flash memory,
A semiconductor device comprising a memory control circuit that accesses the flash memory in units of data groups,
The data group is:
A plurality of sets of data and additional bit data which is additional information associated with the data;
The flash memory is
A data area for storing a plurality of the data, and an additional bit area for storing a plurality of the additional bit data,
The memory control circuit includes:
When writing the data group to the flash memory,
When the data is first data that is identification information of the data group, the first additional bit data associated with the first data is written to the additional bit area,
For the second data the data is not identification information of the group of data, write the different second additional bit data to the additional bit region and said associated second data first added bit data ,
When reading the data group,
The address of the flash memory is changed in one of the first direction in ascending order or descending order or the second direction opposite to the first direction, and the address of the additional bit area is changed. Read the value stored at each address,
Extracting the first data associated with the additional bit data stored at an address whose read value is the same as the first value;
A semiconductor device which reads a data group which is identification information to be read by the extracted first data .
前記メモリ制御回路は、
前記データ群の書き込み時、
アドレスを前記第1の方向に、前記フラッシュメモリのアドレスを変えて、前記付加ビット領域の各アドレスに格納された値を読み出し、
読み出した値が、前記第1の付加ビットデータの値となった第1のアドレスを検出し、
前記第1のアドレスから見て、前記第2の方向に変えたアドレスを基点に前記データ群を書き込む
ことを特徴とする請求項1に記載の半導体装置。
The memory control circuit includes:
When writing the data group,
The address in the first direction, by changing the address of the flash memory, reads the values stored in each address of the additional bit region,
Detecting a first address whose read value is the value of the first additional bit data;
Wherein when viewed from a first address, before Symbol semiconductor device according to claim 1, characterized in that writing the data group the addresses changed in the second direction to the origin.
前記メモリ制御回路は、
前記データ群の書き込み時、
前記データ群を前記組単位で前記フラッシュメモリに書き込み、1つの組の書き込みごとに前記アドレスを前記第2の方向に変えて書き込む
こと特徴とする請求項2に記載の半導体装置。
The memory control circuit includes:
When writing the data group,
3. The semiconductor device according to claim 2, wherein the data group is written in the flash memory in units of sets, and the address is changed in the second direction for each set of writing.
前記メモリ制御回路は、
前記データ群の書き込み時、
前記第1のデータと前記第1の付加ビットデータとの組を前記データ群の書き込みの最後に行う
ことを特徴とする請求項3に記載の半導体装置。
The memory control circuit includes:
When writing the data group,
4. The semiconductor device according to claim 3, wherein a set of the first data and the first additional bit data is performed at the end of writing of the data group.
前記メモリ制御回路は、
前記データ群の書き込み時、
前記組のデータを書き込んだ後、前記組の付加ビットデータを書き込む
ことを特徴とする請求項3または4のいずれか一に記載の半導体装置。
The memory control circuit includes:
When writing the data group,
5. The semiconductor device according to claim 3, wherein the additional bit data of the set is written after the set of data is written.
前記第1の付加ビットデータは、前記フラッシュメモリの消去状態を示す値と逆の値である第1の値である
ことを特徴とする請求項1乃至のいずれか一に記載の半導体装置。
First additional bit data, the semiconductor device according to any one of claims 1 to 5, characterized in that said a first value is a value opposite value indicating an erase state of the flash memory.
前記第1の値は0である
ことを特徴とする請求項6に記載の半導体装置。
The semiconductor device according to claim 6, wherein the first value is zero.
前記第2の付加ビットデータは1である
ことを特徴とする請求項1乃至のいずれか一に記載の半導体装置。
The semiconductor device according to any one of claims 1 to 7, characterized in that said second additional bit data is 1.
前記データが格納された前記データ領域のアドレスと前記付加ビットデータが格納された前記付加ビット領域のアドレスとが同一である場合、
前記メモリ制御回路は、前記データと前記付加ビットデータとを関連付ける
ことを特徴とする請求項1乃至のいずれか一に記載の半導体装置。
When the address of the data area where the data is stored and the address of the additional bit area where the additional bit data is stored are the same,
Said memory control circuit, the semiconductor device according to any one of claims 1 to 8, characterized in that associating the said data and said additional bit data.
前記データが格納された前記データ領域のアドレスの一部が前記付加ビットデータが格納された付加ビット領域のアドレスの一部と同一である場合、
前記メモリ制御回路は、前記データと前記付加ビットデータとを関連付ける
ことを特徴とする請求項1乃至のいずれか一に記載の半導体装置。
When a part of the address of the data area where the data is stored is the same as a part of the address of the additional bit area where the additional bit data is stored,
Said memory control circuit, the semiconductor device according to any one of claims 1 to 8, characterized in that associating the said data and said additional bit data.
前記付加ビットデータのビット長は、1ビットである
ことを特徴とする請求項1乃至10のいずれか一に記載の半導体装置。
The bit length of the additional bit data, the semiconductor device according to any one of claims 1 to 10, characterized in that one bit.
前記フラッシュメモリの付加ビット領域の1アドレスに対応付けられたビット幅が1ビットである
ことを特徴とする請求項1乃至10のいずれか一に記載の半導体装置。
The semiconductor device according to any one of claims 1 to 10, wherein the bit width associated with one address of the additional bit area of the flash memory is one bit.
前記第1のデータと前記第1の付加ビットデータとの組と前記第2のデータと前記第2の付加ビットデータとの組とは、
前記データ領域および前記付加ビット領域の互いに異なるアドレスに格納される
ことを特徴とする請求項1に記載の半導体装置。
The set of the first data and the first additional bit data, the set of the second data and the second additional bit data are:
The semiconductor device according to claim 1, wherein the data area and the additional bit area are stored at different addresses.
前記半導体装置は、さらに中央演算装置を備え、
前記メモリ制御回路は、前記中央演算装置の命令に従って、前記フラッシュメモリへのアクセスを実行する
ことを特徴とする請求項1乃至11のいずれか一に記載の半導体装置。
The semiconductor device further includes a central processing unit,
The memory control circuit according to an instruction of said central processing unit, a semiconductor device according to any one of claims 1 to 11, characterized in that for executing access to the flash memory.
フラッシュメモリと、
中央演算装置と、
前記中央演算装置の命令に従って、データ群の単位で前記フラッシュメモリへアクセスするメモリ制御回路と
を備えるマイクロコンピュータであって、
前記データ群は、
データと前記データに関連づけられた付加情報である付加ビットデータとの組を複数備え、
前記フラッシュメモリは、
前記データを複数格納するデータ領域と
前記付加ビットデータを複数格納する付加ビット領域と
を備え、
前記メモリ制御回路は、
前記フラッシュメモリへの前記データ群の書き込み時は、
前記データが前記データ群の識別情報である第1のデータの場合、前記第1のデータに関連付けられた第1の付加ビットデータを前記付加ビット領域に書き込み、
前記データが前記データ群の識別情報でない第2のデータの場合、前記第2のデータに関連付けられ前記第1の付加ビットデータとは異なる第2の付加ビットデータを前記付加ビット領域に書き込み、
前記データ群の読み出し時は、
アドレスを昇順または降順のいずれか一方の第1の方向または前記第1の方向とは逆の第2の方向のいずれか一方の方向に、前記フラッシュメモリのアドレスを変えて、前記付加ビット領域の各アドレスに格納された値を読み出し、
読み出した値が第1の値と同じ値であるアドレスに格納された前記付加ビットデータに関連付けられた前記第1のデータを抽出し、
抽出された第1のデータが読み出すべき識別情報であるデータ群を読み出す
ことを特徴とするマイクロコンピュータ。
Flash memory,
A central processing unit;
A microcomputer comprising a memory control circuit for accessing the flash memory in units of data groups according to instructions of the central processing unit,
The data group is:
A plurality of sets of data and additional bit data which is additional information associated with the data;
The flash memory is
A data area for storing a plurality of the data, and an additional bit area for storing a plurality of the additional bit data,
The memory control circuit includes:
When writing the data group to the flash memory,
When the data is first data that is identification information of the data group, the first additional bit data associated with the first data is written to the additional bit area,
For the second data the data is not identification information of the group of data, write the different second additional bit data to the additional bit region and said associated second data first added bit data ,
When reading the data group,
The address of the flash memory is changed in one of the first direction in ascending order or descending order or the second direction opposite to the first direction, and the address of the additional bit area is changed. Read the value stored at each address,
Extracting the first data associated with the additional bit data stored at an address whose read value is the same as the first value;
A microcomputer which reads a data group which is identification information to be read by the extracted first data .
JP2011194380A 2011-09-06 2011-09-06 Semiconductor device and microcomputer Expired - Fee Related JP5366159B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2011194380A JP5366159B2 (en) 2011-09-06 2011-09-06 Semiconductor device and microcomputer

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2011194380A JP5366159B2 (en) 2011-09-06 2011-09-06 Semiconductor device and microcomputer

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
JP2005368634A Division JP4999325B2 (en) 2005-12-21 2005-12-21 Flash memory

Publications (2)

Publication Number Publication Date
JP2011243230A JP2011243230A (en) 2011-12-01
JP5366159B2 true JP5366159B2 (en) 2013-12-11

Family

ID=45409751

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2011194380A Expired - Fee Related JP5366159B2 (en) 2011-09-06 2011-09-06 Semiconductor device and microcomputer

Country Status (1)

Country Link
JP (1) JP5366159B2 (en)

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2251324B (en) * 1990-12-31 1995-05-10 Intel Corp File structure for a non-volatile semiconductor memory
JPH0635780A (en) * 1992-07-17 1994-02-10 Olympus Optical Co Ltd File controlling method of large capacity storage device
JP3588231B2 (en) * 1997-08-04 2004-11-10 東京エレクトロンデバイス株式会社 Data processing system and block erase type storage medium
JP2005085011A (en) * 2003-09-09 2005-03-31 Renesas Technology Corp Nonvolatile memory controller
JP4748708B2 (en) * 2005-03-18 2011-08-17 ルネサスエレクトロニクス株式会社 Semiconductor device

Also Published As

Publication number Publication date
JP2011243230A (en) 2011-12-01

Similar Documents

Publication Publication Date Title
JP4999325B2 (en) Flash memory
US7363421B2 (en) Optimizing write/erase operations in memory devices
JP5328020B2 (en) Memory device and memory access method
US5953737A (en) Method and apparatus for performing erase operations transparent to a solid state storage system
US9431069B2 (en) Management method for nonvolatile memory system following power-off
CN109062827B (en) Flash memory control device, flash memory control system, and flash memory control method
WO2000060605A1 (en) Space management for managing high capacity nonvolatile memory
JP2007164318A (en) Storage system
CN107045423B (en) Memory device and data access method thereof
US9971682B2 (en) Wear-leveling system and method for reducing stress on memory device using erase counters
EP3057100B1 (en) Memory device and operating method of same
US20130019056A1 (en) Data Storing Method and Apparatus Applied to Flash Memory Storage Device
JP2008084184A (en) Memory controller
JP5366159B2 (en) Semiconductor device and microcomputer
CN108228095B (en) Method for recording real-time information based on Flash
US10181356B2 (en) Flash memory counter
JP6618941B2 (en) Management apparatus, information processing apparatus, and management method
JP5929398B2 (en) Nonvolatile semiconductor memory device and control method thereof
CN113870931A (en) Data writing method, data reading method, data writing device, data reading device, electronic equipment and storage medium
JP2007323159A (en) Memory controller, flash memory system therewith, and method for controlling flash memory
CN109426443B (en) Memory control apparatus and method
WO2020039927A1 (en) Non-volatile storage device, host device, and data storage system
JP5253471B2 (en) Memory controller
JP2009295089A (en) Memory access control method, memory controller, and computer program
JP6053557B2 (en) Memory management device

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20110906

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20130531

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20130717

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

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20130904

R150 Certificate of patent or registration of utility model

Ref document number: 5366159

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

Free format text: JAPANESE INTERMEDIATE CODE: R150

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