This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
In a previous post (http://e2e.ti.com/support/microcontrollers/hercules/f/312/p/197625/754475.aspx#754475) I was having problems getting the F021 flash library to work. Since then we have updated from the 4.7 to the 5.0.1 compiler.
The solution to my previous problem was to use statements of the form:
#pragma CODE_SECTION(Fls_Erase, ".flashapi") /* Run this function from RAM */
However despite doing this, at the highest optimise for speed setting, the 5.0.1 compiler is inlining code into flash that I have specified for copying to RAM via the pragma statement above.
The end result was that when I compiled with debug settings (no optimisation), everything worked. When I compiled with release settings and full optimisation, the code didn't work.
I have actually resolved the problem by putting the higher level functions in RAM too but it is worrying that the compiler seems to be ignoring the directive to locate functions in sections that are allocated to RAM.
Regards,
Richard
To disable inlining of a particular function, use the #pragma FUNC_CANNOT_INLINE(function_name);
Thanks and regards,
-George
Hi George,
It is useful to know that there is a way to prevent the compiler from inlining code. The solution then is to specify both pragmas (#pragma FUNC_CANNOT_INLINE(function_name) and #pragma CODE_SECTION(function_name, ".flashapi")) for code that must be located in RAM.
Regards,
Richard
Hi George
I'm not really impressed that the CODE_SECTION pragma is ignored by optimisation. There are generally very good reasons why an engineer would locate something in a particular region/section of memory. As a preference for future consideration, I would like to see CODE_SECTION overriding any optimisations the compiler might like to make.
Regards, Tony.