I'm trying to write and erase data into/from internal Flash memory (range 0x0800000 - 0x0807FFFF) of STM32 L152RE. I'm only accessing the last page of Flash ( 0x0807FF00 - 0x0807FFFF) and then writing the data only on half page.
I'm erasing the page using following code: And erasing through following code:
And then writing on the half page using following code below
( here 'data' is the pointer to the array of 128 bytes (32 words) which is the size of half page)
Both writing and erasing are working perfectly fine when placed in while(1). But when I reset the board (through button), it simply do nothing, as if whole Flash memory is erased and there is no code to execute. Is this normal?
I have checked through the keil uvision debugger, the code is in the first bank of flash (range 0x0800000 - 0x0803FFFF) and I'm only accessing the last page of the second bank. Even if I'm overwriting the code section then it should also not run in while(1) as well.
I want to write some data in Flash memory (not EEPROM) and then read that data after reset of microcontroller board.