JP2015225565A - Electronic control device - Google Patents

Electronic control device Download PDF

Info

Publication number
JP2015225565A
JP2015225565A JP2014110868A JP2014110868A JP2015225565A JP 2015225565 A JP2015225565 A JP 2015225565A JP 2014110868 A JP2014110868 A JP 2014110868A JP 2014110868 A JP2014110868 A JP 2014110868A JP 2015225565 A JP2015225565 A JP 2015225565A
Authority
JP
Japan
Prior art keywords
data
storage block
writing
written
current storage
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.)
Pending
Application number
JP2014110868A
Other languages
Japanese (ja)
Inventor
智樹 和田
Tomoki Wada
智樹 和田
圭 近藤
Kei Kondo
圭 近藤
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.)
Advics Co Ltd
Original Assignee
Advics Co Ltd
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 Advics Co Ltd filed Critical Advics Co Ltd
Priority to JP2014110868A priority Critical patent/JP2015225565A/en
Publication of JP2015225565A publication Critical patent/JP2015225565A/en
Pending legal-status Critical Current

Links

Landscapes

  • Techniques For Improving Reliability Of Storages (AREA)
  • Memory System (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide an electronic control device that elongates a product life of a non-volatile memory, and enables improvement in reliability of data stored in the non-volatile memory.SOLUTION: A CPU is configured to perform: writing processing that writes up-to-date data in a current storage block different from a previous storage block having previous data written; and reading processing that reads data from a ring. The reading processing includes processing (S26) that reads the data from the current storage block when it is diagnosed that the writing of the data in the current storage block is normally completed (S23:YES); and processing (S24) that reads the data from the previous storage block when it is diagnosed that the writing of the data in the current storage block is not normally completed (S23:NO).

Description

本発明は、不揮発性メモリと、同不揮発性メモリへのデータの書き込み及び同不揮発性メモリからのデータの読み出しを行うCPUと、を備える電子制御装置に関する。   The present invention relates to an electronic control device including a nonvolatile memory and a CPU that writes data into the nonvolatile memory and reads data from the nonvolatile memory.

従来、この種の電子制御装置として、例えば特許文献1に記載される車載用の電子制御装置が提案されている。この電子制御装置の不揮発性メモリは、データの書き込み及び読み出しが可能な複数の記憶ブロックに区分けされている。そして、不揮発性メモリにデータを記憶させる場合、CPUは、各記憶ブロックのうちの1つの記憶ブロックにデータを書き込むとともに、その記憶ブロックに書き込んだデータと同一のデータを、各記憶ブロックのうちの他の記憶ブロックに書き込むようにしている。すなわち、上記の電子制御装置にあっては、1つのデータを2つの記憶ブロックに書き込むことにより、不揮発性メモリに記憶されているデータの信頼性を高めている。   Conventionally, as this type of electronic control device, for example, a vehicle-mounted electronic control device described in Patent Document 1 has been proposed. The nonvolatile memory of the electronic control device is divided into a plurality of storage blocks capable of writing and reading data. When data is stored in the non-volatile memory, the CPU writes data to one storage block of each storage block, and the same data as the data written to the storage block is stored in each storage block. The data is written to another storage block. That is, in the above electronic control device, the reliability of the data stored in the nonvolatile memory is enhanced by writing one data in two storage blocks.

特開2009−289200号公報JP 2009-289200 A

ところで、不揮発性メモリは、データの書き込み回数が増えるほど劣化が進行しやすい。例えば、データの書き込み回数がその制限回数を超えた記憶ブロックでは、データの書き込みが不能となったり、書き込まれたデータを適切に保持できなくなったりすることがある。このため、上記のように1つのデータを2つの記憶ブロックに書き込む場合にあっては、記憶ブロックの劣化が進行しやすくなり、不揮発性メモリの寿命が短くなるおそれがある。   By the way, the non-volatile memory is more likely to deteriorate as the number of data writing increases. For example, in a storage block in which the number of times data has been written exceeds the limit, data may not be written or the written data may not be retained properly. For this reason, when one data is written to two storage blocks as described above, the deterioration of the storage block is likely to proceed, and the lifetime of the nonvolatile memory may be shortened.

本発明の目的は、不揮発性メモリの長寿命化を図りつつも、同不揮発性メモリに記憶されているデータの信頼性を高めることができる電子制御装置を提供することにある。   An object of the present invention is to provide an electronic control device capable of improving the reliability of data stored in the nonvolatile memory while extending the lifetime of the nonvolatile memory.

以下、上記課題を解決するための手段及びその作用効果について記載する。
上記課題を解決する電子制御装置は、複数の記憶ブロックに区分けされている不揮発性メモリと、記憶ブロックへのデータの書き込み及び同記憶ブロックからのデータの読み出しを行うCPUと、を備える装置を前提としている。この電子制御装置において、CPUは、各記憶ブロックのうち、前回にデータを書き込んだ前回の記憶ブロックとは異なる今回の記憶ブロックにデータを書き込む書き込み処理と、不揮発性メモリからデータを読み出す読み出し処理と、を行うようになっている。そして、読み出し処理は、上記今回の記憶ブロックへのデータの書き込みが正常に完了していると診断されるときには、上記今回の記憶ブロックからデータを読み出す処理と、上記今回の記憶ブロックへのデータの書き込みが正常に完了していないと診断されるときには、上記前回の記憶ブロックからデータを読み出す処理と、を含む。
Hereinafter, means for solving the above-described problems and the effects thereof will be described.
An electronic control device that solves the above problem is premised on a device that includes a nonvolatile memory divided into a plurality of storage blocks, and a CPU that writes data to the storage blocks and reads data from the storage blocks. It is said. In this electronic control unit, the CPU includes a writing process for writing data to a current storage block different from the previous storage block in which data was written last time, and a reading process for reading data from the nonvolatile memory. , Is supposed to do. Then, in the reading process, when it is diagnosed that the writing of data to the current storage block is normally completed, the process of reading data from the current storage block and the data of the data to the current storage block are performed. When it is diagnosed that the writing has not been completed normally, a process of reading data from the previous storage block is included.

上記構成によれば、今回の書き込み処理では、前回の書き込み処理でデータが書き込まれた上記前回の記憶ブロックとは異なる1つの記憶ブロック(上記今回の記憶ブロック)にのみデータが書き込まれる。こうした状態で不揮発性メモリからデータを読み出すに際し、上記今回の記憶ブロックへのデータの書き込みが正常に完了していると診断されるときには、読み出し処理によって、上記今回の記憶ブロックからデータが読み出される。そして、その後にあっては、当該データを参照した制御処理の実施が可能となる。   According to the above configuration, in the current writing process, data is written only in one storage block (the current storage block) different from the previous storage block in which the data was written in the previous writing process. When reading data from the non-volatile memory in such a state, when it is diagnosed that the writing of data to the current storage block is normally completed, the data is read from the current storage block by a read process. Then, after that, it becomes possible to perform control processing with reference to the data.

一方、上記今回の記憶ブロックへのデータの書き込みが正常に完了していないと診断されたときには、上記今回の記憶ブロックに書き込まれたデータが、正常ではない、いわゆる破損データである可能性がある。そのため、上記前回の記憶ブロックからデータ(すなわち、前回のデータ)が読み出される。すなわち、上記前回の記憶ブロックに書き込まれているデータをバックアップデータとして利用することができる。この場合、その後にあっては、上記前回の記憶ブロックから読み出したデータを参照した制御処理の実施が可能となる。   On the other hand, when it is diagnosed that the writing of data to the current storage block is not normally completed, the data written to the current storage block may be abnormal, so-called damaged data. . Therefore, data (ie, previous data) is read from the previous storage block. That is, the data written in the previous storage block can be used as backup data. In this case, after that, it is possible to perform control processing with reference to the data read from the previous storage block.

しかも、上記構成では、1つのデータを1つの記憶ブロックにのみ書き込むようにしているため、1つのデータを複数の記憶ブロックに対して重複して書き込む場合と比較して、記憶ブロック単位でのデータの書き込み回数が少なくなり、不揮発性メモリの劣化を遅らせることができる。したがって、不揮発性メモリの長寿命化を図りつつも、同不揮発性メモリに記憶されているデータの信頼性を高めることができるようになる。   Moreover, in the above configuration, since one data is written only to one storage block, data in units of storage blocks is compared with a case where one data is written to a plurality of storage blocks in duplicate. The number of times of writing can be reduced, and the deterioration of the nonvolatile memory can be delayed. Therefore, it is possible to increase the reliability of data stored in the nonvolatile memory while extending the life of the nonvolatile memory.

なお、CPUは、書き込み処理において、初期化され、データを含む全ての情報が消去されている記憶ブロックに対し、新たなデータを書き込むようにしている。そのため、データを書き込もうとしている記憶ブロックに以前のデータが未だ残っている場合、当該記憶ブロックを消去した後に、新たなデータが当該記憶ブロックに書き込まれることとなる。この場合、記憶ブロックを初期化するために時間を要するため、当該記憶ブロックへのデータの書き込みが完了するまでに時間を要することとなる。そこで、上記電子制御装置において、書き込み処理は、上記今回の記憶ブロックにデータを書き込む処理と、同処理の完了後に実施する処理であって、且つ上記前回の記憶ブロックからデータを消去する処理と、を含むことが好ましい。   In the writing process, the CPU writes new data to a storage block that has been initialized and from which all information including data has been erased. Therefore, when previous data still remains in the storage block to which data is to be written, new data is written to the storage block after erasing the storage block. In this case, since it takes time to initialize the storage block, it takes time to complete the writing of data to the storage block. Therefore, in the electronic control device, the writing process is a process of writing data to the current storage block, a process performed after the completion of the process, and a process of erasing data from the previous storage block; It is preferable to contain.

上記構成によれば、書き込み処理が実施された後では、1つの記憶ブロックにのみデータが書き込まれており、当該記憶ブロック以外の記憶ブロックにはデータが書き込まれていない状況とすることができる。そのため、次に書き込み処理を実施する際には、書き込み対象である記憶ブロック(上記今回の記憶ブロック)は既に初期化されており、当該記憶ブロックには既にデータが書き込まれていない。そのため、書き込み処理時にあっては、書き込み対象である記憶ブロックを初期化する処理を実施しなくてもよい分、当該記憶ブロックへの今回のデータの書き込みを速やかに完了させることができるようになる。   According to the above configuration, after the writing process is performed, data can be written in only one storage block, and no data can be written in any storage block other than the storage block. Therefore, when the next writing process is executed, the storage block to be written (the current storage block) has already been initialized, and no data has been written to the storage block. For this reason, at the time of the writing process, the process of initializing the storage block to be written does not need to be performed, so that the writing of the current data to the storage block can be completed promptly. .

ところで、書き込み処理の実施最中に、電子制御装置への給電が遮断されたり、電子制御装置に印加されている電圧が著しく低くなったりすることがある。こうした場合、書き込み処理が強制的に中断され、書き込み処理が正常に完了されないことがある。このように書き込み処理が正常に完了されない場合としては、記憶ブロック(上記今回の記憶ブロック)へのデータの書き込みが途中で中断される場合を挙げることができる。この場合、当該記憶ブロックには、上記破損データ(例えば、途中まで書き込まれたデータ)が書き込まれていることとなる。そのため、次の読み出し処理では、当該記憶ブロックへのデータの書き込みが正常に完了していないと診断されるため、別の記憶ブロック(上記前回の記憶ブロック)からデータが読み出される。   By the way, during the execution of the writing process, the power supply to the electronic control device may be interrupted, or the voltage applied to the electronic control device may be significantly reduced. In such a case, the writing process is forcibly interrupted, and the writing process may not be completed normally. As a case where the writing process is not normally completed as described above, there can be mentioned a case where the writing of data to the storage block (the current storage block) is interrupted. In this case, the damaged data (for example, data written halfway) is written in the storage block. Therefore, in the next reading process, since it is diagnosed that the writing of data to the storage block is not normally completed, the data is read from another storage block (the previous storage block).

ここで、当該記憶ブロックに上記破損データを残したままにすると、その後、同破損データが残っている記憶ブロックに新たなデータを書き込む際には、当該記憶ブロックに新たなデータを書き込むに先立って、当該記憶ブロックから破損データを消去する必要が生ずる。その結果として、当該記憶ブロックへのデータの書き込みが完了するまでに時間を要することとなる。   Here, if the damaged data is left in the storage block, then when writing new data to the storage block in which the damaged data remains, prior to writing the new data in the storage block. Therefore, it becomes necessary to erase the corrupted data from the storage block. As a result, it takes time to complete the writing of data to the storage block.

そこで、上記電子制御装置において、読み出し処理は、上記今回の記憶ブロックへのデータの書き込みが正常に完了していないと診断されるときに、上記今回の記憶ブロックからデータを消去する処理を含むことが好ましい。この構成によれば、書き込み処理の開始時において、上記今回の記憶ブロックに上記破損データが未だ残っていることがなくなる。そのため、上記今回の記憶ブロックに新たなデータを書き込む際に、当該記憶ブロックから上記破損データを消去する処理を実施しなくてもよい分、当該記憶ブロックへのデータの書き込みを速やかに完了させることができるようになる。   Therefore, in the electronic control device, the reading process includes a process of erasing data from the current storage block when it is diagnosed that writing of data to the current storage block is not normally completed. Is preferred. According to this configuration, the corrupted data is not left in the current storage block at the start of the writing process. Therefore, when writing new data to the current storage block, it is not necessary to perform the process of erasing the damaged data from the storage block, so that the writing of data to the storage block is completed promptly. Will be able to.

また、上記電子制御装置において、上記データは、データ本体と、同データ本体の誤り検出符号とを有し、記憶ブロックには、データ本体が書き込まれる本体領域と、誤り検出符号が書き込まれる符号領域とを設けるようにしてもよい。この場合、書き込み処理において上記今回の記憶ブロックにデータを書き込む処理は、データ本体を上記今回の記憶ブロックの本体領域に書き込む処理と、同処理の完了後に実施される処理であって、且つ誤り検出符号を上記今回の記憶ブロックの符号領域に書き込む処理と、を含むことが好ましい。   In the electronic control device, the data has a data body and an error detection code of the data body, and the storage block has a body area in which the data body is written and a code area in which the error detection code is written. May be provided. In this case, the process of writing data to the current storage block in the writing process is a process of writing the data body to the main body area of the current storage block, a process performed after the completion of the process, and error detection. And writing the code into the code area of the current storage block.

書き込み処理が正常に完了していない場合としては、上記今回の記憶ブロックの本体領域にデータ本体を書き込んでいる最中で、書き込み処理が強制的に終了される場合を挙げることができる。この場合、上記今回の記憶ブロックの符号領域には誤り検出符号が書き込まれていない。そのため、次の読み出し処理では、上記今回の記憶ブロックの符号領域の情報を用いて、同今回の記憶ブロックへのデータの書き込みが正常に完了しているか否かを診断しても、正常に完了していると誤診断されることはない。その結果、上記前回の記憶ブロックの本体領域からデータ本体が読み出されることとなり、上記今回の記憶ブロックの本体領域から上記破損データが読み出されることを抑制することができる。   An example of the case where the writing process has not been completed normally includes a case where the writing process is forcibly terminated while the data body is being written in the main body area of the current storage block. In this case, no error detection code is written in the code area of the current storage block. Therefore, in the next read processing, even if it is diagnosed whether or not data writing to the current storage block has been completed normally using the information of the code area of the current storage block, it is completed normally. You will not be misdiagnosed. As a result, the data body is read from the main body area of the previous storage block, and it is possible to suppress reading of the corrupted data from the main body area of the current storage block.

また、書き込み処理が正常に完了していない場合としては、上記今回の記憶ブロックの符号領域に誤り検出符号を書き込んでいる最中で、書き込み処理が強制的に終了される場合を挙げることもできる。この場合、上記今回の記憶ブロックの符号領域の情報は、正しい誤り検出符号ではない。そのため、次の読み出し処理では、上記今回の記憶ブロックの符号領域の情報(すなわち、正しくない誤り検出符号)を用いて、上記今回の記憶ブロックへのデータの書き込みが正常に完了しているか否かを診断しても、正常に完了していると誤診断されにくい。そして、上記今回の記憶ブロックへのデータの書き込みが正常に完了していないと診断されたときには、上記前回の記憶ブロックの本体領域からデータ本体が読み出されることとなる。   Further, as a case where the writing process is not normally completed, a case where the writing process is forcibly terminated while the error detection code is being written in the code area of the current storage block can be cited. . In this case, the information in the code area of the current storage block is not a correct error detection code. Therefore, in the next read process, whether or not the data writing to the current storage block has been normally completed using the information of the code area of the current storage block (that is, an incorrect error detection code). Even if it is diagnosed, it is difficult to make a wrong diagnosis if it is completed normally. When it is determined that the writing of data to the current storage block is not normally completed, the data body is read from the body area of the previous storage block.

ただし、上記のように上記今回の記憶ブロックの符号領域に誤り検出符号を書き込んでいる最中で、書き込み処理が強制的に終了された場合、上記今回の記憶ブロックの符号領域の情報が、正しい誤り検出符号と偶然に一致することがある。すると、次の読み出し処理時には、上記今回の記憶ブロックへのデータの書き込みが正常に完了していると誤診断され、上記今回の記憶ブロックからデータ本体が読み出される。この場合、上記今回の記憶ブロックの本体領域には、正しいデータ本体が書き込まれているため、上記今回の記憶ブロックの本体領域からデータ本体が読み出されても、問題はない。   However, if the writing process is forcibly terminated while the error detection code is being written in the code area of the current storage block as described above, the information in the code area of the current storage block is correct. It may coincide with the error detection code by chance. Then, at the time of the next reading process, it is erroneously diagnosed that the writing of data to the current storage block is normally completed, and the data body is read from the current storage block. In this case, since the correct data body is written in the body area of the current storage block, there is no problem even if the data body is read from the body area of the current storage block.

また、上記電子制御装置において、書き込み処理は、誤り検出符号を符号領域に書き込む処理の完了後に実施する処理であって、且つ同符号領域に書き込まれている誤り検出符号を用いて、上記今回の記憶ブロックへのデータの書き込みが正常に完了したか否かを診断する処理をさらに含むようにしてもよい。そして、CPUは、書き込み処理において、上記前回の記憶ブロックからデータを消去する処理を、上記今回の記憶ブロックへのデータの書き込みが正常に完了したと診断した後に実施することが好ましい。   In the electronic control unit, the writing process is a process performed after the process of writing the error detection code in the code area is completed, and the error detection code written in the code area is used to You may make it further include the process which diagnoses whether the writing of the data to a storage block was completed normally. In the writing process, the CPU preferably performs the process of erasing data from the previous storage block after diagnosing that the writing of data to the current storage block has been normally completed.

上記構成によれば、上記今回の記憶ブロックへのデータの書き込みが正常に完了していると診断される以前に、上記前回の記憶ブロックからデータが消去されることがなくなる。そのため、上記今回の記憶ブロックへのデータの書き込みが完了するまでは、上記前回の記憶ブロックのデータをバックアップデータとして利用することが可能となる。   According to the above configuration, data is not erased from the previous storage block before it is diagnosed that the writing of data to the current storage block is normally completed. Therefore, the data in the previous storage block can be used as backup data until the writing of data to the current storage block is completed.

また、上記電子制御装置において、記憶ブロックには、他の記憶ブロックからのデータの消去が完了した旨の消去情報が書き込まれる消去情報領域をさらに設けてもよい。そして、書き込み処理は、上記前回の記憶ブロックからデータを消去する処理の完了後に、消去情報を上記今回の記憶ブロックの消去情報領域に書き込む処理をさらに含んでもよい。また、CPUは、読み出し処理において、上記前回の記憶ブロックからデータを消去する処理を、上記今回の記憶ブロックの消去情報領域に消去情報が書き込まれていないときに実施するようにしてもよい。この場合、読み出し処理は、上記前回の記憶ブロックからのデータの消去の完了後に、消去情報を上記今回の記憶ブロックの消去情報領域に書き込む処理をさらに含むことが好ましい。   In the electronic control device, the storage block may further include an erasure information area in which erasure information indicating that erasure of data from another storage block is completed is written. The writing process may further include a process of writing the erasure information in the erasure information area of the current storage block after completion of the process of erasing data from the previous storage block. Further, the CPU may perform the process of erasing data from the previous storage block in the reading process when the erasure information is not written in the erasure information area of the current storage block. In this case, it is preferable that the reading process further includes a process of writing the erasure information in the erasure information area of the current storage block after the completion of the erasure of data from the previous storage block.

上記構成によれば、前回の書き込み処理で上記前回の記憶ブロックからデータを完全に消去できなかった場合には、消去情報が上記今回の記憶ブロックの消去情報領域に書き込まれていない。そのため、次の読み出し処理時には、上記今回の記憶ブロックの消去情報領域に消去情報が書き込まれているか否かに基づき、上記前回の記憶ブロックからデータを消去する処理の実施が必要であるか否かを判断することができるようになる。   According to the above configuration, when the previous write processing cannot completely erase the data from the previous storage block, the erase information is not written in the erase information area of the current storage block. Therefore, at the time of the next read process, whether or not it is necessary to perform a process of erasing data from the previous storage block based on whether or not erase information is written in the erase information area of the current storage block. Will be able to judge.

また、上記電子制御装置において、CPUは、書き込み処理に先立って、各記憶ブロックへのデータの書き込み回数が均等となるように上記今回の記憶ブロックを各記憶ブロックの中から選別するようにしてもよい。この構成によれば、一部の記憶ブロックの劣化が、他の記憶ブロックよりも進んでしまうことを抑制することができる。   In the electronic control unit, prior to the writing process, the CPU may select the current storage block from the storage blocks so that the number of times data is written to each storage block is equal. Good. According to this configuration, it is possible to suppress the deterioration of some storage blocks from proceeding more than other storage blocks.

上記電子制御装置において、不揮発性メモリには、複数の記憶ブロックで構成されるグループが形成され、書き込み頻度の高いデータに対応するグループほど、同グループを構成する記憶ブロックの数を多くしてもよい。この構成では、一部のグループを構成する記憶ブロックの劣化が他のグループを構成する記憶ブロックよりも進んでしまうことが抑制される。したがって、不揮発性メモリの寿命を長くすることができるようになる。   In the electronic control device, a group composed of a plurality of storage blocks is formed in the non-volatile memory, and a group corresponding to data having a high writing frequency may have a larger number of storage blocks constituting the group. Good. In this configuration, it is possible to suppress the deterioration of the storage blocks constituting a part of the group from proceeding more than the storage blocks constituting the other group. Therefore, the lifetime of the nonvolatile memory can be extended.

電子制御装置の一実施形態を示すブロック図。The block diagram which shows one Embodiment of an electronic control apparatus. EEPROMに設けられる複数のリングを示す模式図。The schematic diagram which shows the some ring provided in EEPROM. リングを構成する記憶ブロックの構造を説明する模式図。The schematic diagram explaining the structure of the memory block which comprises a ring. リングのデータを更新する際にCPUが実行する処理ルーチンを示すフローチャート。The flowchart which shows the process routine which CPU performs when updating the data of a ring. リングからデータを読み出す際にCPUが実行する処理ルーチンを示すフローチャート。The flowchart which shows the process routine which CPU performs when reading data from a ring. (a)〜(e)は、リングに対してデータを書き込む様子を説明する模式図。(A)-(e) is a schematic diagram explaining a mode that data is written with respect to a ring. (a),(b)は、記憶ブロックへのデータの書き込みが正常に完了していない場合に、読み出し処理によってリングからデータを読み出す様子を説明する模式図。(A), (b) is a schematic diagram explaining how data is read from a ring by read processing when data writing to a storage block is not normally completed. (a)〜(c)は、記憶ブロックの初期化が正常に完了していない場合に、読み出し処理によってリングからデータを読み出す様子を説明する模式図。(A)-(c) is a schematic diagram explaining a mode that data is read from a ring by read-out processing when initialization of a storage block is not completed normally.

以下、電子制御装置を具体化した一実施形態について、図面を参照して説明する。なお、電子制御装置としては、例えば、車両に搭載される電子制御装置を挙げることができる。   Hereinafter, an embodiment embodying an electronic control device will be described with reference to the drawings. Examples of the electronic control device include an electronic control device mounted on a vehicle.

図1に示すように、電子制御装置10は、CPU11(中央処理装置)、RAM12、ROM13及びEEPROM14を備えている。CPU11は、RAM12、ROM13及びEEPROM14と、データを送受信するためのバス15を介して接続されている。こうした電子制御装置10には、モータなどの制御対象と、同制御対象の状態や車両の走行状態を検出するセンサとが電気的に接続されている。そして、CPU11は、センサからの検出信号に基づいて制御対象を制御する。   As shown in FIG. 1, the electronic control device 10 includes a CPU 11 (central processing unit), a RAM 12, a ROM 13, and an EEPROM 14. The CPU 11 is connected to the RAM 12, the ROM 13, and the EEPROM 14 via a bus 15 for transmitting and receiving data. The electronic control device 10 is electrically connected to a control target such as a motor and a sensor that detects the state of the control target and the running state of the vehicle. Then, the CPU 11 controls the control target based on the detection signal from the sensor.

RAM12はデータの書き込み及び読み出しが可能な揮発性メモリであり、EEPROM14はデータの書き込み及び読み出しが可能な不揮発性メモリである。一方、ROM13は、データの書き込みが不能な一方でデータの読み出しが可能なメモリである。このため、ROM13には、時間の経過とともに内容が変化しない制御プログラムなどが記憶される。一方、EEPROM14には、時間の経過とともに内容が変化する各種のデータ(例えば、学習可能な制御変数やマップ)が記憶される。また、RAM12には、例えば、センサからの検出信号に基づくセンサ値や、ROM13やEEPROM14から読み出された制御プログラムや各種のデータが一時的に記憶される。   The RAM 12 is a volatile memory capable of writing and reading data, and the EEPROM 14 is a nonvolatile memory capable of writing and reading data. On the other hand, the ROM 13 is a memory that cannot read data but can read data. For this reason, the ROM 13 stores a control program whose contents do not change with time. On the other hand, the EEPROM 14 stores various data (for example, control variables and maps that can be learned) whose contents change with time. The RAM 12 temporarily stores, for example, a sensor value based on a detection signal from the sensor, a control program read from the ROM 13 or the EEPROM 14, and various data.

また、電子制御装置10には、同電子制御装置10に電力を供給する電源装置16が接続されている。電子制御装置10と電源装置16との間には、電源装置16から電子制御装置10への給電を許容したり遮断したりするスイッチ17が設けられている。   In addition, a power supply device 16 that supplies power to the electronic control device 10 is connected to the electronic control device 10. A switch 17 is provided between the electronic control device 10 and the power supply device 16 to permit or cut off the power supply from the power supply device 16 to the electronic control device 10.

次に、図2及び図3を参照して、EEPROM14におけるデータの書き込み領域について説明する。
EEPROM14は、データの書き込み及び読み出しが可能な複数の記憶ブロックMbに区分けされている。そして、図2に示すように、これら各記憶ブロックMbが、グループの一例であるリング20に振り分けられている。すなわち、各リング20は、少なくとも2つ以上の記憶ブロックMbで構成されている。
Next, a data write area in the EEPROM 14 will be described with reference to FIGS.
The EEPROM 14 is divided into a plurality of storage blocks Mb in which data can be written and read. Then, as shown in FIG. 2, each of these storage blocks Mb is distributed to a ring 20 which is an example of a group. That is, each ring 20 includes at least two storage blocks Mb.

なお、本実施形態の電子制御装置10にあっては、リング20を構成する記憶ブロックMbの数(以下「記憶ブロック数NB」ともいう。)は、予想されるデータの更新頻度に基づき設定されている。すなわち、更新頻度の高いと予測されるデータ、すなわち書き込み頻度の高いデータが記憶されるリング20ほど、記憶ブロック数NBが多くなっている。   In the electronic control device 10 of the present embodiment, the number of storage blocks Mb constituting the ring 20 (hereinafter, also referred to as “storage block number NB”) is set based on the expected data update frequency. ing. That is, the number of storage blocks NB increases as the ring 20 stores data that is predicted to have a high update frequency, that is, data that has a high write frequency.

例えば、図2に示すように、EEPROM14には、3つのリング20(21,22,23)が予め形成されているものとする。そして、第3のリング23に対応するデータの更新頻度が、第1のリング21に対応するデータの更新頻度や第2のリング22に対応するデータの更新頻度よりも高いと予測されるため、第3のリング23の記憶ブロック数NB(例えば、4つ)は、他のリング21,22の記憶ブロック数NBよりも多い。また、第2のリング22に対応するデータの更新頻度が、第1のリング21に対応するデータの更新頻度や第3のリング23に対応するデータの更新頻度よりも低いと予測されるため、第2のリング22の記憶ブロック数NB(例えば、2つ)は、他のリング21,23の記憶ブロック数NBよりも少ない。   For example, as shown in FIG. 2, it is assumed that the EEPROM 14 has three rings 20 (21, 22, 23) formed in advance. Since the update frequency of the data corresponding to the third ring 23 is predicted to be higher than the update frequency of the data corresponding to the first ring 21 and the update frequency of the data corresponding to the second ring 22, The number of storage blocks NB (for example, four) in the third ring 23 is larger than the number of storage blocks NB in the other rings 21 and 22. Further, since the update frequency of data corresponding to the second ring 22 is predicted to be lower than the update frequency of data corresponding to the first ring 21 and the update frequency of data corresponding to the third ring 23, The number of storage blocks NB (for example, two) in the second ring 22 is smaller than the number of storage blocks NB in the other rings 21 and 23.

なお、本明細書では、リング21〜23を構成する各記憶ブロックMbのうち、図2で最も下に位置する第1の記憶ブロックMb1を「先頭の記憶ブロック」ともいう。また、リング21〜23を構成する各記憶ブロックMbのうち、図2で最も上に位置する記憶ブロックMb(第1のリング21では第3の記憶ブロックMb3、第2のリング22では第2の記憶ブロックMb2、第3のリング23では第4の記憶ブロックMb4)を、「最後尾の記憶ブロック」ともいう。   In the present specification, among the storage blocks Mb configuring the rings 21 to 23, the first storage block Mb1 positioned at the bottom in FIG. 2 is also referred to as a “first storage block”. Among the storage blocks Mb constituting the rings 21 to 23, the storage block Mb located at the top in FIG. 2 (the third storage block Mb3 in the first ring 21 and the second storage block Mb3 in the second ring 22). The storage block Mb2 and the fourth storage block Mb4 in the third ring 23) are also referred to as “the last storage block”.

ここで、あるリング(例えば、第1のリング21)からのデータの読み出し手順、及び同リングのデータの更新手順の概略について説明する。
基本的には、第1のリング21を構成する各記憶ブロックMb1〜Mb3のうち、何れか1つの記憶ブロック(例えば、第1の記憶ブロックMb1)にのみ、データが書き込まれている。そのため、第1のリング21からデータを読み出す際には、データが書き込まれている記憶ブロックMbを特定し、当該記憶ブロックMbからデータが読み出される。そして、このようにデータの読み出し処理が完了された後にあっては、当該データ(詳しくは、後述するデータ本体D1)を用いた制御処理の実施が可能となる。
Here, an outline of a procedure for reading data from a certain ring (for example, the first ring 21) and a procedure for updating data of the ring will be described.
Basically, data is written in only one of the storage blocks Mb1 to Mb3 constituting the first ring 21 (for example, the first storage block Mb1). Therefore, when reading data from the first ring 21, the storage block Mb in which the data is written is specified, and the data is read from the storage block Mb. Then, after the data reading process is completed in this way, the control process using the data (specifically, a data body D1 described later) can be performed.

一方、第1のリング21のデータを更新する際、最新のデータを書き込む記憶ブロックMbが選択される。このとき、各記憶ブロックMbのうち何れか1つの記憶ブロック(例えば、第1の記憶ブロックMb1)には、前回のデータが書き込まれている。そして、前回のデータが書き込まれている記憶ブロック以外の他の記憶ブロック(例えば、第2の記憶ブロックMb2)が選択される。すると、選択した記憶ブロックMbに最新のデータが書き込まれる。その後、選択した記憶ブロックMbに最新のデータが正常に書き込まれると、前回のデータが書き込まれている記憶ブロックMbが初期化され、同記憶ブロックMbからは、前回のデータを含む全ての情報が消去される。このように前回のデータを含む情報の消去が完了されると、データの書き込み処理が終了される。これにより、書き込み処理の終了後にあっては、リング20を構成する各記憶ブロックMbのうち何れか1つの記憶ブロックのみにデータが書き込まれている状態が作り出される。   On the other hand, when updating the data of the first ring 21, the storage block Mb into which the latest data is written is selected. At this time, the previous data is written in any one of the storage blocks Mb (for example, the first storage block Mb1). Then, a storage block other than the storage block in which the previous data is written (for example, the second storage block Mb2) is selected. Then, the latest data is written in the selected storage block Mb. Thereafter, when the latest data is normally written in the selected storage block Mb, the storage block Mb in which the previous data is written is initialized, and all information including the previous data is stored in the storage block Mb. Erased. As described above, when the erasure of the information including the previous data is completed, the data writing process is ended. Thereby, after the end of the writing process, a state is created in which data is written in only one of the storage blocks Mb constituting the ring 20.

なお、1つのリング20において、最新のデータを書き込む記憶ブロックは、所定のルールに従って選択される。すなわち、前回の書き込み処理時に第N(Nは1以上の整数)の記憶ブロックにデータを書き込んだ場合、今回の書き込み処理を実施するに際し、第N+1の記憶ブロックが選択される。ただし、第Nの記憶ブロックが上記最後尾の記憶ブロックである場合、今回の書き込み処理を実施するに際し、先頭の記憶ブロックである第1の記憶ブロックMb1が選択される。すなわち、第Nの記憶ブロックが、前回にデータを書き込んだ「前回の記憶ブロック」に相当する。また、第N+1の記憶ブロックが、「今回の記憶ブロック」に相当する。ただし、前回の記憶ブロックに相当するブロックが最後尾の記憶ブロックである場合、第1の記憶ブロックMb1が「今回の記憶ブロック」に相当することとなる。   In one ring 20, a storage block to which the latest data is written is selected according to a predetermined rule. That is, when data is written in the Nth storage block (N is an integer equal to or greater than 1) during the previous write process, the (N + 1) th storage block is selected when the current write process is performed. However, when the Nth storage block is the last storage block, the first storage block Mb1 which is the first storage block is selected when the current writing process is performed. That is, the Nth storage block corresponds to a “previous storage block” in which data was written last time. Further, the (N + 1) th storage block corresponds to the “current storage block”. However, when the block corresponding to the previous storage block is the last storage block, the first storage block Mb1 corresponds to the “current storage block”.

次に、記憶ブロックMbに書き込まれるデータの構成と、記憶ブロックMbの構造とについて説明する。
データには、制御処理の実施時に使用される制御変数やマップ等に該当するデータ本体D1と、同データ本体D1の誤り検出符号の一例としてのチェックサムD2とが設けられている。チェックサムD2は、データ本体D1の所定の記憶領域への書き込みが正常に完了しているか否かを診断する際に用いられる。
Next, the configuration of data written to the storage block Mb and the structure of the storage block Mb will be described.
The data is provided with a data body D1 corresponding to a control variable, a map or the like used when the control process is performed, and a checksum D2 as an example of an error detection code of the data body D1. The checksum D2 is used when diagnosing whether writing to a predetermined storage area of the data body D1 is normally completed.

図3に示すように、記憶ブロックMbは、データのデータ本体D1が書き込まれる本体領域S1と、チェックサムD2が書き込まれる符号領域S2と、他の記憶ブロックに書き込まれていた全ての情報の消去が完了した旨の消去情報D3が書き込まれる消去情報領域S3とを含んでいる。例えば、書き込み処理によって第2の記憶ブロックMb2にデータ(すなわち、データ本体D1とチェックサムD2)を書き込んだときには、第1の記憶ブロックMb1に書き込まれている全ての情報が消去される。ここでいう「情報」とは、データ(データ本体D1及びチェックサムD2)と消去情報D3とを含んでいる。そして、こうした情報の消去が完了した旨の消去情報D3が第2の記憶ブロックMb2の消去情報領域S3に書き込まれる。また、以降の説明では、符号領域S2に書き込まれたチェックサムD2と区別するために、本体領域S1に書き込まれたデータ本体D1から生成されるチェックサムを「チェックサムD21」ともいう。   As shown in FIG. 3, the storage block Mb includes a main body area S1 in which the data body D1 of data is written, a code area S2 in which the checksum D2 is written, and all information written in other storage blocks. Erasing information area S3 in which erasing information D3 to the effect is completed is included. For example, when data (that is, the data body D1 and the checksum D2) is written in the second storage block Mb2 by the writing process, all information written in the first storage block Mb1 is erased. The “information” here includes data (data body D1 and checksum D2) and erase information D3. Then, erasure information D3 indicating that the erasure of such information has been completed is written in the erasure information area S3 of the second storage block Mb2. In the following description, in order to distinguish from the checksum D2 written in the code area S2, the checksum generated from the data body D1 written in the body area S1 is also referred to as “checksum D21”.

次に、図4に示すフローチャートを参照して、あるリング20のデータを更新する際にCPU11が実行する書き込み処理ルーチンについて説明する。例えば、本処理ルーチンは、上記スイッチ17をオフにし、電子制御装置10への給電を遮断させる場合に実行される処理ルーチンである。また、本処理ルーチンを、こうした電子制御装置10への給電を遮断させる場合以外であっても、データの更新が必要な際には適宜実行してもよい。   Next, a write processing routine executed by the CPU 11 when data of a certain ring 20 is updated will be described with reference to a flowchart shown in FIG. For example, this processing routine is a processing routine that is executed when the switch 17 is turned off and power supply to the electronic control device 10 is interrupted. In addition, this processing routine may be appropriately executed when data update is necessary, even when the power supply to the electronic control apparatus 10 is not interrupted.

図4に示すように、本処理ルーチンにおいて、CPU11は、あるリング20を構成する各記憶ブロックMbのうち、データ(前回のデータ)が書き込まれている記憶ブロックMb(前回の記憶ブロック)を特定し、特定した記憶ブロックMbのブロック番号Npを取得する(ステップS11)。例えば、特定した記憶ブロックが第1の記憶ブロックMb1である場合、取得されるブロック番号Npは「1」である。   As shown in FIG. 4, in this processing routine, the CPU 11 specifies a storage block Mb (previous storage block) in which data (previous data) is written among the storage blocks Mb constituting a certain ring 20. Then, the block number Np of the specified storage block Mb is acquired (step S11). For example, when the specified storage block is the first storage block Mb1, the acquired block number Np is “1”.

続いて、CPU11は、あるリング20を構成する上記各記憶ブロックMbのうち、今回にデータ(最新のデータ)を書き込む記憶ブロックMb(今回の記憶ブロック)を選択し、選択した記憶ブロックMbのブロック番号Nrを取得する(ステップS12)。例えば、選択した記憶ブロックが第2の記憶ブロックMb2である場合、取得されるブロック番号Nrは「2」である。   Subsequently, the CPU 11 selects a storage block Mb (current storage block) in which data (latest data) is to be written this time from among the storage blocks Mb constituting the ring 20, and the block of the selected storage block Mb is selected. The number Nr is acquired (step S12). For example, when the selected storage block is the second storage block Mb2, the acquired block number Nr is “2”.

そして、CPU11は、ステップS12で選択した記憶ブロックMb、すなわち第Nrの記憶ブロックが初期化されているか否かを判定する(ステップS13)。すなわち、第Nrの記憶ブロックを構成する本体領域S1、符号領域S2及び消去情報領域S3の全てが初期化されているときには、第Nrの記憶ブロックの全ての情報が消去されていると判定することができる。そして、第Nrの記憶ブロックが初期化されている場合(ステップS13:YES)、CPU11は、その処理を後述するステップS15に移行する。一方、第Nrの記憶ブロックに情報が未だ残っている場合(ステップS13:NO)、CPU11は、第Nrの記憶ブロックを初期化する(ステップS14)。すなわち、CPU11は、第Nrの記憶ブロックの全ての情報を消去する処理を実施し、消去の完了後に、その処理を次のステップS15に移行する。   Then, the CPU 11 determines whether or not the storage block Mb selected in step S12, that is, the Nrth storage block has been initialized (step S13). That is, when all of the main body area S1, the code area S2, and the erasure information area S3 constituting the Nrth storage block are initialized, it is determined that all the information in the Nrth storage block has been erased. Can do. If the Nr-th storage block has been initialized (step S13: YES), the CPU 11 proceeds to step S15 to be described later. On the other hand, when information still remains in the Nrth storage block (step S13: NO), the CPU 11 initializes the Nrth storage block (step S14). That is, the CPU 11 performs a process of erasing all information in the Nrth storage block, and after the erasure is completed, the process proceeds to the next step S15.

そして、CPU11は、最新のデータを第Nrの記憶ブロックに書き込むための書き込み処理を実施する(ステップS15〜S19)。
すなわち、ステップS15において、CPU11は、第Nrの記憶ブロックの本体領域S1に、最新のデータを構成するデータ本体D1を書き込む処理を実施する。そして、データ本体D1の書き込み完了後に、CPU11は、第Nrの記憶ブロックの符号領域S2に対し、最新のデータを構成するチェックサムD2を書き込む処理を実施する(ステップS16)。
Then, the CPU 11 performs a writing process for writing the latest data into the Nrth storage block (steps S15 to S19).
That is, in step S15, the CPU 11 performs a process of writing the data body D1 constituting the latest data in the body area S1 of the Nrth storage block. Then, after completing the writing of the data body D1, the CPU 11 performs a process of writing the checksum D2 constituting the latest data into the code area S2 of the Nrth storage block (step S16).

その後、CPU11は、念のために、第Nrの記憶ブロックへの最新のデータの書き込みが正常に完了しているか否かを診断する処理を実施する(ステップS17)。すなわち、CPU11は、第Nrの記憶ブロックの本体領域S1に書き込んだデータ本体D1からチェックサムD21を生成し、このチェックサムD21と、第Nrの記憶ブロックの符号領域S2に書き込まれているチェックサムD2とを比較する。そして、CPU11は、チェックサムD21とチェックサムD2とが一致しているときにはデータの書き込みが正常に完了していると診断する。一方、CPU11は、チェックサムD21とチェックサムD2とが不一致であるときにはデータの書き込みが正常に完了していない、すなわち本体領域S1に書き込まれている情報が破損したデータであると診断する。   Thereafter, as a precaution, the CPU 11 performs a process of diagnosing whether or not the writing of the latest data to the Nrth storage block has been normally completed (step S17). That is, the CPU 11 generates a checksum D21 from the data body D1 written in the body area S1 of the Nrth storage block, and the checksum D21 and the checksum written in the code area S2 of the Nrth storage block. Compare D2. Then, the CPU 11 diagnoses that the data writing is normally completed when the checksum D21 and the checksum D2 match. On the other hand, when the checksum D21 and the checksum D2 do not match, the CPU 11 diagnoses that the data writing is not normally completed, that is, the information written in the main body area S1 is damaged data.

そして、第Nrの記憶ブロックへのデータの書き込みが正常に完了していないと診断した場合(ステップS17:NO)、CPU11は、その処理を先のステップS13に移行する。すなわち、CPU11は、第Nrの記憶ブロックへのデータの書き込みを再度実施する。一方、第Nrの記憶ブロックへのデータの書き込みが正常に完了していると診断した場合(ステップS17:YES)、CPU11は、その処理を次のステップS18に移行する。   If it is diagnosed that data writing to the Nrth storage block has not been completed normally (step S17: NO), the CPU 11 shifts the processing to the previous step S13. That is, the CPU 11 performs data writing to the Nrth storage block again. On the other hand, when it is diagnosed that the writing of data to the Nr-th storage block is normally completed (step S17: YES), the CPU 11 proceeds to the next step S18.

ステップS18において、CPU11は、第Npの記憶ブロックを初期化し、第Npの記憶ブロックの全ての情報、すなわちデータ本体D1、チェックサムD2及び消去情報D3を消去する処理を実施する。続いて、第Npの記憶ブロックからの情報の消去の完了後に、CPU11は、第Nrの記憶ブロックの消去情報領域S3に消去情報D3を書き込む処理を実施する(ステップS19)。そして、同処理の終了後に、CPU11は、本処理ルーチンを終了する。   In step S18, the CPU 11 initializes the Np-th storage block and performs a process of erasing all information in the Np-th storage block, that is, the data body D1, the checksum D2, and the erasure information D3. Subsequently, after completing the erasure of information from the Npth storage block, the CPU 11 performs a process of writing the erasure information D3 in the erasure information area S3 of the Nrth storage block (step S19). And CPU11 complete | finishes this process routine after completion | finish of the said process.

次に、図5に示すフローチャートを参照して、あるリング20からデータを読み出す際にCPU11が実行する処理ルーチンについて説明する。例えば、本処理ルーチンは、スイッチ17がオンにされ、電子制御装置10に対する給電が開始される際などに実行される。また、本処理ルーチンは、こうした電子制御装置10への給電の開始時以外であっても、データの読み出しが必要な際には適宜実行してもよい。   Next, a processing routine executed by the CPU 11 when data is read from a certain ring 20 will be described with reference to a flowchart shown in FIG. For example, this processing routine is executed when the switch 17 is turned on and power supply to the electronic control device 10 is started. In addition, this processing routine may be appropriately executed when data reading is necessary even when the power supply to the electronic control device 10 is not started.

図5に示すように、本処理ルーチンにおいて、CPU11は、あるリング20を構成する上記各記憶ブロックMbのうち、最新のデータが書き込まれていると予測される記憶ブロックMb(今回の記憶ブロック)を特定し、特定した記憶ブロックMbのブロック番号Nrを取得する(ステップS21)。すなわち、リング20を構成する各記憶ブロックMbのうち何れか1つの記憶ブロックにのみ情報が残っている場合、その唯一の記憶ブロックが特定される。また、2つの記憶ブロックMbに情報が残っている場合、付されている番号の大きい記憶ブロックが特定される。ただし、最後尾の記憶ブロックと先頭の記憶ブロックとの双方に情報が残っている場合、先頭の記憶ブロックが選択される。そして、例えば、選択した記憶ブロックが第2の記憶ブロックMb2である場合、ブロック番号Nrは「2」である。   As shown in FIG. 5, in this processing routine, the CPU 11 stores the storage block Mb (current storage block) that is predicted to be written with the latest data among the storage blocks Mb that constitute a certain ring 20. And the block number Nr of the specified storage block Mb is acquired (step S21). That is, when information remains only in any one of the storage blocks Mb constituting the ring 20, the only storage block is specified. Further, when information remains in the two storage blocks Mb, the storage block with the larger number is specified. However, if information remains in both the last storage block and the first storage block, the first storage block is selected. For example, when the selected storage block is the second storage block Mb2, the block number Nr is “2”.

続いて、CPU11は、上記各記憶ブロックMbのうち、バックアップデータが書き込まれている可能性のある記憶ブロックMb(前回の記憶ブロック)を特定し、特定した記憶ブロックMbのブロック番号Npを取得する(ステップS22)。例えば、第Nr−1の記憶ブロックが、バックアップデータが書き込まれている可能性のある記憶ブロックとして特定される。ただし、ステップS21で取得したブロック番号Nrが「1」である場合、最後尾の記憶ブロックが、バックアップデータが書き込まれている可能性のある記憶ブロックとして特定される。そして、特定した記憶ブロックが第1の記憶ブロックMb1である場合、取得されるブロック番号Npは「1」である。   Subsequently, the CPU 11 specifies a storage block Mb (previous storage block) in which backup data may be written from among the storage blocks Mb, and acquires a block number Np of the specified storage block Mb. (Step S22). For example, the Nr-1th storage block is identified as a storage block in which backup data may be written. However, when the block number Nr acquired in step S21 is “1”, the last storage block is specified as a storage block in which backup data may be written. When the specified storage block is the first storage block Mb1, the acquired block number Np is “1”.

そして、CPU11は、あるリング20からデータ本体D1を読み出す読み出し処理を実施する(ステップS23〜S29)。
すなわち、CPU11は、第Nrの記憶ブロックへのデータの書き込みが正常に完了しているか否かを診断する(ステップS23)。すなわち、CPU11は、第Nrの記憶ブロックの本体領域S1に書き込まれているデータ本体D1からチェックサムD21を生成し、このチェックサムD21と、第Nrの記憶ブロックの符号領域S2に書き込まれているチェックサムD2とを比較する。そして、CPU11は、チェックサムD21とチェックサムD2とが一致しているときにはデータの書き込みが正常に完了していると診断する。一方、CPU11は、チェックサムD21とチェックサムD2とが不一致であるときにはデータの書き込みが正常に完了していない、すなわち第Nrの記憶ブロックには破損したデータが残っていると診断する。
And CPU11 performs the read-out process which reads the data main body D1 from a certain ring 20 (step S23-S29).
That is, the CPU 11 diagnoses whether or not data writing to the Nrth storage block has been normally completed (step S23). That is, the CPU 11 generates a checksum D21 from the data body D1 written in the body area S1 of the Nrth storage block, and writes the checksum D21 and the code area S2 of the Nrth storage block. Compare with checksum D2. Then, the CPU 11 diagnoses that the data writing is normally completed when the checksum D21 and the checksum D2 match. On the other hand, when the checksum D21 and the checksum D2 do not match, the CPU 11 diagnoses that the data writing is not normally completed, that is, the damaged data remains in the Nrth storage block.

そして、第Nrの記憶ブロックへのデータの書き込みが正常に完了していないと診断した場合(ステップS23:NO)、CPU11は、第Npの記憶ブロックの本体領域S1からデータ本体D1(バックアップデータ)を読み出す処理を実施する(ステップS24)。そして、データ本体D1の読み出しの完了後に、CPU11は、第Nrの記憶ブロックを初期化する(ステップS25)。すなわち、CPU11は、第Nrの記憶ブロックの全ての情報を消去する処理を実施し、情報の消去の完了後、本処理ルーチンを終了する。   If the CPU 11 diagnoses that the writing of data to the Nrth storage block has not been completed normally (step S23: NO), the CPU 11 starts the data body D1 (backup data) from the body area S1 of the Npth storage block. Is performed (step S24). Then, after completing the reading of the data body D1, the CPU 11 initializes the Nrth storage block (step S25). That is, the CPU 11 performs a process of erasing all the information in the Nr-th storage block, and ends this processing routine after the information erasure is completed.

一方、先のステップS23において、第Nrの記憶ブロックへのデータの書き込みが正常に完了していると診断した場合(ステップS23:YES)、CPU11は、第Nrの記憶ブロックの本体領域S1からデータ本体D1を読み出す処理を実施する(ステップS26)。そして、データ本体D1の読み出しの完了後に、CPU11は、第Nrの記憶ブロックの消去情報領域S3に消去情報D3が書き込まれているか否かを判定する(ステップS27)。このとき、CPU11は、消去情報D3が書き込まれている場合、第Npの記憶ブロックの初期化、すなわち第Npの記憶ブロックの全ての情報の消去が完了していると判断することができる。一方、消去情報D3が書き込まれていない場合、第Npの記憶ブロックの初期化が完了しておらず、全ての情報の消去が完了していないと判断することができる。   On the other hand, when it is diagnosed in the previous step S23 that the writing of data to the Nrth storage block has been completed normally (step S23: YES), the CPU 11 reads data from the main body region S1 of the Nrth storage block. A process of reading the main body D1 is performed (step S26). Then, after the reading of the data body D1 is completed, the CPU 11 determines whether or not the erasure information D3 is written in the erasure information area S3 of the Nrth storage block (step S27). At this time, when the erasure information D3 is written, the CPU 11 can determine that initialization of the Npth storage block, that is, erasure of all information in the Npth storage block has been completed. On the other hand, when the erasure information D3 is not written, it can be determined that the initialization of the Npth storage block has not been completed and the erasure of all information has not been completed.

そのため、消去情報D3が書き込まれている場合(ステップS27:YES)、CPU11は、本処理ルーチンを終了する。一方、消去情報D3が書き込まれていない場合(ステップS27:NO)、CPU11は、第Npの記憶ブロックを初期化し(ステップS28)、第Npの記憶ブロックの全ての情報を消去する処理を実施する。そして、CPU11は、第Npの記憶ブロックからの情報の消去の完了後に、第Nrの記憶ブロックの消去情報領域S3に消去情報D3を書き込む処理を実施し(ステップS29)、消去情報D3の書き込み完了後に、本処理ルーチンを終了する。   Therefore, when the erasure information D3 is written (step S27: YES), the CPU 11 ends this processing routine. On the other hand, when the erasure information D3 is not written (step S27: NO), the CPU 11 initializes the Npth storage block (step S28) and performs a process of erasing all the information in the Npth storage block. . Then, after completing the erasure of information from the Npth storage block, the CPU 11 performs a process of writing the erasure information D3 into the erasure information area S3 of the Nrth storage block (step S29), and the writing of the erasure information D3 is completed. Later, this processing routine is terminated.

次に、図6〜図8を参照して、あるリング20のデータの更新時及び同リング20からのデータの読み出し時における電子制御装置10の作用について説明する。
まず、図6を参照して、データの書き込み処理と、そのデータの書き込み処理が正常に完了した場合におけるデータの読み出し処理とについて説明する。なお、図6において、前回のデータは、第1の記憶ブロックMb1に書き込まれているものとする。
Next, with reference to FIGS. 6 to 8, the operation of the electronic control device 10 at the time of updating data of a certain ring 20 and at the time of reading data from the ring 20 will be described.
First, a data writing process and a data reading process when the data writing process is normally completed will be described with reference to FIG. In FIG. 6, it is assumed that the previous data is written in the first storage block Mb1.

図6(a),(b),(c),(d),(e)に示すように、データの書き込み処理時には、前回のデータが書き込まれている記憶ブロック(前回の記憶ブロック)として第1の記憶ブロックMb1が特定される(ステップS11)。続いて、最新のデータを書き込む記憶ブロック(今回の記憶ブロック)として第2の記憶ブロックMb2が選択される(ステップS12)。   As shown in FIGS. 6 (a), (b), (c), (d), and (e), during the data writing process, the storage block in which the previous data is written (the previous storage block) is the first. One storage block Mb1 is identified (step S11). Subsequently, the second storage block Mb2 is selected as a storage block (current storage block) in which the latest data is written (step S12).

なお、今回の記憶ブロックとして選択された第2の記憶ブロックMb2は、既に初期化されている(ステップS13:YES)。そのため、この第2の記憶ブロックMb2には、情報(例えば、以前に書き込まれたデータ)が全く残っていない。   Note that the second storage block Mb2 selected as the current storage block has already been initialized (step S13: YES). Therefore, no information (for example, previously written data) remains in the second storage block Mb2.

すると、図6(b)に示すように、第2の記憶ブロックMb2の本体領域S1に、最新のデータを構成するデータ本体D1が書き込まれ(ステップS15)、データ本体D1の書き込み完了後に、第2の記憶ブロックMb2の符号領域S2に、同データ本体D1のチェックサムD2が書き込まれる(ステップS16)。そして、チェックサムD2の書き込み完了後では、図6(c)に示すように、第1の記憶ブロックMb1が初期化され(ステップS18)、第1の記憶ブロックMb1の全ての情報(データ本体D1、チェックサムD2及び消去情報D3)が消去される。すると、図6(d)に示すように、第2の記憶ブロックMb2の消去情報領域S3に消去情報D3が書き込まれる(ステップS19)。こうして、リング20に対する最新のデータの書き込み処理が完了する。   Then, as shown in FIG. 6B, the data body D1 constituting the latest data is written in the body area S1 of the second storage block Mb2 (step S15), and after the data body D1 has been written, The checksum D2 of the data body D1 is written into the code area S2 of the second storage block Mb2 (step S16). Then, after the write of the checksum D2 is completed, as shown in FIG. 6C, the first storage block Mb1 is initialized (step S18), and all information (data body D1) of the first storage block Mb1 is initialized. , Checksum D2 and erase information D3) are erased. Then, as shown in FIG. 6D, erase information D3 is written in the erase information area S3 of the second storage block Mb2 (step S19). In this way, the latest data writing process to the ring 20 is completed.

その後のデータの読み出し処理時には、最新のデータが書き込まれている記憶ブロック(今回の記憶ブロック)として、第2の記憶ブロックMb2が特定される(ステップS21)。すると、第2の記憶ブロックMb2の符号領域S2に書き込まれているチェックサムD2を用い、第2の記憶ブロックMb2へのデータの書き込みが正常に完了しているか否かが診断される(ステップS23)。そして、第2の記憶ブロックMb2へのデータの書き込みが正常に完了していると診断されると(ステップS23:YES)、第2の記憶ブロックMb2からデータ本体D1が読み出される(ステップS26)。すると、その後にあっては、このデータ本体D1を参照した制御処理の実施が可能となる。   During the subsequent data read process, the second storage block Mb2 is specified as the storage block in which the latest data is written (current storage block) (step S21). Then, using the checksum D2 written in the code area S2 of the second storage block Mb2, it is diagnosed whether or not the data writing to the second storage block Mb2 has been normally completed (step S23). ). Then, when it is diagnosed that the data writing to the second storage block Mb2 is normally completed (step S23: YES), the data body D1 is read from the second storage block Mb2 (step S26). Then, after that, it becomes possible to perform the control process with reference to the data body D1.

なお、この場合、第2の記憶ブロックMb2の消去情報領域S3に消去情報D3が書き込まれていることから(ステップS27:YES)、第1の記憶ブロックMb1の全ての情報は既に消去されている。そのため、第2の記憶ブロックMb2からのデータ本体D1の読み出し完了後に、第1の記憶ブロックMb1を初期化する処理が実施されない。   In this case, since the erase information D3 is written in the erase information area S3 of the second storage block Mb2 (step S27: YES), all information in the first storage block Mb1 has already been erased. . Therefore, the process of initializing the first storage block Mb1 is not performed after the completion of reading of the data body D1 from the second storage block Mb2.

そして、図6(d)に示すように、リング20を構成する各記憶ブロックMb1〜Mb3のうち、第2の記憶ブロックMb2にのみデータが書き込まれているときに、新たに書き込み処理が実施されることがある。この場合、図6(e)に示すように、第2の記憶ブロックMb2には前回のデータが書き込まれているため、最新のデータを書き込む記憶ブロックとして、第3の記憶ブロックMb3が選択される(ステップS12)。すると、第3の記憶ブロックMb3に最新のデータが書き込まれ(ステップS15,S16)、第2の記憶ブロックMb2が初期化される(ステップS17)。   As shown in FIG. 6D, when data is written only in the second storage block Mb2 among the storage blocks Mb1 to Mb3 constituting the ring 20, a new writing process is performed. Sometimes. In this case, as shown in FIG. 6E, since the previous data is written in the second storage block Mb2, the third storage block Mb3 is selected as the storage block into which the latest data is written. (Step S12). Then, the latest data is written in the third storage block Mb3 (steps S15 and S16), and the second storage block Mb2 is initialized (step S17).

次に、図7及び図8を参照して、第2の記憶ブロックMb2に対するデータの書き込み処理が正常に完了していない状況下で、データの読み出し処理を実施する場合の作用について説明する。なお、書き込み処理が正常に完了されない場合としては、同処理の実施最中に、電子制御装置10への給電が遮断されたり電子制御装置10に印加されている電圧が著しく低くなったりすることで、当該処理が中断される場合を挙げることができる。   Next, with reference to FIG. 7 and FIG. 8, an operation when the data read process is performed in a situation where the data write process to the second storage block Mb2 is not normally completed will be described. In the case where the writing process is not normally completed, the power supply to the electronic control device 10 is interrupted or the voltage applied to the electronic control device 10 is significantly lowered during the execution of the processing. A case where the processing is interrupted can be mentioned.

そして、書き込み処理が中断される場合としては、記憶ブロックMbの符号領域S2へのチェックサムD2の書き込みが中断される場合を挙げることができる。この場合、図7(a)に示すように、第2の記憶ブロックMb2の本体領域S1へのデータ本体D1の書き込みは正常に完了している一方、第2の記憶ブロックMb2の符号領域S2のチェックサムD2は、正しくないデータ、すなわち破損したデータである。   A case where the writing process is interrupted includes a case where writing of the checksum D2 to the code area S2 of the storage block Mb is interrupted. In this case, as shown in FIG. 7A, the writing of the data body D1 to the body area S1 of the second storage block Mb2 is normally completed, while the code area S2 of the second storage block Mb2 The checksum D2 is incorrect data, that is, corrupted data.

図7(a),(b)に示すように、最新のデータの書き込みが行われた第2の記憶ブロックMb2(今回の記憶ブロック)と、前回のデータが書き込まれている第1の記憶ブロックMb1とが特定される(ステップS21,S22)。そして、データの読み出し処理時には、第2の記憶ブロックMb2の符号領域S2に書き込まれている情報(すなわち、破損したデータ)をチェックサムD2とし、第2の記憶ブロックMb2へのデータの書き込みが正常に完了しているか否かが診断される(ステップS23)。   As shown in FIGS. 7A and 7B, the second storage block Mb2 (current storage block) in which the latest data has been written and the first storage block in which previous data has been written. Mb1 is identified (steps S21 and S22). At the time of data read processing, information written in the code area S2 of the second storage block Mb2 (that is, damaged data) is used as the checksum D2, and data writing to the second storage block Mb2 is normal. It is diagnosed whether or not it is completed (step S23).

この場合、図7(a)に示すように、第2の記憶ブロックMb2の情報は、正しいチェックサムD2ではないため、第2の記憶ブロックMb2へのデータの書き込みが正常に完了していないと診断される可能性が高い。そして、このように第2の記憶ブロックMb2へのデータの書き込みが正常に完了していないと診断されると(ステップS23:NO)、第1の記憶ブロックMb1からデータ本体D1が読み出される(ステップS24)。続いて、図7(b)に示すように、第2の記憶ブロックMb2が初期化される(ステップS25)。そして、その後にあっては、第1の記憶ブロックMb1から読み出されたデータ本体D1を用いた制御処理の実施が可能となる。   In this case, as shown in FIG. 7A, the information in the second storage block Mb2 is not the correct checksum D2, so that the data writing to the second storage block Mb2 is not normally completed. It is likely to be diagnosed. When it is diagnosed that the writing of data to the second storage block Mb2 is not normally completed (step S23: NO), the data body D1 is read from the first storage block Mb1 (step S23). S24). Subsequently, as shown in FIG. 7B, the second storage block Mb2 is initialized (step S25). Thereafter, the control process using the data body D1 read from the first storage block Mb1 can be performed.

ところで、第2の記憶ブロックMb2に書き込まれている情報が、破損したチェックサムである場合、この破損しているチェックサムと、第2の記憶ブロックMb2の本体領域S1に書き込まれているデータ本体D1から生成したチェックサムD21とが、偶然に一致することもある。この場合、第2の記憶ブロックMb2へのデータの書き込みが正常に完了していると診断されるため(ステップS23:YES)、第1の記憶ブロックMb1からではなく、第2の記憶ブロックMb2からデータ本体D1が読み出されることとなる(ステップS26)。また、この場合、第2の記憶ブロックMb2へのデータ本体D1の書き込み自体は、実際には正常に完了している。すなわち、第2の記憶ブロックMb2から読み出したデータ本体D1は正常なデータである。そのため、第2の記憶ブロックMb2から読み出したデータ本体D1を用いることにより、制御処理が適切に実施される。   By the way, when the information written in the second storage block Mb2 is a damaged checksum, the damaged checksum and the data body written in the main body area S1 of the second storage block Mb2. The checksum D21 generated from D1 may coincide by chance. In this case, since it is diagnosed that the writing of data to the second storage block Mb2 is normally completed (step S23: YES), not from the first storage block Mb1 but from the second storage block Mb2. The data body D1 is read (step S26). In this case, the writing of the data body D1 to the second storage block Mb2 is actually completed normally. That is, the data body D1 read from the second storage block Mb2 is normal data. Therefore, the control process is appropriately performed by using the data body D1 read from the second storage block Mb2.

また、書き込み処理が中断される場合としては、第2の記憶ブロックMb2の本体領域S1へのデータ本体D1の書き込みが中断される場合を挙げることもできる。この場合、第2の記憶ブロックMb2の符号領域S2にはチェックサムD2が書き込まれていない。すなわち、符号領域S2は初期化されたままである。そのため、次の読み出し処理時にあっては、第2の記憶ブロックMb2の符号領域S2から読み出した情報をチェックサムD2として用い、第2の記憶ブロックMb2へのデータの書き込みが正常に完了しているか否かを診断しても、正常に完了していると診断されることはない(ステップS23:NO)。そのため、第1の記憶ブロックMb1からデータ本体D1が読み出され(ステップS24)、第2の記憶ブロックMb2が初期化される(ステップS25)。   Further, the case where the writing process is interrupted may include a case where the writing of the data body D1 to the body area S1 of the second storage block Mb2 is interrupted. In this case, the checksum D2 is not written in the code area S2 of the second storage block Mb2. That is, the code area S2 remains initialized. Therefore, at the time of the next reading process, whether the information read from the code area S2 of the second storage block Mb2 is used as the checksum D2 and the data writing to the second storage block Mb2 has been normally completed. Even if it is diagnosed, it is not diagnosed that it has been completed normally (step S23: NO). Therefore, the data body D1 is read from the first storage block Mb1 (step S24), and the second storage block Mb2 is initialized (step S25).

さらに、書き込み処理が中断される場合としては、第1の記憶ブロックMb1を初期化する処理が途中で中断される場合を挙げることもできる。この場合、第2の記憶ブロックMb2からデータ本体D1を読み出す読み出し処理時にあっては、図8(a)に示すように、第2の記憶ブロックMb2の消去情報領域S3には、消去情報D3が書き込まれていない。その一方で、第2の記憶ブロックMb2へのデータ本体D1及びチェックサムD2の書き込みが正常に完了している。   Furthermore, as a case where the writing process is interrupted, a case where the process of initializing the first storage block Mb1 is interrupted in the middle can also be mentioned. In this case, during the read process for reading the data body D1 from the second storage block Mb2, as shown in FIG. 8A, the erase information D3 is stored in the erase information area S3 of the second storage block Mb2. Not written. On the other hand, the writing of the data body D1 and the checksum D2 to the second storage block Mb2 is normally completed.

そのため、第2の記憶ブロックMb2の符号領域S2に書き込まれているチェックサムD2を用いることにより、第2の記憶ブロックMb2へのデータの書き込みが正常に完了していると診断される(ステップS23:YES)。その結果、第2の記憶ブロックMb2からデータ本体D1が読み出される(ステップS26)。これにより、以降にあっては、第2の記憶ブロックMb2から読み出したデータ本体D1を用いた制御処理の実施が可能となる。   Therefore, by using the checksum D2 written in the code area S2 of the second storage block Mb2, it is diagnosed that the data writing to the second storage block Mb2 has been normally completed (step S23). : YES). As a result, the data body D1 is read from the second storage block Mb2 (step S26). Thereby, thereafter, it becomes possible to perform the control process using the data body D1 read from the second storage block Mb2.

また、第2の記憶ブロックMb2からのデータ本体D1の読み出しの完了後にあっては、第2の記憶ブロックMb2の消去情報領域S3に消去情報D3が記憶されていないため(ステップS27:NO)、図8(b)に示すように、第1の記憶ブロックMb1が初期化される(ステップS28)。そして、図8(c)に示すように、第2の記憶ブロックMb2の消去情報領域S3には、第1の記憶ブロックMb1の全ての情報の消去が完了した旨を示す消去情報D3が書き込まれる(ステップS29)。   Further, after the reading of the data body D1 from the second memory block Mb2 is completed, the erase information D3 is not stored in the erase information area S3 of the second memory block Mb2 (step S27: NO). As shown in FIG. 8B, the first storage block Mb1 is initialized (step S28). As shown in FIG. 8C, the erasure information D3 indicating that the erasure of all information in the first storage block Mb1 is completed is written in the erasure information area S3 of the second storage block Mb2. (Step S29).

以上説明した実施形態によれば、以下に示す効果を得ることができる。
(1)リング20に最新のデータを書き込む場合にあっては、リング20を構成する各記憶ブロックMbのうち、前回のデータが書き込まれている記憶ブロック(前回の記憶ブロック)とは別の記憶ブロックMb(今回の記憶ブロック)が1つだけ選択される。そして、この選択した記憶ブロックMbにデータが書き込まれる。これにより、1つのデータを複数の記憶ブロックMbに対して重複して書き込む場合と比較して、記憶ブロックMb単位でのデータの書き込み回数が少なくなり、EEPROM14の劣化を遅らせることができる。
According to the embodiment described above, the following effects can be obtained.
(1) When writing the latest data to the ring 20, a storage different from the storage block in which the previous data is written (the previous storage block) among the storage blocks Mb constituting the ring 20. Only one block Mb (current storage block) is selected. Then, data is written into the selected storage block Mb. Thereby, compared with the case where one data is written to a plurality of storage blocks Mb redundantly, the number of times data is written in the storage block Mb is reduced, and the deterioration of the EEPROM 14 can be delayed.

また、その後に、リング20からデータ(具体的には、データ本体D1)を読み出す場合にあっては、最新のデータが書き込まれている記憶ブロックMbを特定し、この記憶ブロックMbへのデータの書き込みが正常に完了しているか否かが診断される。そして、正常に完了していると診断したときには、当該記憶ブロックMbからデータ本体D1が読み出される。一方、正常に完了していないと診断したときには、上記前回の記憶ブロックからデータ本体D1が読み出される。すなわち、上記前回の記憶ブロックに書き込まれているデータ本体D1をバックアップデータとして用いることができる。したがって、EEPROM14の長寿命化を図りつつも、同EEPROM14に記憶されているデータの信頼性を高めることができる。   After that, when data (specifically, the data body D1) is read from the ring 20, the storage block Mb in which the latest data is written is specified, and the data in the storage block Mb is specified. It is diagnosed whether the writing is completed normally. When the diagnosis is completed normally, the data body D1 is read from the storage block Mb. On the other hand, when it is diagnosed that it is not completed normally, the data body D1 is read from the previous storage block. That is, the data body D1 written in the previous storage block can be used as backup data. Therefore, the reliability of the data stored in the EEPROM 14 can be improved while extending the life of the EEPROM 14.

(2)書き込み処理では、今回の記憶ブロックへのデータ本体D1及びチェックサムD2の書き込みが完了した後に、前回の記憶ブロックが初期化される。このため、書き込み処理が正常に完了した後にあっては、1つの記憶ブロックMbにのみデータが書き込まれており、当該記憶ブロックMb以外の記憶ブロックMbには情報が何ら残っていない状態となりやすい。そして、このように当該記憶ブロックMb以外の記憶ブロックMbには情報が何ら残っていない場合、次に書き込み処理を実施する際には、書き込み対象となる記憶ブロックMbを初期化することなく、記憶ブロックMbへの今回のデータの書き込みを開始させることができる。したがって、記憶ブロックMbへのデータの書き込みを速やかに完了させることができる。   (2) In the writing process, after the writing of the data body D1 and the checksum D2 to the current storage block is completed, the previous storage block is initialized. For this reason, after the writing process is completed normally, data is written only in one storage block Mb, and there is a tendency that no information remains in the storage blocks Mb other than the storage block Mb. If no information remains in the storage block Mb other than the storage block Mb as described above, the memory block Mb to be written is stored without being initialized when the writing process is performed next time. The writing of the current data to the block Mb can be started. Therefore, data writing to the storage block Mb can be completed promptly.

(3)ただし、書き込み処理が正常に完了されない場合、書き込み対象とされていた記憶ブロックMb(今回の記憶ブロック)に破損したデータが残る場合がある。そこで、読み出し処理では、今回の記憶ブロックへのデータの書き込みが正常に完了していないと診断されるときには、前回の記憶ブロックからデータ本体D1を読み出すことに加え、今回の記憶ブロックを初期化する処理も実施するようにした。これにより、書き込み処理の開始時において、上記今回の記憶ブロックに上記破損したデータが未だ残っていることがなくなる。そのため、上記今回の記憶ブロックに新たなデータを書き込む際に、当該記憶ブロックから上記破損したデータを消去する処理を実施しなくてもよい分、当該記憶ブロックMbへのデータの書き込みを速やかに完了させることができる。   (3) However, if the writing process is not normally completed, damaged data may remain in the storage block Mb (current storage block) that is the target of writing. Therefore, in the reading process, when it is diagnosed that the writing of data to the current storage block is not normally completed, in addition to reading the data body D1 from the previous storage block, the current storage block is initialized. Processing was also implemented. Thus, at the start of the writing process, the corrupted data is not left in the current storage block. Therefore, when writing new data to the current storage block, it is not necessary to perform the process of erasing the damaged data from the storage block, and the data writing to the storage block Mb is completed promptly. Can be made.

(4)書き込み処理では、データ本体D1を本体領域S1に書き込み、その後、チェックサムD2を符号領域S2に書き込むようにした。このため、本体領域S1にデータ本体D1を書き込んでいる最中に書き込み処理が中断される場合や、符号領域S2にチェックサムD2を書き込んでいる最中に書き込み処理が中断される場合には、符号領域S2に書き込まれたチェックサムを用いた診断を行うことにより、記憶ブロックMbへのデータの書き込みが正常に完了していないと診断される。その結果、当該記憶ブロックMbからデータ本体D1が読み出されることを抑制することができる。   (4) In the writing process, the data body D1 is written in the body area S1, and then the checksum D2 is written in the code area S2. Therefore, when the writing process is interrupted while the data body D1 is being written to the body area S1, or when the writing process is interrupted while the checksum D2 is being written to the code area S2, By performing the diagnosis using the checksum written in the code area S2, it is diagnosed that the data writing to the storage block Mb is not normally completed. As a result, it is possible to prevent the data body D1 from being read from the storage block Mb.

なお、符号領域S2へのチェックサムD2の書き込みが中断された場合にあっては、書き込み途中のチェックサムを用いた診断によって、記憶ブロックへのデータの書き込みが正常に完了していると誤診断されることがある。この場合、記憶ブロックMbに書き込まれているデータ本体D1自体は正常であるため、当該記憶ブロックMbからデータ本体D1が読み出されても問題は生じない。   If the writing of the checksum D2 to the code area S2 is interrupted, it is erroneously diagnosed that the data writing to the storage block is normally completed by the diagnosis using the checksum during the writing. May be. In this case, since the data body D1 itself written in the storage block Mb is normal, no problem occurs even if the data body D1 is read from the storage block Mb.

(5)書き込み処理では、今回の記憶ブロックへのデータの書き込みが正常に完了していることが確認された上で、前回の記憶ブロックが初期化される。言い換えると、今回の記憶ブロックへのデータの書き込みが正常に完了していることが確認されるまでは、前回の記憶ブロックのデータ本体D1をバックアップデータとして利用することができる。   (5) In the writing process, it is confirmed that the writing of data to the current storage block is normally completed, and then the previous storage block is initialized. In other words, the data body D1 of the previous storage block can be used as backup data until it is confirmed that the writing of data to the current storage block has been completed normally.

(6)書き込み処理では、今回の記憶ブロックへのデータ本体D1及びチェックサムD2の書き込みの完了後に、前回の記憶ブロックを初期化し、その後、今回の記憶ブロックの消去情報領域S3に消去情報D3が書き込まれる。そのため、次の読み出し処理時には、今回の記憶ブロックの消去情報領域S3に消去情報D3が書き込まれているか否かによって、前回の記憶ブロックを初期化する処理の実施が必要であるか否かを判断することができる。   (6) In the writing process, after the writing of the data body D1 and the checksum D2 to the current storage block is completed, the previous storage block is initialized, and then the erase information D3 is stored in the erase information area S3 of the current storage block. Written. Therefore, at the time of the next read process, it is determined whether or not the process for initializing the previous storage block is necessary depending on whether or not the erase information D3 is written in the erase information area S3 of the current storage block. can do.

(7)書き込み処理に先立って、各記憶ブロックMbへのデータの書き込み回数が均等となるように、最新のデータを書き込む記憶ブロックが選択される。そのため、一部の記憶ブロックMbの劣化が、他の記憶ブロックMbよりも進んでしまうことを抑制することができる。   (7) Prior to the writing process, the storage block to which the latest data is written is selected so that the number of times of writing data to each storage block Mb is equal. Therefore, deterioration of some storage blocks Mb can be prevented from progressing more than other storage blocks Mb.

(8)リング20の記憶ブロック数NBは、リング20に対応するデータの更新頻度の予測に応じて決定されている。そのため、一部のリング20を構成する記憶ブロックMbの劣化が他のリング20を構成する記憶ブロックMbよりも進んでしまうことが抑制される。したがって、EEPROM14の寿命を長くすることができる。   (8) The number of storage blocks NB of the ring 20 is determined according to the prediction of the update frequency of data corresponding to the ring 20. For this reason, the deterioration of the storage blocks Mb constituting some of the rings 20 is suppressed from proceeding more than the storage blocks Mb constituting the other rings 20. Therefore, the lifetime of the EEPROM 14 can be extended.

なお、上記実施形態は、以下に示す他の実施形態に変更してもよい。
・書き込み処理では、記憶ブロックMbへの最新のデータの書き込みが完了した後に、前回のデータが書き込まれている記憶ブロックMb(前回の記憶ブロック)を初期化する処理を実施しなくてもよい。この場合、前回の記憶ブロックには情報が残ったままとなるが、当該記憶ブロックMbにデータを書き込む書き込み処理を実施する際には、当該記憶ブロックMbを初期化する処理を実施した上で(ステップS14)、当該記憶ブロックMbにデータが書き込まれることとなる(ステップS15,S16)。なお、こうした制御構成を採用する場合、記憶ブロックMbに消去情報領域S3を設けなくてもよい。
In addition, you may change the said embodiment into other embodiment shown below.
In the writing process, after the writing of the latest data to the storage block Mb is completed, the process of initializing the storage block Mb (the previous storage block) in which the previous data is written may not be performed. In this case, information remains in the previous storage block, but when performing a writing process for writing data to the storage block Mb, a process for initializing the storage block Mb is performed ( In step S14, data is written in the storage block Mb (steps S15 and S16). Note that when such a control configuration is employed, the erasure information area S3 may not be provided in the storage block Mb.

・書き込み処理において、記憶ブロックMbの符号領域S2にチェックサムD2を書き込む処理(ステップS16)を、同記憶ブロックMbの本体領域S1にデータ本体D1を書き込む処理(ステップS15)よりも先に実施するようにしてもよい。   In the writing process, the process of writing the checksum D2 in the code area S2 of the storage block Mb (step S16) is performed before the process of writing the data body D1 in the main body area S1 of the storage block Mb (step S15). You may do it.

・通常、定められた手順に従って書き込み処理が実施されれば、データは正常に記憶ブロックMbに書き込まれる。このため、書き込み処理において、記憶ブロックMbへのデータ本体D1及びチェックサムD2の書き込み完了後に、当該記憶ブロックMbへのデータの書き込みが正常に完了しているか否かを診断することなく、前回のデータが書き込まれている記憶ブロックMb(前回の記憶ブロック)を初期化する処理を実施するようにしてもよい。また、データの書き込み完了後に、記憶ブロックMbへデータの書き込みが正常に完了しているか否かを診断しない場合には、データの書き込み後、前回の記憶ブロックを必ず初期化することにより、データの書き込み前の記憶ブロックが初期化されているか否かの判定処理(ステップS13)を省略するようにしてもよい。   Normally, if the writing process is performed according to a predetermined procedure, the data is normally written in the storage block Mb. For this reason, in the writing process, after the writing of the data body D1 and the checksum D2 to the storage block Mb is completed, the previous writing is not performed without diagnosing whether the writing of the data to the storage block Mb is normally completed. Processing for initializing the storage block Mb (previous storage block) in which data is written may be performed. In addition, when it is not diagnosed whether or not data writing to the storage block Mb is normally completed after the data writing is completed, it is necessary to always initialize the previous storage block after the data writing. You may make it abbreviate | omit the determination process (step S13) of whether the memory block before writing is initialized.

・読み出し処理では、最新のデータが書き込まれている記憶ブロックMb(今回の記憶ブロック)へのデータの書き込みが正常に完了していないと診断された場合(ステップS23:NO)、当該記憶ブロックMbを初期化する処理を実施しなくてもよい。この場合、書き込み処理を実施するに際し、当該記憶ブロックMbが選択された場合、当該記憶ブロックMbを初期化する処理(ステップS14)を実施した上で、当該記憶ブロックMbにデータが書き込まれることとなる(ステップS15,S16)。   In the reading process, when it is diagnosed that the writing of data to the storage block Mb (current storage block) in which the latest data has been written is not normally completed (step S23: NO), the storage block Mb It is not necessary to carry out the process of initializing. In this case, when the storage block Mb is selected when performing the writing process, the process of initializing the storage block Mb (step S14) is performed, and then data is written to the storage block Mb. (Steps S15 and S16).

・記憶ブロックMbへのデータの書き込みが正常に完了しているか否かの診断を、チェックサムD2によるデータの誤り検出以外の方法で診断するようにしてもよい。例えば、こうした診断方法としては、パリティチェックによるデータの誤り検出やCRC(巡回冗長検査)によるデータの誤り検出などを挙げることができる。   The diagnosis as to whether or not the data writing to the storage block Mb is normally completed may be performed by a method other than the data error detection by the checksum D2. For example, as such a diagnostic method, data error detection by parity check, data error detection by CRC (Cyclic Redundancy Check), and the like can be mentioned.

・チェックサムD2などの誤り検出符号を用いることなく、記憶ブロックMbへのデータの書き込みが正常に完了しているか否かを診断することができるのであれば、記憶ブロックMbに符号領域S2を設けなくてもよい。   If it is possible to diagnose whether or not data writing to the storage block Mb is normally completed without using an error detection code such as a checksum D2, a code area S2 is provided in the storage block Mb. It does not have to be.

・最新のデータを書き込むに際し、前回のデータが書き込まれている記憶ブロックMbとは異なる他の記憶ブロックMbを選択するのであれば、記憶ブロックMb毎のデータの書き込み回数に偏りが生じるようなルールに従って、今回の書き込み対象の記憶ブロックMbを選択するようにしてもよい。   When writing the latest data, if another storage block Mb different from the storage block Mb in which the previous data is written is selected, a rule that causes a bias in the number of times data is written for each storage block Mb Accordingly, the memory block Mb to be written this time may be selected.

・複数の記憶ブロックMbへのデータの書き込み回数が均等となるのであれば、リング20を構成する記憶ブロックMbに対するデータの書き込み順序は、適宜変更してもよい。一例として、乱数を用いて、最新のデータを書き込む記憶ブロックMbを選択するようにしてもよい。   As long as the number of data writes to the plurality of storage blocks Mb is equal, the order of data writing to the storage blocks Mb constituting the ring 20 may be changed as appropriate. As an example, a storage block Mb into which the latest data is written may be selected using a random number.

・リング20の記憶ブロック数NBを、設計段階で予測されるリング20毎のデータの更新頻度に加え、データの重要度を考慮して決定するようにしてもよい。この場合、予測されるデータの更新頻度が同等であっても、書き込まれるデータの重要度の高いリング20の記憶ブロック数NBは、書き込まれるデータの重要度の低いリング20の記憶ブロック数NBよりも多くなる。   The number NB of storage blocks in the ring 20 may be determined in consideration of the importance of data in addition to the data update frequency predicted for each ring 20 in the design stage. In this case, even if the update frequency of the predicted data is the same, the number of storage blocks NB of the ring 20 with high importance of the written data is larger than the number of storage blocks NB of the ring 20 with low importance of the written data. Will also increase.

・各リング20の記憶ブロック数NBは、予測されるデータの更新頻度などとは関係なく同じ数であってもよい。
・記憶ブロックMbの記憶容量を、振り分けられているリング20毎に異ならせるようにしてもよい。
The number NB of storage blocks in each ring 20 may be the same number regardless of the predicted update frequency of data.
The storage capacity of the storage block Mb may be made different for each distributed ring 20.

・電子制御装置10は、EEPROM14以外の不揮発性メモリ(例えば、フラッシュメモリ)を備える装置であってもよい。そして、EEPROM14以外の不揮発性メモリへのデータの書き込み時及び同メモリからのデータの読み出し時には、上記実施形態でのEEPROM14へのデータの書き込み時やEEPROM14からのデータの読み出し時と同等の処理を実施するようにしてもよい。   The electronic control device 10 may be a device including a nonvolatile memory (for example, a flash memory) other than the EEPROM 14. When data is written to the nonvolatile memory other than the EEPROM 14 and when data is read from the memory, processing equivalent to that when data is written to the EEPROM 14 or data is read from the EEPROM 14 in the above embodiment is performed. You may make it do.

10…電子制御装置、11…CPU、14…EEPROM(不揮発性メモリの一例)、20…リング(グループの一例)、Mb…記憶ブロック、D1…データ本体、D2…チェックサム(誤り検出符号の一例)、D3…消去情報、S1…本体領域、S2…符号領域、S3…消去情報領域。   DESCRIPTION OF SYMBOLS 10 ... Electronic control unit, 11 ... CPU, 14 ... EEPROM (an example of a non-volatile memory), 20 ... Ring (an example of a group), Mb ... Storage block, D1 ... Data body, D2 ... Checksum (an example of an error detection code) ), D3... Erasure information, S1... Body area, S2.

Claims (8)

複数の記憶ブロックに区分けされている不揮発性メモリと、前記記憶ブロックへのデータの書き込み及び同記憶ブロックからのデータの読み出しを行うCPUと、を備える電子制御装置において、
前記CPUは、
前記各記憶ブロックのうち、前回にデータを書き込んだ前回の記憶ブロックとは異なる今回の記憶ブロックにデータを書き込む書き込み処理と、
前記不揮発性メモリからデータを読み出す読み出し処理と、を行うようになっており、
前記読み出し処理は、
前記今回の記憶ブロックへのデータの書き込みが正常に完了していると診断されるときには、前記今回の記憶ブロックからデータを読み出す処理と、
前記今回の記憶ブロックへのデータの書き込みが正常に完了していないと診断されるときには、前記前回の記憶ブロックからデータを読み出す処理と、を含む
ことを特徴とする電子制御装置。
In an electronic control device comprising: a nonvolatile memory divided into a plurality of storage blocks; and a CPU that writes data to the storage blocks and reads data from the storage blocks.
The CPU
Of each of the storage blocks, a writing process for writing data to the current storage block different from the previous storage block to which data was previously written;
A read process for reading data from the non-volatile memory, and
The readout process is:
When it is diagnosed that the writing of data to the current storage block is normally completed, a process of reading data from the current storage block;
And a process of reading data from the previous storage block when it is diagnosed that writing of data to the current storage block is not normally completed.
前記書き込み処理は、
前記今回の記憶ブロックにデータを書き込む処理と、
同処理の完了後に実施する処理であって、且つ前記前回の記憶ブロックからデータを消去する処理と、を含む
請求項1に記載の電子制御装置。
The write process
A process of writing data to the current storage block;
The electronic control device according to claim 1, further comprising: a process that is performed after the completion of the process and that erases data from the previous storage block.
前記読み出し処理は、前記今回の記憶ブロックへのデータの書き込みが正常に完了していないと診断されるときに、前記今回の記憶ブロックからデータを消去する処理を含む
請求項2に記載の電子制御装置。
The electronic control according to claim 2, wherein the reading process includes a process of erasing data from the current storage block when it is diagnosed that writing of data to the current storage block is not normally completed. apparatus.
前記データは、データ本体と、同データ本体の誤り検出符号とを有し、
前記記憶ブロックには、前記データ本体が書き込まれる本体領域と、前記誤り検出符号が書き込まれる符号領域とが設けられ、
前記書き込み処理において前記今回の記憶ブロックにデータを書き込む処理は、
前記データ本体を前記今回の記憶ブロックの前記本体領域に書き込む処理と、
同処理の完了後に実施される処理であって、且つ前記誤り検出符号を前記今回の記憶ブロックの前記符号領域に書き込む処理と、を含む
請求項3に記載の電子制御装置。
The data has a data body and an error detection code of the data body,
The storage block is provided with a body area in which the data body is written and a code area in which the error detection code is written,
In the writing process, the process of writing data to the current storage block is:
Processing to write the data body into the body area of the current storage block;
The electronic control device according to claim 3, further comprising: processing executed after completion of the processing and writing the error detection code in the code area of the current storage block.
前記書き込み処理は、
前記誤り検出符号を前記符号領域に書き込む処理の完了後に実施する処理であって、且つ同符号領域に書き込まれている前記誤り検出符号を用いて、前記今回の記憶ブロックへのデータの書き込みが正常に完了しているか否かを診断する処理をさらに含み、
前記CPUは、前記書き込み処理において、前記前回の記憶ブロックからデータを消去する処理を、前記今回の記憶ブロックへのデータの書き込みが正常に完了していると診断した後に実施する
請求項4に記載の電子制御装置。
The write process
A process that is performed after the process of writing the error detection code to the code area is completed, and the writing of data to the current storage block is normal using the error detection code that is written to the code area Further includes a process of diagnosing whether or not
5. The CPU according to claim 4, wherein, in the writing process, the process of erasing data from the previous storage block is performed after diagnosing that the writing of data to the current storage block is normally completed. Electronic control unit.
前記記憶ブロックには、他の記憶ブロックからのデータの消去が完了した旨の消去情報が書き込まれる消去情報領域がさらに設けられており、
前記書き込み処理は、前記前回の記憶ブロックからデータを消去する処理の完了後に、前記消去情報を前記今回の記憶ブロックの前記消去情報領域に書き込む処理をさらに含み、
前記CPUは、前記読み出し処理において、前記前回の記憶ブロックからデータを消去する処理を、前記今回の記憶ブロックの前記消去情報領域に前記消去情報が書き込まれていないときに実施するようになっており、
前記読み出し処理は、前記前回の記憶ブロックからのデータの消去の完了後に、前記消去情報を前記今回の記憶ブロックの前記消去情報領域に書き込む処理をさらに含む
請求項5に記載の電子制御装置。
The storage block is further provided with an erasure information area to which erasure information indicating that erasure of data from other storage blocks has been completed is written,
The write process further includes a process of writing the erase information to the erase information area of the current storage block after completion of the process of erasing data from the previous storage block,
The CPU performs a process of erasing data from the previous storage block in the read process when the erasure information is not written in the erasure information area of the current storage block. ,
The electronic control device according to claim 5, wherein the reading process further includes a process of writing the erasure information into the erasure information area of the current storage block after completion of erasure of data from the previous storage block.
前記CPUは、前記書き込み処理に先立って、前記各記憶ブロックへのデータの書き込み回数が均等となるように前記今回の記憶ブロックを前記各記憶ブロックの中から選別する
請求項1〜請求項6のうち何れか一項に記載の電子制御装置。
The CPU selects the current storage block from the storage blocks so that the number of times of data writing to the storage blocks is equal prior to the writing process. The electronic control apparatus as described in any one of them.
前記不揮発性メモリには、複数の前記記憶ブロックで構成されるグループが形成され、
書き込み頻度の高いデータに対応する前記グループほど、同グループを構成する前記記憶ブロックの数が多い
請求項1〜請求項7のうち何れか一項に記載の電子制御装置。
A group composed of a plurality of the storage blocks is formed in the nonvolatile memory,
The electronic control device according to any one of claims 1 to 7, wherein the number of the storage blocks constituting the group is larger as the group corresponds to data having a higher writing frequency.
JP2014110868A 2014-05-29 2014-05-29 Electronic control device Pending JP2015225565A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2014110868A JP2015225565A (en) 2014-05-29 2014-05-29 Electronic control device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2014110868A JP2015225565A (en) 2014-05-29 2014-05-29 Electronic control device

Publications (1)

Publication Number Publication Date
JP2015225565A true JP2015225565A (en) 2015-12-14

Family

ID=54842243

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2014110868A Pending JP2015225565A (en) 2014-05-29 2014-05-29 Electronic control device

Country Status (1)

Country Link
JP (1) JP2015225565A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1125003A (en) * 1997-07-09 1999-01-29 Sony Corp Method and device for information processing
JP2000222292A (en) * 1999-02-04 2000-08-11 Nec Saitama Ltd Data managing method utilizing flash memory
JP2005322293A (en) * 2004-05-07 2005-11-17 Pioneer Electronic Corp Device, method and program for controlling memory, on-vehicle device, and recording medium
JP2007287022A (en) * 2006-04-19 2007-11-01 Mitsubishi Electric Corp Information storage method for electronic control device
JP2009116521A (en) * 2007-11-05 2009-05-28 Denso Corp Data rewriting method for memory

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1125003A (en) * 1997-07-09 1999-01-29 Sony Corp Method and device for information processing
JP2000222292A (en) * 1999-02-04 2000-08-11 Nec Saitama Ltd Data managing method utilizing flash memory
JP2005322293A (en) * 2004-05-07 2005-11-17 Pioneer Electronic Corp Device, method and program for controlling memory, on-vehicle device, and recording medium
JP2007287022A (en) * 2006-04-19 2007-11-01 Mitsubishi Electric Corp Information storage method for electronic control device
JP2009116521A (en) * 2007-11-05 2009-05-28 Denso Corp Data rewriting method for memory

Similar Documents

Publication Publication Date Title
US7543137B2 (en) Information processing device and information processing method
US8683457B1 (en) Updating firmware of an electronic device by storing a version identifier in a separate header
US8694855B1 (en) Error correction code technique for improving read stress endurance
CN111124517B (en) Embedded chip boot starting method and device, computer equipment and storage medium
US8812910B2 (en) Pilot process method for system boot and associated apparatus
US9086961B2 (en) Repair method and device for abnormal-erase memory block of non-volatile flash memory
CN110286853B (en) Data writing method and device and computer readable storage medium
EP2977907B1 (en) Data storage device, method for storing data, and onboard control device
CN103577332A (en) Control device for vehicle and error processing method in control device for vehicle
JP2012198876A (en) Device and method for curing read inability state in memory device
JP2007287022A (en) Information storage method for electronic control device
US20220300414A1 (en) Unretiring memory device blocks
CN108735268B (en) Nonvolatile memory repair circuit
US20070233940A1 (en) Method for updating data in flash memory
JP2017097576A (en) Rewrite system
JP6021597B2 (en) Information processing apparatus, information processing method, and computer program
JP5660521B2 (en) Nonvolatile semiconductor memory device and memory management method
US11169828B2 (en) Electronic control unit and method for verifying control program
JP2015225565A (en) Electronic control device
CN109643261B (en) Error correction method in flash memory
JP4558393B2 (en) Information processing device
JP4910402B2 (en) Nonvolatile memory rewriting device and rewriting method
JP2007250090A (en) Automatic replacement method for defective cell in nonvolatile semiconductor memory device
JP6092673B2 (en) Memory control device and memory control method
KR100887499B1 (en) Save mistake rehabilitation method of operation time counter to use fram in electron control system for vehicles

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20170323

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20171225

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20180123

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20180312

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20180828