I want to add a user button to my schematic design, so I first take a look at what I consider it could be a good source: the ST Discovery board schematic.
Their use case is the same as mine: user button, microcontroller configuration unknown, Vdd at 3.3 V.
Their button looks like this:
I think I understand most of it (correct me if I am wrong):
- R35 may protect the microcontroller (i.e.: PA0) in case the user configured that pin to be an output (high/low) rather than input (high impedance). Otherwise if PA0 is set to low, pressing the button could be dangerous.
- R39 lowers the Vdd-GND current when the button is pressed (no need to waste current).
- The capacitor should filter the button bouncing and I guess it should charge/discharge through a resistor as well (R38?).
Now, here is what I do not understand: when the button is not pressed, considering stable conditions, at one side and the other of the button we have Vdd and GND potential, same with the capacitor. So...? (initial thoughts that I know must be wrong, but anyway...)
- When we press the button, are not we shorting two cables at different potentials with no resistor in between? (3.3 V from the power source with 0 V from the condenser)
- My intuition would have lead me to put the R38 between Vdd and the switch, rather than between Vdd and the capacitor, but it seems my intuition is bad (STM engineers must be right and I must be wrong).
So, maybe what happens is that when the button is pressed, the lower part of the capacitor (as drawn in the schematic) becomes 3.3 V instantly and then the upper part becomes 6.6 V? (and then discharges through R38)
If that is correct then I guess that if at that exact instant we release the button again (imagine the button bouncing), the upper part of the condenser keeps the 6.6 V potential and goes smoothly to 3.3 V back again and the lower keeps the 3.3 V and goes smoothly as well to 0 V? Otherwise the de-bouncing would not work, right?
Could someone clarify how this works?