cancel
Showing results for 
Search instead for 
Did you mean: 

NUCLEO-H7A3ZI-Q USART2 not communicating with serial console

KRISH_
Associate II

Originally a comment on this tutorial  - moved to main forum for better visibility & discussion ...


I followed the first part of the tutorial (enabled USART2) and included the following code snippets for my STM32 NUCLEO-H7A3ZI-Q board.

 
/* USER CODE BEGIN PV */
uint8_t buffer[1];
/* USER CODE END PV */
  /* USER CODE BEGIN 2 */
  HAL_UART_Receive(&huart2, buffer, 1, 0xFFFF);
  HAL_UART_Transmit(&huart2, buffer, 1, 0xFFFF);
  /* USER CODE END 2 */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
	HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
	HAL_Delay(100);

    /* USER CODE END WHILE */

 But I wasn't able to write any characters or anything on my serial console. Kindly give some suggestions.

5 REPLIES 5
Andrew Neil
Super User

Please show the full code.

 

  HAL_UART_Receive(&huart2, buffer, 1, 0xFFFF);
  HAL_UART_Transmit(&huart2, buffer, 1, 0xFFFF);

You should check the return values from the calls; eg, what if the Receive just times out without receiving anything?

 


@KRISH_ wrote:

 But I wasn't able to write any characters or anything on my serial console. .


What serial console are you using?

How is it connected to USART2 of your STM32 ?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

@Andrew Neil wrote:

How is it connected to USART2 of your STM32 ?


@KRISH_  If you're expecting to use the Virtual COM Port (VCP) in the ST-Link, that is connected to USART3 - not USART2:

AndrewNeil_1-1750845262372.png

 

https://www.st.com/resource/en/user_manual/um2408-stm32h7-nucleo144-boards-mb1363-stmicroelectronics.pdf#page=29

via: https://www.st.com/en/evaluation-tools/nucleo-h7a3zi-q.html#documentation

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
KRISH_
Associate II

Merged - please keep the discussion in one place.


I checked the User manual, it said USART3 .But still I wasn't able to enter anything in the serial console.1.png2.png

KRISH_
Associate II

You're right. I tried with 

 

USART3, and I am still unable to enter anything in the serial console.

/* USER CODE BEGIN PV */
uint8_t buffer[1];
/* USER CODE END PV */

  

  /* USER CODE BEGIN 2 */
  HAL_UART_Receive(&huart3, buffer, 1, 0xFFFF);
  HAL_UART_Transmit(&huart3, buffer, 1, 0xFFFF);
  /* USER CODE END 2 */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
	HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
	HAL_Delay(100);

    /* USER CODE END WHILE */

The LED1 blinks 

So you are trying to go via the ST-Link's VCP, then?

Were you misled by the tutorial into using UART2?

 


@KRISH_ wrote:

I am still unable to enter anything in the serial console. 


How are you testing that?

Are you sure that your board hasn't been reconfigured?

Are you using the correct pins?

Are you sure your console is connected to the correct COM port?

Can you just send from the STM32 to the console?

Again, please show the complete code.

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.