Data cache demo on Teensy 4.0

Status
Not open for further replies.

ossi

Well-known member
Is the data cache used on the Teensy 4.0 in a usual program for holding the data? Or is the on-chip RAM so fast that no data cache is used. How can I demonstrate that the data-cache is used. Is the data cache used if I put data into the flash memory?
 
Cache is used for RAM2 and Flash. RAM1 is as fast as the processor, so cache is not used for RAM1.

See "Memory Layout" on the product page:
https://www.pjrc.com/store/teensy40.html

teensy4_memory.png
 
That would mean that dynamically allocated variables (via malloc) would need the cache, right?
 
That would mean that dynamically allocated variables (via malloc) would need the cache, right?

malloc() uses RAM2.
No, it would use the cache. (not need). As it works automagically, you don't need to worry about the cache.
You need cache-handling manually in one case only: If you use DMA.
DMA does not invalidate the cache, and it does not know that cache may contain data which is not in RAM. The cache is configured as write-back.
 
A cache entry can be cleared and invalidated by:

SCB_CACHE_DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) );

Is there also a posibility to get the info about a cache entry without altering the cache entry?
 
Status
Not open for further replies.
Back
Top