AM263P4-Q1: Should Stack Go In The TCM?

Part Number: AM263P4-Q1

Hello,

Quick question: Would the code run quicker if the stack was located in TCM?

Further to the related question, I don't think the answer to this specific question is dependent on the application since stack is always required in any application. Is that a fair assumption?

Thank you.

  • Typically, recommendation for code or isr placement is in time, because you want lowest latency for them.

    Well performance improvement of placing stack in  tcm vs ram would depend on kind of application code, for example if you have- deep nested function calls or if you have big local variable then you will have significant improvement advantage if they are in tcm.

    But let's say if you have code structure such a way that you use bigger chunk of global variables or functions utilising  cache properly (which is also single cycle access memory) will benefit little from putting stack in tcm vs putting big global variable and code in tcm.

    At this point i would say pick the piece of application for which you want lowest memory access latency like isr or global variable or code.

    In general to get lowest latency - putting your isr and stack both in tcm, so that your code execution as well the context save and restore also get low latency advantage(r5f uses stack to store register when it enters isr)