Tool/software:

1. I am using this flash address 0xAF000 to write some key parameters (Total : First 30 bytes) related to my application.
2. The image attached shows some garbage values like 0xFFEF, 0xEFFF been written which are not intended. It should either be 0xFFFF in case of erase operation or some values related to the parameters I use. This seems like flash is corrupted.
3. After trying to erase this sector while flashing the same code runs fine.
4. I have checked that I am performing erase operation before every write operation.
5. I doubt two things because of which NMI is getting triggered.
a. I am using memcpy() to read data of that flash address which could cause unexpected behaviour.
b. While initializing flash api.
Sequence of my code is first b executes and then a.
I have two questions here
1. What could cause flash corruption ?
2. What is cause of reset ? memcpy or flash api initialization ?
3. Also I want to recreate this.