Main Content

Verify FIR Filter on Raspberry Pi Hardware

This example shows how to use the Code Replacement Library (CRL) for Raspberry Pi hardware with DSP blocks. The model uses the FIR filter block to filter two sine waves of different frequencies.


To open the model, run this command at the MATLAB® command prompt:


Task 1: Simulate

1. Open the FIR NE10 CRL tutorial example model.

2. Change your current folder in MATLAB® to a writable folder.

3. Go to Modeling > Model Settings to open the Configuration Parameters dialog box.

4. Click Hardware Implementation pane, and select Raspberry Pi from the list of Hardware board parameter.

5. Click Apply and OK.

6. On the model tool strip, click Run to start the simulation.

7. Click Stop to end simulation.

Task 2: Setup model for Code Replacement

1. Under Simulation, click Model Configuration Parameters to open the dialog box.

2. Select the Code Generation category.

3. Clear Generate code only option.

4. In the Build Configuration drop-down list, select Specify.

5. Expand Toolchain details and add assembler flags based on the Raspberry Pi board you use. For example, if you are using Raspberry Pi Model B board, then add -mfpu=neon -mcpu=cortex-a72 after -c. For more information on the ARM Cortex-A Processors supported by Raspberry Pi Hardware, see Supported ARM Cortex-A Processors for Raspberry Pi Hardware.

6. Select Interface under the Code Generation category.

7. Set Code replacement library to GCC ARM Cortex-A.

Task 3: Generate code

1. Right-click the FIR subsystem.From the drop-down menu that opens, choose C/C++ Code > BuildThis Subsystem. When the Build code for Subsystem dialog box opens, click Build to start generating code.

2. When build finishes processing, a code generation report comes up.

3. Click on the FIR.c file. Notice the NE10 library function; ne10_fir_init_float in the initialize function (FIR_initialize). Also, notice the NE10 function; ne10_fir_float_neon in the model step function (FIR_step).

Task 4: Use Processor in the Loop (PIL)

The following example show you how to use PIL with Raspberry Pi hardware:

  • Code Verification and Validation with PIL and External Mode example.