I encountered this problem on the Atmel SAMD21 Xplained Pro Evaluation Kit.
The data-logging device that I developed is mainly battery powered, but uses USB every once in a while to download the data and recharge the internal battery. A resistor divider (R307 and R308) is used to detect when USB +5V is connected. This generates a rising edge interrupt on PA14 and wakes up the ARM micro from STANDBY sleep mode. The ARM micro then starts the USB stack, which enables an internal 1.5kΩ pull-up resistor to +3V3 on USB D+ (pin PB05). For more info regarding the pull-up resistor read this page regarding USB speed identification. The pull-up resistor basically tells the USB Host “hey, I’m here” and the operating system proceeds to enumerate the USB device.
The problem rears it’s head when USB is disconnected. USB +5V disappears, but the 1.5kΩ pull-up resistor to +3V3 stays enabled. There is a unintentional current path through the USB ESD protection diode D300 and the PA14 node voltage drops down to 1.2V (logic high), not 0V (logic low) as expected. Consequently, the ARM micro keeps the USB stack and the pull-up resistor enabled and wastes 33μA the whole time. That’s a lot if you want to make the device last a year.
Here is my improved circuit:
Yes, I know, it’s not earth shattering… I just tweaked the resistor divider values and added an extra resistor (R30). Here are some sound engineering calculations that proves that it will work over all tolerances (and that’s the difference):
When USB +5V is present (actually, it could be as low as 4.35V), the minimum voltage on PA14 will be 1.956V, which is still above the maximum threshold of 1.906V.
When USB +5V is absent, the USB Speed pull-up resistor will pull PA14 up to 0.966V (worst case), which is still below the minimum threshold of 1.040V (when VDDIO is 3.465V).
It is possible to unintentionally power up the device via low value resistor R1 when USB is connected, but R30 limits the amount of parasitic current that flows into GPIO pin PA14. Remember that there are internal ESD protection diodes connected to each GPIO pin of the ARM micro and this will form an unintentional current path to the VDDIO supply rail.
I recently came across an alternative solution to the problem. There are ESD protection devices, for example WE-TVS 82400102 (Digi-Key part number 732-4473-1-ND) that have a diode to block the parasitic current flow: