Abstract:
A clocked comparator circuit compares the primary and backup power supply voltages to a system. When the primary voltage falls a given amount below the backup, the circuit provides a signal that may be used to switch to the backup power supply. When the primary voltage is again present, the circuit can switch back to primary power. Alternatively, or additionally, a signal may be generated to initiate graceful shutdown of the system. The clock to the comparator typically operates at a higher frequency when operating on the primary voltage, and a lower frequency when operating on the backup voltage. This circuit is typically used with a portable system that uses a rechargeable battery as its primary power supply. The backup power supply may be a long-life battery that provides power to only a portion of the system. For example, in a computer, only a static memory may be powered by the backup, to allow the full system to retain its proper configuration when the primary power supply is again activated. The circuit may be implemented with all digital logic, typically CMOS, thus minimizing power dissipation and increasing its versatility.

Description:
BACKGROUND OF THE INVENTION 
     1. Field of the Invention 
     The present invention relates to a power supply loss sensor. 
     2. Description of the Prior Art 
     Battery-operated electronic devices are becoming increasingly sophisticated, with microprocessors and other types of integrated logic circuitry being used in a variety of portable, mobile, and other applications. Often a primary battery is used in normal operation, with a backup battery retaining essential data and circuit functions when needed; for example, when the primary battery becomes too weak to function, or when the primary battery is being replaced. Referring to FIG. 8, data corruption or system malfunction due to loss of the primary battery (80) is commonly prevented by using a &#34;diode-switch&#34; method. This method uses two diodes (81,82) external to the system device (e.g., integrated circuit 83), and connected so that one diode is reverse biased while the other diode is forward biased. This type of solution is acceptable if the voltage level of V DD  is high enough so that a diode voltage drop from V DD  will still provide a solid power supply voltage to the system, which is usually true if V DD  is 5 V (plus or minus 10 percent). However, in the case of a 3 V (plus or minus 5  percent) V DD , using this method, the power supply voltage to the integrated circuit 83 is in the range of only 2.2 V to 2.5 V (i.e., V DD  minus the diode voltage drop). This level of power supply voltage (2.2 V to 2.5 V) may degrade the performance of a logic circuit to a point which is not acceptable. For example, the speed degradation due to the lowering of the power supply from 3 V to 2.2 V is typically a factor of 2. 
     One method of reducing the voltage loss across a diode is to switch between the batteries with transistors. For example, U.S. Pat. No. 4,451,742 shows one such circuit. However, in the voltage loss detector discloses therein, analog circuitry is used to compare the primary power supply to one (or more) backup batteries. Hence, an analog process technology is required when implementing the circuit in integrated circuit form. Furthermore, the disclosed circuitry may also result in significant current drain on the power supply. In another example, the use of an analog comparator in a battery switch-over circuit is shown in the Low Voltage Databook of National Semiconductor, 1992 Edition, at page 3-57. 
     SUMMARY OF THE INVENTION 
     We have invented a technique for detecting loss of a power supply voltage. A first power supply voltage from a first source is compared to a second power supply voltage from a second source. The comparison is accomplished in a clocked comparator, which may be implemented in CMOS technology. In a preferred embodiment, the clock rate is higher when operating from the first (e.g., primary) power source than when operating from a lower-voltage second (e.g., backup) power source. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 shows a block diagram of an embodiment of the invention. FIGS. 2 through 7 shows circuitry suitable for implementing the block diagram of FIG. 1. FIG. 8 shows a prior-art battery backup technique. 
    
    
     DETAILED DESCRIPTION 
     The following detailed description relates to a technique and circuit for detecting the loss of a power supply voltage in a system that includes a primary and a backup power supply. One or both of the power sources are typically batteries; for example, a rechargeable battery may be the primary power source, and a long-life battery (e.g., lithium or alkaline) may be the backup, with other power sources being possible. The loss sensor detects a gradual degradation or total loss of V DD , the primary power supply to the system. In a presently-preferred embodiment, either the primary power supply or the backup power supply can be removed from the system at any time and the circuit will maintain power to a selected portion of a system, using the remaining power supply. The loss sensor circuit shown in the illustrative embodiment is designed with all-digital logic, thus minimizing power dissipation and increasing its versatility. That is, this circuit can be fabricated with either a digital or analog integrated circuit fabrication process. The functional description of an illustrative embodiment of a system employing the inventive technique follows. 
     Referring to FIG. 1, a block diagram of an illustrative embodiment of the invention is shown. During normal operation, the loss sensor samples V DD  (primary power source) at a given rate and compares this with V BAT  (backup battery source). If V DD  is lower than V BAT  a warning signal (ENA) is set, to indicate this condition, and the loss sensor output (V ISO ) is switched to draw power from V BAT  rather than V DD . Power to data-critical portions of a device, for example a memory containing system privileges information, can be maintained using this circuit. The generated warning signal may be timed such that a system can be gracefully shut down prior to switching to V BAT . The illustrative circuit embodiment includes 5 logic blocks. They are the CLKGEN (Clock Generator) 10, VLD (V DD  Loss Detector) 11, LSG (Loss of Signal Generator) 12, GDT (Glitch Detector) 13, and PWS (Power Switch) 14. The voltage V ISO  powers all the devices in the LSG and GDT blocks (12,13) as indicated. Power to the devices in the other blocks is supplied from either V.sub. DD, V BAT , or V ISO  as indicated in the other Figures, with V SS  being the common negative voltage. Circuits suitable for implementing these functions are as follows: 
     1. CLKGEN (Clock Generator): 
     Referring to FIG. 2, CLKGEN consists of ROSC (Ring Oscillator) 20, CKMX (Clock Mux) 21, and PHGEN (Phase Generator) 22. ROSC is a low power gated ring oscillator which generates a raw clock input to PHGEN. The frequency of ROSC is primarily controlled by the number and size of inverters in the oscillator loop, along with setting the value of variable capacitors. A secondary control over the ROSC frequency is obtained through variation of the primary power supply, V DD . Signal VSW, an output of the LSG block, is used to gate ROSC on and off. CKMX selects between the high-speed clock signal generated by ROSC and a low-frequency clock, RTCCLK, which in the illustrative-embodiment is generated externally. During normal operation (V DD  valid) ROSC is selected. The frequency of ROSC is typically greater than 1 MHz, and illustratively 10 MHz. This relatively high frequency provides for rapid detection of loss of the primary power supply, so that the system may switch over to the backup supply without loss of vital data or system parameters. The low frequency input RTCCLK is selected during low-power standby modes and periods of V DD  loss; i.e., when operating from the backup power supply (V BAT ). In a typical case the low frequency input RTCCLK provides a signal of less than 1 Mhz, and illustratively about 32 KHz. This relatively low frequency provides for low-power consumption of the sensor circuit when operating from V BAT . PHGEN receives a raw clock from CKMX and produces three clocks, CKA, CKB and CKC. Note that CKA and CKB are overlapping in the low voltage state, in order to compare V DD  and V BAT , as discussed below. The frequency of these clocks dictates the sampling rate of both the V DD  power supply and V BAT  power supply. 
     2. VLD (V DD  Loss Detector): 
     Referring to FIG. 3, the sampling section of the loss sensor circuit (VLD) is illustrated, with the clock waveforms being illustrated in FIG. 4. At initialization, node SOUT is low, indicating that V DD  is greater than V BAT . CKA pulses high (logic one) each sampling period, causing pull-down transistor MN1 to conduct while preventing pull-up transistor MP1 from conducting, to clear node 31 by placing it at V SS . When CKA goes low (logic zero), V DD  is sampled through MP1. The sampled voltage (appearing at node 30), minus a threshold of voltage-dropping transistor MP2, is stored at node 31. When CKA is high, CKB is also high, preventing pull-up transistor MP3 from conducting, and allowing pull-down transistor MN2 to conduct, so that node 33 is pulled low, thereby resetting it. While CKA is low and CKB is low both V DD  and V BAT  are sampled. If the voltage stored at node 31 drops more than a p-channel transistor threshold below the voltage at node 32, switching device MP4 will turn on and pull node 33 up toward V BAT . However, since clock CKB is relatively short compared to CKA, node 33 does not necessarily reach V BAT  during a single clock cycle. As the voltage at node 31 continues to fall, node 33 is pulled up more strongly; this effect helps to avoid false triggering of the signal SOUT. 
     When node 33 reaches the switching point of the first inverter 34, SOUT will be pulled high by inverter 35. SOUT goes to the input of the LSG (Loss of Signal Generator), causing the generation of signals ENA and VSW, which switches the voltage V ISO  from the main power supply to the backup, as discussed below. The amount (Δ) by which V DD  must fall below V BAT  in order for SOUT to be pulled high is determined by the size of transistor MP4 and the duration of CKB. For reasons noted above, it is desirable to minimize Δ, and the present technique readily allows for Δ to be less than or equal to 150 millivolts. In a typical implementation, Δ=50 millivolts. 
     3. LSG (Loss of Signal Generator): 
     Referring to FIG. 5, the Loss of Signal Generator (LSG) receives SOUT from VLD and produces signals VSW (switch control to PWS) and ENA (V DD  loss warning signal). Latch 50 uses SOUT as its clock to capture the current result of the V DD  and V BAT  comparison. The Q output node 51 of latch 50 is normally low after initialization and goes high when triggered by SOUT. When clocked by CKA through NAND gate 52, the high SOUT delivers a clock signal through inverter 53 to latch 54. Depending on the the state of the BOOT signal, ENA will either be high already or will go high sometime after node 51 goes high, due to the action of inverter 56 and NAND gate 57. VSW, the output of latch 54 through inverter 55, will be high during normal operation (i.e. V DD  greater than V BAT ). VSW is the signal indicating the loss of V DD  (or V DD  less than V BAT ) and a valid signal is produced a sampling period after loss of V DD  is detected. This delay is optionally provided for applications which require that output ENA be valid some amount of time prior to output VSW changing state. Thus, ENA may be used to set the system to a power-down state before the power source is switched from V DD  to V BAT . VSW is used as a loss of V DD  indicator to the GDT block 13 and also as a switch control signal to the PWS block 14. The power supply to the LSG block is V ISO , the output of the Power Switch (PWS) block. Both latches 50 and 54 have a reset pin R which is used to reset node 51 to zero and VSW high, respectively, during glitch recovery. 
     4. PWS (Power switch): 
     Referring to FIG. 6, the main components of this logic block are inverters 60, 61 and two large power PMOS transistors, P1 and P2. Transistors N1, N2, N3 and P3 are present to ensure that V ISO  initializes correctly. Transistors P1 and P2 are used as power switches and the inverters are used to generate complementary control signals. V ISO  is electrically connected to V DD  through transistor P1 when the voltage level of V DD  is higher than that of V BAT . Otherwise, V ISO  is electrically connected to V BAT  through transistor P2, as follows: The source nodes of P1 and P2 are connected to V DD  and V BAT  respectively. When the input VSW of this section (from the LSG block) is high, i.e. V DD  is higher than V BAT , P1 is on and P2 is off, thus connecting V ISO  to V DD . Conversely, if VSW is low, P1 is off and P2 and P3 are on, thus electrically connecting V ISO  to V BAT . The delay through inverter 60, from turn-on of P2 to turn-off of P1, ensures glitch-free switching of V ISO  due to the fact that V ISO  is never isolated from both V DD  and V BAT  at the same time. Transistors P3 and N3 ensure that V ISO  will still initialize correctly while avoiding the disadvantageous condition of V DD  back-driving V BAT . 
     5. GDT (Glitch detector): 
     Referring to FIG. 7, the glitch detector (GDT) block provides the master reset signal MRST for the loss sensor as well as reset generation signal RST upon a glitch detection or noise spike on V DD . Any V DD  glitch above the V BAT  voltage level is masked by GDT. The master reset signal MRST is used to initialize the PWS block (FIG. 6). A negative master reset pulse MRST, is generated on the rising edge of the initialization input, PGOOD, by the delay action of inverters 75, 76 and 77, and NAND gate 78. In addition, a negative reset pulse RST is generated from PGOOD by the additional action of NAND gate 73 and inverter 74. The signal PGOOD may be externally supplied from a micro-controller when coming out of a power-down mode, for example, or from other means. The GDT block also generates a reset pulse RST to the LSG block if a glitch is detected on V DD . This condition is detected if, in any sampling period, node VSW has been set low by the LSG and SOUT is also low. If a glitch occurred on the V DD  input then VSW would be low and SOUT would be high resulting in a low output from gate 70. This low output is latched by 71 and no reset pulse is generated in the same sampling period that the glitch occurred. If, in the subsequent sample period, the glitch is no longer present then both VSW and SOUT will be low. CKB would then clock the high output of gate 70 into latch 71. The output of latch 71 is qualified by by NAND gate 72 according to CKC (FIG. 4) to generate a low reset pulse (RST low). This pulse resets VSW back to high (FIG. 5), indicating that the V DD  is greater than V BAT . In summary, the RST signal is normally high, but goes low after 2 clock cycles when V DD  goes greater than V BAT . 
     The V DD  loss warning signal (ENA) may be utilized by a user to initiate graceful shut down of a system. The loss sensor is especially well suited for 3 V systems where a 0.7 V diode drop in the power supply voltage cannot be tolerated. The circuit may be readily integrated with a wide range of integrated circuit fabrication technologies, and typically does not require special processing steps or design requirements in the CMOS implementation shown. As indicated above, the loss sensor circuit may be used in providing a supply voltage to a system at a level Δ which is only slightly below V DD , thereby helping to ensure an adequate power supply voltage margin. The voltage V ISO  may be provided to power one or more integrated circuits. However, it is desirable in many cases to provide V ISO  to only a portion of an integrated circuit where critical information is stored. For example, providing V ISO  to a static memory portion of an integrated circuit allows for system parameters or other information to be stored during the loss of main power (V DD ), thereby allowing for resumption of normal operation of the integrated circuit (or system) when main power is restored.