Configure MATLAB coder for Ti C2000 compiler

7 visualizzazioni (ultimi 30 giorni)
Valeriy
Valeriy il 20 Mar 2025
Risposto: Vanita il 14 Ago 2025
I have trying to use Ti functions based on driverlib library and running into the saqme issue as the one answered in this post: https://www.mathworks.com/matlabcentral/answers/2035869-how-to-compile-c2000-driverlib-calls-into-an-s-function
After separating the build process between 'MATLAB' and codegen the code generation still uses MinGW to compile the code:
>> mex -setup c
MEX configured to use 'MinGW64 Compiler (C)' for C language compilation.
How can I add the TI compiler to the available compilers and change to default to the one for C2000 products?
Thanks.

Risposte (2)

Maneet Kaur Bagga
Maneet Kaur Bagga il 4 Apr 2025
Hi,
As per my understanding, you are trying to compile C2000 "driverlib" functions into an S-Function in MATLAB. To use the TI compiler for C2000, please refer to the steps below:
Locate the TI Compiler path, which is generally found under the following path:
C:\ti\ccs\ccs_base\tools\compiler\ti-cgt-c2000_xx.x.x
Register the TI compiler in MATLAB using the following command:
mex -setup C
Use the "coder.updateBuildInfo" by referring to the following MathWorks documentation to explicitly set the TI Compiler inside S-function.
Invoke the "mex" function with the TI compiler using the following command and ensure that the environment variables are set before running it in MATLAB :
mex -v -f path_to_TI_compiler_cfg my_s_function.c
Hope this helps!
  1 Commento
Valeriy
Valeriy il 4 Apr 2025
Maneet, after further looking into my issue I see that I am using the correct C2000 compiler.
The errors I have are because the driverlib is using the same MCU resources as controlsuite that the Simulink is using when generating the code for C2000 microcontroller.
Do you have any documentation on how to create MEX functions to control C2000 either using controlsuite or how to add driverlib functions without any collisions.
Thanks.

Accedi per commentare.


Vanita
Vanita il 14 Ago 2025
Hi Valeriy,
To avoid resource conflicts between Simulink-generated code and custom driverlib/ControlSuite code, make sure that only one approach configures each hardware resource. Use S-Functions or the Custom Code feature to integrate your code, but coordinate resource usage to prevent collisions.
For more details you can refer to the following documentations:
Hope this helps!

Prodotti


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by