Using the CMSIS DSP Library in Code

Using the CMSIS DSP Library in Code
Application Report
SPMA041G – January 2012 – Revised October 2015
Using the CMSIS DSP Library in Code Composer Studio™
for TM4C MCUs
Amit Ashara
ABSTRACT
This application report describes the process required to build the ARM® CMSIS DSP library in Code
Composer Studio v6.1 with ARM Compiler version up to 5.2.5 . This document also describes how to use
Code Composer Studio v6.1 to build, run, and verify the 11 ARM DSP example projects that are included
in the CMSIS package.
Project collateral and source code discussed in this application report can be downloaded from the
following URL: http://www.ti.com/lit/zip/spma041.
NOTE: This document applies to both the TM4C Series and the Stellaris® Cortex®-M4 MCUs. All
screen captures reflect the TM4C version of the device.
1
2
3
4
5
6
1
Contents
Introduction ................................................................................................................... 1
CMSIS DSP Library ......................................................................................................... 1
Building the DSP Library in Code Composer Studio v6.1 .............................................................. 2
ARM Example Projects .................................................................................................... 13
Conclusion .................................................................................................................. 31
References .................................................................................................................. 32
Introduction
Many microcontroller-based applications can benefit from the use of an efficient digital signal processing
(DSP) library. To that end, ARM has developed a set of functions called the CMSIS DSP library that is
compatible with all Cortex M3 and M4 processors and that is specifically designed to use ARM assembly
instructions to quickly and easily handle various complex DSP functions. Currently, ARM supplies example
projects for use in their Keil uVision IDE that are meant to show how to build their CMSIS DSP libraries
and run them on an M3 or M4. This application report details the steps that are necessary to build these
DSP libraries inside Code Composer Studio version 6 and run these example applications on a TM4C
Series TM4C129 Connected LaunchPad.
2
CMSIS DSP Library
To build the CMSIS DSP library, download and extract the source code from the ARM CMSIS website:
http://cmsis.arm.com. The source code for the DSP library and example projects are in this directory:
CMSIS-<version>/CMSIS/DSP_Lib
A full description of the DSP libraries, including a description of examples, the data structures used, and
an API for each available function, is in the ARM-provided documentation at this location:
CMSIS-<version>/CMSIS/Documentation/DSP/html/index.html
Code Composer Studio, TivaWare are trademarks of Texas Instruments.
Stellaris is a registered trademark of Texas Instruments.
ARM, Cortex are registered trademarks of ARM Limited.
All other trademarks are the property of their respective owners.
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
1
Building the DSP Library in Code Composer Studio v6.1
www.ti.com
If ARM releases a future update to CMSIS, you might need to download and install a patch to the DSP
library in order to provide support for new functionality and to fix any bugs that ARM discovers in the
CMSIS source code. After you download the patch files from the ARM web site, follow these instructions
to install:
1. Unzip the patch file.
2. Navigate to the patch directory and copy any files found in that directory to the corresponding location
of the CMSIS DSP library.
3. Overwrite existing files when prompted.
For example, if the patch directory contains a file named arm_common_tables.c in the
CMSIS/DSP_Lib/Source/CommonTables directory, copy this file into the same directory
(CMSIS/DSP_Lib/Source/CommonTables) of your original CMSIS installation, overwriting the
arm_common_tables.c that already exists in the original installation directory.
After the CMSIS source code has been downloaded, you must download and unzip the CCS CMSIS
Patch Files. This CCS CMSIS zip package is located on the Texas Instruments’ website at
http://www.ti.com/lit/zip/spma041. The zip package contains a set of support files that are needed for
building and running the CMSIS DSP library in Code Composer Studio. After you download the zip
package, run the unzip application and select a location in which to extract the files.
3
Building the DSP Library in Code Composer Studio v6.1
This section details the steps required to build the ARM CMSIS DSP library from source. It is possible to
skip this section by using a precompiled .lib (such as one of those found in CMSIS<version>/CMSIS/Lib/ARM or CMSIS-<version>/CMSIS/Lib/GCC), but doing so requires changing the
Code Composer Studio compiler settings to call floating-point functions in a way that is different from the
default Code Composer Studio settings. This requires rebuilding all .lib files that are used in a project with
the DSP libraries, most notably the TivaWare™ for C Series Software driverlib, grlib, and usblib libraries.
This method is not recommended and the process is not described in this application report. Also this
application report has been updated for the support of CMSIS release r4p2 onwards.
3.1
Adding the CCS-Required Header Files to the DSP Libraries
To compile the CMSIS DSP libraries using Code Composer Studio, you must modify the DSP library
include files, add a Code Composer Studio specific include file, and add a new assembly file. The zip
package contains pre-modified versions of these files, which can be used during the build process or you
can elect to modify the files yourself by using the following steps:
1. Copy arm_math.h and cmsis_ccs.h from this application report into the CMSIS/Include directory
2. Copy arm_bitreversal2.asm from this application report into
CMSIS/DSP_Lib/Source/TransformFunctions.
3.2
Creating the dsplib Project
Before building the DSP library in Code Composer Studio, you must create a project for the library. You
can build a project by completing the following steps:
1. Launch CCSv6.1 and select an empty workspace.
2. Select File → New → CCS Project. The New Code Composer Studio Project window will be displayed.
3. Select Target as TM4C Series and then use the drop down menu to select TM4C1294NCPDT. Select
the Connection as Stellaris In-Circuit Debug Interface (see Figure 1).
4. In the Project name, type dsplib-cm4f and keep the check box ticked for the Use default location.
5. In Advanced settings, select:
• Output type: Static Library
• Output format: eabi (ELF)
• Device endianness: little
6. In Project templates and examples (see Figure 2), select Empty Project.
7. Click Finish to create the project. The dsplib-cm4f project appears in the Project Explorer.
2
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
Building the DSP Library in Code Composer Studio v6.1
www.ti.com
Figure 1. Creating the dsplib Project
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Figure 2. Creating the dsplib Project
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
3
Building the DSP Library in Code Composer Studio v6.1
3.3
www.ti.com
Adding the dsplib Source Code
Before adding the dsplib source code to the project, you should familiarize yourself with the CMSIS library
structure. Open your preferred file navigation tool and navigate to the directory where the CMSIS .zip file
downloaded from ARM was extracted. Then, descend to CMSIS-<version>/CMSIS/DSP_Lib/Source/. This
is the directory ARM uses to group the DSP functions into various sub-categories. The ARM directory
contains the project files necessary to build the DSP library in uVision with ARM’s compiler, and the GCC
directory contains the project files to build the DSP library in uVision using the open source GCC compiler.
All other directories contain the source code necessary to build the category of functions indicated by the
directory name.
To
1.
2.
3.
4.
5.
add the dsplib source code to the dsplib project in Code Composer Studio:
Right-click the dsplib-cm4f project in the Project Explorer and click Import…
Click General to expand and then click File System. Click Next.
Click the Browse button and navigate to the location of the CMSIS DSP library source code.
Select the top level Source directory and click OK.
When the Source directory appears in the Import window, click the checkbox beside the folder to select
all of the contents of that folder to be imported.
6. Deselect the ARM and GCC folders by clicking to the left of the checkbox.
7. Click the TransformFunctions folder, which causes the contents of that folder to be displayed in the
panel on the right.
8. Uncheck the box beside arm_bitreversal2.S.
9. Make sure that the Into Folder: text field contains the name of the DSP library project where you want
to import the files (for this example, dsplib-cm4f).
10. Check the Overwrite existing resources without warning. Verify the Create top-level folder check box is
deselected.
11. Click the Advanced button, then click to select the Create links in workspace checkbox.
12. Verify the Create link locations relative to: checkbox is selected. If it is not, click to select it.
4
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
Building the DSP Library in Code Composer Studio v6.1
www.ti.com
13. Verify that the drop-down menu of environment variables is set to PROJECT_LOC (see Figure 3). If
there are no variables listed in the drop-down menu, select Edit Variables… and add a variable to
represent the location of the dsplib project file.
Figure 3. Importing the DSP_Lib Source Code
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
5
Building the DSP Library in Code Composer Studio v6.1
www.ti.com
14. Click Finish to link the DSP_Lib source code into the project.
Figure 4. The Project Explorer Window After the DSP_Lib Code has Been Imported
3.4
Editing the dsplib Project Settings
After linking in all the source files, change the following default Code Composer Studio project settings:
1. Right-click the dsplib-cm4f project in the Project Explorer and select Properties.
2. Expand the Build entry, and then expand the ARM Compiler entry.
3. Confirm that the Target_processor version (--silicon_version, -mv) entry matches your processor in the
Processor Options panel (see Figure 5). For this example, the Target processor should be 7M4 (as
opposed to 7M3 for any of the Stellaris Cortex-M3 products).
6
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
Building the DSP Library in Code Composer Studio v6.1
www.ti.com
Figure 5. The Processor Settings for a Cortex-M4 Processor With Hardware FPU Support
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
7
Building the DSP Library in Code Composer Studio v6.1
www.ti.com
4. Click the Optimization level (--opt_level, -O) drop-down menu in the Optimization panel and select 2
(see Figure 6).
Figure 6. The Proper Optimization Settings for Compiling the DSP_Lib Source Code
5. Expand the Advanced Options section of the ARM Compiler pane, and select Assembler Options.
8
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
Building the DSP Library in Code Composer Studio v6.1
www.ti.com
6. Click the Use unified assembly language (--ual) checkbox to select that option (see Figure 7).
Figure 7. Setting the Assembler to Use Unified Assembly Language
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
9
Building the DSP Library in Code Composer Studio v6.1
www.ti.com
7. Click the Emit diagnostic identifier numbers (--display_error_number, -pden) checkbox in the
Diagnostic Options panel to deselect.
Figure 8. Verifying That Diagnostic Identifier Numbers will not be Emitted
10
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
Building the DSP Library in Code Composer Studio v6.1
www.ti.com
8. Add the DSP library CMSIS-<version>/CMSIS/Include directory to the compiler’s include path in the
Include Options panel. This is done by pressing the Add button by the Add dir to #include search path
(--include_path, -I) (see Figure 9), then either typing in the path to the CMSIS Include directory or
clicking Browse and navigating to the Include directory and navigating to the Include directory
(CMSIS-<version>/CMSIS/Include).
Figure 9. Adding the CMSIS Top Level Include Directory to the Compiler's #include Search Path
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
11
Building the DSP Library in Code Composer Studio v6.1
www.ti.com
9. Expand the Advanced Options menu again and select the Predefined Symbols panel. Create a
symbol to tell the DSP library to use Cortex-M4 based math functions. Click the Add... button in the
Pre-define NAME (--define, -D) area. In the Enter Value dialog box, type ARM_MATH_CM4 into the
Pre-define NAME (--define, -D) field and click OK (see Figure 10). Click the Add… button again type
__FPU_PRESENT=1 into the Pre-define NAME (--define, -D) field and click OK.
Figure 10. Adding Project Level #defines for the Processor Characteristics
12
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
Building the DSP Library in Code Composer Studio v6.1
www.ti.com
10. Select the on option from the Place each function in a separate subsection (--gen_func_subsections, ms) drop-down menu in the Runtime Model Options panel (see Figure 11).
Figure 11. The Proper Runtime Model Options for Compiling the DSP_Lib Source Code
3.5
Building the dsplib Source Code
Build the CMSIS DSP libraries by right-clicking dsplib-cm4f in the Project Explorer and selecting Build
Project. Depending on hardware, this build might take up to ten minutes to complete. After the build is
finished, the resulting dsplib-cm4f.lib file is created in the Debug folder of the project workspace.
NOTE: The CMSIS file structure currently contains a directory located at CMSIS<version>/CMSIS/Lib that is intended for storing compiled library files. It is recommended for
organization’s sake that this directory be used for storing the Code Composer Studio
compiled CMSIS DSP libraries. To do so, create a CCS/M4 sub-directory inside CMSIS/Lib,
then copy the .lib that was generated by the above steps into the Code Composer Studio
sub-directory.
4
ARM Example Projects
The ARM CMSIS download contains eleven example projects that demonstrate how to use the various
DSP library functions. This section details the steps required to create the same projects in Code
Composer Studio v6.1, compile the projects, and run them on a TM4C microcontroller. These steps are
focused on running the code on an EK-TM4C129 Connected LaunchPad, but can be easily modified to
work with any other TM4C or Stellaris MCU (see http://www.ti.com/tool/ek-tm4c1294xl).
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
13
ARM Example Projects
4.1
www.ti.com
Creating the ARM Example Projects
The source code for all of the example projects can be found at CMSIS<version>/CMSIS/DSP_Lib/Examples. Projects for each of the ARM examples can be created in Code
Composer Studio via the following steps:
1. Launch CCSv6.1 and select either an empty workspace or the workspace used in the previous section
to build the DSP library.
2. Select File > New > CCS Project. The New CCS Project window will be displayed.
3. Type ti_cortexM4_<example name> in the Project name field.
4. Select Executable from the Output Advanced settings.
5. Make the following selections from the Target Device:
• Target: TM4C Series
• TM4C1294NCPDT
• Connections: Stellaris In-Circuit Debug Interface
6. Select the Empty Project in the Project templates and examples field.
7. Click Finish to create the project (see Figure 12 and Figure 13). The project now appears in the
Project Explorer.
14
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
ARM Example Projects
www.ti.com
Figure 12. The New CCS Project Window With Options Set to Build the arm_dotproduct_example Project
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
15
ARM Example Projects
www.ti.com
Figure 13. The New CCS Project Window With Options Set to Build the arm_dotproduct_example Project
16
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
ARM Example Projects
www.ti.com
Figure 14. The Project Explorer After the arm_matrix_example Project has Been Created
4.2
Adding the Example Source Code
Once the project is created, it is necessary to point the project to the source files necessary for
compilation:
1. Right-click the project in the Project Explorer and select Add Files…
2. Navigate to the CMSIS-<version>/CMSIS/DSP_Lib/Examples/<example> directory. Select all of the C
source file and click Open (see Figure 15).
Figure 15. Adding the Source Files for arm_matrix_example to the Project
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
17
ARM Example Projects
www.ti.com
3. Select the Link to files radio button, check the Create link locations relative to: checkbox, and select
PROJECT_LOC from the drop-down menu when the File Operation dialog box appears (see
Figure 16). Press OK to add the source file(s) to the project.
Figure 16. Selecting the Proper Options to Link the Source Files Into the Project
18
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
ARM Example Projects
www.ti.com
4.3
Editing the Example Project Settings
Before building the example projects, it is necessary to properly configure the project settings:
1. Right-click the project in the Project Explorer and select Properties.
2. Expand the Build entry, and then expand the ARM Compiler entry.
3. Confirm that the Target_processor version (--silicon_version, -mv) entry matches your processor in the
Processor Options panel (see Figure 17). For this example, the Target processor should be 7M4 (as
opposed to 7M3 for any of the Stellaris Cortex-M3 products).
Figure 17. The Processor Options Used for Building the Example on a Cortex-M4 Process With hardware
FPU Support
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
19
ARM Example Projects
www.ti.com
4. Click the Optimization level (--opt_level, -O) drop-down menu and select 2 in the Optimization panel
(see Figure 18).
Figure 18. The Proper Optimization Settings for Compiling the Example Projects
5. Expand the Advanced Options section of the ARM Compiler pane, and select Assembler Options.
20
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
ARM Example Projects
www.ti.com
6. Click the Use unified assembly language (--ual) checkbox to select that option (see Figure 19).
Figure 19. The Proper Assembler Options Needed for Compiling the Example Projects
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
21
ARM Example Projects
www.ti.com
7. Expand the Advanced Options menu again and select the Predefined Symbols panel. Create a
symbol to tell the DSP library to use Cortex-M4 based math functions. Click the Add... button in the
Pre-define NAME (--define, -D) area. In the Enter Value dialog box, type ARM_MATH_CM4 into the
Pre-define NAME (--define, -D) field and click OK (see Figure 20). Click the Add... button in the Predefine NAME (--define, -D) area. In the Enter Value dialog box, type __FPU_PRESENT=1 into the
Pre-define NAME (--define -D) field and click OK.
Figure 20. Adding the Pre-Processor Statements Necessary for Building an Example Project on a CortexM4 Part With Hardware FPU Support
22
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
ARM Example Projects
www.ti.com
8. Look for the Add button to #include search path (--include_path, -I) field in the Include Options section
(see Figure 22).
Figure 21. Compiler's #include Search Path Modified to Contain Both the Base CMSIS Include Directory
and the Example Projects' Common Include Directory
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
23
ARM Example Projects
www.ti.com
9. Click the Add… button again, then the Browse button and browse to the Include directory located in
the CMSIS directory, then click OK (see Figure 21).
Figure 22. Using the File System Option to Add the Base CMSIS Include Directory to the Compiler's
#include Search Path
24
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
ARM Example Projects
www.ti.com
10. Select the on option from the Place each function in a separate subsection (--gen_func_subsections, ms) drop-down menu (see Figure 23), in the Runtime Model Options panel.
Figure 23. The Runtime Model Options Set Up for Compiling the Example Projects
11. Open the File Search Path panel in the ARM Linker section.
12. Create an entry for the precompiled CMSIS DSP binary (.lib) that will be used in the Include library file
or command file as input (--library, -l) area (see Figure 24). For this example, the library file created in
section three will be used, so click on the Add… button, then the File system… button and navigate to
the location of the .lib you want to use. If you built the precompiled binary from scratch as detailed in
section 3 without changing the default project location, the .lib will be found at
C:\Users\<user_name>\CCS workspaces\<your workspace>\dsplib-cm4f\Debug\dsplib-cm4f.lib. When
you have found the binary, click Open, then OK.
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
25
ARM Example Projects
www.ti.com
Figure 24. The Linker's File Search Path Modified to Include the dsplib Binary Compiled in Section 3
26
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
ARM Example Projects
www.ti.com
4.4
Building, Running, and Verifying the Project
Once the project has been created, the source code has been added to the work space, and the project
properties have been properly configured, the project can be built by right clicking on it in the Project
Explorer and selecting Build Project.
If this is the first time that Code Composer Studio is being used to connect to a target via the Stellaris InCircuit Debug Interface, it might be necessary to install the proper drivers before it is possible to connect
to the target to run code. Instructions for doing this can be found in the Code Composer Studiov6.1 Quick
Start Guide, available at http://processors.wiki.ti.com/index.php/Category:Code_Composer_Studio_v6.
Once the code has been built and the proper drivers have been installed, you can run your code by using
the following steps:
1. Press the Debug icon in the Code Composer Studio toolbar (see Figure 25).
Figure 25. The Debug Context Being Displayed After the arm_matrix_example Project has Been Set Up
for Debugging
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
27
ARM Example Projects
www.ti.com
2. It takes a moment for Code Composer Studio to connect to the MCU and download the code. Once
the connection has been established and the flash programmed with the compiled project code, the
MCU will run until it reaches the project’s main() function (see Figure 26). Press the Resume button
(or F8) to cause the program to start executing.
Figure 26. The arm_matrix_example Project, After it has Been Loaded Into Flash and the Startup Code
has run to the main() Function
28
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
ARM Example Projects
www.ti.com
3. After a few seconds have passed, the program will run to completion (see Figure 27). Press the
suspend button, which will halt the processor and show you what line of code is being executed.
Figure 27. The arm_matrix_example Project Having Run to Successful Completion
4. For every function other than the class marks example, the program will have halted in one of two
while loops. If the program did not successfully execute, it will be caught in a while loop surrounded by
an if statement with a test condition of (status != ARM_MATH_SUCCESS). If the program did
successfully execute, it is caught in a while loop found immediately after the previously mentioned if
statement. For the class marks example, there is no built in method by which the microcontroller’s
execution state can be verified.
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
29
ARM Example Projects
4.5
www.ti.com
Source Code Modifications
For almost all of the ARM example projects, the above steps can be followed in a similar manner to build
and run the ARM-provided source code. There is one project, though, that require modifications to the
source code to properly build and run on the TM4C123G Launchpad.
The linear interpolation example contains a table of values meant to represent a waveform of sin(x) as x
goes from negative pi to 2*pi by increments of 0.00005. This granularity causes the resulting compiled
binary to be too large in size for the TM4C series launchpad. An alternate data file,
ti_linear_interp_data_37968.c, has been provided along with this application report that represents the
same array given increments of 0.00025 instead. This causes the compiled binary to be small enough to
fit into a part with a flash size of 256 kB and an SRAM size of 32 kB for the TM4C123 Platform devices.
This necessitates a change in the linear interpolation example code as well (as the size and name of the
statically allocated array has been changed), so when adding the source code for this example, it is
necessary to use the ti_linear_interp_example_f32.c file included with this application report
The linear interpolation example also contains a bug that might cause it to give the appearance of failing
when executing. The purpose of the example is to show the difference in accuracy that can be achieved
by using the CMSIS DSP library’s linear interpolation sin function, which uses both cubic interpolation and
linear interpolation to derive its return values, and the library’s standard sin function, which uses only cubic
interpolation. The method that is used to compare the accuracy of these two functions is to calculate the
signal-to-noise ratio of both signals with respect to a pre-calculated signal that is known to be correct.
Unfortunately, the method of using linear interpolation gives a result that almost exactly matches the precalculated signal, which causes the SNR function to attempt to take the log of a value divided by 0. As
such, the function’s self-test method cannot be assumed trustworthy. The user should instead use the
debugger to verify that the 10-element-long arrays representing the sin values are indeed more accurate
when using the linear interpolation functions than when using the standard functions. This can be done
using the following steps:
1. Select the Expression view in the Code Composer Studio debugger context
2. Click Add new expression, and type in testRefSinOutput32_f32. This will add the array containing the
pre-calculated reference sin output to the expressions list.
3. Click the arrow to the left of testRefSinOutput32_f32 to display all elements of the array.
4. Click Add new expressions, and type testOutput. This will add the array containing the sin values as
calculated by the CMSIS DSP_Lib sin function that uses cubic interpolation to the expression list.
5. Click the arrow to the left of testOutput to display all elements of the array.
6. Click Add new expressions, and type testLinIntOutput. This will add the array containing the sin values
as calculated by the CMSIS DSPlib that uses both cubic and linear interpolation sin function to the
expression list.
7. Click the arrow to the left of testLinIntOutput to display all elements of the array (see Figure 28).
30
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
Conclusion
www.ti.com
Figure 28. Using the Debugger to Examine the Results of the linear_interp_example Project
8. If you manually examine the values stored at each element, you will see that for the most part, the sin
values calculated using both cubic and linear interpolation are closer to the reference values than
those calculated using only cubic interpolation. In the example above, this is especially noticeable on
element 7 of the output arrays.
5
Conclusion
Using the information provided in this document, combined with the resources available from ARM’s
CMSIS website, it is possible to easily and quickly implement various complex DSP algorithms. While it is
possible to code a number of these functions independently, the result would likely lead to a much greater
development time and produce less efficient code. It is highly recommended that anytime a Texas
Instruments’ TM4C or Stellaris microcontroller is being used for an application that requires complex DSP
functionality, the procedure listed here should be followed to ensure accurate, reliable, efficient code.
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
Copyright © 2012–2015, Texas Instruments Incorporated
31
References
6
www.ti.com
References
The following related documents and software are available on the TM4C Series web site at:
http://www.ti.com/product/tm4c1294ncpdt
• Tiva TM4C1294NCPDT Microcontroller Data Sheet (SPMS433)
• Tiva C Series TM4C129x Microcontrollers Silicon Revisions 1, 2, and 3 Silicon Errata (SPMZ850)
• The source code for the CMSIS DSP Library and example code can be downloaded from ARM’s
CMSIS website: cmsis.arm.com.
• A quick start guide for using Texas Instruments’ Code Composer Studio v6.1 can be found on the TI
processor wiki at: http://processors.wiki.ti.com/index.php/Category:Code_Composer_Studio_v6.
32
Using the CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
Revision History
www.ti.com
Revision History
Changes from F Revision (May 2015) to G Revision ...................................................................................................... Page
•
•
•
•
•
•
Updates were made in the Abstract..................................................................................................... 1
Information was updated in Section 3.1. ............................................................................................... 2
Information was updated in Section 3.2. ............................................................................................... 2
Information was updated in Section 3.4. ............................................................................................... 6
Information was updated in Section 4.1............................................................................................... 14
Information was updated in Section 4.3............................................................................................... 19
NOTE: Page numbers for previous revisions may differ from page numbers in the current version.
SPMA041G – January 2012 – Revised October 2015
Submit Documentation Feedback
Copyright © 2012–2015, Texas Instruments Incorporated
Revision History
33
IMPORTANT NOTICE
Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, enhancements, improvements and other
changes to its semiconductor products and services per JESD46, latest issue, and to discontinue any product or service per JESD48, latest
issue. Buyers should obtain the latest relevant information before placing orders and should verify that such information is current and
complete. All semiconductor products (also referred to herein as “components”) are sold subject to TI’s terms and conditions of sale
supplied at the time of order acknowledgment.
TI warrants performance of its components to the specifications applicable at the time of sale, in accordance with the warranty in TI’s terms
and conditions of sale of semiconductor products. Testing and other quality control techniques are used to the extent TI deems necessary
to support this warranty. Except where mandated by applicable law, testing of all parameters of each component is not necessarily
performed.
TI assumes no liability for applications assistance or the design of Buyers’ products. Buyers are responsible for their products and
applications using TI components. To minimize the risks associated with Buyers’ products and applications, Buyers should provide
adequate design and operating safeguards.
TI does not warrant or represent that any license, either express or implied, is granted under any patent right, copyright, mask work right, or
other intellectual property right relating to any combination, machine, or process in which TI components or services are used. Information
published by TI regarding third-party products or services does not constitute a license to use such products or services or a warranty or
endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property of the
third party, or a license from TI under the patents or other intellectual property of TI.
Reproduction of significant portions of TI information in TI data books or data sheets is permissible only if reproduction is without alteration
and is accompanied by all associated warranties, conditions, limitations, and notices. TI is not responsible or liable for such altered
documentation. Information of third parties may be subject to additional restrictions.
Resale of TI components or services with statements different from or beyond the parameters stated by TI for that component or service
voids all express and any implied warranties for the associated TI component or service and is an unfair and deceptive business practice.
TI is not responsible or liable for any such statements.
Buyer acknowledges and agrees that it is solely responsible for compliance with all legal, regulatory and safety-related requirements
concerning its products, and any use of TI components in its applications, notwithstanding any applications-related information or support
that may be provided by TI. Buyer represents and agrees that it has all the necessary expertise to create and implement safeguards which
anticipate dangerous consequences of failures, monitor failures and their consequences, lessen the likelihood of failures that might cause
harm and take appropriate remedial actions. Buyer will fully indemnify TI and its representatives against any damages arising out of the use
of any TI components in safety-critical applications.
In some cases, TI components may be promoted specifically to facilitate safety-related applications. With such components, TI’s goal is to
help enable customers to design and create their own end-product solutions that meet applicable functional safety standards and
requirements. Nonetheless, such components are subject to these terms.
No TI components are authorized for use in FDA Class III (or similar life-critical medical equipment) unless authorized officers of the parties
have executed a special agreement specifically governing such use.
Only those TI components which TI has specifically designated as military grade or “enhanced plastic” are designed and intended for use in
military/aerospace applications or environments. Buyer acknowledges and agrees that any military or aerospace use of TI components
which have not been so designated is solely at the Buyer's risk, and that Buyer is solely responsible for compliance with all legal and
regulatory requirements in connection with such use.
TI has specifically designated certain components as meeting ISO/TS16949 requirements, mainly for automotive use. In any case of use of
non-designated products, TI will not be responsible for any failure to meet ISO/TS16949.
Products
Applications
Audio
www.ti.com/audio
Automotive and Transportation
www.ti.com/automotive
Amplifiers
amplifier.ti.com
Communications and Telecom
www.ti.com/communications
Data Converters
dataconverter.ti.com
Computers and Peripherals
www.ti.com/computers
DLP® Products
www.dlp.com
Consumer Electronics
www.ti.com/consumer-apps
DSP
dsp.ti.com
Energy and Lighting
www.ti.com/energy
Clocks and Timers
www.ti.com/clocks
Industrial
www.ti.com/industrial
Interface
interface.ti.com
Medical
www.ti.com/medical
Logic
logic.ti.com
Security
www.ti.com/security
Power Mgmt
power.ti.com
Space, Avionics and Defense
www.ti.com/space-avionics-defense
Microcontrollers
microcontroller.ti.com
Video and Imaging
www.ti.com/video
RFID
www.ti-rfid.com
OMAP Applications Processors
www.ti.com/omap
TI E2E Community
e2e.ti.com
Wireless Connectivity
www.ti.com/wirelessconnectivity
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2015, Texas Instruments Incorporated
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertising