Microcontroller provides SRAM battery backup
To maintain content in the event of power loss, many designs that include SRAM require a dedicated device that can automatically switch from a standard power supply to battery operation. Microcontrollers seldom find use in power-switching applications. Because microcontrollers typically operate from the primary power supply, they stop execution if that supply drops, thereby making it impossible to perform the switching operation. However, by using a characteristic of many microcontrollers, you can perform this switching function without interruption to the SRAM (Figure 1). Many microcontrollers have internal protection diodes on their I/O pins. Therefore, if the VCC pin is left floating, the CPU in many instances powers up and runs if you apply power only to an I/O pin. With this fact in mind, you can create an "automatic voltage switch" by connecting the main power-supply rail and a secondary battery backup to two separate I/O pins of the microcontroller. The microcontroller can then have firmware that drives a third I/O to a logic-high (source) mode or otherwise source current to an output pin. This output then provides the uninterrupted power to the external low- power SRAM device.
When the VCC rail is present, the microcontroller draws current from the VCC pin and operates normally. If the VCC rail drops below the battery-input voltage, the microcontroller automatically draws current from the battery instead. Although this scenario requires no firmware whatsoever, many microcontrollers can run firmware and continue execution throughout this power-supply transition. Continuing the microcontroller's firmware execution allows other firmware-based functions, such as deassertion of SRAM chip enable, battery- and rail-health indication, and analog-to-digital conversion. When you use this technique, you must take care to ensure that the entire design draws less current than the forward-bias-current rating of the protection diode. Also, the external SRAM circuit must draw no more current than the microcontroller's output can source. This stipulation remains true whether the VCC rail or the battery provides power. It is also important to realize that, because the protection diodes are sourcing the power, a slight voltage drop exists on the microcontroller's uninterrupted-power-supply output. This voltage drop is equivalent to the one that the microcontroller's manufacturer specifies. You should consider this drop when you select the battery, VCC rail, and external-SRAM voltage requirements.