Skip to main content
Visitor II
June 19, 2024
Question

UART in STM32-L432KC

  • June 19, 2024
  • 3 replies
  • 3328 views

This is regarding the UART1 and UART2.

 

1. I am trying to learn how UART works by communicating between STM32 and ESP32. I am able to send data from STM32 to ESP32 and it works. However, when I do the same from ESP32 to STM32, for some reason I cannot receive the incoming data. I have clearly checked the UART settings and it is the same for both the devices. What could be the possible problem here?

2. When I use UART1, data is being sent from STM32 to ESP32 but I cannot see it getting displayed on the STM32 IDE's serial monitor. However, data is visible from the ESP32 monitor which indicates UART is working. However, if I use UART2, the data is getting displayed on both monitors. I do not understand what is happening here.

 

Please advise me on these issues and refer me to the respective documents if needed. I am a new embedded engineer who is trying to use STM32.

    This topic has been closed for replies.

    3 replies

    ST Employee
    June 19, 2024

    Hi All,

     

    This post has been escalated to the ST Online Support Team for additional assistance. We'll contact you directly.

     

    Regards,

    Jake

    ST Support

    Super User
    June 19, 2024

    What board is this STM32 on?

    If it's on an ST Nucleo, Discovery, or EVAL board - perhaps you have the same problem as this:

    https://community.st.com/t5/stm32-mcus-boards-and-hardware/uart-not-receiving-data-when-sent-through-putty/td-p/687406

    You would need to disconnect the STM32's UART Rx from the VCP before you can connect it to your ESP32.

    AbijithAuthor
    Visitor II
    June 20, 2024

    The board is STM32-L432KC.

    Can you tell how I can disconnect the VCP? Upon seeing the board manual, I only see like a VCP attached to TX.

    Super User
    June 20, 2024

    @Abijith wrote:

    The board is STM32-L432KC.


    That's the part number of the chip - not the board.

    Did you mean NUCLEO-L432KC:

    https://www.st.com/en/evaluation-tools/nucleo-l432kc.html

     


    @Abijith wrote:

    Can you tell how I can disconnect the VCP? Upon seeing the board manual, I only see like a VCP attached to TX.


    If in doubt, check with the schematics - they're on the 'CAD Resources' tab of the Product Page:

    https://www.st.com/en/evaluation-tools/nucleo-l432kc.html#cad-resources

    But this seems clear:

    AndrewNeil_0-1718872699631.png

    So you need to disconnect (at least) SB3

     

    Graduate II
    June 21, 2024

    PA15 is used for the VCP so it's not routed to the connector pins.

    Don't mess with UART2 for the VCP. Use the VCP for debugging or to send data to the STM32 from Docklight

     

    Just enable UART1 for PA9 and PA10 which are the first two pins on the CN3 connector. Connect those pins to the ESP's UART pins. 

     

     

    See the attached project to help you get started. I am using the NUCLEO-L432KC for testing the code.

     

    I use Docklight to communicate through VCP (UART2) and pass the data to the ESP (UART1). 

    When receiving from ESP, you can pass it back to Docklight.

     

    This is VCP side

    KarlYamashita_0-1718942199120.png

     

    This is a second Docklight emulating an ESP32

    KarlYamashita_1-1718942257445.png

     

    AbijithAuthor
    Visitor II
    June 24, 2024

    Hi, thanks for the reply. I will try it and check if it works.

    Is it possible to receive data from Docklight to STM? I have been using HAL_UART_Receive and HAL_UART_Receive_IT but I am unable to get the data from docklight. Like you said UART2 is only for debugging and I tried to receive the data from UART1 and print using UART2 but it still fails.

     

     

    Super User
    June 24, 2024

    @Abijith wrote:

    Is it possible to receive data from Docklight to STM?


    Docklight is just another terminal program - like Hyperterminal, PuTTY, TeraTerm, etc - any of which can be used to communicate with any UART on any microcontroller.

     


    @Abijith wrote:

    Like you said UART2 is only for debugging


    That's not true - it can be used for any purpose where you want the data to go over the USB VCP.

     


    @Abijith wrote:

    I tried to receive the data from UART1 and print using UART2 but it still fails.


    For that to work requires both your UART2 code and your UART1 code to be working, and some "plumbing" in between the two.

    So take a few steps back: is anything being received by UART1? Use the debugger to check.