2019-01-29 01:49 AM
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:
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.
2019-01-29 04:42 AM
> 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.
2019-01-29 05:17 AM
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.
2019-01-29 06:15 AM
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.
2019-01-29 08:05 AM
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?