I an trying to write into flash. i can write a few bytes but after that the writing fails.what should i do in that case?should i retry writing for that particular address for say 3 times. for rewriting i will have to erase and than try rewriting to the same address again. but i am not sure whether i'll be able to erase that particular address in between writing. please suggest.
Hi,
I suggest to follow the ST application note AN2594. It show how to implement EEPROM emulation using the embedded Flash. So you can find any detail about writing flash memory. See the link below:
Your question seem related to writing internal flash and I link to the related ST application note.
If have you some issue to writing into a external flash memory, please give more info to get some help.
Well,
If for any reason you fail to write you can:
Reading in your target address: if have all bit=1 then you can retry to write.
If some bit is already cleared , you must before erase the entire page.