| Embedded IDE Link™ CC | ![]() |
| On this page… |
|---|
Descriptions of the Two Tutorial Tasks Task 1 — Export Filter by Generating an ANSI® C Header File Task 2 — Export Filter by Writing Directly to Processor Memory |
This tutorial shows you how to export filters from FDATool to CCS IDE with the Export to Code Composer Studio (tm) IDE dialog box. The tutorial covers exporting filters by generating ANSI® C header files, and by writing filter coefficients directly to the target memory. Also see the previous section, Guidelines on Exporting Filters from FDATool to Code Composer Studio™ IDE.
Task 1 — Export Filter by Generating an ANSI® C Header File — You should complete this task before starting Task 2. Exporting a filter by generating a C header file not only exports your filter; it also ensures that you allocate enough target memory for the exported filter coefficients.
Task 2 — Export Filter by Writing Directly to Processor Memory — You should complete Task 1 before starting this task to ensure you allocate enough target memory for the filter coefficients to export. Exporting directly to target memory is useful when you want to repeatedly tune your filter in FDATool, and then export the updated filter coefficients directly to the allocated target memory.
To complete this tutorial, you must install both Signal Processing Toolbox and Target Support Package™ TC6. You do not need to open CCS IDE before starting the tutorial.
In Task 1, you export a filter by generating a ANSI C header file. The generated ANSI C header file defines global arrays of filter coefficients that correspond to static memory locations in the final target program. By generating a program file from the ANSI C header file and loading the program file into your target, not only do you export your filter, but you ensure that you allocated enough memory for the exported filter coefficients. In Task 2, you write filter coefficients directly to the memory allocated in Task 1. You should complete Task 1 before starting Task 2.
Open FDATool by entering fdatool in the MATLAB® command window.
fdatool % Open FDATool
FDATool opens with a default lowpass equiripple FIR filter displayed. The filter that you export in this tutorial is an IIR filter (to match the tutorial, design an IIR filter by changing Design Method from FIR to IIR).

Open the Export to Code Composer Studio(tm) IDE dialog box by selecting Targets > Code Composer Studio(tm) IDE from the FDATool menu bar.


Set Export mode to Generate C header file.
![]()
You must name the variables that store the filter coefficients in the generated ANSI header file by setting the Numerator, Denominator, Numerator length, and Denominator length parameters. (These correspond to the four variables for the numerator filter coefficients, denominator filter coefficients, number of numerator coefficients, and number of denominator coefficients.) For this tutorial, use the default variable names, NUM, DEN, NL, and DL. Use NS for the number of filter sections variable name, as provided by the dialog box.
The generated ANSI header file will define global arrays, NUM, DEN, NL, and DL, that correspond to static memory locations containing the filter coefficients in the final target program.

Use the suggested data type to export your filter coefficients by selecting the Export suggested parameter.

If you know the board number and processor number of your target DSP, select your target by setting the DSP Board # and DSP Processor # values.

Alternatively, click Select target, which opens the Selection Utility: Embedded IDE Link™ CC dialog box when you have more than one board defined in the CCS setup. Select the board name and processor name of the DSP target and click Done to set the DSP Board # and DSP Processor # values in the Export to Code Composer Studio(tm) IDE dialog box.

If you have only one board or simulator, Embedded IDE Link CC opens the Selecting Boardnum & Procnum dialog box and sets your target to the board and processor automatically.
Click Generate to generate the ANSI header file. FDATool prompts you for a file name to save the generated header file with the .h extension, and a location to store the file. In addition, this opens the generated ANSI header file in CCS IDE. (CCS IDE will be opened for you if you did not have it open.)
Add the generated ANSI header file to an appropriate project, generate a program file, and load the program file into your target DSP. The program file allocates static memory locations in the target, and writes the filter coefficients to these locations. Refer to the following note.
By completing steps 1 through 8, you allocated target memory for the filter coefficients and exported the coefficients to these memory locations. Now you can tune the filter in FDATool, then export the updated filter coefficients directly to the allocated memory locations as described in Task 2 of this tutorial.
Note You can edit the generated ANSI header file so the associated program file allocates extra target memory. This allows you to change your filter and export the new filter coefficients directly to the allocated memory. You do not have to worry about whether there is enough memory. For example, in the following header file, you could modify const real64_T NUM[47] = {...} to real64_T NUM[256] = {...} to allow NUM to store up to 256 numerator filter coefficients rather than 47. |
/*
* Filter Coefficients (C Source) generated by the Filter Design and Analysis Tool
*
* Generated by MATLAB(R) 7.0.1 and the Signal Processing Toolbox 6.2.1.
*
* Generated on: xx-xxx-xxxx 14:57:57
*
*/
/*
* Discrete-Time FIR Filter (real)
* -------------------------------
* Filter Structure : Direct-Form FIR
* Filter Length : 51
* Stable : Yes
* Linear Phase : Yes (Type 1)
*/
/* General type conversion for MATLAB generated C-code */
#include "tmwtypes.h"
/*
* Expected path to tmwtypes.h
* M:\perfect\matlab\extern\include\tmwtypes.h
*/
const int BL = 51;
const real64_T B[51] = {
-0.0009190982084683,-0.002717696026596,-0.002486952759832, 0.003661438383507,
0.01365092523066, 0.01735116590109, 0.007665306190422,-0.006554718869642,
-0.007696784037065, 0.006105459421394, 0.01387391574864,0.0003508617282909,
-0.01690892543669,-0.008905642749159, 0.01744112950085, 0.02074504452761,
-0.01229649425194, -0.03424086590958,-0.001034529605572, 0.0477903055208,
0.02736303791485, -0.05937951883105, -0.08230702592923, 0.06718690943287,
0.3100151770903, 0.4300478803435, 0.3100151770903, 0.06718690943287,
-0.08230702592923, -0.05937951883105, 0.02736303791485, 0.0477903055208,
-0.001034529605572, -0.03424086590958, -0.01229649425194, 0.02074504452761,
0.01744112950085,-0.008905642749159, -0.01690892543669,0.0003508617282909,
0.01387391574864, 0.006105459421394,-0.007696784037065,-0.006554718869642,
0.007665306190422, 0.01735116590109, 0.01365092523066, 0.003661438383507,
-0.002486952759832,-0.002717696026596,-0.0009190982084683
};
In Task 2 you export a filter by writing the filter coefficients directly to processor memory. Before starting this task, allocate enough memory for the filter coefficients by completing Task 1 — Export Filter by Generating an ANSI® C Header File. After you allocate enough memory, you can tune your filter in FDATool and export the updated filter coefficients directly to the allocated memory by following the steps in this task. For important guidelines on writing directly to target memory, refer to Cautions Regarding Writing Directly to Memory.
Tune your filter coefficients in FDATool to improve its performance. Set the numerical precision of your filter by using the Quantized Filter pane in FDATool, available when you install Filter Design Toolbox. If you do not have Filter Design Toolbox™ software, your filters in FDATool have the default precision, double-precision floating point.
If you have the Export to Code Composer Studio(tm) IDE dialog box open from Task 1, the dialog box updates itself as you tune the filter in FDATool. If you closed the dialog box, reopen it as described in Step 2 — Open the Export to Code Composer Studio(tm) IDE Dialog Box.
Note If you allocated exactly enough memory for the filter coefficients in Task 1, do not tune your filter such that it requires more memory than did the original filter (by increasing the filter order, for example). If you need more memory for your updated filter, allocate extra memory by editing the generated ANSI C header file from Task 1 (as described in the previous note), generating a program file, and loading the program file into your target. |
Set Export mode to Write directly to memory. Clear the parameter Disable memory transfer warnings so that you get a warning if your target does not support the export data type.
![]()
To write to the memory allocated in Task 1, enter the names of the variables in the target symbol table corresponding to the allocated memory. These names are the same as the names of the filter coefficient variables in the ANSI C header file from Task 1: NUM, DEN, NL, and DL. You do not need to type these names in, because they are the default setting of the Numerator, Denominator, Numerator length, and Denominator length parameters. (These parameters correspond to the memory locations that store the numerator filter coefficients, denominator filter coefficients, number of numerator coefficients, and number of denominator coefficients.)

Select an export data type and indicate your target DSP as in Steps 5 and 6 of Task 1.
Load the program file associated with your target into CCS IDE to activate the target symbol table. The program file must contain the global variables you entered in Step 11.
Click Apply to export your filter. Before the filter export begins, a warning dialog box appears if your target does not support the export data type. You can choose to continue to export the filter, or to cancel the export. To prevent this warning dialog box from appearing, select the parameter Disable memory transfer warnings in Step 10.

Continue to optimize filter performance by retuning your filter in FDATool and exporting the updated filter coefficients directly to target memory. Because you already set up the export process to write to specific memory locations, you can click Apply to export updated coefficients to these same memory locations.
When the Export to Code Composer Studio (tm) IDE dialog box is open, it automatically updates as you tune your filter in FDATool, and preserves the parameter settings from Steps 10 through 13. The dialog box stays open as long as you do not click Cancel or OK. Keep the dialog box open when exporting multiple times to the same memory locations so you do not have to repeat Steps 10 through 13, and can just click Apply.
For more information on exporting filters from FDATool to CCS IDE, refer toGuidelines on Exporting Filters from FDATool to Code Composer Studio™ IDE, which contains the following sections:
To learn to use FDATool, refer to the section "Filter Design and Analysis Tool" in the Signal Processing Toolbox™ documentation.
Also refer to the reference pages for the following Embedded IDE Link CC functions:
![]() | Guidelines on Exporting Filters from FDATool to Code Composer Studio™ IDE | Function Reference | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |