cancel
Showing results for 
Search instead for 
Did you mean: 

Can you help me to get the right UART data from my STM32´s?

SJank.3
Associate III

Hello, i get the wrong data from my UART connections. I try to transmit the data "HELLO WORLD\r\n" from my STM32 to my PC with a UART-USB adapter. Every cycle my LED blinks the transmitted signs are "…ýQa[gwëåÿÿÿÿÿÿÿÿ{FF}«" I tried STM32F103RBT6 and STM32L476RG. My USB adapter to RS232 is also working (i changed it too).

So i assume i forgot something in my code. But my code comes from the STM32CubeIDE , Baudrate is 9600(on STM32CubeIDE, windows driver for my RS232-USB adapter and on my data recieving programm).

Please help me to solve my five weeks Problem^^

1 ACCEPTED SOLUTION

Accepted Solutions
SJank.3
Associate III

Hi Tesla DeLorean,

thank you very much for your answer, yes i tested it with the "UUUUU" and that is received correctly, thx for your example too :)

Hi waclawek.jan,

thx for your answer, well i wasnt aware that the protocol is not RS232.

To solve the problem i used the Rx Tx connectors from my Nucleoboard-Debuger

Thx guys you helped me alot :)

View solution in original post

3 REPLIES 3

The primary answer would be "check the signal using oscilloscope/LA", and you probably answer "I don't have any", to which the answer is "get some, you'll make use of it now and later".

More questions.

What hardware? Is this some "known good" board like Nucleo or Disco? What is the primary clock source? Do you have it properly configured in CubeMX? What is the resulting baudrate divisor in UART_BRR? What exactly is "USB adapter to RS232"? Is it real RS232? Are you aware of the fact that UART as output from mcu is *not* RS232, and you'd need to add a transceiver IC?

JW

Need a basic USB to CMOS Serial adapter

Outputting CMOS levels, not RS232 ones,so basically you're reading the inverse of the signals you want to see.

Could send 0xAA pattern to see if you get 'U's

Watch also that sizeof() sends the whole buffer, including NULs, for strings use strlen()and let the compiler determine space required.

ie

void OutString(char *str)

{

HAL_UART_Transmit(&huart1, (uint8_t *)str, strlen(str), 1000);

}

OutString("HELLO WORLD\r\n");

OutString("\xAA\xAA\xAA\xAA");

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

Hi Tesla DeLorean,

thank you very much for your answer, yes i tested it with the "UUUUU" and that is received correctly, thx for your example too :)

Hi waclawek.jan,

thx for your answer, well i wasnt aware that the protocol is not RS232.

To solve the problem i used the Rx Tx connectors from my Nucleoboard-Debuger

Thx guys you helped me alot :)