cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with STM32L552 USB-VCP

GS1
Senior III

Is there anybody out there who got the USB running as VCP on a STM32L552 ?

We have problems to get the system running with USB attached to a PC via VCP. We used the MXCube release 5.6.1 and created a small project with USB VCP. The VDD-USB Pin is connected to 3.3V, the system boots, but USB is not detected on the PC side.

We have USB as VCP working on several other processors before (STM32F4, STM32F7, STM32H7) without any issues. But on L552 there must be something different which is not working when using the same firmware handling and hardware layout.

Any comments are very much appreciated.

14 REPLIES 14

Hi RDKS,

good to know for eventual future use. We always use HSE and therefore did not encounter the problem you described.

BR GS

Good evening,

It seems I just see the problem to use CDC class with a new project created with latest HAL Version 1.4.0.

In my previous project with identical hardware setup and HAL Version 1.2.0 I got USB CDC class working seemlessly. But in the new project I am stuck currently.

The HAL sets the USB connection to "Suspended".

As soon as the call to "USB_DevConnect" (in HAL_PCD_Start) is processed my PC tells me "USB Device can not be detected...".

Comparing the difference between the 2 version is actually not possible as too many changes have been done by ST.

Did you find a solution in your project meanwhile?

RDKS
Associate II

HAL 1.4.0 works for me.

I created a demo project here in case you are interested: https://github.com/tickelton/stm32l562_usb_cdc_demo

There are a couple of caveats, though:

  • I don't use Link Power Management, because I don't need it and it has caused problems for me before.
  • As I mentioned in a previous comment, there are issues with the default clock configuration.
  • There seems to be a bug in the code generation for usbd_cdc_if.c. I had to apply this patch to get it working:
--- a/USB_Device/App/usbd_cdc_if.c 2021-08-18 16:39:03.489377113 +0200
+++ b/USB_Device/App/usbd_cdc_if.c  2021-08-02 17:19:28.353500125 +0200
@@ -284,11 +284,15 @@
   uint8_t result = USBD_OK;
   /* USER CODE BEGIN 7 */
   USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData;
-  if (hcdc->TxState != 0){
-    return USBD_BUSY;
+  if (hcdc) {
+         if (hcdc->TxState != 0){
+               return USBD_BUSY;
+         }
+         USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len);
+         result = USBD_CDC_TransmitPacket(&hUsbDeviceFS);
+  } else {
+         result = USBD_BUSY;
   }
-  USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len);
-  result = USBD_CDC_TransmitPacket(&hUsbDeviceFS);
   /* USER CODE END 7 */
   return result;
 }

GS1
Senior III

Hello RDKS,

thank you very much for your post.

I copied your implementation just the same way - also had a look at alle GPIO inits etc., but still this does not get the USB to work. PC refuses to detect the device.

I also tried to create the project with version 6.2. and HAL 1.2.0 (which works with a former system), but this doesn't work either with the new board.

I guess the hardware development department has to check all lines again...

Thank you anyway!

Have a good evening. BR.

GS

GS1
Senior III

Ok, we found the reason:

There was a 10k resistor on the VDD_USB line, which had to be removed. This resistor was introduced in the new project due to a recommendation - but this was obviously a wrong one.

So now my USB port is working!