cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with USB on STM32L412KBT

MKele
Associate II

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...

6 REPLIES 6
Pavel A.
Evangelist III

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

-- pa

MKele
Associate II

__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.
Evangelist III

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

MKele
Associate II

No luck with stack size...

MKele
Associate II

Yes... thank you...