Skip to main content
MKele
Associate
July 8, 2019
Question

Problem with USB on STM32L412KBT

  • July 8, 2019
  • 6 replies
  • 1207 views

Hi, I have problem running USB on STM32L412KBT. The code hangs inside MX_USB_DEVICE_Init. Sometimes in function HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg) (file stm32l4xx_ll_usb.c), sometimes in function HAL_StatusTypeDef USB_DevConnect(USB_TypeDef *USBx) (the same file).

  • Using CubeMX 5.2.1, STM32Cube FW_L4 V1.14.0
  • Custom board, stable 3v3 power source with many filtering capacitors
  • Successfully upload code using USB DFU, so I think wiring is OK
  • Tried multiple CPU clock speed
  • Tried multiple USB clock source
  • Tried multiple USB class type CDC, HID, ...
  • When I comment MX_USB_DEVICE_Init all other peripherals seems to work correctly

Any help appreciated...

This topic has been closed for replies.

6 replies

Pavel A.
July 8, 2019

As a quick workaround, while waiting for more useful replies, try to disable interrupts around MX_USB_DEVICE_Init()

-- pa

MKele
MKeleAuthor
Associate
July 8, 2019

__disable_irq() did not help.

Strange thing is that it randomly hangs on different places.

One thing I forgot to mention is that I am using crystal-less USB, but I should be OK with this CPU. Is there anything special that I must setup or the CubeX generated code should be fine ?

Thanks....

Pavel A.
July 8, 2019

Next quick try while waiting for more useful replies: increase stack size,

MKele
MKeleAuthor
Associate
July 8, 2019

No luck with stack size...

MKele
MKeleAuthor
Associate
July 8, 2019

Yes... thank you...