cancel
Showing results for 
Search instead for 
Did you mean: 

I am using STM32L476G-DISCO board with dual usb (micro and mini). through mini I program, and through micro I want to send data. There was a problem with micro usb transfer.

DOgur.1
Associate II

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:

  1. It's not clear if VBUS Sensing needs to be turned on. I tried both with and without it, all the same, the data is not transmitted. But judging by the description, you need to turn off VBUS.

0693W00000AMXxtQAH.png 

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?

 0693W00000AMXyDQAX.png0693W00000AMXxjQAH.pngExample of the project I send below.

5 REPLIES 5
Peter BENSCH
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
DOgur.1
Associate II

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

0693W00000AMZNJQA5.png/Dmitriy

Peter BENSCH
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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

Peter BENSCH
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.