PIC32MZ Change Cache Policy
Last modified by Microchip on 2023/11/09 09:01
The MPLAB® XC32 C compiler provides an easy-to-use cache configuration file, pic32_init_cache.S. If you copy this file into your local project directory it will override the default runtime setup code used to initialize the cache. The default runtime setup code initializes the cache policy to write-back with write allocation.
You can find the pic32_init_cache.S file in the …xc32/vx.xx/pic32-libs/libpic32/stubs XC32 install directory.
/* Cache Coherency Attributes */
#define _CACHE_WRITEBACK_WRITEALLOCATE 3
#define _CACHE_WRITETHROUGH_WRITEALLOCATE 1
#define _CACHE_WRITETHROUGH_NOWRITEALLOCATE 0
#define _CACHE_DISABLE 2
/* Set __PIC32_CACHE_MODE to the desired coherency attribute */
#define __PIC32_CACHE_MODE _CACHE_WRITEBACK_WRITEALLOCATE //default runtime setup policy
#define _CACHE_WRITEBACK_WRITEALLOCATE 3
#define _CACHE_WRITETHROUGH_WRITEALLOCATE 1
#define _CACHE_WRITETHROUGH_NOWRITEALLOCATE 0
#define _CACHE_DISABLE 2
/* Set __PIC32_CACHE_MODE to the desired coherency attribute */
#define __PIC32_CACHE_MODE _CACHE_WRITEBACK_WRITEALLOCATE //default runtime setup policy