Cache Management Assembly Instructions

The PIC32 microAptiv core includes special instructions for managing the cache.


The CACHE instruction is primarily used at start-up to initialize the cache. To manage coherency, the CACHE instruction can be used to:

  • Invalidate a Cache Address Hit – Searches the cache for the specified address, and if a hit occurs, invalidates (evicts) the cache line. No write back is performed even if the cache line is dirty.
  • Write back a Cache Address Hit – Searches the cache for the specified address, and if a hit occurs and the line is dirty, writes the cache line to memory.
  • Fill Cache – Fills the instruction cache (I-Cache) with data from the specified address. For data cache (D-Cache) fills the PREF instruction is used.
  • Fetch and Lock – Fills the instruction or data cache with data from the specified address, and locks it in the cache. The data remains locked in the cache until it is invalidated with the cache instruction.


The PREFECT instruction (PREF) is provided to optimize D-Cache performance by allowing software to specify the optimum cache fill operation:

  • Fill a cache line for write operation: a cache line is reserved but no fill from memory is performed as memory will ultimately be written with new data.
  • Fill a cache line for a read operation: a cache line is reserved and filled with the contents of memory.
  • Streamed and Retained Options: allow the user to specify a cache hierarchy where streamed data will not evict retained data.
  • Write back and invalidate: allows the user to free a cache line, writing it back to memory if it is dirty. Sometimes referred to as ‘nudge’.
© 2017 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.