🛠 Arduino as ISP : programmer un autre ATmega328P
Objectives
Use the classic Nano as an ISP programmer ("Arduino as ISP") to burn the bootloader or a binary directly into a second ATmega328P: this bypasses the master board's bootloader via the 6-pin ICSP connector located at the top of the board. This is the fallback method when a bootloader is lost, and the first step toward using a bare ATmega328P on a breadboard.
Hardware
- 1 × Classic Arduino Nano (master programmer)
- 1 × ATmega328P (or pre-programmed bare 328P) + 16 MHz crystal + 2 × 22 pF ceramic capacitors + 10 kΩ resistor on RESET (target)
- 6 × cables for the ICSP-to-ICSP connection; power the target with 5 V
- >
Complete Code
1. Cote MAITRE (Nano) : Televerser le croquis File > Examples >
11.ArduinoISP > ArduinoISP (le sketch, PAS l'option « Burn the
bootloader » qui suppose un programmateur deja branche).
2. Cabler ICSP maitre -> ICSP cible : MOSI-MOSI, MISO-MISO,
SCK-SCK, RESET-RESET, VCC-VCC, GND-GND.
3. Cote IDE : Tools > Programmer > « Arduino as ISP ».
4. Graver les fusibles puis le bootloader :
avrdude -c arduino -P COMx -b 19200 -p m328p -U flash:w:optiboot_atmega328.hex
ou via l'IDE : Sketch > Upload Using Programmer, puis
Tools > Burn Bootloader (choisir « Arduino as ISP (Nano) » si
l'option dediee existe, sinon le speedo du sketch ArduinoISP).
Expected Verification
avrdude or the IDE respond with "Connecting......done" and then read the ATmega328P signatures (0x1E 0x95 0x0F). After burning the bootloader, the target behaves like a classic Nano: serial uploading works again on the burned board. The read fuses (lfuse 0xFF, hfuse 0xDE) confirm full-frequency crystal mode.
Common Errors
- Forgetting to select "Arduino as ISP" as the programmer: the IDE continues to communicate with the master's serial bootloader and fails the handshake.
- Crossed MISO/MOSI between master and target: permanent "device not responding" error; rewire pin-to-pin, never in mirror configuration.
- Target without a clock (default fuses on a new chip, internal oscillator divided): burn the internal fuses first if the crystal is not yet wired.
- Confusing the two menu options: "Burn Bootloader" uses the already configured programmer, whereas the ArduinoISP sketch must first be uploaded to the master.
Other tutorials for this board
Code examples for this board
buzzer-melodie.inoArduinoservo-sweep.inoArduinoultrason-hcsr04.inoArduinolcd-i2c.inoArduinoeeprom-contre.inoArduinosommeil-watchdog.inoArduino