2024-09-22 06:45 PM - edited 2024-09-22 06:46 PM
Dear all
I'm starting a design with the STM32L412R8I (or maybe STM32L412RBI6) and I cannot find the VBUS dedicated pin in the datasheet nor in the manual. In this design the USB will be always device (no OTG)
Is it enough to have VDDUSB powered to detect a bus connection?
Additionally, the design is going to be battery powered and be disconnected from the USB bus most of the time. Can I have the microcontroller powered by its regular power pins (VBAT, VDD, VDDA) and power VDDUSB only when the device gets attached to an USB bus?
Thanks in advance
Ignacio
Solved! Go to Solution.
2024-09-23 05:52 AM
You can use any GPIO pin to detect VBUS. Hook it up to a resistor divider network that sets it high when VBUS is present. Initialize USB when it's present a de-initialize it when it goes away.
> Is it enough to have VDDUSB powered to detect a bus connection?
The chip doesn't know when VDDUSB is powered. At least I don't think there's a way to probe this information.
> Can I have the microcontroller powered by its regular power pins (VBAT, VDD, VDDA) and power VDDUSB only when the device gets attached to an USB bus?
Technically, yes, but the above point makes this difficult in practice, plus it's not going to save much power.
2024-09-23 05:52 AM
You can use any GPIO pin to detect VBUS. Hook it up to a resistor divider network that sets it high when VBUS is present. Initialize USB when it's present a de-initialize it when it goes away.
> Is it enough to have VDDUSB powered to detect a bus connection?
The chip doesn't know when VDDUSB is powered. At least I don't think there's a way to probe this information.
> Can I have the microcontroller powered by its regular power pins (VBAT, VDD, VDDA) and power VDDUSB only when the device gets attached to an USB bus?
Technically, yes, but the above point makes this difficult in practice, plus it's not going to save much power.
2024-09-23 05:59 AM
Thank you TDK
Cheers
Ignacio
2024-09-23 07:38 AM
> The chip doesn't know when VDDUSB is powered. At least I don't think there's a way to probe this information.
You can use PVM1 to find out this information, see chapter Peripheral Voltage Monitoring (PVM) in RM0394 (and even throw an interrupt thus wakeup from a sleep upon its change). It compares VDDUSB with cca 1.2V, so it's not a perfect information, but probably sufficient enough for purposes of VBUS detection.
You have to regulate VBUS down to 3.3V, though, if you want to use it as VDDUSB.
JW
2024-09-23 08:00 AM
Hello
My main concern about to power VUSB upon the bus connection (to 3.3V) is because the rest of voltages are going to be 1.8V, so the USB feature isn't going to work with that voltage, unless the voltage be switched on to 3.3V when the bus is connected, or to be OR powered with 1.8V while no bs is connected and to 3.3V when the USB cable is connected, but I'm not sure about thist last one
regards
Ignacio
2024-09-23 08:16 AM - edited 2024-09-23 08:16 AM
VDDUSB is pin E5 on the STM32L412R8I. It is independent from VDD. You can have VDD = 1.8 V and VDDUSB = 3.3 V.
Power that with 3.3 V when USB is present and things should work.