PIC32MZ Level 1 Cache

Last modified by Microchip on 2023/11/09 09:01

A Central Processing Unit (CPU) cache is a separate small block of memory used to compensate for the slower access time of the main memory. A cache described as a Level 1 (L1) cache uses memory that is as fast as the CPU, so as long as the CPU is accessing the cache, it will never have to wait for instruction or data. Level 2 and Level 3 caches are used in conjunction with a Level 1 cache and have memory whose access times are greater than the CPU, but are less than main memory.

cache memory

The PIC32MZ family uses an L1 cache only. The L1 cache is divided into two parts: an instruction cache and a data cache. The use of the cache is critical to achieving maximum performance from the PIC32MZ family. Memory access to and from the cache always occurs in a single clock cycle. Accessing the main memory could take three or more cycles.

"Single cycle" refers to one instruction cycle, which is one PBCLK7 clock.

​Application Note "AN1600" covers the detailed use of L1 cache memory on PIC32MZ devices.

Also, there is a PIC32MZ cache tutorial that goes into further detail on the configuration/use of the L1 cache.

​By default, MPLAB® XC32 start-up code enables the cache and configures it in write-back with write allocation mode.

This policy is the easiest for the hardware to implement and consumes the least system bus resources and power. However, it is the least useful for keeping shared data coherent. Combining this cache policy with using uncached (KSEG1) memory for shared data is the simplest cache management approach, and is recommended for getting your project up and running.