cancel
Showing results for 
Search instead for 
Did you mean: 

Can't get to work the introductory tutorial on UART

FAuza.1
Associate III

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?

1 ACCEPTED SOLUTION

Accepted Solutions
AScha.3
Chief II

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".

View solution in original post

6 REPLIES 6
AScha.3
Chief II

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
Associate III

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
Associate III

Here is some more information:

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

AScha.3
Chief II

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
Associate III

Great! Thanks a lot, it works !

FAuza.1
Associate III