0

I am using STM32F103C8T6 board and CubeMX to generate the code. I transmit the data via UART using the function HAL_UART_Transmit(). I configured the baud rate as 9600 in CubeMX and I chose the speed as 9600 in Putty also. Still I got some junk values only. How to sync up my data transmission?

Thanks in advance..

Vignesh
  • 55
  • 3
  • 12

3 Answers3

0

I tried the same and got it working. Please make sure all other transmission settings are the same and check your code. My Settings are: Mode: Asynchronous Hardware Flow Control: Disable Baud Rate: 9600 Word length: 8 Bits Parity: None Stop Bits: 1 Data Direction: Receive and Transmit Over Sampling: 16 Samples

It looks like this: STM32CubeMX parameters

In Putty make sure you have Speed: 9600; Data bits: 8 Stop bits: 1 Parity: None Flow control: None to match the settings! It looks like this:

PuTTY configuration

Lastely my code to send "Hello World" to the PuTTY console is:

char* msg2 = "Hello World\n\r";
HAL_StatusTypeDef status = HAL_UART_Transmit(&huart1, msg2, strlen(msg2), 100);

make sure to #include "string.h" to use strlen()

I hope this helps, make sure you don't miss something :)

0

USART1 -> BRR = USART_CLOCK / BAUD;

0___________
  • 60,014
  • 4
  • 34
  • 74
0

Did you connect the GND pin from the board to your UART adapter?

Because it should work if you did call the init fuction CubeMX generated. Your junk values seem more connected to that than the baudrate.

Tarick Welling
  • 3,119
  • 3
  • 19
  • 44