2020-11-18 09:59 AM
Hi everyone,
We are facing issues with USB in our new products due to EMC (electromagnetic compatibility). IEC61000-4-4 burst, mediuum severity.
The USB stops working fequently when the device is connected to a PC and a burst is applied to the AC power line, which is near the equipment (less than 1mm). Oir equipment power source is supplid by the PC USB PORT.
To restart the communication we have to switch off, disconnect the USB cable and turn the equipment on again.
We have improved the situation by using twisted pair cable, clamp ferrites, capacitors in power line, shielded cable, etc. but when the severity of the burst is increased it happens again.
Due to certification purposes, we can not change the system otherwise we would not get approved. NOte the the microcontroller (STM32L4) works all the time.
Does anyone knows how to reset the USB Device to reestablish the connection automatically without the need to unplug the cable?
Thanks you for any tips.
2020-11-18 12:35 PM
Which L4?
Both the device-only USB in lower-end 'L4, and the OTG in upper-end, incorporate the DP pullup on-chip. In the former case, it's controlled by USB_BCDR.DPPU, in latter by OTG_DCTL.SDIS.
You of course need also to restart the whole software stack.
There is probably some Deinit/Init couple of Cube incantations which would achieve the same effect, indirectly; see UM1734. I don't use Cube.
JW
2020-11-18 02:17 PM
You can use this to reset the USB peripheral to default:
__HAL_RCC_USB_OTG_FS_FORCE_RESET();
__HAL_RCC_USB_OTG_FS_RELEASE_RESET();
You'll need to reinitialize it as if the program was starting over.