When a FLASH memory array is to be erased or written, an internal voltage generator is started, which applies an appropriated elevated voltage to the array, and subsequent activation of appropriate row/column address and data lines results in electrons tunelling to or from the floating gate, which is the physical basis of data storage in FLASH, to take place. During this time, it is impossible to read data from the array, as that would result in writes to unwanted locations.
As data write - and even more so array erase - takes significant time, this is a major drawback of using FLASH in microcontrollers. Particularly, in STM32, when a FLASH array is being written or erased, any attempt to read - including fetching instructions - leads to the FLASH controller signalling WAIT to the processor, effectively stalling execution until the hardware finishes the ongoing write/erase operation.
As in some applications Read-While-Write - mainly program execution while writing e.g. a program update to a different portion of FLASH - is a vital requirement, some higher-end STM32 come with Dual-Bank FLASH organization. In these, the FLASH is physically split into two pieces (Banks), each with its own programming-voltage generator and read/write circuitry. This allows one Bank of FLASH to be written/erased, while program still can execute from the other Bank.
However, sometimes users experience processor stall during programming/erasing the non-active FLASH Bank in Dual-Bank STM32, too. This can have several reasons:
- any of the common issues, which apply to single-bank FLASH models, too, e.g. inadvertent write to FLASH
resulting in non-zero FLASH status bits before programming/erasing
- interrupts using the inactive bank - this can happen, if for example the SCB_VTOR register points to the inactive, currently-being-erased/programmed Bank.
A careful review of the RM to understand exact mapping of the banks under various settings, and/or checking content of SCB_VTOR and NVIC registers content during the
FLASH operation in question, may be needed.
- in the 'F7 family (and maybe also in the dual-core 'H7 models), speculative access of the Cortex-M7 core, especially through otherwise unused ITCM interface
(as reported e.g. here)
- as discovered by user mark03, reading factory-programmed constants (such as temperature-sensor and VREFINT calibration constants, unique-ID, silicon revision etc.) from system memory while programming/erasing Bank 1 in 'H7 leads to stalls, as system memory is part of Bank 1.