Showing results for 
Search instead for 
Did you mean: 

Nucleo-G491RE: communication error with MATLAB/Simulink XCP protocol via LPUART1


Hi all,

I'm not able to connect Simulink to the model running on the Nucleo-G491RE board using the "Monitor&Tune" mode via Simulink XCP protocol -> Virtual COM Port -> STLINK-V3E -> VCP LPUART1.

I can deploy the model itself successfully to the board (Simulink: Build&Deploy). The model just contains a pulse generator driving the user LED on the board, which works.

In the attachment, I have prepared the Simulink model, the *.ioc CubeMX project file and the output of the Simulink diagnostic viewer after running the "Monitor&Tune" mode.

The jumpers on the board are configured to use LPUART1 between the STLINK-V3E and the MCU (default):

LPUART1 (PA2/PA3) connected to STLINK-V3E Virtual COM port:

SB17, SB23: ON

SB18, SB22, SB12, SB20: OFF

USART1 (PC4/PC5) connected to ARDUINO® (D1 & D0) and ST morpho connector (CN10 pin 35 & 37).

SB13, SB19: ON

SB12, SB20, SB18, SB22: OFF

I followed an example from Mathworks called "Code Verification and Validation with PIL for STMicroelectronics STM32 Processors Based Boards" (unfortunately I'm not allowed to post links here).

I use following MATLAB related versions:

MATLAB 2022b

Embedded Coder Support Package for ARM Cortex-M Processors V22.2.0

Embedded Coder Support Package for STMicroelectronics STM32 Processors V22.2.1 (this supports the STM32G4xx)

I use following STM32 related versions:

STM32CubeMX V 6.4.0

STM32CubeProgrammer 2.6.0

STM32G4 firmware: STM32Cube_FW_G4_V1.5.1

Two more notes:

- I tried to modify the jumpers such that the USART interface is used instead of LPUART, which was also not working - the same error message arises.

- Also, I tried the same example on a Nucleo-F446RE using the normal USART interface, which works as expected using the "Monitor & Tune" mode.

Has anyone had this problem before? If so, I would be happy to hear his/her solution to the problem.

Also I'm about to measure the signals of the LPUART with a logic analyzer. I will post the results when I'm ready.

Thank you in advance!


In the meantime, I was able to measure the LPUART1 communication, while Simulink tries to connect to the board. At the same time I analyzed the USB commands using a serial port analyzer. The files are attached. The RX signal of LPUART1, I measured at SB23 and TX at SB17.

On the TX, I don't see anything. On the RX, I receive two data patterns followed by each other with a delay of 2s:

_legacyfs_online_stmicro_images_0693W00000bi1QBQAY.png If we look closer to one data pattern using the following serial interpretation settings

_legacyfs_online_stmicro_images_0693W00000bi1GbQAI.pngI get the following framing errors:

_legacyfs_online_stmicro_images_0693W00000bi1QpQAI.pngAs I have read, LPUART has low active signals, so if I change the configuration to "inverted" as follows,

_legacyfs_online_stmicro_images_0693W00000bi1R9QAI.pngthe framing errors disappear and 7 data words are being interpreted by the logic analyzer:

_legacyfs_online_stmicro_images_0693W00000bi1RYQAY.pngE.g. the first data word is 1111 1101. As it seems, the LSB is transmitted first, this translates to BF. Now, these are the two data sequences interpreted in the way described above:
_legacyfs_online_stmicro_images_0693W00000bi1SvQAI.pngWhen I look at the USB serial port analyzer, I see following write commands:

_legacyfs_online_stmicro_images_0693W00000bi1WOQAY.pngThe write commands shown in the picture, are the only write commands in the whole recording. The write commands marked yellow in the picture, are 2s apart from each other, so this makes sense when we look back at the LPUART measurements. However, I'm not able to figure out, how the data sequences seen on the USB, translate to those of the LPUART1.

First, what I don't understand is, that on the LPUART, I see 7 words, on the USB it seems to be 8. And second, the data itself - from my understanding - has no relation between USB and LPUART, or am I missing something?

Since I'm not an expert on serial communications, I would be happy to get some support!

Thanks in advance!

ST Employee

Hi All,

This question was routed to the online support center for direct support from our specialist team.



ST Support

Did u fix this problem as i have the same problem ?


Hi, was the problem fixed? I am trying to do this and have the same error with my f411 discovery board. Could you please support.