This example shows how to use the Code Replacement Library (CRL) for ARM with DSP blocks. The model uses the fixed-point FIR filter block to filter two sine waves of different frequencies.
1. Open the model with fixed-point FIR filter.
2. Change your current folder in MATLAB® to a writable folder.
3. Simulate and setup model for ARM Cortex-M code replacement by following the Task 1 and Task 2 ofexample.
1. Open the FIR subsystem.
2. Verify that the input to the FIR Filter block is real with data type sfix16_En15 (signed fixed-point with 16 bits word length and 15 bits fractional length).
3. Double clicking the Discrete FIR Filter block brings up the block dialog box.
4. On the Main pane, ensure the following conditions are met:
The Filter structure is Direct form
The number of filter coefficients must be even and greater than or equal to 4
The Input processing is set to Columns as channels (frame based) and input has one column
The Initial states are set to 0
5. Set coefficients, product output, accumulator and output etc. fixed-point data type properties to match the corresponding CMSIS function Specifications.
General fixed-point property settings:
Rounding Method: floor
Saturate On Integer Overflow: On
Lock data type settings against changes by the fixed-point tools: On
1. Generate code for the FIR subsystem by following the Task 3 ofexample.
2. In the code generation report, click on the FIR.c file. Notice the CMSIS function, arm_fir_init_q15 in the model initialize function (FIR_initialize). Also, notice the CMSIS function, arm_fir_q15 in the model step function(FIR_step).
To perform the previous steps using PIL, you need to have the Embedded Coder Support Package for ARM Cortex-M Processors, and the DST Support Package for ARM Cortex-M Processors. The following example shows you how to use PIL with ARM Cortex-M:
Code Verification and Validation with PIL and External Mode example.