cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L432-KC Not possible to receive data from the computer using USART

rtr
Associate

Hi all,

I am trying to use the virtual COM port in the STM32L432KC Nucleo to send and receive data from the PC using UART. I have managed to transmit data to the computer succesfully but when I try to receive data, then it doesn't work. I am trying with a simple program and I have used STM32CubeMX to generate the code. I have set it as follows:

  • USART2 (baud rate 115200)
  • Enabled USART2 global interrupt
  • USART2_RX and USART2_TX added (Circular mode, Increment Address Memory)

The code is the following:

  HAL_UART_Receive_DMA(&huart2, rxData, 11);
 
  while (1)
  {
    HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_3);
    HAL_Delay(200);
  }

And in the Rx complete callback function I am transmiting the data received:

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
  HAL_UART_Transmit(&huart2, rxData, 11, 10);
}

I have executed it in debug mode and watched the rx buffer but it doesn't receive anything.

4 REPLIES 4
AvaTar
Lead

> I have executed it in debug mode and watched the rx buffer but it doesn't receive anything.

Digging deeper ?

Is the PC side properly configured/set up ?

Do you see any transmission on the RX pin ? Use a scope to check the lines.

For the VCP from the ST-Link, normal digital level is sufficient.

AFAIK, UART2 is not the VCP link, so you need RS232 level shifters.

Imen.D
ST Employee

Hello,

Check if you have set the correct system clock and other UART paremeters (wordlength, parity and HwFlowCtl...).

To give you a better help, you can share your ioc file or post some screenshots of the CubeMX configuration to check it.

I recommend you also, to check one of the UART examples available in the STM32CubeL4 firmware package to identify what you have missed.

Examples path: STM32Cube_FW_L4_V1.13.0\Projects\NUCLEO-L432KC\Examples\UART

Kind Regards,

Imen.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
AvaTar
Lead

If there are no incoming data on the RX pin, any action of your firmware is of no avail.

Once you confirmed proper input, start checking your firmware, and debugging.

I have attached the .ioc file. The UART parameters are the same as in the examples of STM32CubeL4 except from the baud rate (in the examples is 9600), so if you could take a look and see if I am missing something it would be great. The other thing is that I thought that I could do this with the microUSB only, is this true or I need RS232?