主要内容

为 ARM Cortex-M 处理器优化代码

R2026b

您可以配置您的模型,将通用代码替换为针对 ARM® Cortex®-M 处理器进行了优化的 ARM CMS 代码。

为了衡量优化的效果,您可以在完成此过程之前和之后运行探查。有关详细信息,请参阅Replace Code for Embedded Targets。

要为 ARM Cortex-M 处理器启用代码替换库,请执行以下操作:

  1. (可选)要查看代码生成过程将优先执行的代码替换库,请输入:

    crviewer('ARM Cortex-M')

    代码替换查看器将打开并显示代码替换库。

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

  2. 在模型中,打开建模选项卡,并按 CTRL+E 打开“配置参数”对话框。转至硬件实现 > 硬件板,确保设备供应商设置为 ARM compatible,并且设备类型为 ARM Cortex。

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

  3. 在“配置参数”对话框中,展开代码生成,然后选择接口窗格。

  4. 在代码替换库参数的右侧点击选择...。将打开 Choose one or multiple Code replacement libraries for code generation 对话框。

  5. 在“所选的代码替换 - 优先”部分选择 ARM Cortex-M,然后点击确定。

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