Embedded Flash memory
RM0365
59/1080
DocID025202 Rev 7
4.2.2 Read
operations
The embedded Flash module can be addressed directly, as a common memory space. Any
data read operation accesses the content of the Flash module through dedicated read
senses and provides the requested data.
The read interface consists of a read controller on one side to access the Flash memory and
an AHB interface on the other side to interface with the CPU. The main task of the read
interface is to generate the control signals to read from the Flash memory and to prefetch
the blocks required by the CPU. The prefetch block is only used for instruction fetches over
the ICode bus. The Literal pool is accessed over the DCode bus. Since these two buses
have the same Flash memory as target, DCode bus accesses have priority over prefetch
accesses.
Read accesses can be performed with the following options managed through the Flash
access control register (FLASH_ACR):
•
Instruction fetch: Prefetch buffer enabled for a faster CPU execution.
•
Latency: number of wait states for a correct read operation (from 0 to 2)
Instruction fetch
The Cortex
®
-M4 fetches the instruction over the ICode bus and the literal pool
(constant/data) over the DCode bus. The prefetch block aims at increasing the efficiency of
ICode bus accesses.
Prefetch buffer
The prefetch buffer is 2 blocks wide where each block consists of 8 bytes. The prefetch
blocks are direct-mapped. A block can be completely replaced on a single read to the Flash
memory as the size of the block matches the bandwidth of the Flash memory.
The implementation of this prefetch buffer makes a faster CPU execution possible as the
CPU fetches one word at a time with the next word readily available in the prefetch buffer.
This implies that the acceleration ratio is in the order of 2 assuming that the code is aligned
at a 64-bit boundary for the jumps.
Prefetch controller
The prefetch controller decides to access the Flash memory depending on the available
space in the prefetch buffer. The Controller initiates a read request when there is at least
one block free in the prefetch buffer.
After reset, the state of the prefetch buffer is on. The prefetch buffer should be switched
on/off only when no prescaler is applied on the AHB clock (SYSCLK must be equal to
HCLK). The prefetch buffer is usually switched on/off during the initialization routine, while
the microcontroller is running on the internal 8 MHz RC (HSI) oscillator.
Note:
The prefetch buffer must be kept on (FLASH_ACR[4]=’1’) when using a prescaler different
from 1 on the AHB clock.
If there is not any high frequency clock available in the system, Flash memory accesses can
be made on a half cycle of HCLK (AHB clock). This mode can be selected by setting a
control bit in the Flash access control register.
Half-cycle access cannot be used when there is a prescaler different from 1 on the AHB
clock.