# Problems with input leakage current in a microcontroller

I'm trying to build a system in which a microcontroller receives (through one of its input pins) a logic 1 if a switch is pressed and a logic 0 if it's not. For that purpose, I want to implement a circuit like the following:

I understand that the 10k resistor is necessary for avoiding a short-circuit between the 3.3V and ground, what I haven't completely clear is why it must be 10k.

According the explanation I'm reading, that value is chosen doe to the microcontroller IIL and IIH (Input Leakage Current, right?) is 0.2 micro amps, and this is what I don't truly understand.

In the text I'm reading it's called the input current of the microcontroller input pin, and I'm assuming that it is something like a residual current that the microcontroller is delivering out (thorugh the input pint). Am I right?

If so, how is possible that that current exists if the circuit is openned? How can an INPUT pin deliver current to the outside?

Finally, if my assumptions are more or less correct, that means that what I need is to achieve a voltage between 0 and 0.8 V (considered logic 0 by the microcontroller according its datasheet).

So, since V = I * R, if I put a R of 10k, that means V = 2 microAmps * 10K ohms = 20 millivolts, which is between 0 and 0.8 so I will obtain a logic 0. Is this correct?

If so, as far as I understand, we could achieve the same goal with many different resistors, always if the generate a voltage between the input pin and the resistor which is between 0 and 0.8, right?

• Correct. But have you considered that the environment might be noisy, with nearby logic signals flying up and down? If the switch is remote, you might consider a smallish value for the pull-down resistor. Commented Sep 1, 2018 at 13:20
• An input pin has (usually) a 2 transistor input stage, often with over and undervoltage protection (usually schottky devices in modern parts). All these elements will have some leakage from the power rail (when the input is low) and from the negative rail (when the input is high). That is where the leakage current comes from. Commented Sep 1, 2018 at 13:35
• 10k R is just an easy-to-find value. Commented Sep 1, 2018 at 13:39
• why it must be 10k. It doesn't have to be 10 k. 100 ohms would work but then 3.3V/100 = 33 mA flows when you press the button. That 33 mA is "wasted" and adds to the power consumption of the device. 10 Mohm could also work but then the "pull down" is so weak that a nearby cellphone or moisture can disrupt normal operation. In general we use 10 k to 100 k ohms as that is a good compromise between these. Commented Sep 1, 2018 at 13:41
• What the exact TM4Cxx device? What the pin (slow/fast I/O))? Commented Sep 1, 2018 at 17:02