USB connection problems with STM32F7
Hello,
In one of our products we've moved from a PIC32 to a STM32F7. The product is self powered and has a USB connection (USB-Device Full-Speed, HID).
Everything works as expected normally. Sometimes however, when I plug in the USB cable, I get an error on Windows "USB device not recognized" and the connection will not work. When this happened once, the USB will not work anymore even if I reconnect the device again. It does also not help when using another USB port on the PC or even connect the device to another PC. The only thing that helps is resetting our device.
I have added some loggings inside the usbd_core.c file. When unplugging the cable, USBD_LL_Suspend will get called once. When Inserting the USB cable, I see multiple USBD_LL_Resume / USBD_LL_Suspend (about 3 each most of the time). When the device is in the "error mode" I get a ton of USBD_LL_Resume when plugging in the cable until the windows message that the device is not recognized appears.
To reproduce this error easily, I've cut a USB extension cable in half and wired all cables through relays so I can connect/disconnect each cable separately. I've created a simple on/off program that switches all the relays at the same time on/off for some time (0.5 - 2s). I can run this program for hours without any issue, USB on our product will always work and I get exactly one USBD_LL_Resume and one USBD_LL_Suspend each on/off cycle. I've then changed my test device program to randomly connect/disconnect cables before the on/off cycle very fast. When I do this random connect/disconnect for about 10 seconds before the on/off cycle I'll get the connection error after one cycle most of the times. I did the same test with our old PIC32 device and it works without problems.
To ensure that there is no problem with our hardware/software, I took a NUCLEO-F767ZI board and loaded the demo "Ux_Device_HID" (simulates a mouse). When running my test, the same happens here.
