adl_adRecompact doesn´t Erase all the CELLs

Hi to all!, im having a huge problem. When im developing the FIFO library i use the adl_adRecompact to make liberate all the deleted Cells, the problem is that when i shut down the CPU in the middle of the progress some cells are liberated but not all!. This is big because when the CPU restarts doesnt know this!.

Does anyone knows how can i solve it?.

Thanks!

can you just set a flag before starting compact operation. And reset the flag when operation complate. And when your CPU starts, it should check the flag. If it is still set, the means last recompact operation is not successfull then it must do compaction again.

The flag value has to be stored on the flash in order the CPU to read this value after reset.

Is this simple way suit for you?

Thank a lot zafer!!, but unfortunately i considered that option before and cannot do that. The Flash mem has only 1000000 writes per page, so if i need to save a state flag there this must be written every time i write the A&D. In result, if i do this my equipment will not live too much. There is another path to solve this, instead of manage a flag in FLASH you can use the “Finalize” flag of the CELL. Lets say you have 10 CELLS whose sizes are defined, so you write in the first CELL till fill it, and then you write then next and so, later you begin to Read from the first one, once you finish reading and move to the nex one, you Finalize that CELL (doesn mather if you have the CELL size defined, you can still finalize it) and then remove it. If the power fails and your app cant erase the cell the cell wont be freed, so when your app restarts just check for finalized Cells and erase it.

Conclution.
1-Make the CELLS with the defined sizes.
2-Write and read them as you please.
3-When your want to erase the Cells, you “paint” them with the Finalize command.
4-If you need to restart or the app is interrupted, the first thing to do is to erase the Finalize Cells.

With this method you dont need to use the Flash mem to know wich Cells have to been erased. I tested this one and it works!.

Best Regards,
Nicolas.