Many TI processors and microcontrollers (MCUs) store code in flash memory and then execute out of that same flash memory. When the CPU core is running at full frequency, wait states must be introduced on reads from flash memory. This can have a significant performance impact on the application. RAM typically operates with 0 wait states, even at full frequency. It can be very beneficial for performance-critical functions to execute from RAM instead of flash. TI’s MCU compilers for ARM-based MCUs, MSP430™ MCUs and C28x MCUs, starting with version 15.9.0.STS, provide a simple mechanism to accomplish this.
In version 15.9.0.STS we added support for the ramfunc attribute.
This attribute provides a simple source-level mechanism for executing code from RAM. The attribute instructs the tools to place the function in flash memory and copy it to RAM at boot time. All calls to the function will call the copy in RAM.
Because the attribute is applied to the function, the compiler can optimize the code for execution from RAM. At the time of writing, the only example of this is on C28x. On C28x, there is a fast branch instruction which is optimal only when executing from RAM. With the attribute, the compiler will automatically select the correct branch instruction. In the future, we plan to expand the optimizations done for code executing from RAM.
This is a brand new feature and we are still rolling out the device file updates to make it a seamless experience. If you receive this error message:
error: ".TI.ramfunc" section generated by __attribute__((ramfunc)) or
--ramfunc=on requires a SECTIONS specification to function.
Please add the following line in the SECTIONS directive of your linker command file:
The TI compiler tools provide more complex functionality for executing code from RAM. One example would be to have functions in RAM placed at the same address and copied into RAM before being called.
I'm trying to use the __attribute__((ramfunc))
but the compiler rejects it. #1173-D unknown attribute "ramfunc"
i'm using ccs 6.1.2.00015 (MSP432).
how can i place functions in ram?
Shai, Please make sure you are using the 15.12.x.LTS or 16.9.0.LTS compiler releases. These are available through the CCS App Store or "Install New Software" dialog. The compiler version is distinct from the CCS version.
I have just implemented
#if __TI_COMPILER_VERSION__ >= 15009000
for a function that I need to reduce the execution time.
However, the function takes longer to execute when assigned the (ramfunc) attribute than without. Why?
Is there some over setting regarding code execution from RAM that is necessary (i.e. wait states, etc. )
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.