Skip to main content
ABIZO.1
Associate II
August 3, 2023
Solved

USART2 problem

  • August 3, 2023
  • 1 reply
  • 1280 views

Hello,

I would like to ask a question, I'm usin a STM32F429I-DISC1 REV-E01 for a TouchGFX application. I want to send data by UART to my pc. I configure CubeMX (screenshot attached) and then, in my code, I write those lines for a test. But it does'nt work. In Tera Term, the port is disconnected and I receive nothing.

Can you help me ?

Regards

That is my Init USART function

 

static void MX_USART2_UART_Init(void)
{

 /* USER CODE BEGIN USART2_Init 0 */

 /* USER CODE END USART2_Init 0 */

 /* USER CODE BEGIN USART2_Init 1 */

 /* USER CODE END USART2_Init 1 */
 huart2.Instance = USART2;
 huart2.Init.BaudRate = 9600;
 huart2.Init.WordLength = UART_WORDLENGTH_8B;
 huart2.Init.StopBits = UART_STOPBITS_1;
 huart2.Init.Parity = UART_PARITY_NONE;
 huart2.Init.Mode = UART_MODE_TX;
 huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
 huart2.Init.OverSampling = UART_OVERSAMPLING_16;
 if (HAL_UART_Init(&huart2) != HAL_OK)
 {
 Error_Handler();
 }
 /* USER CODE BEGIN USART2_Init 2 */

 /* USER CODE END USART2_Init 2 */

}

 

 

That is my code, it is called every 2s.

 

extern UART_HandleTypeDef huart2;
extern const uint8_t test[];
extern int longueur;
/*
const uint8_t test[] = "Bonjour\n";
int longueur = strlen("Bonjour\n");
*/

HAL_UART_Transmit(&huart2, test, longueur, 10);

 

 

This topic has been closed for replies.
Best answer by TDK

How are the USART2 pins connected to the PC?

Note that the VCP is on USART1, not USART2.

TDK_0-1691052535944.png

 

1 reply

TDK
TDKBest answer
Super User
August 3, 2023

How are the USART2 pins connected to the PC?

Note that the VCP is on USART1, not USART2.

TDK_0-1691052535944.png

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
ABIZO.1
ABIZO.1Author
Associate II
August 3, 2023

Thank you for your answer,

PA2 is Tx and PD6 is Rx