SPRUII0F May 2019 – June 2024 TMS320F28384D , TMS320F28384D-Q1 , TMS320F28384S , TMS320F28384S-Q1 , TMS320F28386D , TMS320F28386D-Q1 , TMS320F28386S , TMS320F28386S-Q1 , TMS320F28388D , TMS320F28388S
Flash memory is typically used to store application code. During code execution, instructions are fetched from sequential memory addresses, except when a discontinuity occurs. Usually, the portion of the code that resides in sequential addresses makes up the majority of the application code, and is referred to as linear code. To improve the performance of linear code execution, the FMC includes a Flash prefetch mechanism. This prefetch mechanism does a look-ahead prefetch on linear address increments starting from the address of the last program access.
Apart from linear code, in general application code, there can be several loops wherein a set of instructions located in sequential addresses are executed repeatedly in a loop, until a condition holds true. To improve the performance of small loop code execution, an 8-level deep 128-bit wide (8 x 128) direct mapped program cache has been implemented in the FMC. Whenever instructions in the cache are fetched for CPU processing, the Flash prefetch mechanism does a look-ahead prefetch of 128 bits from the next linear 128-bit aligned address from last address access, and fills the program cache as shown in Figure 13-3.
Up to four 32-bit instructions or up to eight 16-bit instructions can reside within a single 128-bit access. For every 128-bit instruction fetch from the Flash bank, it is likely that there are up to eight instructions (assuming 16-bit instructions) in each level of cache, ready to process through the CPU. During the time it takes to process these instructions, the Flash prefetch mechanism automatically initiates another access to the Flash bank to prefetch the next 128 bits. In this manner, the Flash prefetch mechanism works in the background to keep the cache as full as possible with data corresponding to the next linear address. Using this technique, the overall efficiency of sequential code execution and small loop code execution from Flash or OTP is improved significantly.
The Flash program cache and prefetch mechanism features are disabled by default. Setting the PROG_CACHE_EN bit in the FRD_INTF_CTRL register enables this cache mode. The Flash prefetch and cache mechanisms are independent of the CPU pipeline.
When the Cortex®-M4 CPU (CM) initiates an ICODE access from an address in program space in Flash:
When cache mode is enabled, avoid placing code in the last row of 128 bits in the Flash bank. Doing so can result in an ECC error caused by a look-ahead prefetch access to an address past the bank address boundary.
The Flash prefetch mechanism is aborted only on a PC discontinuity caused by executing an instruction such as a branch, function call, or loop, and so on. When this occurs, the prefetch is aborted. There are two possible scenarios when this occurs: