Skip to main content
Explorer II
November 20, 2024
Solved

STM32L496ZGT6PU STLINK UART communication not working

  • November 20, 2024
  • 3 replies
  • 1512 views

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.

    This topic has been closed for replies.
    Best answer by Andrew Neil

    @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

    3 replies

    Technical Moderator
    November 20, 2024
    Super User
    November 20, 2024

    @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:

     

     

    Technical Moderator
    November 20, 2024

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

    Thank you @Andrew Neil for pointing out to me.

    Super User
    November 20, 2024

    @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

    Technical Moderator
    November 20, 2024

    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