Can Arduino be damaged when is used as an ISP programmer?

Zápisník experimentátora

This question is asked by people trying to program another microcontroller using the Arduino. If other components are connected to the microcontroller, and the microcontroller has a program that manipulates the pins through which it is programmed, is there a real chance that Arduino will be damaged? To get the answer to this question, let's look at how ISP programming works.

The ISP programming algorithm is as follows:

  • A reset signal is set, which the target microcontroller switches to the programming state. Then the target microcontroller can not control its pins.
  • The programmer activates the SPI interface.
  • The target microcontroller is programmed.
  • The programmer deactivates the SPI interface.
  • The reset signal is turned off and the target microcontroller starts. Now the target microcontroller can control its pins.

There is ArduinoISP sketch for Arduino. In its source code, you can view the entire algorithm.

Function start_pmode

void start_pmode() {

  // Reset target before driving PIN_SCK or PIN_MOSI

  // SPI.begin() will configure SS as output, so SPI master mode is selected.
  // We have defined RESET as pin 10, which for many Arduinos is not the SS pin.
  // So we have to configure RESET as output here,
  // (reset_target() first sets the correct level)
  pinMode(RESET, OUTPUT);
  SPI.beginTransaction(SPISettings(SPI_CLOCK, MSBFIRST, SPI_MODE0));

  // See AVR datasheets, chapter "SERIAL_PRG Programming Algorithm":

  // Pulse RESET after PIN_SCK is low:
  digitalWrite(PIN_SCK, LOW);
  delay(20); // discharge PIN_SCK, value arbitrarily chosen
  // Pulse must be minimum 2 target CPU clock cycles so 100 usec is ok for CPU
  // speeds above 20 KHz

  // Send the enable programming command:
  delay(50); // datasheet: must be > 20 msec
  spi_transaction(0xAC, 0x53, 0x00, 0x00);
  pmode = 1;

Function end_pmode

void end_pmode() {
  // We're about to take the target out of reset so configure SPI pins as input
  pinMode(PIN_MOSI, INPUT);
  pinMode(PIN_SCK, INPUT);
  pinMode(RESET, INPUT);
  pmode = 0;

Can the Arduino be damaged?

Due to the fact that the target microcontroller is reset before programming and can not set the HIGH / LOW to the pin, there can be no unnecessary shortcut on programming pins. However, it is important that these pins are no hardly connected to power or GND. If there are LEDs with a resistor, it is completely safe.

Neither the connection to power or GND should not damage Arduino. Arduino has internal protection diodes, which will also survive short circuit and ISP programmer should very quickly find out that its pins can not control and disconnect. From my own experience, I can confirm that the ATtiny85 and ATmega328P microcontrollers will also survive short switch of the VCC and GND, so in normal circuits you should under no circumstances manage to destroy your Arduino.