STM32G4 Flash writes at BOR
Hello,
We have currently moved on to the STM32G4 series, and we are now looking at a project where data will be occasionally written to flash under control of our own code. Of course, this exposes us to flash memory corruption during unforeseen power loss events. To protect against this, I intend to use the internal Power Supply Supervisor block of the microcontroller.
I am tempted to directly use the BOR threshold to protect us, so that the microcontroller gets reset as soon as the voltage drops under some 2.9V. This will still give us some time (based on on-board capacitance discharge time) until the voltage drops below the 1.7V minimum operating voltage so that the eventual flash memory write operation would have time to finish. We plan to write a maximum One row (32 double word) at a time, so the micro power supply has to be able to remain above the 1.7V threshold for 2.7ms, which is the maximum t_prog_row value. Whereas I can ensure such a low decay of voltage, with sufficient on-board capacitance, it is unclear to me if already started flash write operations are allowed to finish in case a BOR occurs. Do you know if this is the case?
I have seen in other documents indications that the PVD (Programmable Voltage Threshold) must be used to detect a falling supply voltage and to trigger an interrupt, which would then allow the micro to not initiate any other flash writes. But this would take som considerable time, I suppose.
Best regards,
Cristian