|
>>I also noted that I cannot write in the same FLASH region where the code is running.
This is in fact very usual with the way flash memory planes are implemented. The writes/erases typically take micro or milli seconds to perform. In order for the processor to appear to keep running, you would need to stall the processor. The STM32 does this, but the resulting stall effectively breaks the ability to service peripherals in a timely manner. ie the serial port will have overruns and data loss.
The value read from flash during the write is typically a status, not the data you actually want, from the address your writing, or any other cells for that matter.
The trick is to place the code you want to run while the flash is writing in SRAM (internal, external, whatever). This would need to include interrupt code.
|