cancel
Showing results for 
Search instead for 
Did you mean: 

MX_USB_DEVICE_Init() : VDDUSB presence not checked before removing power isolation

OE1
Associate II

Hi,

I'm using CubeIDE 1.4.2 with CubeMX 6.0.1-RC3 and target is STM32L452.

This problem only occured with VDDUSB independent from VDD.

I had problems with USB FS device initialization (using CDC class but I guess it applies to other classes as well).

The problem was that after boot, when calling MX_USB_DEVICE_Init() with VDDUSB not present (usb not plugged in), the program was endlessly interrupted and stuck in USB_IRQHandler(), after calling USB_DevInit() in HAL_PCD_Init() in the file stm32l4xx_hal_pcd.c.

The problem never occured when VDDUSB was present (usb plugged in).

Here's the call hierachy :

0693W000003Qp2gQAC.png

Reading the Reference Manual RM0394, it's mentioned page 137 : 0693W000003Qp6EQAS.png

As specified in the title, MX_USB_DEVICE_Init() never follows this sequence before removing the power isolation by setting the USV bit in PWR_CR2 by calling HAL_PWREx_EnableVddUSB(). The PVMO1 bit is never checked, which surely caused problems in further USBD initialization.

Call hierachy :

0693W000003Qp9DQAS.png

Checking if VDDUSB is present before calling MX_USB_DEVICE_Init() solved the thing.

Hope it can help someone.

(and maybe the check could be added in next version of CubeMX FW_L4 Package?

I'm using V1.15.1 here but I checked and it's still the same in V1.16.0)

Regards,

OE

2 REPLIES 2

Hello @OE​ 

Thank your for your post. We need a step by step scenario to be able to understand and reproduce your issue.

Can you please give us the exact scenario and the ioc file or the all zipped project to try reproduce what you are seeing?

Best regards,

Nesrine

OE1
Associate II

Hi, thanks for the reply,

I detailed (maybe too much) everything in the original post, but I'll try to be clearer and more concise here (though I thought the title was summing it up quite efficiently)...

The problem's symptoms :

  • This problem needs the STM32 powered with VDDUSB independent from VDD, and VDDUSB either floating or grounded.
  • Use USB Device FS in CubeMX
  • When running the code generated by the joined ioc file : the execution is stuck because it's endlessly interrupted by USB_IRQHandler() after reaching a specific step in MX_USB_DEVICE_Init() (specific step which is detailed in the 1st call hierarchy screenshot of the original post).

The problem's source :

  • the VDDUSB power isolation is removed (2nd call hierarchy screenshot in original post) without checking if VDDUSB is set or not (as it should be as specified in the Reference Manual RM0394 page 137, once again screenshot provided in original post).

The question : was this check omitted intentionally by the team managing MX generated code? :

  • if no, then maybe it would be nice to add this check in the next firmware package version
  • if yes, then not checking it was my responsibility, and then everything's all right, and I hope this post will help some people who would have the same problem

Regards,

OE