6
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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? \$\endgroup\$ – Gustavo Litovsky Jan 22 '13 at 16:57
  • \$\begingroup\$ Sorry, it's ATTiny 45/85 \$\endgroup\$ – Pablo Jan 22 '13 at 16:58
  • 1
    \$\begingroup\$ electronics.stackexchange.com/questions/6884/debouncing-buttons is related. \$\endgroup\$ – pjc50 Jan 22 '13 at 16:58
  • \$\begingroup\$ The switch arrangement is a bit strange to me. What are you detecting, a rising edge or falling edge? \$\endgroup\$ – Gustavo Litovsky Jan 22 '13 at 16:59
4
\$\begingroup\$

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

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Chris Stratton Jan 22 '13 at 17:10
2
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Wow, look at my comment. I said the same thing :D \$\endgroup\$ – Gustavo Litovsky Jan 22 '13 at 16:57
  • \$\begingroup\$ I didn't get the popup before I committed. \$\endgroup\$ – Adam Lawrence Jan 22 '13 at 16:58
  • \$\begingroup\$ Any chance to solve it by lowering capacitor value or use some diode? \$\endgroup\$ – Pablo Jan 22 '13 at 16:59
  • \$\begingroup\$ @Pablo: yes. I believe 10nF could help a bit, but software would be the way to go with a timer. \$\endgroup\$ – Gustavo Litovsky Jan 22 '13 at 17:00
  • \$\begingroup\$ @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). \$\endgroup\$ – Gustavo Litovsky Jan 22 '13 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.