I'm using a Attiny45 microcontroller and USBtinyISP as my programer, and this is the first time I need to hook stuff up (in this case just LEDs, but eventually I'll want to conect a raspberry pi) to the programing pins (SCK, MISO, MOSI). As I want the microcontroller to be re-programmable when it's all soldered up. I first breadboarded the circuit to make sure it works. This is what I found:

If I have a LED and resistor in series between SCK or MOSI, avrdude throws this error at me:

avrdude: initialization failed, rc=-1

unplugging the LED gets rid of the error, but isn't ISP ment to allow this?(Arduino's have a LED connected to pin 13 SCK)

However on MISO this never happens and I'm free to upload the program with the LED attached. Why is this? Is there a way to obtain this behaviour on the SCK and MOSI? How is this issue going to be affected if I replace the LEDs with raspberry pi GPIO thru a logic level converter?

  • 1
    \$\begingroup\$ atmel.com/Images/… \$\endgroup\$ Apr 9, 2014 at 21:03
  • \$\begingroup\$ "the programmer must be protected from any device, other than the AVR, that may try to drive the lines." I don't see how LEDs could drive the lines \$\endgroup\$
    – Michal
    Apr 9, 2014 at 21:15
  • \$\begingroup\$ @Michal: Not sure if your comment was before or after alexan_e's answer, but: The AVR spec sheet is saying the lines used to program the AVR must not be disrupted by other connected devices, and especially not by another device sending signals that could be (mis)interpreted as part of the programming communication. Failure to program, or worse, difficult-to-correct programming of the fuses could result. LEDs "drive" in the sense that they draw current from the AVR or programmer pin, preventing the AVR or programmer producing valid 0 and 1 voltage levels. Luckily avrdude notices this. \$\endgroup\$
    – gwideman
    Apr 10, 2014 at 0:20

1 Answer 1


Arduino's have a LED connected to pin 13 SCK (and have no problem)

Yes they do , but take a look at a typical schematic of Arduino UNO (as an example)

enter image description here

As you can see the SCK pin is connected to an OPAMP wired as a buffer which then drives the LED. The effect of that, is that the SCK pin only sees as a load the high input impedance of the OPAMP, so the pin can be easily driven by the programmer.

However on MISO this never happens

The MISO pin is the slave output and in this case the slave is the AVR which apparently has a higher drive ability compared to the programmer and can successfully drive the output even with the LED attached.

If you want to use a LED then you should ether use a high impedance driver (like an OPAMP, a comparator, a mosfet etc), or you can use a jumper to detach the LED while programming.

  • \$\begingroup\$ As an aside, I have LEDs connected to AVR programming pins quite commonly without any consequence. I think the real problem with the OP circuit is the current path from one pin to the other through the LED. In any case, using a driver like this is good practice. \$\endgroup\$ Apr 10, 2014 at 1:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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