11.6.6 Cache Load and Lock
It is possible to lock a specific way for code optimization by writing the Lock Way register (LCKWAY.LCKWAY). The CMCC does not update the locked way as part of cache operations.
The load and lock mechanism can be implemented to use cache memory in a deterministic way. Follow these steps to load and lock a way:
- Disable cache controller by clearing the CTRL.CEN bit.
- Invalidate the desired WAY line by line. This resets the round robin algorithm of the invalidated line, which becomes eligible for the next load operation.
- Disable the instruction cache, but keep the data cache enabled.
- Enable the cache by setting the CTRL.CEN bit.
- Place the respective piece of code and/or data to the corresponding WAY due to simple LOAD operations. Loading the piece of code and/or data forces the cache to refill the previous invalidated line in the right way. Validate only the first byte. The cache automatically refills the complete line.
- Lock the specific WAY by setting LCKWAY.LCKWAY[3:0].
- Re-enable the instruction cache. The locked WAY is now loaded and ready to operate. The user can use the remaining WAYS as I-cache or D-cache as per the requirement.