2023-10-05 03:53 PM
I'm trying to understand the correct way to do self-powered devices with STM32L0. Most datasheets for other MCUs document using PA9 as a sensing pin using an alternate function, but I'm not finding this for L073, which I'm using on a Nucleo L073RZ board.
Do I need to do this all at my application level with a different normal GPIO pin and enable/disable USB functionality at that layer?
2023-10-05 11:44 PM - edited 2023-10-05 11:45 PM
Welcome @petejohanson, to the community!
VBUS is part of the Host functionality, which is also included with USB OTG. However, STM32L073 has USB with Device functionality and therefore does not offer VBUS.
Does it answer your question?
Regards
/Peter
2023-10-06 10:45 AM
Peter,
I am trying to use this as a USB *self-powered* device, which means *sometimes* there will be an upstream host, and other times there won't. I need to detect which state I'm in, which is usually done on devices via VBUS sensing. Right now, it seems the HAL layer (I'm using Zephyr RTOS layered over the ST HAL) is triggering the "suspended" callback, which, AFAICT, is happening because there's no VBUS sensing set available on L0 hardware to even have the HAL piece properly detect the *disconnected* state which it is really in.
Am I missing something?
2023-10-07 06:04 PM
There are two cases:
• The USB device is bus-powered. VBUS sensing is not mandatory (USB is always connected when the
device is powered)
• The device is self-powered. VBUS sensing is mandatory.
PA9 is not the mandatory for self-powered, any GPIO with 5V FT is good for detection.
please refer AN4879 on www.st.com.