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 all!
I am working a project in CCS_V6, with cl430 as compiler and MSP430F5438A
I'm looking for an instruction which enable to me to link an unused function. In fact, I need to use the code of my function without calling it.
I've ever tried something like that by calling directly my function:
#ifndef => it's not good for the precompilation
#pragma FUNC_EXT_CALLED(my_function) => I thought it would be useful, but it doesn't work as well
Create an impossible condition in which I call my function => not good according to me
So, does anyone would have an idea or would have ever done something like that ?
Regards,
Bertrand
Use #pragma RETAIN(function_name). Please read about it in the MSP430 compiler manual.
Thanks and regards,
-George
Bertrand.V said:My section doesn't appear in my .map file and there is nothing at the .name address
I am unable to reproduce that result. Is your code organized as a CCS project? I'd appreciate if you would submit the project.
Thanks and regards,
-George
If the empty function X is called by another function Y, then Y will refer to X and X should be included in the link. Are you sure Y is being included in the link?
Also, make sure you refer to X by name in Y, not by address.
This works for me.
#pragma SET_CODE_SECTION(".BSL") // specify code section #pragma RETAIN(cBSL_main) // The retain pragma, notice function name in parenthesis void cBSL_main(void) { // The function I need to retain. // ..... My code here } #pragma SET_CODE_SECTION()
The only thing I see that can make a difference is the --gcc option. You may want to use the GCC approach:
void tsim_reflash_test(void) __attribute__((section(".ramcode1"), used));
This should be in your forward declaration in your header file. Per TI C/C++ compiler user guide, this should work.
Bertrand.V said:I'm looking for an instruction which enable to me to link an unused function. In fact, I need to use the code of my function without calling it.
Use the RETAIN pragma. Something like this ...
#pragma RETAIN(name_of_function_here)
This pragma is documented in the MSP430 compiler manual.
Thanks and regards,
-George
Bertrand.V said:I've ever tried to implement it, but it doesn't work with my compiler.
I presume you use the TI MSP430 compiler, and not gcc. Please show what you tried to implement. What do you see that makes you say it doesn't work?
Thanks and regards,
-George
Bertrand's previous posts said that the TI MSP430 compiler version in use is V3.3.3George Mock said:Use the RETAIN pragma. Something like this ...#pragma RETAIN(name_of_function_here)
Yes I use another compiler as gcc, it's cl430 compiler
My purpose :
I use 2 functions. Each function is located in Flash memory with a section assigned.
On the one hand, "reflash()" contains all data what I need, its size is ~4KB
On the other hand, I use an empty function which will be executed from RAM "virtual_function()" after
having copied inside my function the code of "reflash()" function. It sounds like "copy_in()" function using .UNION directive.
Only one function should be called during execution of my code, "virtual_function()".
So, I would like to find a solution for keeping up my "reflash()" function though during the compilation,
using optimized code option, it disappears and isn't linked.
Then, during "virtual_function()" execution from RAM, I would like to understand why it starts correctly at the right address
and at any time it jumps in Flash. (Probably a problem with range of my variable .def, .ref and .global)
I hope that I have been able to throw some light on my matter!
Regards,
Bertrand
Sorry for the delay.
I somehow overlooked that you are using a very old compiler. Version 3.3.3 was released in 2010, 6 years ago. It would be much easier to support you if you upgraded to recent tools. I hope that is a practical alternative.
If you are using version 3.3.3, then you are building with the old COFF ABI. That being the case, I think adding --disable_clink to your linker options will fix your problem. I cannot test whether I am right on this. But I am confident enough to tell you to give it a try.
Thanks and regards,
-George