2025-06-25 2:40 AM - last edited on 2025-06-25 2:57 AM by Andrew Neil
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.
2025-06-25 2:49 AM
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 ?
2025-06-25 2:53 AM - edited 2025-06-25 2:54 AM
@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:
via: https://www.st.com/en/evaluation-tools/nucleo-h7a3zi-q.html#documentation
2025-06-25 4:16 AM - last edited on 2025-06-25 4:25 AM by Andrew Neil
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.
2025-06-25 4:21 AM
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
2025-06-25 4:32 AM - edited 2025-06-25 4:32 AM
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.