STM32 gotchas
285. In dual-bank FLASH STM32, erasing a bank may stall execution for various reasons

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: