Skip to main content
Visitor II
August 20, 2025
Solved

nucleo STM32G474RE UART communication

  • August 20, 2025
  • 1 reply
  • 516 views

Hello,

I just created a default project with the nucleo board template and with VCP initialized, how can I transmit data via UART using the VCP?

    This topic has been closed for replies.
    Best answer by mfgkw

    The VCP is simply one (LP)U(S)ARTx routed to the ST-Link, which in turn appears as an USB device at the PC.

    In case of your NUCLEO-STM32G474RE it is LPUART1 used for this by default. It can be changed to USART1 by changing solder bridges, see UM2505 chapter 6.6.5 "Virtual COM port (VCP): LPUART and USART".

    The prinf() function calls

     int _write( int file, char *ptr, int len );


    which must be implemented to transfer characters to the UART. If you need no other files and file handles the  function might ignore its first argument and print everything to the same UART.

    1 reply

    Super User
    August 20, 2025

    Use printf to send characters over the VCP once it's enabled by the BSP.

     

    printf("Hello world!\n");

     

     

    eneeAuthor
    Visitor II
    August 20, 2025

    Thank you for the answer, but I know that I can do it like this. I would like to learn more about the abstraction implemented by the BSP on the VCP over the redirection of printf.

    Super User
    August 20, 2025

    The source code is available for inspection. It's all in the project.