8

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).

dim
  • 15,845
  • 3
  • 39
  • 84
  • 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. – Mark Apr 25 '16 at 21:53
  • why not use a resistor divider? 430k and 630k will give you 3.3v on the pin. – b degnan Apr 25 '16 at 23:26
  • 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. – Mark Apr 25 '16 at 23:35
  • 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. – dim Apr 26 '16 at 05:11

2 Answers2

4

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).

ThreePhaseEel
  • 8,858
  • 4
  • 26
  • 41
  • 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. – dim Apr 27 '16 at 06:41
0

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

Sam
  • 3,639
  • 13
  • 16
  • 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. – Chris Stratton Apr 26 '16 at 05:11
  • 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? – Sam Apr 26 '16 at 06:19
  • 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. – dim Apr 26 '16 at 07:42
  • 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. – Sam Apr 26 '16 at 07:51
  • Mmh. According to the datasheet, PA9 pin is these conditions can draw a current anywhere from 0 to 650nA. With such low currents, the zener will not be accurate at all, especially the low voltage zeners. It is hard to predict how many volts will be dropped. – dim Apr 26 '16 at 08:16
  • Yeah a zener's not going to be very reliable at nanoamp scales, that's a pretty small current. Looks like you might have to go with your original solution afterall. The only other thingI'd check would be to see what ST themselves do on their own dev boards, manufacturers are pretty unlikely to make a dev board that'll fry itself as it reflects poorly on them and their reputation. So whatever ST does is probably fine, the trick will be to find an actual schematic from them. – Sam Apr 26 '16 at 08:47
  • 1
    @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 ? – dim Apr 26 '16 at 18:51
  • Link to the STM32L476 discovery board manual, including schematics [here](http://www2.st.com/content/ccc/resource/technical/document/user_manual/d1/84/86/4b/08/82/47/91/DM00172179.pdf/files/DM00172179.pdf/jcr:content/translations/en.DM00172179.pdf). – dim Apr 26 '16 at 18:53