Skip to main content
Associate III
March 3, 2024
Question

UART not working

  • March 3, 2024
  • 3 replies
  • 2748 views

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 */

}

´´´

3 replies

Pavel A.
Super User
March 3, 2024

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

JS8Author
Associate III
March 3, 2024

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

TDK
Super User
March 3, 2024

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""."
JS8Author
Associate III
March 3, 2024

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

Tesla DeLorean
Guru
March 3, 2024

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 VenmoUp vote any posts that you find helpful, it shows what's working..
TDK
Super User
March 8, 2024
"If you feel a post has answered your question, please click ""Accept as Solution""."