[FAQ] AM275-FREERTOS-SDK: How do I import or run a DSPLib example inside of a CCS 20.x project?

Part Number: AM275-FREERTOS-SDK


The FreeRTOS SDK and MCUPlus SDKs both contain additional libraries, such as DSPLib. These libraries by default are not meant to run within CCS projects directly, but rather to be compiled with cmake.

It is possible to import the DSPLib example code into a CCS project for easier debugging or pull the libraries into your larger project.

This will assume there is no existing project, so we will start from the "empty" project example ("empty" is a C project. If you require C++, then you should select the C++ hello world example code instead and the below steps will be the same), and use CCS 20.x to do this. However the steps are nearly identical in older versions of code composer.

1) Open CCS 20.x, and go to File -> Import Project
2) Browse to your FreeRTOS/MCUPlus SDK location (on windows, this is typically C:\ti\freertos_sdk_xxxxxx. For linux, there is no default, but a common location is ~/ti/freertos_sdk_xxxxxx). Go to Examples -> empty and select the folder of interest.
3) Since DSPLib is meant to run on a C7x core, it is recommended to select one of the C7 cores. In my example AM275x EVM, I would select the "empty_am275x-evm_c75ss0-0_freertos_ti-c7000" project. Import the example project
4) In the workspace, you should see the project you just imported. Select it (left click) and go to Project drop down -> Properties (or right click on the project in the workspace and go to properties).
5) First, we need to disable warnings as errors by going to Build -> Tools -> C7000 Compiler -> Advanced Options -> Diagnostic Options. Scroll down and uncheck the box for "Treat warnings as errors"

6) Now to add the DSPLib source code files. In the same properties dialog, go to Build -> Tools -> C7000 Compiler -> Include Options and in the "add Dir to #include search path" file, add the SDK by clicking on the "+" in the top right of the box and pasting "${MCU_PLUS_SDK_PATH}/source/dsplib/src" without quotation marks. Hit OK to add this path to the search path.

7) Now to add the DSPLib compiled library files to the linker. In the same properties dialog, go to Build -> Tools -> C7000 Linker -> File Search Path.
8) We need to add the library path and the library file names. First let's add the directory by clicking on the + icon for the "Add <dir> to library search path" window. Add "${MCU_PLUS_SDK_PATH}/source/dsplib/lib/Release" without quotation marks and hit OK.

9) Now we must add 2 libraries to the "Include library file or command file as input" window. Click on the "+" for that window and add "DSPLIB_C7524.lib" without quotations. Ignore the warning about it not resolving and hit OK. Then click on the + again and add "DSPLIB_common_C7524.lib" without quotations. Again, ignore the error and press OK.

10) Now we should add a define for the C7524 that is used by some kernels. In the same properties dialog, go to Build -> Tools -> C7000 Compiler -> Predefined Symbols and in the "Pre-define Name" window, click on the + button and add "__C7524__" without quotations (This is specific to the AM275x CPU, if your processor has a different C7x core, you should put that correct version in). Click OK.

11) We are complete with the initial project setup. Click on "Save and Close" to close the project properties window.

Now you can import an example file of interest and make a few modifications for FreeRTOS to call.

For a simple example, let's import the Mul kernel.

1) Open the example file that you want to import. For the path for this example, we would navigate to <SDK root directory>/source/dsplib/examples/DSPLIB_mul/DSPLIB_mul_example.cpp (on windows, this is typically C:\ti\freertos_sdk_xxxxxx. For linux, there is no default, but a common location is ~/ti/freertos_sdk_xxxxxx)
2) The "empty" project is a C project, not a CPP, so we cannot directly use the .cpp file. We will just use it as a reference. Looking at the main function inside of this file, there are just a few things that make it a cpp file. So we can copy the contents of the dsplib example file to the empty.c's empty_main() function and correct these issues.
3) the for loop under the "// print results" comment needs to be modified so that size_t c; is placed above the for loop and we change the for loop to below in order to compile in C

   size_t c;
   for (c = 0; c < size; c++) {
      printf("%10g * %10g = %10g\n", in0[c], in1[c], out[c]);
   }

4) Don't forget to add the dsplib.h include to the empty.c file.
#include "dsplib.h"
#include <stdint.h>

5) Build the project

Doing this allowed me to run the mul_example code within CCS. I have attached an example dsplib project for CCS 20.4 (latest at the time of writing)

dsplib_example_am275x-evm_c75ss0-0_freertos_ti-c7000.zip