cancel
Showing results for 
Search instead for 
Did you mean: 

UART in STM32-L432KC

Abijith
Associate II

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.

9 REPLIES 9
Jacob WOODRUFF
ST Employee

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

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.

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.


@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

 

Please bear with me!

Yes, it's the nucleo 32 board. Also, by disconnect are you telling to remove the solder from the board?

Also, when I select the peripherals on STM32 Cube, it shows PA15 but on my L432KC itself there is no PA15. How do I interpret which is the RX and TX. TX is PA2 but the corresponding RX is PA3. Where does PA15 come in this picture?L432KC.PNG

Karl Yamashita
Lead III

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

 

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

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.

 

 


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


@Abijith wrote:

by disconnect are you telling to remove the solder from the board?


Yes.

You remove the blob of solder to break the electrical connection - ie, to "disconnect".

This photo shows two solder bridges (SB58 & 59) which are "disconnected":

AndrewNeil_2-1719226754966.png

Image credit: https://electronics.stackexchange.com/questions/402385/usefull-0402-and-0603-solderbridge-footprints-compatible-with-machine-manufactur 

 

Here's another one - J1, J2, and J4 are connected; J3 is disconnected:

AndrewNeil_4-1719226970483.png

Image credit: https://www.pcblibraries.com/forum/footprint-for-solderable-jumper_topic2089.html

#SolderBridge