6

enter image description here

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.

W5VO
  • 18,303
  • 7
  • 63
  • 94
Pablo
  • 1,551
  • 3
  • 20
  • 41

3 Answers3

4

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.)

Wouter van Ooijen
  • 48,407
  • 1
  • 63
  • 136
3

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.

Phil Frost
  • 56,804
  • 17
  • 141
  • 262
  • 1
    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
2

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.

Adam Lawrence
  • 32,921
  • 3
  • 58
  • 110