2020-12-07 03:41 PM
I have VBUS sensing enabled and when I step through the call to HAL_PWREx_EnableUSBVoltageDetector(), you'd expect a difference in the bit states in the
OTG_HS_GCCFG register but there is no difference whether the cable is plugged in or not.
I find it especially disconcerting that when the DCDEN bit is set, the DCDET bit is also set whether or not a USB cable is plugged in or not. This is supposed to tell me whether or not it see data lines connected. What am I missing. I want to use the VBUS sensing on PA9 to know if a USB cable is plugged in. What do I need to do?
2020-12-07 03:42 PM
NOTE: This is on an STM32H743VI part using the v1.80 HAL libraries
2020-12-07 03:59 PM
I don't use the 'H7 nor Cube/HAL, but on 'F4, GOTGCTL.BSVLD is controlled by the VBUS pin, if VBUS sensing is enabled by GCCFG.VBDEN (or by GCCFG.VBUSBSEN on older models - it's very thoughtful of ST to mess around with the signals and bits names, to keep the users alert and entertained).
JW
2020-12-11 02:20 PM
Can someone from ST please answer this question?
Is it possible to read the output of the VBUS sensing comparators?
How can firmware determine if a USB cable is plugged in when enabling the VBUS sensing on PA9?
2021-01-06 07:28 AM
Hi FStra.9,
The comment about BSVLD is correct (outside of the standard HAL). This is the direct way of knowing the current state of the VBUS detector (and yes as indicated it is dependent on VBDEN enable).
USB33DEN is a voltage regulator enable (specific to H7 in MCUs also similar in MP1), effectively it is not directly linked. It is needed to get the full power-up of the USB IPs.
For battery charging detection, there is in the HAL how to do the software contact detection after a fixed timeout (alternate method, since the direct DCDEN / DCDDET are not reliable).
Hope this is helpful.
Best Regards,
Ons.
2021-04-02 03:30 AM
Hi FStra.9,
Any updates ?
Best Regards,
Ons.