Skip to main content
Associate
Oct 24, 2026 1:58 PM UTC
Question

Problem with USART2 on NUCLEO-G070RB

Hi, I'm trying to get USART2 on my G070RB operational. When connected in loopback it doesnt recieve the sent message. When connected to computer Putty terminal doesnt recieve anything from board and vice versa. Both fuctions for rx and tx return HAL_OK.

9 replies

AScha.3
Super User
Oct 25, 2026 10:09 AM UTC

Hi,

what board ? nucleo or …?

+

clock on HSE ?

Can you show circuit ?

If you feel a post has answered your question, please click on " Best Answer ".
rich.g.williams
Senior
Oct 25, 2026 1:43 PM UTC

 

​@AScha.3   Title says NUCLEO-G070RB

 

​@Darneak   Have you selected USART2 and done the pin configuration on STM32CubeMX (Pin Configuration diagram etc).

How about the schematic for NUCLEO-G070RB does it confirm that the pins you selected are not used for other tasks, also if they are can you configure alternate pins for USART2.

Does USART2 have Peripheral Clock and Kernel Clock enabled, check the Clock Configuration diagram on STM32CubeMX.

Bill's Notes
DarneakAuthor
Associate
Oct 25, 2026 1:59 PM UTC

Yes, I have configured USART2 in STM32CUbeMX.

I have checked the schematic and the pins are not used for other tasks then USART, and does not have any alternate pins.

It does have the clock enabled, with frequency of 16 MHz.

rich.g.williams
Senior
Oct 25, 2026 2:33 PM UTC

USART2 needs a Baud Clock (Kernel Clock)  The peripheral clock makes the logic work, the Baud Clock sets the USART’s Baud rate.  

Also USART2 has control signals RX, TX,CTS, RTS if hardware handshaking is enabled they need connecting appropriately - best is to make sure no handshaking is enabled, USART has a few control status registers too many for me to look through at the moment (it doubles as async and synchronous (SPI like operation) but all registers must be set up properly.

if you have a scope easiest way forward is to work first on TX only looking at TX output pin. 

Check your code in STM32CubeIDE and if you are using HAL functions expand each to see what’s happening. Also you can study RM0454   26.8   USART registers on page 827 go through the config status registers.  

Also suggest you look for an ST example app that uses USART  note also that USART2 is an alternate for USART1 

As a last resort you could get some help from using USART2 as bootloader see AN2606 :-


STM32G07xxx/08xxx device bootloader 48.1  Bootloader configuration


The STM32G07xxx/G08xxx bootloader is activated by applying Pattern 11 (described in
Table 2).
Table 107 shows the hardware resources used by this bootloader.
When using Pattern 11, consider that STM32G070xx devices do not have
BOOT_LOCK(bit).

 

USART2
Enabled
Once initialized, the configuration is 8-bit, even
parity, and one stop bit
USART2_RX pin
Input
PA3 pin: USART2 in reception mode. Used in
alternate push-pull, pull-up mode.
USART2_TX pin
Output
PA2 pin: USART2 in transmission mode. Used in
alternate push-pull, pull-up mode.

PA2 will float as you enter bootloader then if you send the correct character on PA3 PA2 will reply with 1 char and go high.  

The initial char and the bootloader protocol are all explained in  AN2606  and AN3155.

Hope that helps

Bill's Notes
AScha.3
Super User
Oct 25, 2026 4:27 PM UTC

Hi,

sorry - didnt look at the title again…. but now, on nucleo:

  1. You use uart2 - funny , but THIS IS used on the nucleo board.
  2. You didnt setup  clock tree, etc. --- why ?
  3. Your program seems ...useless. What you wanna see with uart loopback without output ? uart is on chip ?
  4. Why not test the cpu add +1 ? Maybe it cannot…?
  5. So just send something on uart2 and see in in modem/terminal prog. , to check it is working - ok ?
  6. need a basic useful chip setup...i made it, see attached.
  7. mco is set to 64/8 = 8 MHz , to check internal cpu clock
  8. If you want test uart loopback, set JP6 ; but if st-link still active , it will drive the rx also, that might not work.
  9. so dont put JP6 , remove short rx--tx .
  10. uart speed set to 115200, 8n1; so use this setting in terminal on PC also.
  11. Which is the VCP from st-link, just check in PC system/hardware.
  12. The “standard” uart check would be: in your program, just send a received char back, so you see the nucleo “echo” the characters you type on the PC.

see the circuit: https://www.st.com/resource/en/schematic_pack/mb1360-g070rb-c02_schematic.pdf

uart2 --- > st-link rx/tx

 

 

If you feel a post has answered your question, please click on " Best Answer ".
DarneakAuthor
Associate
Oct 25, 2026 9:46 PM UTC

The reason why the program was so barebones, was beacause I was watching if the interrupt from recieving would ever trigger (it did not), and if transmitting didnt throw any error.

Anyway, using the setup you provided I wrote a simple echo program and tested it with a putty terminal(after removing the short). HAL_UART_Receive(&huart2, &rx, 1, HAL_MAX_DELAY) == HAL_OK never triggered. Afterwards I changed it to only HAL_UART_Transmit(&huart2, &rx, 1, HAL_MAX_DELAY) where rx was incrementing unit8, and there was a delay of 1s between each transmition. Putty again recieved nothing. And yes, I am 100% sure that I am connecting putty to the right port with the right settings.

AScha.3
Super User
Oct 25, 2026 10:28 PM UTC

> And yes, I am 100% sure that I am connecting putty to the right port with the right settings.

Ok, so check with a scope on tx (PA2) , the byte coming out , if running > HAL_UART_Transmit(&huart2, “U”, 1, 0xFF) <  in a loop.

And check speed, about 9 us pulse/pause  (115200 kbit).

+

Also check signal on rx (PA3) , when typing ‘U’ in putty/terminal .

 

Then we know : signals are there, so just software/settings not ok, or signal not there at all.

If you feel a post has answered your question, please click on " Best Answer ".
Karl Yamashita
Super User
Oct 30, 2026 9:13 PM UTC

Your transmit buffer is 19 bytes, but your receive is configured to wait for 20 bytes. As a result, the receive interrupt will never trigger during your loop test because the expected 20 bytes are never received. The interrupt will only occur after the test times out, execution returns to the main while loop, and another transmission sends at least one additional byte to complete the 20-byte receive.

Also, USART2 is connected to the ST-Link Virtual COM Port (VCP). If you're using a jumper across the two-pin header to loop TX back to RX, you have a hardware contention issue. The ST-Link TX pin is configured as push-pull, so when the STM32G070 TX pin drives low while the ST-Link TX pin drives high, the two outputs are fighting each other. This effectively creates a short between 3.3 V and ground through the output drivers, potentially damaging the hardware.

For a proper UART loopback test, use USART1 instead. You can safely connect PC4 and PC5 together for the TX/RX loopback test without interference from the ST-Link.

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source