“I’ve written my code for Arduino UNO board. Is it possible to upload my sketch to an AVR microcontroller except ATmega328? I think it’s the most common question of Arduino lovers. This may have different reasons such as:
In this tutorial you will learn how to program an ATmega8 using Arduino IDE. It’s not restricted to ATmega8 only and can be generalized to other cores which are available at MCUDude’s GitHub. It consists of two parts. In part one, Installing Arduino bootloader on ATmega8 is described. Part two shows how to program an ATmega8 using Arduino IDE and a USB to TTL convertor.
Part one: Installing Arduino BootloaderIn this part, we add ATmega8 support to Arduino IDE. Then we set up the breadboard and connect ATmega8 to Arduino UNO board.
Step One: Adding ATmega8 Support to Arduino IDE Using Board ManagerThere are different types of cores available on MCUDude’s GitHub repository. MiniCore is used for ATmega8 microcontroller. Supported microcontrollers in this core are:
Follow steps below to install MiniCore in your Arduino IDE.
https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json
The above steps are shown graphically here:
ATmega8 pinout is shown in the following figure.
Step Two: Programming Arduino as an ISP (In-system programming)To burn Arduino bootloader, we need to make our Arduino UNO as an ISP. There’s a sketch named ArduinoISP in the built-in examples of Arduino IDE. Follow these steps to program your Arduino UNO as an ISP.
Arduino ----------ATmega8
SCK / Pin 13 ----------SCK / PB5
MISO / Pin 12 ----------MISO / PB4
MOSI / Pin 11 ----------MOSI / PB3
SSN / Pin 10 ----------RESET
If the operation was successful, it says “Done burning bootloader”. Congratulations! You have done it.
Part Two: Programming ATmega8 Using Arduino IDE and a USB to TTL ConvertorHere we have an ATmega8 with Arduino bootloader. As you know, there is a USB to TTL convertor on all Arduino boards. It acts as a bridge between microcontroller and Arduino IDE. We use CH340 USB to TTL convertor module to upload the sketch to ATmega8.
Step Four: Setting up the ConnectionsConnect components as shown below.
CH340 ---------- ATmega8
VCC ---------- VCC
GND ---------- GND
Tx ---------- RX / PD0
Rx ---------- Tx / PD1
Step Five: Uploading the Sketch to ATmega8Press and hold the reset pushbutton. Now click on upload in IDE. Hold the pushbutton until it says “Uploading…”on the IDE status bar. Release the button after uploading process begins. It’s because microcontroller should be in the RESET state when the uploading process starts.
Note: If the process was unsuccessful, place a 100nF capacitor at Vcc and GND of microcontroller as close as possible.
Note: Some USB to TTL convertor modules have a pin named DTR. If yours has this pin too, you can connect it to the RESET pin of ATmega8 and there’s no need to use the pushbutton to manually reset the microcontroller.
“I’ve written my code for Arduino UNO board. Is it possible to upload my sketch to an AVR microcontroller except ATmega328? I think it’s the most common question of Arduino lovers. This may have different reasons such as:
In this tutorial you will learn how to program an ATmega8 using Arduino IDE. It’s not restricted to ATmega8 only and can be generalized to other cores which are available at MCUDude’s GitHub. It consists of two parts. In part one, Installing Arduino bootloader on ATmega8 is described. Part two shows how to program an ATmega8 using Arduino IDE and a USB to TTL convertor.
Part one: Installing Arduino BootloaderIn this part, we add ATmega8 support to Arduino IDE. Then we set up the breadboard and connect ATmega8 to Arduino UNO board.
Step One: Adding ATmega8 Support to Arduino IDE Using Board ManagerThere are different types of cores available on MCUDude’s GitHub repository. MiniCore is used for ATmega8 microcontroller. Supported microcontrollers in this core are:
Follow steps below to install MiniCore in your Arduino IDE.
https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json
The above steps are shown graphically here:
ATmega8 pinout is shown in the following figure.
Step Two: Programming Arduino as an ISP (In-system programming)To burn Arduino bootloader, we need to make our Arduino UNO as an ISP. There’s a sketch named ArduinoISP in the built-in examples of Arduino IDE. Follow these steps to program your Arduino UNO as an ISP.
Arduino ----------ATmega8
SCK / Pin 13 ----------SCK / PB5
MISO / Pin 12 ----------MISO / PB4
MOSI / Pin 11 ----------MOSI / PB3
SSN / Pin 10 ----------RESET
If the operation was successful, it says “Done burning bootloader”. Congratulations! You have done it.
Part Two: Programming ATmega8 Using Arduino IDE and a USB to TTL ConvertorHere we have an ATmega8 with Arduino bootloader. As you know, there is a USB to TTL convertor on all Arduino boards. It acts as a bridge between microcontroller and Arduino IDE. We use CH340 USB to TTL convertor module to upload the sketch to ATmega8.
Step Four: Setting up the ConnectionsConnect components as shown below.
CH340 ---------- ATmega8
VCC ---------- VCC
GND ---------- GND
Tx ---------- RX / PD0
Rx ---------- Tx / PD1
Step Five: Uploading the Sketch to ATmega8Press and hold the reset pushbutton. Now click on upload in IDE. Hold the pushbutton until it says “Uploading…”on the IDE status bar. Release the button after uploading process begins. It’s because microcontroller should be in the RESET state when the uploading process starts.
Note: If the process was unsuccessful, place a 100nF capacitor at Vcc and GND of microcontroller as close as possible.
Note: Some USB to TTL convertor modules have a pin named DTR. If yours has this pin too, you can connect it to the RESET pin of ATmega8 and there’s no need to use the pushbutton to manually reset the microcontroller.