cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103RBT6 UART is sending garbage data

Prasad Dait
Associate II
Posted on April 21, 2018 at 13:38

 I am Working on STM32F103RBT6 and need to implement UART in my Requirement. I tried Using UART1 and UART2 Both individually on my code to send character data  'Hi I am Working ' to the PC. But Every time UART is sending garbage data. I tried sending via different UART but both time the data received at PC End was garbage value. There was one thing constant and it is that the garbage value was constant it was not changing on both UART. But when I change Transmission data the garbage value changes to and it was still constant on both UART.

      I am using ST Standard HAL Library Functions and using CubeMx To generate code. The Zip file of Code is attached Below. IN this file I have initialized both the UART and sending data on one at a time.

   Thank You..

   If anyone have STM32F103RBT6 Nucleo board please verify the code given below and check whether the output obtained or not. The project is  true studio project.

https://community.st.com/tags♯/?tags=stm32f1%20uart

‌  

https://community.st.com/tags♯/?tags=stm32f103rbt6

‌ 

‌

#stm32f103rbt6_uart #stm32f103rbt6 #stm32f1-uart
10 REPLIES 10
Posted on April 21, 2018 at 17:10

The STM32 outputs CMOS levels, these aren't directly compatible with RS232 levels expected by a PC port, you'd need a MAX3232 type translator chip.

Perhaps you could diagram exactly how you have this wired up, and review signals with a scope.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist III
Posted on April 21, 2018 at 19:49

UART is sending garbage data

Or the PC is failing to recognise what the UART is sending?

The most common reason for seeing garbage data like this:

https://learn.sparkfun.com/tutorials/serial-communication

is that your baud rate is wrong.

So, as

Turvey.Clive.002

‌ said, what have you done to verify your baud rate?

Posted on April 21, 2018 at 19:33

I am using  USB to serial converter for this operation instead of RS232. And this converter is working properly. I have tried same operations on STM32F103C8T6 and it is working properly so this is surely not causing any problem to communication.

Posted on April 21, 2018 at 20:01

Initially I thought this is a baud rate issue but Device baud rate and Baud Rate set By PC is verified Twice and it was correct I have also checked stop bit, Parity and  Data length and crosschecked but it was still providing error value. I have checked the data received at MCU end on Attolic Truestudio and it was also receiving garbage value and sending one too.

Posted on April 21, 2018 at 20:40

But how did you verify it?

Posted on April 21, 2018 at 20:47

I checked settings of baud rate and stop bit and parity at both the end the system was working Fine when same code was run at STM32F103C8T6  but it was throwing garbage value at STM32F103RBT6

Posted on April 21, 2018 at 21:19

Send repetitive 'U' pattern and verify data and bit timing with a scope. Look to be using HSI so shouldn't have issues related to HSE_VALUE

USART1 PA9/PA10

USART2 PA2/PA3

Not familiar with the specific board or wiring being used, if you exhaust options with software look more closely at the hardware.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Brian D
Associate III
Posted on April 22, 2018 at 00:56

We're you sending hex or ascii bytes? Pc will not display hex correctly. Just try to send '1' char repeatedly and the scope should show 8bit number 0x31, and verify the bit rate also.

Posted on April 22, 2018 at 16:08

The OP attached source code, sending ASCII strings.

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