9
\$\begingroup\$

I am designing a device around the STM32L476. My device is primarily battery-powered, but has a USB port that, when plugged, I want to use as an alternative power source (through a 3.3V regulator) to limit battery drain. It is also possible that the user connects the USB port while there is no batteries.

I want to be able to sense when the USB port is connected, so I'm using PA9 as OTF_FS_VBUS.

The good news: the datasheet says that the PA9 pin is 5V tolerant.

The bad news: 5V tolerant pins seems to actually be 5V tolerant only when power is applied. Datasheet §6.2 table 18 says:

Max input voltage on FT_xxx pins: min(VDD, VDDA, VDDIO2, VDDUSB, VLCD)+4.0V

In my case, if there is no batteries and the user connects the USB port, there is a time, before the regulator starts, during which the voltage on PA9 will be 5V while no power is applied at all on the CPU supply pins.

The even more bad news: current injection is not allowed: datasheet §6.2, table 19, says:

Injected current on FT_xxx: -5/+0 (see note 4)

Note 4: A positive injection is induced by VIN > VDDIOx while a negative injection is induced by VIN < VSS. IINJ(PIN) must never be exceeded.

So it seems I can't use a simple resistor to limit excess current on PA9 during the time the regulator starts. Any amount of current that would flow from VBUS to PA9 before VDD ramps up is apparently forbidden.

What did the others do ?

I had a look at numerous designs around STM32 chips, looking at their VBUS connections, and they don't seem to care. They connect VBUS directly to PA9, or eventually through a resistor, but I never saw anything more complicated. But they mostly are development boards, so I guess the ruggedity (is that a word ?) is not very important. And they are usually not powered through the USB port, and certainly assume the user won't connect USB port before powering the board.

What is my plan ?

Putting this between VBUS on the USB port and the PA9 pin of the MCU:

VBUS protection

I really tried to keep it simple. Basically, it ensures that VUSB_CPU (which is the PA9 pin) can never be above VCPU + 4V (Vz+Vbe), without consuming any power if it is OK.

My main questions are: Am I right in my analysis ? Is this circuit a good solution ? Am I worrying about things that are irrelevant ? Why nobody else seems to care about this potential problem ?

Additional question: I plan to use USB OTG. Is that a problem if there is a 4.7k resistor between the connector and the PA9 pin ? I guess it would be if I had to use VBUS pulsing during SRP, but this method is apparently deprecated. So am I good, whatever the role (device/host) of my device ?

A last one: What is the max current drawn by the VDDUSB supply pin ? The datasheet specifies, for the USB peripheral: 16.4µA/MHz for AHB clock domain + 23.2µA/MHz for independant clock domain, but we don't know from where it is drawn (VDD or VDDUSB).

\$\endgroup\$
  • \$\begingroup\$ Another PA9 protection option would be to put a mos switch between the USB's +5v and PA9, and then drive the gate of the switch with the output of the regulator. \$\endgroup\$ – Mark Apr 25 '16 at 21:53
  • \$\begingroup\$ why not use a resistor divider? 430k and 630k will give you 3.3v on the pin. \$\endgroup\$ – b degnan Apr 25 '16 at 23:26
  • \$\begingroup\$ But a resistor divider will not solve the injection issue. The divider will inject 3.3 volts into the pin before the part has powered-up. \$\endgroup\$ – Mark Apr 25 '16 at 23:35
  • \$\begingroup\$ I understand from the datasheet that the pin can withstand 4v, even when powered off (is this correct?). So a resistor divider would be a good solution, but would draw power permanently. I forgot to mention i have tight constraint about that. \$\endgroup\$ – dim Apr 26 '16 at 5:11
4
\$\begingroup\$

Go with the resistor divider (430k/620k) on Vbus -- this will keep the microcontroller in spec, and the parasitic current draw won't be a problem as it will be sourced exclusively from Vbus, not from the battery (which is what I assume you wish to conserve).

\$\endgroup\$
  • \$\begingroup\$ Stupid me... I was ruling the resistor divider out because of current consumption, but my reasoning was obviously incomplete. Indeed, it is not a problem to draw power from vbus. Now, why nobody does even that in their boards ? ST itself (discovery board), olimex, ... ? I still don't understand that point. \$\endgroup\$ – dim Apr 27 '16 at 6:41
0
\$\begingroup\$

Probably the simplest method, use a highish value resistor (10-100k) feeding a largish capacitor (couple of uF or more) so that it takes time for the voltage to ramp up, I wouldn't worry about the fraction of a volt that builds up across the capacitor while the regulator is starting up, if the micro's got esd protection then the inputs can handle 5-10V for a few tens of uS

\$\endgroup\$
  • \$\begingroup\$ This sounds great... but only until you think about what happens when power is removed. The capacitor may actually make things worse, than just having the large value resistor - the resistor can't provide much current, but the charged capacitor can. \$\endgroup\$ – Chris Stratton Apr 26 '16 at 5:11
  • \$\begingroup\$ could you drive it through a small zener? That section of the datasheet said VDD+4V right? If you had a zener dropping the rail down to less than VDD+4V would that be ok? \$\endgroup\$ – Sam Apr 26 '16 at 6:19
  • \$\begingroup\$ I don't visualize well your zener suggestion without schematic. But if the solution has the same complexity as mine (3 cheap discrete components), I won't gain much. \$\endgroup\$ – dim Apr 26 '16 at 7:42
  • \$\begingroup\$ Basically: Input->zener->PA9, zener in series with the input as opposed to a series resistor, zener drops a volt or two so the voltage at PA9 is always a bit lower. If the dev boards just tie them, then it's probably ok, I think the warnings might apply after the MCU is powered up though, see if there's a section on power sequencing or on start-up behavior. \$\endgroup\$ – Sam Apr 26 '16 at 7:51
  • 1
    \$\begingroup\$ @Tom that's my main problem actually. I checked, they do nothing. PA9 is connected directly to VBUS on the USB port (not even through a resistor), on their Discovery demo board. So, unless I missed something, this is in complete contradiction with the datasheet. My problem is not really the protection circuit in itself. I think my solution, even if it may certainly be improved, can do the work. To be honest, my main problem is just: is all that really necessary ? \$\endgroup\$ – dim Apr 26 '16 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.