This example shows how to use the Code Replacement Library (CRL) for ARM with DSP blocks. The model uses the FIR filter block to filter two sine waves of different frequencies.
Task 1: Simulate
Open the model by typing ex_fircmsis_tut on MATLAB's command line.
Change your current folder in MATLAB® to a writable folder.
On the model toolstrip, Click Play to start the simulation.
Click Stop to end simulation.
Task 2: Setup model for Code Replacement
Under Simulation, click Model Configuration Parameters to open the dialog box.
Select Code Generation category.
Set the System target file to ert.tlc, and select Generate code only.
Select Interface under the Code Generation category.
Set Code replacement library to ARM Cortex-M.
Task 3: Generate code
Right-click the FIR subsystem. From the drop-down menu that opens, choose C/C++ Code > Build This Subsystem. When the Build code for Subsystem dialog box opens, Click Build to start generating code.
When build finishes processing, a code generation report comes up.
Click on the FIR.c file. Notice the CMSIS function; arm_fir_init_f32 call in the initialize function (FIR_initialize). Also, notice the CMSIS function; arm_fir_f32 in the model step function (FIR_step).
Task 4: Use Processor in the Loop (PIL)
To perform the previous steps using PIL, you need to have the Embeded Coder Support Package for ARM Cortex-M Processors, and the DST Support Package for ARM Cortex-M Processors. The following examples shows you how to use PIL with ARM Cortex-M:
Code Verification and Validation with PIL and External Mode
Code Optimization Using CMSIS DSP Library
For instructions on accessing these examples, see: Open Examples for This Support Package.