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.
Tool/software:
Hi,
I am using CLA in my program. I have a function defined on a separate .c file, which I need to call inside Cla1Task1 in CLA file. The "--cla_default" option has choosen under "C2000 Compiler -> Advanced Options -> Language Options", from the properties of the specified .c file. I have added following pragma in the same .c file for the shared variables across C28x and CLA to a "cla_shared" section. This section is allocated to RAMLS1 in linker cmd file.
#pragma SET_DATA_SECTION("cla_shared")
When I am calling the function inside Cla1Task1, the function is not executing.
Can I define and initialize the shared variables on the same .c file, which is set as --cla_default? How it should be handled?
Where should I declare the function?
Is there any example project available on how to call a function defined in .c file from .cla file? What are the steps to be followed?
Hi Varna,
CLA tasks can only call functions (and access variables) in files that are compiled for the CLA and usually only file types of .cla or .h should be compiled for the CLA. I would suggest implementing the functionality straight inside the CLA task. This would be the optimal choice as well since it is recommended to limit code branch instructions on the CLA. Another way you can do this is to define your functions as inline functions in a header file and include this header file in your .cla file. This would result in the function contents being moved inside the CLA task at compile time but would be a little more readable from a development standpoint.
Best Regards,
Delaney
Hi Delaney,
The following is mentioned in this document https://www.ti.com/lit/ug/spru514w/spru514w.pdf in section 10.1 How to Invoke the CLA Compiler.
"If you use the --cla_default option, files with an extension of .c are also compiled as CLA files."
Is it possible to call a function by CLA task from .c file which is also compiled as CLA file? What are the steps to be followed for this?
Hi Varna,
My apologies, you are correct, you can use the cla_default option to compile C files as CLA files. The cl2000 "does not support compiling files using both the C and CLA compilers in a single invocation" though, so you wouldn't be able to use .cla files in combination with .c files for the CLA.
Despite this being possible, I still wouldn't recommend it. You're better off moving your function to a .h file and making it an inline function. If you want to define a variable that is shared between the CLA and the CPU, you can include it under the #pragma SET_DATA_SECTION("cla_shared") in your main C file for the CPU, and therefore be able to read/write it from both CLA code and CPU code. You may have already referenced this, but the cla_ex6_cpu_offloading example in C2000ware does something similar to your application. I would suggest using this example as a starting point and defining your function like loop1_task() is defined in a .h file. You can define your variables like how ref_data is defined in the main C file under the pragma and it can be accessed by the function you make.
Best Regards,
Delaney
Hi Delaney,
Thanks for replying.
Your above statement looks contradictory. In one sentence you are saying that "cl2000 does not support compiling files using both the C and CLA compilers in a single invocation". Later you are saying "despite this being possible, I still wouldn't recommend it".
I have few queries regarding this,
1) In my application the C file is generated outside CCS studio, and I wanted to integrate it to the existing CCS project as a function called from CLA task. I cannot use inline function as it is auto generated file in this case. First of all, if it is possible, what are the steps to achieve this?
2) In your statement, you are not recommending this approach, I would like to know the reason behind it.
3) Could you please share any example project on how to call a function defined in .c file from .cla file if it is possible?
Thanks in advance.
Hi Varna,
Delaney is out of office today, returning tomorrow. Please expect a response back by then.
Thank you,
Luke
Hi Everyone,
Thankyou for the support provided
It is working. Defined the shared variables same way as in the cla_ex6_cpu_offloading example in C2000ware. Defined the function to be called in seperate c file. The "--cla_default" option has choosen under "C2000 Compiler -> Advanced Options -> Language Options", from the properties of the specified .c file. The function is executing while calling inside CLA task.
I would like to know why this approach is not recommended?
Thanks in advance