0

I am following this tutorial on how to use the USART port on a STM32 board.

https://www.youtube.com/watch?v=d6MZHdgCQx0

The tutorial says to do the following:

  • Clear all pins
  • Select your USART pins Tx and Rx

Then make the setting below.

enter image description here

enter image description here

The problem I am having is when I'm receiving the serial data on my PC my terminal program is saying it's getting a frame error and all the data is messed up.

This is the code I am using to send:

uint8_t myTx[13] = "Hello Wolrd\r\n";
HAL_UART_Transmit(&huart2, myTx, 13, 10);
    HAL_Delay(1000);

I have checked and the baud rates are all set to 9600.

I don't know what I am doing wrong.

I am using a slightly different board than he is using in the video: mine is a NUCLEO-L031K6

https://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-mpu-eval-tools/stm32-mcu-mpu-eval-tools/stm32-nucleo-boards/nucleo-l031k6.html

Edit

Logic analyser output:

I have plugged it into a logic analyser and it seems to check out.

enter image description here

Any clues as to why it would show garbage in a terminal program?

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
James Morrish
  • 455
  • 6
  • 24
  • Aside from baud rate, make sure that parity, stop bits and number of data bits also match. – J_S Mar 16 '19 at 19:15
  • hi @JacekŚlimok, i have also made sure they are all the same, I have tried changing my terminal program to try all different baud rates and its still scrambled data. I think i need a scope to figure out what is happening – James Morrish Mar 17 '19 at 10:05
  • It's probably going to be the fastest way. Even the simplest logic analyzer should do the trick. – J_S Mar 17 '19 at 10:06
  • @JacekŚlimok could you recommend one? – James Morrish Mar 17 '19 at 10:11
  • For this kind of purposes - anything you can get your hands on / whatever you can afford. – J_S Mar 17 '19 at 20:43
  • @JacekŚlimok i have edited my question with a logic analyser output. – James Morrish Mar 18 '19 at 13:42
  • The logic analyzer seems to show 10 bits per characters. So it must be something like 8 bits plus parity plus stop bit. – Codo Dec 10 '19 at 21:45

0 Answers0