Skip to main content
Visitor II
April 1, 2021
Question

USB Host sesets with a device plugged in at power on.

  • April 1, 2021
  • 1 reply
  • 561 views

Hi,

I developing on stm32F4 and I having a problem with a USB Key Mass Storage Device.

I using the MX library host usb as is, stand alone without other procedures.

If I plug the usb key AFTER power on all is OK.

If I power on with the usb key plugged in, then a reset happens.

Debugging step by step I could see that then problem happens as soon as vbus start.

Some suggestion?

Thanks

    This topic has been closed for replies.

    1 reply

    LPode.1Author
    Visitor II
    April 2, 2021

    Hi everyone,

    I fixed it and I go posting the way I did.

    STM CUBE MX auto source look so:

    int main(void)

    ...

    MX_USB_HOST_Init();

    ...

    /* USER CODE */

    Then VBus will be set in mx_usb_host_init();

    I fixed my problem removing the VBus setting form the library, and moving it before in the program.

    This way:

    int main(void)

    ...

    MY_USB_VBusOn(); // (this is user procedure, not from library)

    ...

    MX_USB_HOST_Init();

    ...

    /* USER CODE */

    So all works now, both with usb key plugged at power and plugging it after power on.

    I not have a concrete understaning of what happen but I will see further.

    Maybe a short timings that crossing vbus and stack frame on strm32 go crashing.