I am trying to establish communication between my host machine (running Ubuntu 22.04) and the STM32 Nucleo F401RE board. I only need to transmit data from the board to the host computer (only single direction). I have successfully achieved this via USART2 with the following function:
HAL_UART_Transmit(&huart2, (uint8_t*)test_buffer, s_test_buffer, HAL_MAX_DELAY);
However, when I try to do the same with USB_OTG_FS configuration, I receive no data on my host machine. I use the following function to transmit the data:
CDC_Transmit_FS((uint8_t*)test_buffer, s_test_buffer);
When I configure USB_OTG_FS, I can see that it uses pins PA11 and PA12 as USB_OTG_FS_DM and USB_OTG_FS_DP respectively. At the same time, USART2 is configured on PA2 and PA3 as USART_TX and USART_RX respectively. Since there is an embedded ST-Link on this board, I don't need to attach anything extra for receiving and transmitting data via UART, meaning I am able to receive data through the on-board USB port.
I also have an RS232 UART adapter for receiving and transmitting serial data. I have tried attaching the RX and TX pins to pins PA11 and PA12 as illustrated in the CubeMX screenshot, but still I do not receive any data.
My question is: How can I transmit data from the nucleo board to the host machine using the CDC (VPC) configuration?
Any help shall be greatly appreciated. Please let me know if you need more information for understanding the issue.
References:
Here is a screenshot of my CubeMX Pin Layout.
Here is a screenshot of USB_OTG_FS configuration.
Here is a screenshot of the USB_DEVICE configuration.