Main Content

Monitoring and Tuning Using STMicroelectronics STM32 Processor Based Boards

This example shows how to use Embedded Coder® Support Package for STMicroelectronics® STM32 Processors for Monitoring and Tuning simulations using STM32 processor based boards.


In this example you will learn how to configure a Simulink® model to Monitor and Tune the simulations.

Monitor and Tune enables parameter tuning and data logging while the model is running on the target.


Complete the following tutorials:

Required Hardware

  • STMicroelectronics NUCLEO-F429ZI board.

  • Micro USB cable.

Monitor and Tuning of STM32 Processor Based Board

When you are prototyping and developing algorithms, it is useful to monitor signals and tune parameters while the algorithms are running on the hardware. The Simulink Monitor & Tune feature enables this capability. The STM32 processor based boards support Monitor and Tuning over Universal Measurement and Calibration Protocol (XCP).

Simulink provides these additional features for the targets that support XCP:

  • Dashboard objects such as Slider and Dashboard Scope. For more information, see Dashboard.

  • Simulation Data Inspector (SDI) for visualizing the logged signals. For more information, see Simulation Data Inspector.

In this task, you will run the stm32_external_mode model.

1. Open the stm32_external_mode model.


2. This example model has one signal selected for logging. To select additional signals, right-click the required signal and select the Log Selected Signals option.

3. Specify the COM Port and USART. In this example USART3 is selected.

Note: To see the list of available COM ports on your computer, select Start > Control Panel > Device Manager > Ports (COM &LPT).

4. Configure the same USART3 in the STM32CubeMX project. For more, see Serial Configuration for Monitor & Tune and PIL for STM32 Processor-Based Boards

5. Go to Hardware tab, and click Monitor & Tune to configure the model for simulation.

At this point, your model is running on the STMicroelectronics® STM32 board and communicating with Simulink from Monitor & Tune. You can select the Simulation > Data Inspector button to view the logged signals, as shown.

6. You can tune the parameters and visualize the signals selected for logging by:

  • Double-clicking the Manual Switch block to change the input source.

  • Using the Slider to change the signal gain.

  • Double-clicking the Scope block to view the simulation results.

The model is running in real-time on the target while performing these actions.

7. Stop Monitor & Tune simulation by clicking the Stop button, as shown.

Stopping the Monitor & Tune simulation terminates the execution of the code running on the STM32 board.

Note: At any point during the course of the simulation, you can open the External Mode Control Panel, as shown. The Hardware > control panel provides more options, such as the ability to connect or disconnect to the target without terminating the execution of the generated code.


Running Monitor & Tune over XCP has a few limitations. For a detailed list, see External Mode Simulation by Using XCP Communication (Simulink Coder).

More About