Skip to main content
FAuza.1
Associate II
October 7, 2022
Solved

Can't get to work the introductory tutorial on UART

  • October 7, 2022
  • 6 replies
  • 1992 views

I'm trying the tutorial on UART (https://wiki.st.com/stm32mcu/wiki/STM32StepByStep:Step3_Introduction_to_the_UART) with an STM32MP157F-DK2 board.

I tried defining the USART2 GPIOs with CubeMX as found in the reference document UM2637: DP5 - TX, PD6 - RX (I even tried alternate ports such as PA2, PA3). The generated code compiles well.

I then open a Putty connexion on COM19 (the ST Link port) with the required settings, but nothing is printed when I launch the debug.

What am I doing wrong?

This topic has been closed for replies.
Best answer by AScha.3

so you send Hello.. in loop. , ok.

Uart 115k/8n1 ok.

 + not Uart2 !

Correct port pins Uart4 to Tx ST Link Port: (seems pg11 on STM32MP157F-DK2 )

0693W00000UnbC7QAJ.png 

0693W00000UnbENQAZ.png

6 replies

AScha.3
Super User
October 7, 2022

What are you doing ? send char or string? correct port pins to ST Link port ? speed/mode setting?

"If you feel a post has answered your question, please click ""Accept as Solution""."
FAuza.1
FAuza.1Author
Associate II
October 7, 2022

Thanks for your answer.

The code is generated by CodeMX, I just added the following lines, as found in the tutorial:

while (1)
 {
 /* USER CODE END WHILE */
 
 /* USER CODE BEGIN 3 */
	 uint8_t Test[] = "Hello World !!!\r\n"; //Data to send
	 HAL_UART_Transmit(&huart2,Test,sizeof(Test),10);// Sending in normal mode
	 HAL_Delay(1000);
 }
 /* USER CODE END 3 */
}

 Speed / mode settings : also as shown in the tutorial. Is this what you mean?

0693W00000UnasbQAB.pngHere is what is inside the MX_USART2_UART_Init() function:

huart2.Instance = USART2;
 huart2.Init.BaudRate = 115200;
 huart2.Init.WordLength = UART_WORDLENGTH_8B;
 huart2.Init.StopBits = UART_STOPBITS_1;
 huart2.Init.Parity = UART_PARITY_NONE;
 huart2.Init.Mode = UART_MODE_TX_RX;
 huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
 huart2.Init.OverSampling = UART_OVERSAMPLING_16;
 huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
 huart2.Init.ClockPrescaler = UART_PRESCALER_DIV1;
 huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

 Correct port pins to ST Link Port: I honestly don't know what you mean here.

FAuza.1
FAuza.1Author
Associate II
October 7, 2022

Here is some more information:

0693W00000UnawEQAR.png0693W00000UnawOQAR.png0693W00000UnawTQAR.png0693W00000UnawdQAB.pngI hope it helps

AScha.3
AScha.3Best answer
Super User
October 7, 2022

so you send Hello.. in loop. , ok.

Uart 115k/8n1 ok.

 + not Uart2 !

Correct port pins Uart4 to Tx ST Link Port: (seems pg11 on STM32MP157F-DK2 )

0693W00000UnbC7QAJ.png 

0693W00000UnbENQAZ.png

"If you feel a post has answered your question, please click ""Accept as Solution""."
FAuza.1
FAuza.1Author
Associate II
October 7, 2022

Great! Thanks a lot, it works !

FAuza.1
FAuza.1Author
Associate II
October 7, 2022

... Maybe you can also help me here... :smiling_face_with_smiling_eyes:

https://community.st.com/s/question/0D53W00001qq9ddSAA/cant-blink-a-led-on-stm32mp157dk2