cancel
Showing results for 
Search instead for 
Did you mean: 

UART not working

JS8
Senior

I have an STM32WB55CGU6 on a custom board with a 32MHz HSE. I'm using low power uart1 with PA2 & PA3 pins. My settings for it are: 

- baud rate 9600

- word length 8 bits

- 1  stop bit

- parity none

It won't transmit. Cube doesn't receive it, any terminal doesn't receive it and the pins just remain low all the time. When I tried adding an if clause to test if the result is HAL_OK, the code wouldn't even upload. What's up here, shouldn't be this hard getting basic UART to work.

code:

 

uint8_t text[]={0,1,2,3,4,5,6,7,8,9};

 

/* USER CODE END 2 */

 

/* Infinite loop */

/* USER CODE BEGIN WHILE */

while (1)

{

 

HAL_UART_Transmit(&hlpuart1, text, 10, 100);

HAL_Delay(500);

 

/* USER CODE END WHILE */

 

/* USER CODE BEGIN 3 */

}

´´´

9 REPLIES 9
Pavel A.
Evangelist III

But this is a custom board. All bets are off. Have you tried this on a well known ST evaluation board?

TDK
Guru

Verify PA2/PA3 are connected to what you think they're connected to by setting them as GPIO outputs and toggling.

> When I tried adding an if clause to test if the result is HAL_OK, the code wouldn't even upload.

Probably have other things going on here. The upload process doesn't care what the code being uploaded is. In what way wouldn't it upload? What happened when you tried?

If you feel a post has answered your question, please click "Accept as Solution".

It either says 'target not found' or 'no device on target' and 'couldn't open STM32_Programmer_CLI.exe'. If I remove the if clause the error goes away. Makes no sense but somewhy it still happens. Thanks for your reply

No. To my knowledge a simple UART connection does not need an entire evaluation board to get working.

Correct, but it allows for the code to be tested on a known platform. 

You're sending non-printable characters, perhaps send something you can read. Perhaps send U 0x55 characters and scope the signals.

Not clear on your circuit or serial connectivity.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

No connection suggests that the debug interface is also being disabled, PA13/PA14, or the chip is going to a low-power mode

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

The reason there is no UART traffic visible is because the UART pins on my ST-LINK/V2 are connected to GND. Do I need to activate the UART interface somewhere?

The ST-LINK/V2 doesn't have a working VCP. The UART_TX/RX was a future development and as far as I know, was never implemented.

You can upgrade to a ST-LINK-V3 or use a generic USB<>TTL adapter.

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.
TDK
Guru

This was reposted and answered here:

https://community.st.com/t5/stm32-mcus-products/st-link-v2-lpuart-connection/td-p/647622

 

If you feel a post has answered your question, please click "Accept as Solution".