Skip to main content
rtr
Associate
January 29, 2019
Question

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

  • January 29, 2019
  • 4 replies
  • 1418 views

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.

This topic has been closed for replies.

4 replies

AvaTar
Senior III
January 29, 2019

> 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.

ST Technical Moderator
January 29, 2019

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.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
rtr
rtrAuthor
Associate
January 29, 2019

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?

AvaTar
Senior III
January 29, 2019

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.