I was testing a program to read analog data at high frequency. I was using a function generator generating a sinusoidal wave at 500hz, 2 V of amplitude, 1.5 V of mean value. I turned on the function generator before the arduino and I realized that one of the LED of the arduino was on with a dim light, also the LED of the SD module I was using was on. After it I also turned on the arduino and everything worked fine but I am worried. I am pretty sure that I connected the ground of the function generator to one of the GND of my mega 2560, the output to A0 and I shorted A0 and A1 (I was reading the same signal twice).
The 2V signal will have been fed through the pin protection diodes on the processor inputs to the processor Vcc (+5V) line. The LED you saw illuminated was probably the 5V power LED.
If there is any chance that Arduino inputs may be powered when the Arduino itself is not powered, then it is safest to use a resistor of at least 3K and preferably 10K in series with each of those inputs.
The name of this effect is "parasitic powering" and is best totally avoided. It can lead to chip latch up, that is the chip could not power up correctly and draw a lot of current.
CrossRoads:
And if that current exceeds 1mA, you can blow the diode, leading to a failed chip.
The only figure I have seen is in an Atmel application note relating to detecting mains zero-crossing. The suggested limit was either 1mA or 2mA, I don't remember which. I suspect the reason for the limit is not related to blowing the diode, rather the risk of latch-up (due to parasitic SCRs etc.) that Mike mentions.
And two more places:
"The series input resistor is a 1 M? resistor. It is not recommended that the clamping diodes are conducting more than maximum 1 mA and 1 M? will then allow a maximum voltage of approximately 1,000V.
Any voltage higher than 1,000V would probably be spikes or surges. The clamping
diodes are able to handle spikes for a short period of time but not surges. The application note will not go into how to protect against surges, but simply recommend implementing protection against surges in the design."
"The series resistor can also be modified somewhat to make the detection closer but note that the maximum current through the AVR’s clamping diode should not be higher than 1 mA."
Adding the resistor is much better idea, you don't have to remember anything about
power-up sequencing then. Analog inputs are fine with an source impedance of 10k
anyway.
Another way to protect is to back-up the internal protection with external schottky
diodes, thus preventing the internal one's from conducting - you'll still get the parasitic
powering, but without it all going through 1mA diode.
Combine the schottkys and the resistor for the most robust protection.