2018-08-01 05:47 AM
Hi.
I'm currently trying to develop a simple USB (CDC) application with an STM32 MCU that is configured using CubeMX. So far I have managed to make the device send some text message to my host machine which is displayed using a serial terminal program. But, I have noticed, that after programming new firmware to the target, I must physically disconnect and connect my board in order to reestablish the connection. I was wondering if there was a better way to do this ?
Best Regards,
abaldur
2018-08-01 11:33 AM
Disable the USB controller and wait several seconds, this works for me with MCUs that have internal resistor on USB data lines.
-- pa
2018-08-01 12:41 PM
Hi Pavel.
Thank you for the answer. Can you be specific about how you disable the USB controller?
Will USBD_DeInit() be sufficient?
Best Regards,
abaldur
2018-08-01 02:15 PM
Yes, USBD_Deinit should call the right USB driver function (thru several layers added by CubeMX )
Note that the correct behavior depends also on the host side. When the USB device disappears, the host application should immediately close its handle or whatever. Otherwise re-enumeration can fail or create duplicate zombie device.
-- pa