Safety of 300uA pull to 12V on IO pin before MCU startup - Page 1
Forum section: electronics / general

author: Psi
author_rank: Super Contributor
timestamp: July 30, 2022, 06:22:33 am
content: I have a circuit with 12V going to an ADC pin of ATMega809 through a 39k resistor (part of batt Vsense divider)The MCU is powered from a 7805 output from that 12V source too.When the power switch is closed the 7805 will take some time to startup but the ADC input gets 12V through the 39k instantly. So for a very short time the GPIO maybe above VCC/AVCC and the protection diodes will try toshunt that 300uA to VCC.Is there any risk of damage to the MCU from this 300uA?I would have expected it to be totally fine due to only being 300uA and only for a very short time until the 7805 starts. I also have 100nF across the ADC input so the cap has to charge first.Although I guess if you cycle the power quickly the cap will already be charged.But I'm trying to track down an issue where the MCU is getting damaged and develops an internal short on AVCC to GND. So I just thought I'd confirm that my understanding is correct and that 300uA isn't going to do shit so i need to look elsewhere for the issue.Thanks.

author: Psi
author_rank: Super Contributor
timestamp: July 30, 2022, 06:29:11 am
content: My justification that it's fine is the pic below from datasheet.Which seems to suggest the inputs will be fine as long as current is limited to 1mA into the port.

author: ataradov
author_rank: Super Contributor
timestamp: July 30, 2022, 06:36:57 am
content: I'm not familiar with ATmega behaviour, but this is the exact text and limiting values used in the SAM D21, for example. And there your use would allowed and perfectly within the spec.

author: Psi
author_rank: Super Contributor
timestamp: July 30, 2022, 06:44:02 am
content: I'm somewhat worried the AVCC pin might be a little more sensitive on this MCU vs preveious ATMegas.It's one of the newer MCUs Microchip has released since they bought ATMEL and some of the peripherals are quite different register wise compared to an older ATMega, so I do wonder what else has changed inside the chip.hm.. is it a good idea to use a zener or TVS to clamp AVCC under VCC?I don't actually need the full 5V on AVCC since the ADC reference being used is the internal 2.5V ref.

author: ataradov
author_rank: Super Contributor
timestamp: July 30, 2022, 06:55:10 am
content: How exactly is your capacitor connected? Is it right on the pin with no further limiting? Would not that make it discharge into the pin with the current limited only by the ESR when power disappears?But also, if it is a resistive divider, then the pin would still only have the divided voltage no matter what. So, it will never see 12 V.

author: tszaboo
author_rank: Super Contributor
timestamp: July 30, 2022, 07:01:00 am
content: Some stuff might latch-up and then you MCU wouldn't work properly.Place a schottky diode from the pin to VCC. And put a zener or a TVS, like 5.2V voltage on the supply rail. That will clamp the voltage and makes sure nothing will blow up. Reset controller or power good pin from the power supply could help, but if you use a 7805 then probably thats not an option.

author: Psi
author_rank: Super Contributor
timestamp: July 30, 2022, 07:13:51 am
content: Quote from: ataradov on July 30, 2022, 06:55:10 amyes, it will never see 12V, but it may rise faster than VCC does.Yeah, cap is across the GPIO to GND, with divider feeding the cap.You reckon all pins should have a resistor in series first, to limit back feeding current at power off from any caps?The cap is only 100nF

author: ataradov
author_rank: Super Contributor
timestamp: July 30, 2022, 07:18:26 am
content: Well, it is hard to tell, but the true current limiting resistor would be a resistor between the pin and the rest of the circuit. You don't have that right now. I don't know how much current this capacitor can deliver. It really depends on how your power supply behaves on power off.

author: Psi
author_rank: Super Contributor
timestamp: July 30, 2022, 07:30:41 am
content: Quote from: ataradov on July 30, 2022, 07:18:26 amYeah, point taken.I'm adding some 10k's in the lines now.Easy thing to add and cost is trivial

author: gamalot
author_rank: Super Contributor
timestamp: July 30, 2022, 07:50:56 am
content: Since you say that this ADC input pin is used to sense the battery voltage, we can assume that the output of the voltage divider network you use is always less than 6V (the limit voltage given in the data sheet), then 300uA of current for your MCU is safe.

author: Psi
author_rank: Super Contributor
timestamp: July 30, 2022, 07:55:11 am
content: Quote from: gamalot on July 30, 2022, 07:50:56 amYeah, that's how I read it too. I don't think the battery sense voltage is the issue.The caps directly across the inputs are more of a concern if VCC falls away faster and they discharge into the IO pin with no current limit.

author: gamalot
author_rank: Super Contributor
timestamp: July 30, 2022, 08:31:47 am
content: Quote from: Psi on July 30, 2022, 07:55:11 amThere is a resistor connected in series at the input pin of the ADC. In theory, if the resistor is greater than 330 ohms, it is safe for an input voltage of 5V. Although I don't know the exact value of this resistor(will not be greater than 14k ohms, which is the input impedance of the ADC given in the datasheet), in practice I don't think that 100nF cap would cause any trouble.---I just looked at the datasheet again and it states that the ADC is optimized for signal sources with less than 10kohm impedance. So if you're still concerned, you can connect an external 1kohm resistor in series with the ADC input.

author: tom66
author_rank: Super Contributor
timestamp: July 30, 2022, 08:42:02 am
content: It probably won't break the microcontroller permanently.But one thing to be aware of, if this will ever happen outside of 'startup' then it can swamp the ADC. The issue is, the ADC is only rated as producing accurate results from 0-Vdd for instance. It won't be damaged if you go out of that range, but it also might not clip correctly. In fact, it might even cause adjacent channels to misbehave (I have encountered this behaviour on both PIC32 and TI's TM4C series) which can be a really difficult bug to solve.

author: Ian.M
author_rank: Super Contributor
timestamp: July 30, 2022, 09:57:49 am
content: In PICs, passing current through the protection diodes of analog-capable pins can lead to all sorts of odd misbehaviors that don't cause permanent damage (but may require power-cycling to recover from), including disturbing or even stopping internal oscillators, shifting internal references which may result in unexpected BOR resets, and of course degrading or corrupting ADC results on other pins. SeeMicrochip TB3013for details. Anecdotally, passing current through the lower protection diode seems particularly problematic as that can lead to current diffusing into the substrate, and I have seen several instances where even a few hundred uA causes massive (>50%) internal oscillator frequency shifts.