# Capacitor and ISP issue

If I remove C5 I am able to use ISP. However, with C5 on board ISP programming fails... Capacitor is for button debouncing.

What is the quick workaround to have debouncing routine and use ISP? I can't change the board because it's already on PCB, just can make a patch.

• You haven't mentioned which microcontroller you're using. From the tags I can see Attiny, but your question should plainly show which it is. 1uF seem to me to be too large for debouncing. Did you look at the RC constant? – Gustavo Litovsky Jan 22 '13 at 16:57
• Sorry, it's ATTiny 45/85 – Pablo Jan 22 '13 at 16:58
• – pjc50 Jan 22 '13 at 16:58
• The switch arrangement is a bit strange to me. What are you detecting, a rising edge or falling edge? – Gustavo Litovsky Jan 22 '13 at 16:59

A simple solution could be to connect the junction of C5 and R1 via a 10k resistor to PB2, and connect the ISP connector directly to PB2.

This is a general solution that you can use whenever you want to override a signal with a stronger signal that will not be present (or is in tri-state) when the weaker signal must be read. Of course, the series resistor put 'before' the weaker signal to make it weak must not cause a problem. Generally, digital microcontroller input pins have a very high impedance, so a 10k extar won't be noticed at anything but very high frequencies. (but remember: analog inputs might might have a much lower impedance, so in that case this trick likely won't work.)

That capacitor breaks ISP because it limits the rise and fall times on PB2. The programmer can only source or sink so much current, and so only charge/discharge this capacitor so fast.

If you can't change the board, you will have to remove the capacitor and do debouncing in software.

Alternately, make R1 bigger, and C5 much smaller. If C5 is small enough that the edges are still sharp enough, you won't have this problem. Programming at a lower speed will also help.

• A bit surprised at the hardware debouncing to begin with. Is there some extreme limitation on the software, which prevents debouncing there? It can be as simple as ignoring the button for some interval after its activation is detected. – Chris Stratton Jan 22 '13 at 17:10

You haven't specified which micro you're using, but in many(most) cases a 1uF cap is going to wreak havoc with the ISP programming clock.

I'd nopop the cap and go for a software debounce instead of brute-forcing it.

• Wow, look at my comment. I said the same thing :D – Gustavo Litovsky Jan 22 '13 at 16:57
• I didn't get the popup before I committed. – Adam Lawrence Jan 22 '13 at 16:58
• Any chance to solve it by lowering capacitor value or use some diode? – Pablo Jan 22 '13 at 16:59
• @Pablo: yes. I believe 10nF could help a bit, but software would be the way to go with a timer. – Gustavo Litovsky Jan 22 '13 at 17:00
• @Madmanguruman: I wasn't complaining about the answer. Just was amazed we said exactly the same two things (missing micro info and large cap value). – Gustavo Litovsky Jan 22 '13 at 17:00