Main Content

STMCubeMX Based PIL Execution Using the MATLAB Coder App

You can use the processor-in-the-loop (PIL) executions with STMicroelectronics® STM32 based boards to verify the generated code that you deploy to the target hardware by using a MATLAB® Coder™ procedure. You can profile algorithm performance and speed of your generated code on the target hardware. To verify generated code with the MATLAB Coder app, you must have MATLAB Coder and an Embedded Coder® license.

You can set up PIL execution with the MATLAB Coder app.

To open the MATLAB Coder app, see Open the MATLAB Coder App and Create a Project File.

To configure the build type and hardware board:

  1. Configure the build type and hardware board. In the MATLAB Coder tab of the toolstrip:

    • Set the Output Type to Static Library (.lib).

    • Under Settings > Hardware, select STM32F4-Discovery.

  2. If necessary, modify the settings for your board. To modify the settings, click Settings > View all settings, and then click Hardware.

    Specify the stack usage of the generated code in the Memory > Stack usage max parameter. The memory of the hardware board is limited, and a default value of 20000 is beyond the stack size available in the hardware. We recommend you to set the value to 512. However, specify an appropriate stack usage based on your algorithm.

  3. From the Hardware pane of the Configuration Parameters Dialog Box, you can

  4. To generate the library, in the toolstrip, click Generate Code > Generate Code and Build.

  5. Because the hardware board is not MATLAB Host Computer, the Verify Code section of the toolstrip shows the Run Using PIL button.

    In the Run Using PIL drop-down menu:

    • Select Verification Mode > Use generated code.

    • Enter the name of the test file for PIL execution. PIL execution starts automatically.

  6. To stop the PIL execution, click Stop.

For another example of PIL verification, see the Processor-in-the-Loop Verification of MATLAB Functions example in the documentation of the Embedded Coder Support Package for STMicroelectronics STM32 Processors.

To install the Embedded Coder Support Package for STMicroelectronics STM32 Processors, see Embedded Coder Supported Hardware.

See Also

| |

Topics