I understand that, before I can write to flash, I have to erase the entire segment. My question is:
I am trying to write integers to flash every 0.1 seconds. The data comes in from the ADC. If I erase the blocks I want to use at the very beginning of my main function, and then write the data as it comes in, do I have to erase every time? Or can I do this:
void main()
{
int x = 0;
erase_flash();
while(true)
{
do other stuff...
x = read_data();
write_flash(x);
}
}
Where we can assume that I've already written the functions erase_flash, read_data, and write_flash, and that I'm addressing everything correctly.
I guess the question is: do I only need to erase the whole segment once in the program?
Mike