Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Data cache demo on Teensy 4.0

  1. #1
    Senior Member
    Join Date
    Feb 2019
    Posts
    123

    Data cache demo on Teensy 4.0

    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?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,497
    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


  3. #3
    Senior Member
    Join Date
    Feb 2019
    Posts
    123
    That would mean that dynamically allocated variables (via malloc) would need the cache, right?

  4. #4
    Senior Member
    Join Date
    Feb 2019
    Posts
    123
    Cache demo seems to work now with a buffer in RAM2
    Last edited by ossi; 04-30-2020 at 03:46 PM. Reason: error found

  5. #5
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,920
    Quote Originally Posted by ossi View Post
    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.

  6. #6
    Senior Member
    Join Date
    Feb 2019
    Posts
    123
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •