C8051F120/1/2/3/4/5/6/7
Rev. 1.2
195
likely to be interrupted repeatedly (such as a code loop that is waiting for an interrupt to happen). Instructions that are
part of an interrupt service routine (ISR) can also be excluded from caching. By default, ISR instructions are cached,
but this can be disabled by clearing the CHISR bit (CCH0CN.2) to ‘0’. The other information that can be explicitly
excluded from caching are the data returned by MOVC instructions. Clearing the CHMOV bit (CCH0CN.1) to ‘0’
will disable caching of MOVC data. If MOVC caching is allowed, it can be restricted to only use slot 0 for the
MOVC information (excluding cache push operations). The CHFIXM bit (CCH0TN.2) controls this behavior.
Further cache control can be implemented by disabling all cache writes. Cache writes can be disabled by clearing the
CHWREN bit (CCH0CN.7) to ‘0’. Although normal cache writes (such as those after a cache miss) are disabled, data
can still be written to the cache with a cache push operation. Disabling cache writes can be used to prevent a non-crit-
ical section of code from changing the cache contents. Note that regardless of the value of CHWREN, a FLASH
write or erase operation automatically removes the affected bytes from the cache. Cache reads and the prefetch engine
can also be individually disabled. Disabling cache reads forces all instructions data to execute from FLASH memory
or from the prefetch engine. To disable cache reads, the CHRDEN bit (CCH0CN.6) can be cleared to ‘0’. Note that
when cache reads are disabled, cache writes will still occur (if CHWREN is set to ‘1’). Disabling the prefetch engine
is accomplished using the CHPFEN bit (CCH0CN.5). When this bit is cleared to ‘0’, the prefetch engine will be dis-
abled. If both CHPFEN and CHRDEN are ‘0’, code will execute at a fixed rate, as instructions become available
from the FLASH memory.
Cache locations can also be pre-loaded and locked with time-critical branch destinations. For example, in a system
with an ISR that must respond as fast as possible, the entry point for the ISR can be locked into a cache location to
minimize the response latency of the ISR. Up to 61 locations can be locked into the cache at one time. Instructions
are locked into cache by enabling cache push operations with the CHPUSH bit (CCH0LC.7). When CHPUSH is set
to ‘1’, a MOVC instruction will cause the four-byte segment containing the data byte to be written to the cache slot
location indicated by CHSLOT (CCH0LC.5-0). CHSLOT is them decremented to point to the next lockable cache
location. This process is called a cache push operation. Cache locations that are above CHSLOT are “locked”, and
cannot be changed by the processor core, as shown in Figure 17.3. Cache locations can be unlocked by using a cache
pop operation. A cache pop is performed by writing a ‘1’ to the CHPOP bit (CCH0LC.6). When a cache pop is ini-
tiated, the value of CHSLOT is incremented. This unlocks the most recently locked cache location, but does not
remove the information from the cache. Note that a cache pop should not be initiated if CHSLOT is equal to 111110b.
Doing so may have an adverse effect on cache performance.
Important: Although locking cache location 1 is not
explicitly disabled by hardware, the entire cache will be unlocked when CHSLOT is equal to 000000b. There-
fore, cache locations 1 and 0 must remain unlocked at all times.
TAG 62
SLOT 62
TAG 61
SLOT 61
TAG 2
SLOT 2
TAG 1
SLOT 1
TAG 0
SLOT 0
TAG 60
SLOT 60
TAG 59
SLOT 59
CHSLOT = 58
LOCKED
LOCKED
LOCKED
UNLOCKED
UNLOCKED
UNLOCKED
Lock Status
Cache Push
Operations
Decrement
CHSLOT
Cache Pop
Operations
Increment
CHSLOT
LOCKED
TAG 58
SLOT 58
UNLOCKED
UNLOCKED
TAG 57
SLOT 57
UNLOCKED
Figure 17.3. Cache Lock Operation
Summary of Contents for C8051F120
Page 2: ...C8051F120 1 2 3 4 5 6 7 2 Rev 1 2 Notes ...
Page 8: ...C8051F120 1 2 3 4 5 6 7 8 Rev 1 2 26 2 Flash Programming Commands 318 26 3 Debug Support 321 ...
Page 16: ...C8051F120 1 2 3 4 5 6 7 16 Rev 1 2 Notes ...
Page 48: ...C8051F120 1 2 3 4 5 6 7 48 Rev 1 2 ...
Page 98: ...C8051F120 1 2 3 4 5 6 7 98 Rev 1 2 ...
Page 106: ...C8051F120 1 2 3 4 5 6 7 106 Rev 1 2 Notes ...
Page 183: ...C8051F120 1 2 3 4 5 6 7 Rev 1 2 183 Notes ...
Page 184: ...C8051F120 1 2 3 4 5 6 7 184 Rev 1 2 ...
Page 214: ...C8051F120 1 2 3 4 5 6 7 214 Rev 1 2 Notes ...