kender
Advanced Member level 4
I've got a is self-powered USB device, which means that I have to do VBUS detection. The device is built around STM32G474. Unlike some other STM32s, the STM32G4 don't have a dedicated pin for VBUS detection, so I have to do it through a GPIO pin and firmware. VBUS is connected to the GPIO pin PA10 through a 2x 100kΩ divider. What should be done in firmware for VBUS detection through a GPIO pin?
I checked the code examples for STM32G4s, but I couldn’t find examples for USB. If somebody could point me to a code example, that would be great.
I’ve read this knowledgebase article on VBUS detection which is a collection of excerpts from AN4879 (and I’ve read the app note too).
Does the VBUS detection have to be done in an interrupt? Or can it be done in the main loop? If it can be done in the main loop, then are there timing constraints?
I have to pick up where that knowledgebase article left off. What should the firmware do when it detects that VBUS (re)appeared? What should the firmware do when VBUS has disappeared?
I checked the code examples for STM32G4s, but I couldn’t find examples for USB. If somebody could point me to a code example, that would be great.
I’ve read this knowledgebase article on VBUS detection which is a collection of excerpts from AN4879 (and I’ve read the app note too).
Any 5V tolerant pin with external interrupt functionality... [from knowledgebase article]
Does the VBUS detection have to be done in an interrupt? Or can it be done in the main loop? If it can be done in the main loop, then are there timing constraints?
However, the disadvantage of this solution is that the software handling of VBUS presence event needs to be implemented by the user. This is not managed within our STM32 USB library for the time being. [from the same knowledgebase article]
I have to pick up where that knowledgebase article left off. What should the firmware do when it detects that VBUS (re)appeared? What should the firmware do when VBUS has disappeared?