This example shows you how to use Embedded Coder™ Support Package for Texas Instruments C2000 Processors and Embedded Coder Support Package for Texas Instruments C2000 F28M3x Concerto Processors for real-time execution profiling of generated code.
C2000 LaunchPadXL TMS320F28377S (LAUNCHXL-F28377S): f28377S_RTProfiler.slx
The following figure shows the example model:
Sample times specified in a Simulink® model determine the time schedule for running generated code on target hardware. If the target hardware has sufficient computing power, the code runs according to specified sample times in real-time.
You can use real-time execution profiling to check whether generated code meets real-time performance requirements. Execution Profiling results can also be used to take actions to enhance design of your system. For example, if the code easily meets the real-time requirements, you may consider adding more functionality to your system to exploit available processing power. If, on the other hand, the code does not meet real-time requirements, you may look for ways to reduce execution time. For example, you can identify the tasks that require the most time and then investigate whether trade-off between functionality and speed is possible.
This example introduces a workflow for real-time code execution profiling by showing you how to:
Configure the model for code execution profiling, and generate code.
Run generated code on target hardware.
Analyze performance through code execution profiling plots and reports.
1. Open the model. This model is configured for C2000 LaunchPadXL TMS320F28377S (LAUNCHXL-F28377S) target hardware.
2. Open the Modeling tab and press CTRL+E to open Configuration Parameters dialog box. Go to Code Generation > Verification.
3. Select Measure task execution time, and select Measure function execution times > Detailed (all function call sites) option. These options enable you to profile execution time for each task and function in generated code. Click OK.
4. Check that Hardware Implementation > Build Options > Build, load and run is selected. This option must be selected, or the generated executable does not download into the target.
5. Open the Hardware tab and click Build, Deploy & Start to run the code inside the target hardware.
6. Run the following code in MATLAB Command Window to get the profiling data into MATLAB workspace:
The variable executionProfile is available in the MATLAB workspace at the end of execution of this command.
7. Run the following code in MATLAB Command Window to obtain the Profiling Report for the session you just ran. Analyze the report on different turnaround and execution times for each task and function. Close the report when you are done.
8. Execute the following code in MATLAB Command Window to obtain the Profiling Timeline for the session you just ran. Analyze the execution timeline of different tasks and functions. Notice where the faster task pre-empts the slower one and where different functions start and end. Close the timeline when you are done.
The code execution profiler uses an on-chip timer. If you use a processor simulator, select one that can simulate processor timers.
The model needs to run long enough to collect sufficient profiling data. This time depends on the number of profiling samples specified and the sample rates of the model. If you use a simulator, data collection can take considerably longer than when you use hardware.
The shipped target configuration file (ccxml) removes RAM initializations done by the debugger while connecting to the target. Please make sure of this behavior on using a custom target configuration file.
Code execution profiling is currently not supported for models with asynchronously executed subsystems. For example, subsystems triggered by C28x Interrupt Block is not supported.