> ## Documentation Index
> Fetch the complete documentation index at: https://docs.t3gemstone.org/llms.txt
> Use this file to discover all available pages before exploring further.

# DSPLIB

> Using digital signal processing functions with acceleration chips

<Tip>C7-based MCU projects using the DSPLIB library leverage the DSP accelerator unit within the processor.
This enables hardware acceleration of basic DSP operations such as filtering, convolution, correlation, and
similar tasks, resulting in high performance in real-time applications.</Tip>

## Example Project

A working example project that you can examine as a reference for DSPLIB library integration is provided in
the `MCU` directory within T3 Gemstone's GitHub `examples` repository.

While inside the `devbox shell` within the examples repository, you should run the following command.

```bash theme={"system"}
PROJECT=mcu task clean build
```

The `dsplib_demo.out` file located in `examples/mcu/dsplib_demo/j722s-evm/c75ss0-0_freertos/ti-c7000`
and `examples/mcu/dsplib_demo/j722s-evm/c75ss1-0_freertos/ti-c7000` is now ready to run on the C7 cores.

To run it on the development board, you can follow the steps in the
[Running the compiled project at the U-Boot stage](/en/boards/o1/peripherals/mcu#2-8-running-the-compiled-project-at-the-u-boot-stage) section.

In this example project, the generated outputs are transmitted via the UART1 interface.
You can find the related pin connections in the [Pinout documentation](/en/boards/o1/peripherals/introduction#1-pinout).

The terminal output of the DSPLIB example project is as follows.

```bash theme={"system"}
DSPLIB Demo start

------------------------------------
      T3 Gemstone DSPLIB Test              
------------------------------------

0.716499  +   nane-308 =    0.716499
0.135435  +   0.785398 =    0.920833
0.509235  +    1.57080 =    2.08003
0.541196  +    2.35619 =    2.89739
0.192425  +    3.14159 =    3.33402
0.383086  +    3.92699 =    4.31008
0.563632  +    4.71239 =    5.27602
0.245671  +    5.49779 =    5.74346
0.0562966 +   nane-308 =    0.0562966
0.991528  +   0.785398 =    1.77693
0.479954  +    1.57080 =    2.05075
0.973097  +    2.35619 =    3.32929
0.798400  +    3.14159 =    3.93999
0.0669125 +    3.92699 =    3.99390
```

## Integrating into an Existing MCU Project via MakeFile

To integrate the DSPLIB library into your existing MCU project, you need to define the root directory path
of the SDK and the `.cpp` file you will use.

```makefile theme={"system"}
SDK_ROOT_PATH := ${MCU_PLUS_SDK_PATH}/..

FILES_cpp := \
	dsplib_demo.cpp \
```

Then, you should add DSPLIB's `src` directory to the list of included folders (`INCLUDES_common` variable) as
follows. You may need to adjust the path according to your DSPLIB version.

```makefile theme={"system"}
-I${SDK_ROOT_PATH}/dsplib/src \
```

You must add the following necessary definitions to the compiler FLAGS parameters (`CFLAGS_common` variable) for
the library to compile correctly.

```makefile theme={"system"}
-DMCU_PLUS_SDK \
-DBUILD_C7X \
-DSOC=j722s \
--silicon_version=7524 \
```

You should add DSPLIB's compiled library directory to the library path definitions (`LIBS_PATH_common` variable).

```makefile theme={"system"}
-i${SDK_ROOT_PATH}/dsplib/lib/Release \
```

You need to add the name of the DSPLIB library to the list of included library files (`LIBS_common` variable) as follows.

```makefile theme={"system"}
-lDSPLIB_C7524.lib \
-lDSPLIB_common_C7524.lib \
```

To enable the compilation of .cpp files in the project, the following additions must be made right below the line
where `OBJS` and `DEPS` definitions are made.

```makefile theme={"system"}
OBJS += $(FILES_cpp:%.cpp=%.obj)
DEPS := $(FILES:%.cpp=%.dpp)
vpath %.cpp $(FILES_PATH)

$(OBJDIR)/%.obj %.obj: %.cpp
	@echo  Compiling: j722s:c75ss0-0:freertos:ti-c7000 $(OUTNAME): $<
	$(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -ppd=$(OBJDIR)/$(basename $@).dpp -ppa -fr=$(OBJDIR)/ -fp=$<
```

Upon completion of these steps, the DSPLIB library will be successfully integrated into the project via Makefile.

## Integrating DSPLIB into an Existing CPP File

After completing the necessary configurations via Makefile, to use the DSPLIB library, you need to include its header
file in the .cpp file within your project. Following this step, you can directly use DSPLIB's functions and definitions
within your existing project.

You can access all modules available in the DSPLIB library via
[this link](https://software-dl.ti.com/jacinto7/esd/processor-sdk-rtos-j722s/10_01_00_04/exports/docs/dsplib/docs/user_guide/index.html).

```cpp theme={"system"}
#include <dsplib.h>
```

With this process, the DSPLIB integration will be complete.
