cancel
Showing results for 
Search instead for 
Did you mean: 

UART reception isssue

Nour
Associate III

Hello everyone,

I am working with a STM32WB5MMDK. I want to use the USART to print a message on Tera Term but i just have inversed triangles instead of "Hello world". I checked and both Tera Term and USART1 have the same parameters (baud rate, etc). I find it weird that i have a succession of triangles, and the other subjects related don't mention that.

Does anyone know how to fix this ?

Thank you

22 REPLIES 22
Andrew Neil
Evangelist III

@Nour wrote:

i just have inversed triangles instead of "Hello world".


The most common reason for seeing "junk characters" is wrong baud rate:

https://learn.sparkfun.com/tutorials/serial-communication/all#:~:text=If%20all%20the%20receiving%20device%20sees%20on%20its%20receive%20line%20is%20garbage%2C%20check%20to%20make%20sure%20the%20baud%20rates%20match%20up.

 

How did you verify that your STM32 is actually transmitting at the correct baud rate? The best way is to use an oscilloscope to check ...

 


@Nour wrote:

I find it weird that i have a succession of triangles, and the other subjects related don't mention that.


"junk" characters can take any form!

 

One think to note specifically with TeraTerm is that it can misinterpret "junk" characters as control codes, and so it ends up in some weird "graphics" mode - where it displays all received characters as strange glyphs ...

So it might be worth also checking some  other terminals ...

 

#JunkCharacters #WrongBaudRate #SerialComms

Nour
Associate III

Well, I just checked that the baud rate of Tera Term and for the UART were the same...

I wanted to start from the example given by STM32CubeIDE but their example doesn't work either.

So, I tried with HyperTerminal, and I get just 'H'. So, it seems to be cut ?

Since I got one letter, I don't know if it is the correct baud rate (it was 115200 bits/s, the one by default, i didn't change it, and same for the clock).


@Nour wrote:

Well, I just checked that the baud rate of Tera Term and for the UART were the same...


But, again, how did you check what the baud rate coming out of the UART actually was?

 


@Nour wrote:

So, I tried with HyperTerminal, and I get just 'H'.


So you got the first character of "Hello, world", then?

This suggests the the communication is actually working - but your code is getting "stuck" after the 1st character.

Use the debugger to investigate what's happening in your code ...

Nour
Associate III

I am a beginner so i don't know how to check the real baud rate :grinning_face_with_sweat:

I changed the sentence, and I have again strange characters so I think that the H wasn't really the first character (because it can't receive well 'u' for example). I, then, doubt that the communication is really working.


@Nour wrote:

I am a beginner so i don't know how to check the real baud rate :grinning_face_with_sweat:


Again, The best way is to use an oscilloscope to check ...

Get the UART transmitting just a continuous stream of uppercase 'U' to give you a steady waveform to look at.

Nour
Associate III

I will, but i have to then check the PINS of the USART1 on my board with the oscilloscope ? because i wasn't sure about where to check the right signal.

Yes, you need to look at the TX pin of your UART.

JJhin.1
Senior

Not selecting input crystal frequency properly, may affect baudrate and garbage data will get recevied or transmitted.

Nour
Associate III

Hello, so I used an oscilloscope and I've found 1428 bauds. But, when I put 1200 or 2400 (the closer baud rates) for my hyperterminal, it still doesn't work.

The input crystal frequency is in the .ioc ?

Thank you