Most of the UCD3138 family EVM codes support the store default all and restore default all commands. This post explains the correct and incorrect way to use it, and how to make it more robust to misuse.
The store default all command uses data flash to store lots of system parameters, including gain settings, system calibration, and filter parameters.
There are two flash blocks which are used alternately.
One flash block stores the current data, and the other flash block is kept erased.
When a store default all command is received on the PMBus, the data is written to the data flash block.
This is done in the software interrupt and takes typically about 5 milliseconds. or less. During this time the interrupts are disabled, so it is recommended that this not be done while the power supply is running.
After this, the other data flash block is erased. This erase takes at least 20 msec for each page erased.
Some EVM codes have more pages to erase than others. It can take 300 msec for the erases to complete in some cases.
If another store default all command is run while the erase process is going on, it will not execute. The program checks for ongoing erase and just returns.
If the erase process is interrupted by a power down, the firmware will detect the status and restart it on the next power down.
Note that while the data flash is being erased, any attempt to write to the program flash checksum will fail. This is because the flash logic only permits operation on one flash block at a time. So while the data flash is being erased, the program flash write will be ignored.
If this is not desired behavior, you can make have the command to return to ROM mode check for erase completion. If the erase isn't complete, the return to ROM mode can set a new flag variable instead of trying to go write to the lash. Then you also need to add code to check for this flag when the data flash erase is complete, and then clear the checksum.
Normally this last case doesn't occur in device operation, only in testing. Normally the store default all occurs during board testing, just before the board is shut off. There it is much more likely that the board will be shut off before the erase, or even the write is complete. Obviously the power should not be shut off at least until the write to data flash is complete. Ideally time should be added to let the erase complete as well.