cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 - USART1 & USART2 (USART2 non working)

SMusc.1
Associate III

 

 

Hello everyone, I am having a problem with a simple program. My board is a STM32-U575ZITxQ.
Using only the USART1 interface, if I try to print the string: "USART1_READY" on my laptop's serial port, I have no problem. However, as soon as I also enable the USART2, I cannot print anything. Whether with only the USART2 enabled, or with both USART1 and USART2 enabled, if I try to print the string with USART2, I cannot. I checked all the settings of the USART1 and USART2 and they are the same (in GPIO, in Parameter setting, etc.).

/* USER CODE BEGIN PV */
char USART1 = "USART1_READY:\r\n";
char USART2= "USART2_READY:\r\n";
/* USER CODE END PV */

/* USER CODE BEGIN 2 */
HAL_TIM_Base_Start_IT(&htim4);//ready for trigger at 1 seconds
/* USER CODE END 2 */

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
    if(htim->Instance == TIM4)
       {
      //HAL_UART_Transmit(&huart1, &USART1, sizeof(USART1),HAL_MAX_DELAY);
        HAL_UART_Transmit(&huart2, &USART2, sizeof(USART2),HAL_MAX_DELAY);
       }
}

where am I going wrong?

13 REPLIES 13

@SMusc.1 wrote:

 VCP is the com serial port of laptop right? 


"VCP" = Virtual COM Port - it is part of the ST-Link on the board:

AndrewNeil_0-1748524300307.png

AndrewNeil_1-1748524379674.png

https://www.st.com/resource/en/user_manual/um2861-stm32u5-nucleo144-board-mb1549-stmicroelectronics.pdf#page=10

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

AndrewNeil_2-1748524458278.png

 

 

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.

I am using a simple USB cable connected to USB port of my laptop tho the board. I see that the port com associate to this connection is any time COM4. How can i know which com port are used from USART2 and USART3 of my nucleo board?


@SMusc.1 wrote:

I am using a simple USB cable connected to USB port of my laptop tho the board. I see that the port com associate to this connection is any time COM4. 


That is the VCP of the ST-Link - see my previous post

 


@SMusc.1 wrote:

How can i know which com port are used from USART2 and USART3 of my nucleo board?


There is no other COM port.

If you want additional COM ports to connect to those UARTs, you will need to provide them yourself; eg, using  USB-to-UART adaptors or cables

AndrewNeil_0-1748524846952.jpeg

https://shop.pimoroni.com/products/cp2102-usb-to-serial-uart-with-usb-type-c-plug?variant=39428362207315

 

AndrewNeil_1-1748524885704.png

https://uk.rs-online.com/web/p/development-tool-accessories/6877770 

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.

okay clear, tks a lot to everyone