Electronic – arduino – AVR ISP-Programing LEDs SCK

arduinoavravrdudeispraspberry pi

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?

Best Answer

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.