Zibb

Design Idea

Power up a microcontroller with pre-power-down data

Stephan Roche, Santa Rosa, CA; Edited by Brad Thompson -- EDN, 3/17/2005

It is sometimes necessary to retrieve data at power-up in the same way that they were at the last power-down, so that the product wakes up in the state it had before shutdown or to retrieve some measurement. One approach is to save critical variables into EEPROM or flash memory as soon as they change. This approach is generally not a good idea, because flash is typically limited to 100,000 write cycles, and EEPROM is typically limited to 1 million cycles. These numbers may seem large, but a product can easily reach them during their lifetimes.

Another approach is to use a battery to keep the microcontroller supplied so that it doesn't lose its RAM contents. This Design Idea presents an alternative option: detecting a power-down and triggering an interrupt routine that saves all the parameters in EEPROM or flash before the microcontroller supply falls below the operating threshold. Figure 1 implements such an approach for a PIC18F6720 microcontroller.

One of the many features of this microcontroller is its low-voltage detection, which can trigger an interrupt when its LVD input goes below a threshold. You can set the threshold at 2.06V to 4.64V. The PIC18 microcomputer ceases functioning when its voltage supply is less than 4.2V. Because the EEPROM/flash-saving cycle is fairly time-consuming, the tactic is to monitor the voltage at the input of the 5V regulator to detect the power drop even before the microcomputer's supply starts to drop.

Select the LVD trip point inside the PIC18F6720 to be 1.22V, and calculate the required value of R2/R1 with the following equation:

where VIN_THRESHOLDis the trip point below which a "data-save" function triggers. You should select this trip point to be as high as possible but not too high to avoid triggering on the ripples and noise on VIN–.

Figure 2 shows the VIN and VCC waveforms when a power-down occurs. The ΔT represents the time allowed for saving data, which starts when the circuit detects the drop of VIN and finishes when the voltage on the microcontroller goes below 4.2V, at which point it ceases to function. If the same 5V supply powers other devices , add a Schottky diode in series to ensure sufficient energy storage for the microcontroller to save the data. Listing 1 contains the assembly code that saves the data when a power-down occurs and retrieves the saved data at power-up.

 

Check out our Best of Design Ideas section!



Reed Business Information Resource Center

Featured Company


Related Resources

ADVERTISEMENT

ADVERTISEMENT

Related Content

 

By This Author


ADVERTISEMENT

Knowledge Center



Technology Quick Links

EDN Marketplace


©1997-2009 Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy

Please visit these other Reed Business sites