MEMORY DEVICE

Abstract: A memory device includes a reset signal generator (5) for generating a reset signal when an output voltage from a main power supply circuit (1) to supply a driving voltage to a memory (2) decreases to a first predetermined voltage, and a switching circuit (3, 9) for allowing a data holding voltage from a backup power supply (10, 11) to be supplied to the memory (2) in place of the driving voltage from the main power supply circuit (1) in response to the reset signal. This memory device further includes a comparator (7, 12, 13) for generating an inhibiting signal when it detects that the data holding voltage from the backup power supply (10, 11) at the end of the reset signal is lower than the voltage necessary to hold the data in the memory (2), and a control circuit (6, 8, DEC) for setting the memory (2) into the opera­ tion inhibition state when it detects that the inhibiting signal was generated from the comparator (7, 12, 13) at the end of the reset signal.

Description: The present invention relates to a memory device which is backed up by a backup power supply when a main power supply is interrupted. Hitherto, among random access memories (RAMs) for use as the memory devices of microcomputers and the like, some RAMs using CMOS memory elements have been known. This CMOS memory element is used as a pseudo nonvolatile memory in many cases because its electric power consumption is very low and data can be held for a long time by the data holding voltage from a backup power supply. Therefore, by connecting a chargeable Ni-Cd battery or the like to the CMOS memory elements as a backup power supply, the CMOS memory elements can produce data holding characteristics similar to a real nonvolatile memory. The memory device using such CMOS memory elements needs to check whether the memory contents are correctly held in the memory device or not when the main power supply is recovered after the elapse of a certain period of time after the main power supply was interrupted due to, for example, a power failure or the like. Conventionally, as one of those checking methods, there has been known the following method. Namely, a predetermined special collating code is stored in a part of the RAM composed of the CMOS memory elements and the collating code stored in the read only memory (ROM). The collating code is read out from the RAM and compared with the collating code stored in the ROM when the main power supply is recovered and the reset signal is released. If those collating codes coincide, it is determined that the memory contents stored in the other memory areas in the RAM are correct. However, when using the aforementioned method whereby the collating code is stored in a part of the RAM for the memory device using the CMOS memory elements constituted as explained above, the memory contents can be determined to be correct by comparison with that collating code. But, since the collating codes cannot be stored in all areas of the RAM, it is impossible to determine that all the memory contents of the RAM are correct. In addition, when the power supply of the main power supply unit to supply the driving voltage to the RAM is interrupted due to a power failure or the like, the backup power supply is connected to the RAM by a switching circuit, thereby supplying the data holding voltage of the backup power supply to the RAM. On the other hand, in the case where the driving voltage which is supplied to the control section such as a central processing unit (CPU) or the like to execute the writing and readout of information in and from the RAM drops to the allowable lower limit voltage, a reset signal is generally produced from a reset signal generator provided for the main power supply unit. When the CPU receives the reset signal, it stops all operations. However, since an output voltage detector for producing a switch control signal to drive the switching circuit and the reset signal generator are independently provided, the timing when the reset signal is generated and the operation timing of the switching circuit can deviate. Therefore, in the case where the reset signal was generated after the power supply voltage to the RAM had been switched to the data holding voltage from the main power supply voltage due to the operation of the switching circuit, there is a risk that the CPU will execute the storing operation in the RAM for the interval of time from when the driving signal for the switching circuit was generated until the reset signal is generated. In such a case, there is a chance that erroneous data will be stored or that the data to be stored is not stored. It is an object of the present invention to provide a memory device having high reliability in which the memory contents of the RAM can be checked to see if they are correct or not by detecting the voltage of the backup power supply immediately before the main power supply is recovered and, further, when the main power supply is interrupted, it is possible to prevent erroneous data from being stored in the RAM and ensuring that the data to be stored. This object is accomplished by a memory device comprising: a memory; a main power supply circuit for applying a driving voltage to this memory; a reset signal generator for generating a reset signal when the output voltage from the main power supply circuit decreases to a predetermined voltage; a backup power supply circuit for applying data holding voltage to the memory; a switching circuit for allowing the data holding voltage from the backup power supply circuit to be supplied to the memory in place of the driving voltage from the main power supply circuit in response to the reset signal from the reset signal generator; a comparator for comparing the data holding voltage from the backup power supply circuit with a second predetermined voltage which is needed to hold data in the memory and is lower than the first predetermined voltage, thereby generating an output signal corresponding to the result of the comparison when the reset signal from the reset signal generator ends; and a control circuit which checks the output signal from the comparator in response to the end of the reset signal from the reset signal generator and sets the memory in the operation inhibition state when this control circuit detects that the output signal from the comparator indicates that the data holding voltage from the backup power supply circuit is lower than the second predetermined voltage. According to this invention, the level of the data holding voltage from the backup power supply circuit immediately before the main power supply circuit is recovered is detected and in response to the level of this data holding voltage, it is possible to check whether or not the contents of the memory were properly held by the backup power supply circuit during the interruption of the main power supply circuit. This invention can be more fully understood from the following detailed description when taken in conjunction with the accompanying drawings, in which: Fig. 1 is a circuit diagram of a memory device according to an embodiment of the present invention; Figs. 2 and 3 are flowcharts for explaining the operation of the memory device shown in Fig. 1; and Figs. 4A to 4F and Figs. 5A to 5D are voltage waveform diagrams for explaining the operation of the memory device shown in Fig. 1. Fig. 1 illustrates a memory device according to an embodiment of the present invention. This memory device has power supply circuit 1 connected to an AC power supply (not shown) and RAM 2 which is constituted by a number of CMOS memory elements and receives power of a DC driving voltage of, e.g., +5V. This power is received from output terminal VD of power supply circuit 1 at supply terminal VD through switching circuit 3. On one hand, output terminal VE of power supply circuit 1 is connected to both the input terminal of power supply interruption detector 4 and reset signal generator 5. When output voltage E generated from output terminal VE of the power supply circuit decreases from reference voltage E₀ to interruption voltage E₁ indicating that the power supply was interrupted due to a power failure or the like, detector 4 outputs high level interruption detecting signal DS to interruption input terminal INT of CPU 6. On the other hand, when output voltage E which is generated from output terminal VE of power supply circuit 1 decreases from reference voltage E₀ to allowable lower limit voltage E₂ lower than interruption voltage E₁ in order to drive the system, reset signal generator 5 generates low level reset signal RS to reset terminal R of CPU 6, thereby setting CPU 6 to the initial condition. At the same time, this reset signal RS is supplied to clock pulse terminal CP of D-type flip-flop 7 as an output state holding circuit and also to the input terminal of AND gate 8. Reset signal RS is also supplied to the input terminal of delay circuit 9. Delay circuit 9 delays received reset signal RS by predetermined constant delay time T₁ and generates this delayed signal as turn-off signal TS to switching circuit 3. Battery 11 of, for example, 3V serving as a backup power supply to output data holding voltage for RAM 2 through charge limiting resistor 10 is connected to the terminal of switching circuit 3 on the RAM 2 side. The data holding voltage which is generated from the terminal of resistor 10 on the side of switching circuit 3 is supplied to the negative input terminal of voltage comparator 12. A data holding lower limit voltage to hold the memory contents of RAM 2 which is generated from reference voltage generator 13 is supplied to the positive input terminal of comparator 12. Output signal CS of comparator 12 is supplied to the D input terminal of flip-flop 7. Output signal FS from the Q output terminal of flip-flop 7 is supplied to input terminal INP of CPU 6. Data bus port D of CPU 6 is connected to data bus port D of RAM 2 through a data bus. Address bus port A of CPU 6 is connected to address bus port A of RAM 2 through an address bus. The output signal of decoder DEC, used to decode the address signal outputted from address bus port A, is inputted to the other input terminal of AND gate 8. The output signal of AND gate 8 is inputted to chip enable terminal CE as the operation control terminal of RAM 2. The driving voltage of AND gate 8 is supplied from output terminal VD of power supply circuit 1 or from backup power supply 11 as is the driving voltage of RAM 2. In the ordinary operating mode, CPU 6 starts execution of the main routine as shown in Fig. 2. Namely, when the main routine is started, CPU 6 detects the signal level of interruption input terminal INT to which interruption detecting signal DS is inputted from detector 4. When the signal DS is high, it is determined that the power supply of power supply circuit 1 had been interrupted due to a power failure or the like and output voltage E decreased to interruption detecting voltage E₁ from reference voltage E₀, so that the write-in operation of data into RAM 2 is inhibited. In this case, if data is being written into RAM 2, data write-in operation is inhibited after the data write-in is ended. At the same time, a nonselecting signal is generated from address bus port A and a low level signal is sent to AND gate 8 from decoder DEC. Therefore, terminal CE of RAM 2 becomes low irrespective of the value of the driving voltage which is generated from output terminal VD of power supply circuit 1, so that RAM 2 is in the write inhibit state. In the case where the signal level at interruption input terminal INT is detected to be low, CPU 6 sets RAM 2 to the write enable state to enable the ordinary writing operation to be executed. On the other hand, when the power supply is recovered and the signal level of reset terminal R , to which reset signal RS is supplied from generator 5, is changed from low to high, CPU 6 checks the signal level of input terminal INP to which output signal FS of flip-flop 7 is supplied as shown in Fig. 3. When this signal level is high, it is decided that the memory contents of RAM 2 cannot be assumed to be correct since the data holding voltage of the backup power supply supplied to RAM 2 dropped lower than the data holding lower limit voltage when the power supply was interrupted. Thus, the contents of RAM 2 are cleared and then an error is displayed on display 14. When the signal level of input terminal INP is low, it is determined that the memory contents of RAM 2 are correct since the data holding voltage of the backup power supply was continuously over the data holding lower limit voltage even during the interruption of the power supply, so that the ordinary process can continue being executed. The operation of each section will then be described with reference to the time charts shown in Figs. 4A to 4F and Figs. 5A to 5D. In Fig. 4A, it is assumed that the power supply voltage was interrupted at time t₀ due to, for example, a power failure or the like. Switching circuit 3 is closed in the normal condition before the power supply is interrupted and the driving voltage is supplied to each section from power supply circuit 1. When the power supply voltage is interrupted at time t₀, output voltage E gradually decreases from reference voltage E₀ due to the influence of a smoothing capacitor or the like located in power supply circuit 1. When output voltage E decreases to interruption detecting voltage E₁ at time t₁, interruption detecting signal DS of detecting circuit 4 becomes high as shown in Fig. 4B. When detecting signal DS becomes high, CPU 6 executes the process shown in the flowchart of Fig. 2. When output voltage E then decreases to allowable lower limit voltage E₂ at time t₂, reset signal RS changes from high to low as shown in Fig. 4C. When reset signal RS changes to low, output signal TS of delay circuit 9 becomes low at time t₃ after the expiration of constant delay time T₁ as shown in Fig. 4D, thereby turning off switching circuit 3. The data holding voltage is supplied from battery 11 of the backup power supply to power supply terminal VD of RAM 2 after time t₃. This permits the memory contents of RAM 2 to remain intact during the interruption of the power supply. When reset signal RS becomes low at time t₂, the signal level of terminal CE to which the output signal of AND gate 8 is applied becomes low, so that new data cannot be written in RAM 2. Each circuit section starts operating after the power supply was recovered at time t₄. First, the terminal voltage of resistor 10, namely, the data holding voltage of the backup power supply and data holding lower limit voltage E₂ from reference voltage generator 13 are compared by voltage comparator 12. When the data holding voltage of the backup power supply is higher than lower limit voltage E₂, low level output signal CS is supplied to the D input terminal of flip-flop 7 as shown in Fig. 4E. When output voltage E increases to allowable lower limit voltage E₂ at time t₅, reset signal RS changes to high as shown in Fig. 4C. At this time, the output signal of delay circuit 9 remains at low level as shown in Fig. 4D, so that switching circuit 3 is kept off. When reset signal RS changes to high level, output signal FS at a level equal to that of an output signal generated at the D input terminal before the reset signal is supplied, namely in this case, at the low level, as shown in Fig. 4F, is sent to input terminal INP of CPU 6 from the Q output terminal of flip-flop 7. After CPU 6 detected the signal level of input terminal INP, switching circuit 3 is closed at time t₆ after the elapse of delay time T₁ from leading time t₅ of reset signal RS and the driving voltage is supplied from power supply circuit 1 to RAM 2. At the same time, charging of battery 11 is started. When reset signal RS is reset to a high level at time t₅, CPU 6 executes the process shown in the flowchart of Fig. 3. Further, when output voltage E increases to interruption voltage E₁ at time t₇, CPU 6 sets RAM 2 in the write enable state as shown in the flowchart of Fig. 2. On the other hand, when the power supply interruption time is long and the data holding voltage of the backup power supply becomes lower than the data holding lower limit voltage, output signal CS of voltage comparator 12 becomes high when the power supply is recovered as shown in Fig. 5C. Thus, when reset signal RS changes to high at time t₅ as shown in Fig. 5A, output signal FS of flip-flop 7 changes to high as shown in Fig. 5D and input terminal INP of CPU 6 changes to high. Therefore, CPU 6 displays an error after the memory contents of RAM 2 were cleared as shown in the flowchart of Fig. 3. Output signal CS of comparator 12 changes to low at time t₆ when the output signal shown in Fig. 5B from delay circuit 9 changes to high level. With the memory device using CMOS memory elements constituted as described above, for example, in the case where the power supply of the power supply circuit was interrupted due to a power failure or the like, when output voltage E decreases to interruption detecting voltage E₁, interruption detecting signal DS is generated and CPU 6 stops the writing operation in RAM 2 in accordance with the program. Further, when output voltage E drops to allowable lower limit voltage E₂, reset signal RS is generated and switching circuit 3 is turned off after an elapse of delay time T₁. Consequently, the data holding voltage is supplied to RAM 2 from the backup power supply, protecting the memory contents of RAM 2. When output voltage E increases to lower limit voltage E₂ after the power supply was recovered, the reset signal is released and switching circuit 3 is turned on after expiration of delay time T₁, so that the driving voltage is supplied to RAM 2 from power supply circuit 1. When output voltage E increases to interruption detecting voltage E₁, CPU 6 sets the write enable state for RAM 2. However, when it is determined by voltage comparator 12 that the data holding voltage of the backup power supply immediately before the power supply is recovered was reduced to a level lower than the data holding lower limit voltage, this information is supplied to CPU 6 from flip-flop 7. CPU 6 then executes the process corresponding to this information. Therefore, when the data holding voltage of RAM 2 dropped below the data holding lower limit voltage during the interruption of the power supply, this state can be detected by CPU 6 when the power supply is recovered, and this prevents CPU 6 from further processing on the basis of possible erroneous memory contents in RAM 2. In addition, since switching circuit 3 is opened after reset signal RS was produced when the power supply was interrupted, CPU 6 is prevented from erroneously writing data of RAM 2. Also, a control signal responsive to the address signal, which is outputted from CPU 6 in addition to reset signal RS, is inputted to operation control terminal CE to control the writing and reading operations into and from RAM 2 through use of AND gate 8. Consequently, when output voltage E of power supply circuit 1 decreases to the allowable lower limit voltage and reset signal RS is generated, the writing into RAM 2 is inhibited by software and at the same time the writing is inhibited by AND gate 8 using hardware (by a circuit). Thus, erroneous writing into RAM 2 can safely be prevented. Moreover, when power supply circuit 1 is interrupted and output voltage E starts decreasing, interruption detecting signal DS indicating that the power supply was interrupted before reset signal RS is generated is supplied to CPU 6. CPU 6 then inhibits the writing into RAM 2 using software in accordance with the flowchart of Fig. 2 after interruption detecting signal DS was generated. Therefore, reset signal RS is prevented from applying while CPU 6 is executing the writing operation into RAM 2, thereby preventing erroneous writing into RAM 2. Although the present invention has been described above with respect to one embodiment, the invention is not limited to only this embodiment. For example, in the memory device shown in Fig. 1, the function shown in Fig. 2 can be omitted by removing power supply interruption detector 4.

Claims: A memory device comprising: memory means (2); a main power supply circuit (1) for applying a driving voltage to said memory means (2); reset signal generating means (5) for generating a reset signal when an output voltage from said main power supply circuit (1) decreases to a first predetermined voltage; a backup power supply circuit (10, 11) for applying a data holding voltage to said memory means (2); and switching means (3, 9) for allowing said data holding voltage from said backup power supply circuit (10, 11) to be applied to the memory means (2) in place of said driving voltage from said main power supply circuit (1) in response to the reset signal from said reset signal generating means (5), characterized by further comprising comparing means (7, 12, 13) for comparing the data holding voltage from the backup power supply circuit (10, 11) with a second predetermined voltage which is the mininum voltage needed for the memory means (2) to hold data, and generating an output signal corresponding to the result of the comparison when the reset signal from the reset signal generating means (5) is ended, and control means (6, 8, DEC) which checks the output signal from said comparing means (7, 12, 13) in response to the end of the reset signal from said reset signal generating means (5) and sets said memory means (2) into the operation inhibition state in the case where said control means detects that the output signal from the comparing means (7, 12, 13) indicates that the data holding voltage from said backup power supply circuit (10, 11) is lower than said second predetermined voltage. A memory device according to claim 1, characterized by further comprising power supply interruption detecting means (4) which generates an output signal when said detecting means (4) detects that the output voltage of the main power supply circuit (1) drops lower than a third predetermined voltage between said first and second predetermined voltages, and in that said control means (6, 8 DEC) sets said memory means (2) into the operation inhibition state in response to the output signal of said power supply interruption detecting means (4). A memory device according to claim 2, characterized in that said comparing means includes a reference voltage generator (13) for generating said second predetermined voltage, a comparator (12) for comparing the output voltage of the backup power supply circuit (10, 11) with the output voltage of said reference voltage generator (13), and a signal holding circuit (7) for holding the output signal of said comparator (12) in response to the end of the reset signal from said reset signal generator (5). A memory device according to claim 2 or 3, characterized in that said control means comprises a control circuit (6, DEC) for generating a nonoperating signal in response to the output signal of said power supply interruption detecting means (4) and a logic circuit (8) for setting said memory means (2) into the operation inhibition state in response to at least one reset signal from the reset signal generating means (5) and the nonoperating signal from said control circuit (6, DEC). A memory device according to claim 1, characterized in that said comparing means includes a reference voltage generator (13) for generating said second predetermined voltage, a comparator (12) for comparing the output voltage of the backup power supply circuit (10, 11) with the output voltage of said reference voltage generator (13), and a signal holding circuit (7) for holding the output signal of said comparator (12) in response to the end of the reset signal from said reset signal generator (5). A memory device according to any one of preceding claims, characterized in that said switching means comprises a delay circuit (9) for delaying the reset signal from said reset signal generating means (5) by only a predetermined time and a switch (3) for allowing the data holding voltage from said backup power supply circuit (10, 11) to be supplied to said memory means (2) in place of the driving voltage of said main power supply circuit (1) in response to the reset signal which is supplied through said delay circuit (9).

Inventors: ITO, YOSHIAKI, MATSUSHITA, TSUYOSHI
Applicants: TOKYO ELECTRIC CO., LTD.
Application year: 1985
Main classification: G11C5
IPC codes: G11C5, G11C7, G06F1