cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L496ZGT6PU STLINK UART communication not working

RiccardoMilici
Associate

Goodmorning

I have a new STM32L496ZGT6PU board and I'm currently trying to print a message on the debugger serial terminal, I've followed many official guides step by step failing every time.

In particular, I perform the following:

  1. Connect the board through a USB type micro-B cable to my laptop (USB PWR connector).
  2. Create a new STM32 project, selecting the NUCLEO-L496ZG-P board from the board selector -> target language C++ -> initialize the peripherals with their default mode (YES).
  3. In Pinout & Configuration I go to Connectivity -> USART2 -> Mode Asynchronous and leave the default values.
  4. Device Configuration Tool Code Generation
  5. In Src/main.c simply write the following two lines of code in the main() function:

 

/* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
	  HAL_UART_Transmit(&huart2, (uint8_t*)"Ciao ", 6, 100);
	  HAL_Delay(1000);
  }
  /* USER CODE END 3 */

 

Then I build the project and start Debug keeping the default settings.

During the debug I create a new command shell console with

  • Connection Type: Serial Port
  • Serial port: COM6 (my PC seems to correctly recognize the STLINK on this COM port)
  • Baudrate: 115200
  • Data size: 8
  • Parity: none
  • Stop bits: 1

By clicking on "resume", the code seems to run, but nothing pops on the serial console.

 I tried to use an equal board, change the cable, and change USART interface but this didn't solve the problem.

1 ACCEPTED SOLUTION

Accepted Solutions

@RiccardoMilici wrote:

3. In Pinout & Configuration I go to Connectivity -> USART2 -> Mode Asynchronous and leave the default values.


User manual says it's LPUART1 connected to the VCP:

AndrewNeil_0-1732102274040.png

https://www.st.com/resource/en/user_manual/um2179-stm32-nucleo144-boards-mb1312-stmicroelectronics.pdf#page=26

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

View solution in original post

5 REPLIES 5
Imen.D
ST Employee

Hello @RiccardoMilici ,

Check your pins configuration and I recommend you follow these articles :

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

@RiccardoMilici wrote:

3. In Pinout & Configuration I go to Connectivity -> USART2 -> Mode Asynchronous and leave the default values.


User manual says it's LPUART1 connected to the VCP:

AndrewNeil_0-1732102274040.png

https://www.st.com/resource/en/user_manual/um2179-stm32-nucleo144-boards-mb1312-stmicroelectronics.pdf#page=26

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
mƎALLEm
ST Employee

Hello, 

Simply because USART2 is not connected to STLINK virtual comport on NUCLEO-L496ZG-P board.

Based on the board schematics, you need to use LPUART1 instead:

SofLit_0-1732103560137.png

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@Imen.D wrote:

Check your pins configuration and the USART2 alternate functions on which pins are mapped.


It's LPUART1 - not USART2

 


@Imen.D wrote:

I recommend you follow these articles :


Yes, but they should be done in the opposite order:

 

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

You are right, I didn't pay attention on the used board.

Thank you @Andrew Neil for pointing out to me.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen