UG-1262
Rev. B | Page 188 of 312
FLASH ACCESS
Flash memory can be read, written, and erased by user code. Read access is provided through the cache controller using two AHB ports
(as shown in Figure 53): ICode for instructions and DCode for data. Write access is provided through keyhole writes using APB control
of memory mapped registers. The keyhole write implementation includes support for both DMA-based and manual user initiated writes.
READ PATH
CUSTOM INTERFACE
FLASH
CONTOLLER
APB
WRITE PATH
AHB ICode
AHB DCode
CACHE
CONTROLLER
1667
5-
03
6
Figure 53. Flash Memory Read and Write Data Paths
Bus errors are generated if user code reads from a protected or an out of bounds address. Writes or erasures of protected addresses result
in appropriate error flags set in the status register. The address setup for writes and erasures is automatically constrained to the flash
address range.
READING FLASH
The flash controller provides two interfaces for reading nonvolatile storage: ICode and DCode. The ICode and DCode interfaces are
accessed through the cache controller module through the AHB. The flash controller includes a prefetch buffer for ICode, by which it is
possible to return data on both ICode and DCode interfaces in the same cycle.
Flash memory is available to read only after an automatic initialization process. Attempts to read during the flash controller initialization
stall. Reads also stall if the flash controller is already busy performing another command (such as writing the flash), unless the prefetch
buffer satisfies those reads.
ERASING FLASH
The flash controller provides page level granularity when erasing user space through the erase page command. Alternatively, user code
can erase the entirety of user space at once using the mass erase command. These two commands have the same execution time.
Write protected pages cannot be erased, and the command is denied. Pages that are write protected also deny a mass erase command.
WRITING FLASH
Flash memory operates by settings bits to 1 when erased and selectively clearing bits to 0 when writing data. No write operation is
capable of setting any bit to 1. For this reason, generalized write accesses must be prefixed by an erase operation.
Initial uploading of user content generally occurs immediately following a mass erase operation. Subsequent modification of already
written locations in flash generally follows selective page erase operations with user code. During this process, the user must copy a full
page to SRAM, erase the affected page, modify the in-memory content, and then finally write the page back to flash.
User space protections may prevent a page erase operation (see the Protection and Integrity section). All user space protections are
cleared automatically after a mass erase or blank check. Note that a blank check passes only if all user space is already erased. In these two
cases, there is no user space content to protect.