I am working on RA2E1. When I am storing any data to flash data memory, that data is getting retained but when I apply power cycle at a very fat rate i.e. within 1 second a power cycle is done then it is observed that the data gets erased.
Any suggestions to overcome this issue?
Hi Sudhanshu. VEE is simply an easy way to maintain data in data flash. You can't treat a data flash "variable" like a RAM variable. If you want to update data, you have to erase the entire data block…
The dataflash on the RA2E1 is disabled at power on, it isn't enabled until this point in the startup code :-
How can this create the issue which I am facing?
After power cycling the RA2E1 device, at which point in the exectuion of the code do you check the data flash? If you look at the data flash content in the debugger before the code has executed to enable the data flash, you will not see the the data you expect.
Within the main function, First I initialize my flash driver thereafter I read the data I stored in my data block.
Also if I add some time between two power cycles let's say 1 power cycle at every 5 seconds then data stays intact.
Without an FSP project and a detailed description of how to recreate the issue you are seeing, it is very difficult to say what is going on.
Okay. I'll attach the relevant files
I have attached the code snippet for my flash handling.
I maintain two copies of my data, at every power-up, I read the data and when any data needs to be modified I modify my data and write the same into my two data blocks.
When the time between two power cycles is less than 1 second( approx) I lose my data, but with 5 seconds it works fine.
You have provided a single .c file, not an FSP project. If you remove the power before the flash operation has completed (Erase and Write), then the Data flash contents will be not as exepcted. How do you judge the flash operation has completed before removing the power?
This is my FSP project.
If you remove the power before the flash operation has completed (Erase and Write), then the Data flash contents will be not as exepcted. How do you judge the flash operation has completed, and that it is safe to remove the power?
In the field conditions, the removal of power will be uncertain.
Any suggestions on how to overcome this problem?
Any updates on this?
Have you looked at the VEE driver in the FSP, it has fault tolerance :-
What are the use cases for r_flash_lp and VEEprom on flash?
In what scenarios do we use r_flash_lp and VEEprom on flash.
Hi Sudhanshu. VEE is simply an easy way to maintain data in data flash. You can't treat a data flash "variable" like a RAM variable. If you want to update data, you have to erase the entire data block first or write to a different location (and remember which is the more recent location). Then you also have to hope that the processor doesn't reset or lose power in the middle of an erase or write operation or you could end up with corrupted data. VEE writes all data to data flash in record format using an ID assigned by the user. So the user simply does VEE writes with a pointer to the data to write to flash along with its ID (e.g. ID_MY_SENSOR_VALUE), and then does a VEE read whenever the latest data needs to be accessed. If a reset or power loss occurs during an erase or write operation, VEE will detect corrupted data when it starts up next and account for it. The most data you could ever "lose" with VEE is one partially written record.