SAMD21 - Voltage on analog input trickles into 3.3V rail - Page 1
Forum section: electronics / general

author: Vulpecula
author_rank: Newbie
timestamp: January 18, 2022, 09:51:33 am
content: Hey there!I have observed a rather strange thing regarding a circuit, where the voltage of a 7.4V 2S LiPo battery gets divided down with a voltage divider (ratio: 1kOhm/3kOhm) and is then fed into an analog input pin of a SAMD21 microcontroller. The circuit is turned on and off by a pushbutton controller which is connected to the enable-pin of a buck converter. Also, the battery is always connected to that voltage divider and the connection does not get cut off in case the circuit is turned off.Here's the strange thing: When turned off, I can measure a voltage between 0,8V and 1V on the 3.3V rail and a current of 2.5mA coming from the battery. Changing the resitor values (without changing the ratio) does lower the voltage and the current of course. For instance: 100kOhm/300kOhm lowers the voltage on the 3.3V rail to 0.4V and the current to 0,15mA.Can someone explain why this happens? My best guess is, that when the 3.3V rail on the microcontroller is turned off, something inside the SAMD21 lets current seep through. But after all, I do not know enough about the internals of those microcontrollers so maybe some of you guys can tell me what is going on here.Thanks and greetingsVulpecula

author: Ian.M
author_rank: Super Contributor
timestamp: January 18, 2022, 10:11:44 am
content: Your MCU is getting parasitic power via its input protection diodes.EEVblog #831 - Power A Micro With No Power Pin!Forum thread:https://www.eevblog.com/forum/blog/eevblog-831-power-a-micro-with-no-power-pin!/

author: ataradov
author_rank: Super Contributor
timestamp: January 18, 2022, 06:00:10 pm
content: Yes, all pins on SAM D21 have clamping diodes, and if there is no VDD voltage, but there is a voltage on the pin, then the VDD diode opens and powers the VDD rail.

author: nemail2
author_rank: Regular Contributor
timestamp: June 25, 2022, 01:27:54 pm
content: how would you stop this, let's say for the UART pins where you have your USB/UART converter connected during development all the time, even if the power source for your DUT is temporarily turned off? Is there an easy fix for that, if I'm too lazy/annoyed to disconnect the USB/UART adapter everytime I disconnect power from my SAMD21?

author: Ian.M
author_rank: Super Contributor
timestamp: June 25, 2022, 01:42:00 pm
content: Get a USB<=>UART converter that senses target power to set its logic levels and also disables its outputs when target power is not present.Alternatively mod your existing USB<=>UART converter by adding74LVC1T45dual supply level translating buffers, with the target side powered from target Vcc, which are guaranteed to go Hi-Z if one supply is missing. They also bring the benefit of target level conversion over the range 1.8V to 5.5V. Strap their DIR pins according to whether the signal is an input or output. If you've got two signals in the same direction you could use74LVC2T45buffers, for a reduction in board area and component count.

author: ataradov
author_rank: Super Contributor
timestamp: June 25, 2022, 05:02:46 pm
content: In most cases you don't really need to worry about it. There are rare cases where this effect causes problems and there you need to act according to the situation, but in most cases it is fine.

author: coppice
author_rank: Super Contributor
timestamp: June 25, 2022, 05:08:20 pm
content: You can get some really funky things happening through those protection diodes. If your device needs to work in a high EMI environment you may find picked up energy feeding into the I/O pins gets through to the Vdd rail through the protection diodes, pushing that rail's voltage up until something fails from over-voltage. There are times when a simple LDO doesn't cut it for a power supply, and you need a regulator with the ability to clamp Vdd as well as regulate it.

author: TimFox
author_rank: Super Contributor
timestamp: June 25, 2022, 05:56:10 pm
content: (I posted this anecdote previously.)When RCA first introduced their "COS-MOS" line (4000-series higher-voltage CMOS), I attended a presentation by an RCA field engineer.He related a personal story: he had been tasked with verifying the toggle-frequency spec on an MSI counter.He set up the equipment late on Friday, and returned Monday morning to document the measurements.The result was horrible: the maximum toggle frequency was way below the specification.He then found that he had forgotten to turn on the bench power supply: the square wave from a low-impedance source had produced enough voltage on the supply rail (through the protection diodes) for the counter to function badly.No problems after powering-on the external supply.

author: floobydust
author_rank: Super Contributor
timestamp: June 25, 2022, 06:16:04 pm
content: Ref. SAMD21 injection current specs, VDD <=3V is 15mA but for VDD= 3-3.6V it's only 1mA.

author: coppice
author_rank: Super Contributor
timestamp: June 25, 2022, 06:53:24 pm
content: Quote from: TimFox on June 25, 2022, 05:56:10 pmThat kind of thing happens a lot with ULP MCUs, like the MSP430.

author: eugene
author_rank: Frequent Contributor
timestamp: June 26, 2022, 03:11:41 pm
content: I occasionally teach a few different courses at a local community college. I couldn't begin to count the number of times students wired the inputs and outputs of logic gates but didn't supply power to the IC, yet the circuit still worked!

author: Simon
author_rank: Unknown
timestamp: June 26, 2022, 05:10:02 pm
content: Quote from: TimFox on June 25, 2022, 05:56:10 pmit's actually what happened when the very first ARM processor was tested, they fired it up and it worked, they tried to measure the consumption as they had no way of knowing what the power draw would be and found there was none. They had forgotten to power it and it was running on the power from an input pin. It's often told in relation to how low power it was and how much lower than they expected.

author: DavidAlfa
author_rank: Super Contributor
timestamp: June 26, 2022, 05:26:48 pm
content: Yep, thats' the clamping diodes, most mcu pins are like this:Simplest way is to just put a 100Ohm resistor to the VDD rail, the clamping diodes will dump the current into it.Not good for battery powered because that will cause permanent VDD current consumption when ON.For more power-critical circuits, you can use this simple circuit.When VDD is present, Vb >= Analog input, so the transistor can't turn on, there's no extra current consumption.When it's gone, VDD itself goes near 0V providing a path for the base current flow.Anything >0.7V will turn on the transistor and clamp the voltage. 0.7V shouldn't cause any problem.

author: peter-h
author_rank: Super Contributor
timestamp: June 29, 2022, 02:42:05 pm
content: Use much higher value resistors for that voltage divider.I do this with the ADC of a 32F417, 3.3V powered, to measure a +5V rail. I use a 100k/10k divider, so the max current that can source is 5V/100k=50uA. This is OK because the Zin of that ADC is pretty high, so check that yours is too.There are other solutions but they involve more components; basically clamping the max input voltage just below the VCC of the micro, to the upper input protection diode doesn't turn on. The limit for that is normally VCC+0.2V, or if going below GND it is VSS-0.2V.This touches on the interesting topic that capacitor-switching delta-sigma ADCs (those that deliver a 2's complement value) actually workaround0V and can sense below zero, down to about -0.2V