Data preserving method and data accessing method for non-volatile memory

A data preserving method and a data accessing method for a non-volatile memory are provided. In the data preserving method, a data is checked according to an error correcting code (ECC) to obtain an error bit number of the data. When the error bit number is greater than a threshold, the data is moved from a first memory unit to a second memory unit and is corrected according to the ECC. Thereby, the data stability of the non-volatile memory is improved.

CROSS-REFERENCE TO RELATED APPLICATION

This application claims the priority benefit of Taiwan application serial no. 96142823, filed on Nov. 13, 2007. The entirety of the above-mentioned patent application is hereby incorporated by reference herein and made a part of this specification.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention generally relates to a non-volatile memory, in particular, to a data preserving method and a data accessing method for a non-volatile memory.

2. Description of Related Art

Generally speaking, non-volatile memories (for example, a flash memory) are always faced with the problem of data instability caused by, for example, bad blocks, write disturb, and read disturb. The problem of read disturb will be explained in detail below.

FIG. 1is a diagram of memory units in a non-volatile memory. Referring toFIG. 1, read disturb is produced because of the physical characteristic of the non-volatile memory. The address lines101a,102a,101b,102b,103b. . . are used for transmitting data voltages or for addressing a data. In other words, if a data in memory unit101is to be read, the data in the memory unit101is addressed and read through the address lines101aand101b, and accordingly a residual voltage is left on the address lines101aand101b. Since the address line101ais shared by the memory units101,102, and103, the residual voltage on the address line101amay affect the data in the memory units102and103and may even cause errors to the data in the memory units102and103. Similarly, since the address line101bis shared by the memory units101and104, the residual voltage on the address line101bmay also affect the data in the memory unit104and may even cause error to the data in the memory unit104.

SUMMARY OF THE INVENTION

Accordingly, the present invention is directed to a data preserving method for a non-volatile memory, wherein the data stability of the non-volatile memory is improved.

The present invention is directed to a data accessing method for a non-volatile memory, wherein the data validity of the non-volatile memory is improved.

The present invention provides a data preserving method for a non-volatile memory. In the data preserving method, a data is checked according to an error correcting code (ECC) to obtain an error bit number of the data. In addition, when the error bit number is greater than a threshold, the data is moved from a first memory unit to a second memory unit and is corrected according to the ECC.

According to an embodiment of the present invention, the step of checking the data according to the ECC to obtain the error bit number further includes reading the data according to a read address. According to another embodiment of the present invention, the second memory unit is a blank memory unit before the data is moved from the first memory unit to the second memory unit. According to yet another embodiment of the present invention, the first memory unit is erased or marked as a high risk memory unit after the data is moved from the first memory unit to the second memory unit. According to still another embodiment of the present invention, the threshold is smaller than a tolerable error number of the ECC. According to yet still another embodiment of the present invention, the first memory unit and the second memory unit are blocks or pages.

The present invention also provides a data accessing method for a non-volatile memory. In the data accessing method, an ECC is generated according to a data, and the data and the ECC are written into a first memory unit of the non-volatile memory. When the data is read, the data is checked according to the ECC to obtain an error bit number of the data. In addition, when the error bit number is greater than a threshold, the data is moved from the first memory unit to a second memory unit and is corrected according to the ECC.

According to an embodiment of the present invention, the step of writing the data and the ECC into the first memory unit further includes writing the data into a data storage area of the first memory unit according to a write address and writing the ECC into a spare area of the first memory unit according to the write address.

In the present invention, a data in a non-volatile memory is checked according to an ECC so as to obtain an error bit number, and when the error bit number is greater than a threshold, the data is moved from a first memory unit to a second memory unit and is corrected according to the ECC. Thereby, the data stability of the non-volatile memory is improved.

DESCRIPTION OF THE EMBODIMENTS

Conventionally, a non-volatile memory is always faced with the problem of read disturb, and which may cause error to data stored in the non-volatile memory. Generally speaking, the bit error number of a data increases along with the number of times the data is read.

Accordingly, in embodiments of the present invention, the data in a memory unit of a non-volatile memory is checked according to an error correcting code (ECC) so as to monitor the error bit number of the data. When the error bit number is greater than a threshold, the data is moved to another memory unit and is corrected according to the ECC. Accordingly, the data can be programmed again and errors produced in the data can be corrected.

FIG. 2is a block diagram of a NAND flash memory according to an embodiment of the present invention. Referring toFIG. 2, in the present embodiment, a NAND flash memory is described as an example of the non-volatile memory. Generally speaking, a NAND flash memory has a plurality of blocks110, each of the blocks110includes a plurality of pages120, and each of the pages120is further divided into a data storage area130and a spare area140, wherein the data storage area130is used for storing data, and the spare area140is used for storing an ECC.

As described above, an ECC is used for correcting the errors produced in a data. It should be noted that different types of ECCs have different error tolerances. In the present embodiment, it is assumed that the tolerable error bits number of the ECC is 8. Once the error bits in the data exceed 8 bits, the ECC will not be able to correct these errors and may even increase the number of errors in the data.

FIG. 3is a flowchart of a data accessing method and a data preserving method according to an embodiment of the present invention. The present embodiment is described with reference to the example illustrated inFIG. 1so please refer toFIG. 1,FIG. 2, andFIG. 3for following description. In the present disclosure, a memory unit may refer to a storage space of any unit. To be specific, a memory unit may be a block110, a page120, or a sector. In the present embodiment, the memory units101˜106are assumed to be different blocks110; however, the present invention is not limited thereto, and in another embodiment of the present invention, the memory units101˜106may also be different pages120or different sectors. Additionally, the data preserving method in the present embodiment includes steps S303and S304, and the data accessing method includes steps S301˜S306. Below, various steps in the data accessing method for storing a data will be described in detail.

In the present embodiment, it is assumed that a first data is to be stored in a non-volatile memory. First, in step S301, a memory controller (not shown) generates an ECC according to the first data. Next, in step S302, the memory controller writes the first data and the ECC into the non-volatile memory according to a write address. In the present embodiment, assuming the write address is memory unit101, the memory controller writes the first data into the data storage area130of the memory unit101and the ECC corresponding to the first data into the spare area140of the memory unit101. By now the data writing operation is completed. Other data may be written into the non-volatile memory in similar process and which will not be described herein.

Along with the increase in the number of times the data stored in the non-volatile memory is read, errors may be caused to the data due to problems such as read disturb. Thus, data stored in the non-volatile memory should be appropriately preserved by using an ECC.

For example, step S303can be executed whenever a data is read from the non-volatile memory. To be specific, when the memory controller is about to read the first data from the non-volatile memory, the memory controller searches for the first data and the corresponding ECC according to a read address. Next, the memory controller checks the first data stored in the data storage area130of the memory unit101according to the ECC stored in the spare area140of the memory unit101to obtain an error bit number of the data.

Here it is assumed that the error bit number of the first data is 6 and the threshold is 3. Next, in step S304, whether the error bit number is greater than the threshold is determined. If the error bit number is greater than the threshold, which means the first data is in a high risk state, step S305is executed to correct the first data; otherwise, if the error bit number is smaller than the threshold, which means the first data is in a safe state and has low possibility of being damaged, step S306is executed to end the data preserving operation. It should be mentioned that even though the threshold is assumed to be 3 in the present embodiment, the present invention is not limited thereto, and those skilled in the art should be able to set the threshold according to the actual requirement. The advantage of foregoing method is that the memory controller does not have to correct the data in a memory unit whenever an error is found. Accordingly, time for correcting errors is considerably reduced and the access speed to the non-volatile memory is not affected.

As described above, in the present embodiment, the error bit number 6 is greater than the threshold3preset by the system. Thus, step S305is executed to move the first data from the memory unit101to another blank memory unit and to correct the first data. To be specific, if the memory unit102is a blank memory unit, the first data is moved from the memory unit101to the memory unit102, and the first data is corrected according to the ECC. Thereby, errors in the first data can be corrected before the error bit number of the data exceeds the error tolerance of the ECC, so that the correctness of the first data can be ensured. In addition, the first data can be programmed again so that the first data will not be damaged for being in the high risk state for long time.

Most data errors are caused by current leakage, and current leakage is usually caused by defect in devices or physical structure of the non-volatile memory. A user cannot fix the problem of current leakage. A memory unit can be presumed to be a defective memory unit if a certain number of errors are caused to the data in the memory unit. Generally speaking, a defective memory unit is more likely to have errors occur to the data stored therein again than a normal memory unit.

Accordingly, the memory controller may also determine whether to mark the memory unit101as a high risk memory unit according to the error bit number of the data stored therein while executing foregoing step S305. For example, when the error bit number of the data in the memory unit101is between 6 and 7, step S305is executed and the memory unit101is marked as a high risk memory unit, and when the error bit number of the data in the memory unit101is between 3 and 5, step S305is executed and the memory unit101is erased. When a data is to be stored into the non-volatile memory later on, the memory controller can select a memory unit which is not marked as a “high risk memory unit” to store the data, so that the possibility of the data being damaged is reduced and data stability of the non-volatile memory is improved.

Foregoing situation that the error bit number falls between 6 and 7 or between 3 and 5 is not intended to limit the present invention, and those skilled in the art can set the range of the error bit number according to the actual requirement.

In summary, in the data preserving method for a non-volatile memory provided by the present invention, the data stability of the non-volatile memory can be improved and the data correctness thereof can be ensured without changing the structure of the non-volatile memory. Moreover, if the data preserving method is integrated with a data accessing method for the non-volatile memory, not only the functions described above can be achieved, but the data stored in the non-volatile memory can be maintained appropriately so that the data can be corrected before the error bit number of the data exceeds the error tolerance of an ECC. Furthermore, the methods provided by the present invention also have following advantages:

1. by setting a threshold, whether a data is corrected can be determined by checking whether an error bit number of the data is greater than the threshold. The data is corrected only when the error bit number is greater than the threshold so that it is not necessary to correct the data whenever an error occurs to the data. Accordingly, the access speed of the non-volatile memory is not affected.

2. a memory unit can be marked as a high risk memory unit when a certain number of errors are caused in the data stored in the memory unit. When a data is to be stored into the non-volatile memory later on, a memory unit which is not marked as a “high risk memory unit” can be selected to store the data so that the data stability of the non-volatile memory can be improved.