Algorithm keeps data safe
Prevent data loss against power blackouts and other interruptions.
Luis G Uribe C, Caracas, Venezuela; Edited by Martin Rowe and Fran Granville -- EDN, January 21, 2010
Many embedded systems must regularly update multibyte data to EEPROM, flash memory, or a database server. This Design Idea presents a robust algorithm for this process that prevents data losses and inconsistencies due to program interruptions or power failures. You can avoid data losses by maintaining two separate memory areas, duplicating critical variables in each. Memory can be battery-backed RAM, magnetic disks, flash memory, or local or remote storage subsystems. You can use a simple FSM (finite-state machine) that uses three or four states with appropriate Gray coding to track the status of each main variable and its mirrored value in the storage devices. The states run in a sequence that the software driver can use to write data to both the main and the backup variables. The driver sets and resets two variables, B0 and B1, as status bits. B0 is the main variable status bit, and B1 is a mirror status bit. Both bits are recorded in the same storage medium as the data.
| See all of EDN's Design Ideas |
This algorithm prevents race conditions and ambiguous situations. You can enter the power-up verification routine at any time, interrupting the main flow of the program without losing any data. Figure 1 shows the flow of the algorithm, which begins with a power-up routine. Table 1 identifies and defines each of the possible states for the variables. Click here for other algorithms.
-
More info & updates: guribe.linuxsis.net/MyEDN-Article-01
Luis G. Uribe C. - 2010-25-1 19:50:00 PST -
Table 1 should be headed: B1 B0 (not B0 B1 as it is...)
Luis G. Uribe C. - 2010-21-1 21:29:00 PST -
Hi, Nice article! Very simple.
Can not see Figure 1 !
Nihil Obstat (Niky) - 2010-21-1 06:39:00 PST





















