Support Fixed-Point FIR Filter on ARM Cortex-M Processor
This example shows how to use the code replacement library (CRL) for ARM® processors with DSP blocks. The model uses the fixed-point FIR filter block to filter two sine waves of different frequencies.
Task 1: Simulate and Setup Model for Code Replacement
1. Open the ex_fircmsis_tut_q15 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 of Verify FIR Filter on ARM Cortex-M Processor example.
Task 2: Configure the FIR Filter Block for Code Replacement
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. Click on the Main pane.
5. Set the Filter structure to Direct form.
6. The number of filter coefficients must be even and greater than or equal to 4.
7. The Input processing is set to Columns as channels (frame based) and input has one column.
8. Set the Initial states to 0.
9. Set the values for coefficients, product output, accumulator, and output as fixed point data type 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
Task 3: Generate Code
1. Generate code for the FIR subsystem by following the Task 3 of Verify FIR Filter on ARM Cortex-M Processor example.
2. In the code generation report, click on the FIR.c
file. Observe the CMSIS function arm_fir_init_q15
in the FIR_initialize
model initialize function. Also, observe the CMSIS function arm_fir_q15 in the FIR_step
model step function.
Task 4: Use Processor in the Loop (PIL)
The Code Verification and Validation with PIL example shows how to use processor in the loop (PIL) with ARM Cortex-M processors.