cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 USB self powered device / VBUS handling

MFuch.3
Associate II

I am setting up a STM32G4 based USB self powered device with CubeMX. The CDC/ACM stack nearly runs fine. How shall I implement VBUS handling? The part has no dedicated VBUS pin. So some app notes suggest to connect VBUS to a GPIO-extInt or ADC and implement the VBUS handling from application code. But what needs to be called on VBUS change by application? I did not find an example for an application based VBUS handling.

1 REPLY 1
TDK
Guru

Use any GPIO pin to monitor VBUS. When it's present, initialize the USB, when it goes away, deinitialize the USB.

The USB standard requires that you do not energize the data lines unless VBUS is present, hence the need to monitor VBUS unless your device is strictly powered through it.

If you feel a post has answered your question, please click "Accept as Solution".