Main Content

Optimize Code for ARM Cortex-M Processors

R2026b

You can configure your model to replace generic code with ARM® CMSIS code that is optimized for ARM Cortex®-M processors.

To measure the effects of optimization, you can perform Execution profiling before and after completing this procedure. For more information, see Replace Code for Embedded Targets.

To enable the code replacement libraries for ARM Cortex-M processors:

  1. (Optional) To see the code replacement libraries that the code generation process will prioritize, enter:

    crviewer('ARM Cortex-M')

    Code Replacement Viewer opens and displays the code replacement libraries.

    Code Replacement Viewer showing the ARM Cortex-M library with four replacement tables

  2. In the model, open the Modeling tab and press CTRL+E to open the Configuration Parameters dialog box. Go to Hardware Implementation > Hardware board and ensure that the Device vendor is set to ARM compatible and Device type is ARM Cortex.

    Configuration Parameters with Hardware Implementation pane showing Device vendor set to ARM Compatible and Device type set to ARM Cortex

  3. In the Configuration Parameters dialog box, expand Code Generation, and select the Interface pane.

  4. Click Select of Code replacement library parameter. A Choose one or multiple Code replacement libraries for code generation dialog box is opened.

  5. Select ARM Cortex-M to the selected code replacement libraries-prioritized and click OK.

    Configuration Parameters showing Code Generation Interface pane with ARM Cortex-M selected in the prioritized code replacement libraries