SPRADI0 July   2024

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Introduction
    1. 1.1 Getting Started
  5. 2Model-Based Design of eCompressor
    1. 2.1 General Texas Instruments High Voltage Evaluation (TI HV EVM) User Safety Guidelines
    2. 2.2 Block Diagram
    3. 2.3 Hardware, Software and Testing Requirements
      1. 2.3.1 Hardware setup
      2. 2.3.2 Software setup
      3. 2.3.3 Test Procedure
  6. 3 Simulink Configuration Settings
    1. 3.1 Simulink Tool Optimization
      1. 3.1.1 Optimum Code Generation
    2. 3.2 C2000 Specific Optimization
      1. 3.2.1 Using TMU Through Simulink
      2. 3.2.2 Using Software Libraries Through Simulink
      3. 3.2.3 Running Code From RAM
    3. 3.3 Performance Comparison
  7. 4 Profiling Using Simulink
    1. 4.1 Processor-in-loop (PIL) Method
    2. 4.2 C2000 Timer-Based Profiling
    3. 4.3 Code Composer Studio tools
  8. 5Summary

Optimum Code Generation

The configurations showcased in the table can be manually configured by configuring each parameter in the Hardware Settings in Simulink. To avoid manual effort, MATLAB also allows to configure settings in Simulink through MATLAB script.

The optimized code generation configuration can also be simply parsed through a script by either including the script in the existing model or just by running the script once to configure all settings before running the application code. The parameter 'mdl' in the script needs to reflect the name of the model in use to correctly configure the settings. It can be validated, if the settings are configured, by manually checking the configurations in the Hardware Settings in Simulink window.

%% Load the model
mdl = 'TIDM_02012_F280039_MBD';%Model Name
load_system(mdl);

%% Set Build Configurations and Prioritized Objectives in Code Generation tab
set_param(mdl,'BuildConfiguration','Faster Runs') ; %Build Configurations
set_param(mdl,'ObjectivePriorities','Execution efficiency');  %Prioritized Objectives
%% Set Level, Priority in Optimization levels and enable some advanced Parameters in Optimization tab
set_param(mdl,'OptimizationPriority','speed');%Optimization Priority

set_param(mdl,"OptimizationCustomize","off");%Customize Optimizations Checkbox
%% TODO: Check -- updated Code Config > Optimization > default parameter behaviour to inlined instead of tunable to make the below config work
set_param(mdl,"InlineInvariantSignals","on");%Inline Invariant Signals
set_param(mdl,"EfficientMapNaN2IntZero","on");% Removes code from float to int with saturation mapping NaN to zero.
%%  Remove support for non-finite, complex and absolute time Interface tab
set_param(mdl,"SupportAbsoluteTime","off");%Remove Absolute time support
set_param(mdl,"SupportComplex","off");%Remove Complex Number support
set_param(mdl,"SupportNonFinite","off");%Remove Non-Finite Number support
%% Application Lifetime setting
set_param(mdl,"LifeSpan","1");%Remove Absolute time support
Note: In the code block above, replace the model name with the application model name in use and run the script before executing the code generation for the application model to incorporate all the optimized configuration.