Interrupt causes flash operations to fail
Hello,
I was using the flash to save the configuration data of my mcu. But I've got two problems:
The HAL_FLASHEx_Erase function fails with a sequence error.
The first 4 bytes get zeroed with HAL_FLASH_Program. The mcu never boots up after that since the first 4 bytes are the stack pointer.
I checked all the parameters and they are all correct. After disabling the interrupts, the function works. While with a high frequency interrupt, the function always fails.
However, I never found anything about this in the reference manual as well as the errata. The reference manual says the processor will be paused and the read requests will be processed correctly after the operation is done.
Chip is STM32F401RC.
Below is my flash layout:
|Sect 0-1| 2 | 3 | 4 - |
|Bootldr | Cfg1 | Cfg2 | Program code|
The erased and programed data is in sector 2. And the code that starts the flash operation is in the last block.

