Program chip with Arduino ISP

hi , im beginer , plz help me , how can program an atmega8 with arduino nano in platformio

Open the Arduino IDE (or a temporary project in PlatformIO). Go to File > Examples > ArduinoISP. Upload this sketch to Arduino Nano. Disconnect everything from power before wiring. Connect the SPI interface pins of your Nano to the corresponding pins on your ATmega8:

You connect the Nano’s 5V and GND to the ATmega8’s power and ground pins, then map the data transfer lines by matching D11 to MOSI, D12 to MISO, and D13 to SCK, while connecting the Nano’s D10 pin to the ATmega8’s RESET pin. Finally, you must bridge a 10µF capacitor between the Nano’s Reset (+) and GND (-) pins.

When you try to connect the ATmega8 chip with the Arduino board, this Unikeyic blog can help.

Pin to pin connection

Create a new PlatformIO project for the ATmega8. Replace everything inside your platformio.ini file with the following configuration:

[env:ATmega8]
platform = atmelavr
board = ATmega8
framework = arduino

; Tell PlatformIO to use the Nano as an ISP programmer
upload_protocol = stk500v1
upload_speed = 19200
upload_flags =
    -P$UPLOAD_PORT
    -b$UPLOAD_SPEED

; Replace COM4 with your Nano's actual serial port (e.g., /dev/ttyUSB0 on Linux/Mac)
upload_port = COM4

By default, standard PlatformIO assumes an external 16MHz crystal oscillator. If your ATmega8 is running bare on its internal 1MHz or 8MHz RC oscillator, timings like delay(1000) will be completely broken. If you aren’t using a crystal, add this line to your platformio.ini to match your target chip speed:

board_build.f_cpu = 8000000L  ; Change to 1000000L for 1MHz

Open your src/main.cpp file and write a simple blink test:

#include <Arduino.h>

// On a raw ATmega8, digital pin 13 is physical Pin 19 (PB5)
#define LED_PIN 13 

void setup() {
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  digitalWrite(LED_PIN, HIGH);
  delay(1000);
  digitalWrite(LED_PIN, LOW);
  delay(1000);
}

Click the Upload arrow at the bottom of PlatformIO (or press Ctrl+Alt+U). PlatformIO will now compile your program and pass it through the Nano straight into the flash memory of your ATmega8.

Here is a reference in github that you can see.

PlatformIO ATtiny85 Programming with Arduino Nano

1 Like