2021-04-26 07:57 AM
good afternoon, can you tell me, I have a board with two usb (micro and mini) through the mini connector I program, and through the micro I want to send data. I fiddled with the USB Vurtual COM port implementation, tried to send string data, but the data in the COM port was not displayed. Then I started looking for the problem.
As a result, I found that there are 2 bottlenecks:
2.
The virtual port in the device manager is displayed as STLink Virtual COM port. And here in the information the name will not coincide with what I asked in CubeMX. Those. only the virtual COM port for STLink is visible, and this is the mini usb input, and the micro usb is not displayed. have you encountered this?
Example of the project I send below.
2021-04-26 11:00 AM
Are you familiar with USB communication?
Do you know when to use VBUS Sensing?
What do you think of trying out one of the USB examples from the STM32 repository for the STM32L476GDISCOVERY and developing your application with it?
Good luck!
/Peter
2021-04-26 11:18 AM
Thanks for the answer, yes, I read that VBUS sensing is used when the power comes from the board itself and not from USB.
I tried an example from this library and it didn't work either.
/* Private functions ---------------------------------------------------------*/
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/* STM32L4xx HAL library initialization:
- Configure the Flash prefetch
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Set NVIC Group Priority to 4
- Low Level Initialization
*/
/* Initialize the HAL Library */
HAL_Init();
/* Configure the system clock to 80 MHz */
SystemClock_Config();
/* Enable Power Clock*/
__HAL_RCC_PWR_CLK_ENABLE();
/* Enable USB power on Pwrctrl CR2 register */
HAL_PWREx_EnableVddUSB();
/* Configure LED_GREEN and LED_RED */
BSP_LED_Init(LED_GREEN);
BSP_LED_Init(LED_RED);
/* Initialize Joystick */
if (BSP_JOY_Init(JOY_MODE_GPIO) == HAL_OK)
{
joyready = 1;
}
/* Configure Joystick select button for remote wakeup */
JOY_SEL_Init();
/* Init Device Library */
USBD_Init(&USBD_Device, &HID_Desc, 0);
/* Add Supported Class */
USBD_RegisterClass(&USBD_Device, USBD_HID_CLASS);
/* Start Device Process */
USBD_Start(&USBD_Device);
uint8_t num = 0;
/* Rune Applicatione (Interrupt mode) */
while (1)
{
USBD_CtlSendData(&USBD_Device,&num,1);
HAL_Delay(1000);
num++;
}
}
The main question:
I have an STLink Vurtual COM port displayed, that is, a virtual COM port from the USB MINI side.
the question is: I understand correctly that the same Vurtual COM port should be displayed on the USB micro side and then there should be 2 virtual ports? but my second one is not displayed.
I am enclosing an example.
I found a video that displayed 2 virtual ports, but 2 are not displayed for me.
https://www.youtube.com/watch?v=7oED-m34EKk
/Dmitriy
2021-04-26 12:15 PM
No, the virtual COM port is currently only routed via the debugger USB port, i.e. the one with Mini USB connector. In fact it is one of the physical UARTs of the STM32L476 connected to the STM32 acting as debugger.
You will need to insert a USB CDC to emulate a VCP directly from the target (STM32L476) if you need a 2nd virtual COM port via its USB port. This is what the guy in the video did.
Good luck! У�?пехов!
/Peter
2021-04-27 05:17 AM
thanks for the answer, could you please suggest how you can insert a USB CDC to emulate a VCP directly from the target (STM32L476)?
Or throw off the link to the instructions for it?
/Dmitriy
2021-04-27 05:49 AM
You will find examples in the repository for STM32L4, e.g. for the STM32L476G-EVAL or the 32L496GDISCOVERY, each in Applications > USB_Device> CDC_Standalone. You only have to adapt them to the settings required for your board.
Regards
/Peter