Main Content

Code Execution Profiling on Texas Instruments C2000 Targets in XCP External Mode

This example shows how to use for Texas Instruments™ C2000™ Microcontroller Blockset to profile real-time execution of the generated code running as an executable on a Texas Instruments C2000 board with XCP on Serial and XCP on TCP/IP Interface.


Sample times you specify in the Simulink® models determine the time schedule for running generated code on target hardware. With enough computing power on the hardware, the code runs in real-time according to the specified sample times. With real-time execution profiling, you can check if the generated code meets your real-time performance requirements. This support blockset supports the code execution profiling on any Texas Instruments C2000 board.

At the end of the Simulink model code profile execution, you can:

  • View a report of code execution times.

  • Access and analyze execution time profiling data.


Complete the Getting Started with Embedded Coder Support Package for TI C2000 Processors video.

Note: Starting R2023a, the workflow for getting started tutorial for support package will continue to support in C2000™ Microcontroller Blockset.

Required Hardware

Any Texas Instruments C2000 board


This example uses a f28379D_profiling_xcp preconfigured model.

Configuring the Model

In this example, you will configure a Simulink model and enable profiling.

Note: These steps are not required in the pre-configured model. Perform these steps if you have changed the hardware or not using the pre-configured model.

1. Open the model.

2. Go to Modeling > Model Settings to open the Configuration Parameters dialog box.

3. Open the Hardware Implementation pane, and select the required Texas Instruments C2000 board from the list in Hardware board parameter.

4. Expand Target hardware resources for that board.

5. Go to External mode tab and choose XCP on Serial as the Communication interface.

6. Go to Code Generation > Verification > Code execution time profiling and select Measure task execution time.

7. Select the required option for Measure function execution times, Workspace Variable and Save Options. For information on different save options, see Save Options.

8. Click Apply and OK.

Initiate Monitor and Tune Action for the Model

On the Hardware tab of the Simulink toolstrip, click Monitor & Tune to monitor signals and tune parameters.

This generates a profiling report with profiling metrics of different tasks/functions that are being profiled. This also contains links to plot the data on SDI, bar charts, pie charts and CPU Utilization which provides further analysis of the data.

All data report

Code Execution Profiling Report Details

The profiling report is generated at the end of the simulation or when simulation is stopped manually. This example model contains three synchronous rates (200 microseconds, 600 microseconds, 1 microseconds) and an Asynchronous Hardware Interrupt block. The report is generated with All data save option and Detailed Function profiling. In the report following tasks/functions are profiled.

  • All the three synchronous rates (step0, step1 and step2)

  • Asynchronous rate (isr_int1pie1_task_fcn)

  • ADC and PWM blocks inside the Hardware Interrupt block

  • For Iterator Atomic subsystem

  • Sine Wave block.

All the functions/tasks contain the following data:

  • Maximum and average execution time taken on the target.

  • Maximum and average self time taken on the target.

  • Number of times the function/task is called.

The report also contains links to:

  • MATLAB® Workspace variable containing the profiling data, which can be used to conduct a custom analysis of profiling data.

  • Simulink Data Inspector: Profiling data can be visualized over the duration of simulation. A screen is shown below.

  • Bar chart: Contains normalized frequency of the execution times of the task/function. A sample Bar chart is shown below.

  • Pie chart: Shows the time taken by a function and its child functions. A sample Pie chart is shown below.

Metrics only report

This report contains only summary metrics of Average/Maximum execution times of each task/function being profiled. Also, it contains the number of times each function/task is called during simulation.

Note: Profiling with All data or Summary data save options and Detailed option selected for Measure function execution times requires high bandwidth. This is because large amount of data must be sent in real-time. If the target does not have enough bandwidth to stream data in real-time, then select Metrics Only save option. Running profiling with this option stores summary profiling data on the target and will only send data to the host at the end of simulation.

Other Things to Try

Profile other Simulink models from the Texas Instruments C2000 blockset. Observe the time taken for implementing steps in the Simulink model that helps to improve its efficiency.

Related Topics