380
SAM4CP [DATASHEET]
43051E–ATPL–08/14
24.4
Functional Description
24.4.1 Cache Operation
On reset, the cache controller data entries are all invalidated and the cache is enabled. The cache is transparent to
processor operations. The cache controller is activated with its configuration registers. The configuration interface is
memory mapped in the private peripheral bus.
The cache must always be enabled, even if the code is running out of a non-cached region.
When the cache is disabled, the accesses to the cache on its slave port are “forwarded” to the master port. In this case,
there are two simultaneous accesses on the matrix: one on a non-cached region, and another “dummy” access on the
cache master port. These two accesses can slow down the system due to the wait error introduction on the cache master
port.
24.4.2 Cache Maintenance
If the contents seen by the cache has changed, the user needs to invalidate the cache entries. It can be done line by line
or for all cache entries.
24.4.2.1 Cache Invalidate by Line Operation
When an invalidate by line command is issued the cache controller resets the valid bit information of the decoded cache
line. As the line is no longer valid the replacement counter points to that line.
Use the following sequence to invalidate one line of cache.
1.
Disable the cache controller, writing 0 to the CEN bit of the Control Register (CMCC_CTRL).
2.
Check CSTS bit of the CMCC_SR to verify that the cache is successfully disabled.
3.
Perform an invalidate by line writing the bit set {index, way} in the Maintenance Register 1 (CMCC_MAINT1).
4.
Enable the cache controller, writing 1 to the CEN bit of the CMCC_CTRL register.
24.4.2.2 Cache Invalidate All Operation
To invalidate all cache entries, write a 1 to the INVALL bit of the Maintenance Register 0 (CMCC_MAINT0)
24.4.3 Cache Performance Monitoring
The Cortex M cache controller includes a programmable 32-bit monitor counter. The monitor can be configured to count
the number of clock cycles, the number of data hits or the number of instruction hits.
Use the following sequence to activate the counter
1.
Configure the monitor counter, writing the MODE field of the Monitor Configuration Register (CMCC_MCFG).
2.
Enable the counter, writing one to the MENABLE bit of the Monitor Enable Register (CMCC_MEN).
3.
If required, reset the counter, writing one to the SWRST bit of the Monitor Control Register (CMCC_MCTRL).
4.
Check the value of the monitor counter, reading EVENT_CNT field of the CMCC_SR.