2023-03-31 04:11 AM
Hello,
So in our project we are saving some of out parameters on last page of our controller and reads that during startup.
We are able to read and write content properly.
Issue we are facing is that when a power on/off cycle is happening multiple times in a day at random instance during this process the data being read at startup is not correct and we get different values.
This issue is not happening at every power on/off cycle, this happens just randomly at any moment like once or twice in a day.
It would be grateful if someone can help regarding this.
Regards,
Tirthraj Solanki
2023-03-31 11:30 AM
If power drops while writing to flash, all bets are off. The write may or may not have happened, or happened fully. The ST "EEPROM Emulation" package has lots of code to try and deal with that, but at the end of the day, nothing can guarantee the data will be stored correctly.
The usual way to deal with this is have a low power input to the CPU that detects when the power supply is dropping, and to have enough capacitance on the CPU to run the CPU long enough for a write sequence to finish. Only start a write operation is the power supply is "OK".
2023-03-31 11:37 AM
Journal content, and use checksums/CRC to check validity, find most recent valid entry on startup.
Use two pages so you can erase one without loosing recent valid content.
Likely minimum write size of 64-bits (8-bytes)
Use NVRAM as a secondary store