Programming ATmega328 With Arduino IDE Using 8MHz Crystal

Introduction: Programming ATmega328 With Arduino IDE Using 8MHz Crystal

In this Instuctable I'll be covering a step by step guide of programming an ATmega328P IC (The same microcontroller present on Arudino UNO) using Arduino IDE and an Arduino UNO as a programmer to make yourself a custom Arduino, to make your projects more scalable and cost-effective.

Most of the time while programming a ATmega328, you'll be using a external 16MHz crystal, but in cases when you want to have low power applications you should use an external 8MHz crystal. The IC has an inbuilt internal 8MHz oscillator but the internal clock has a higher drift compared to a quartz crystal, so it is better to use and external crystal oscillator.

Step 1: Components Required

You'll need

1) ATmega328P IC..................x1

2) 8MHz Crystal Oscillator...x1

3) Capacitor - 22pF.................x2

4) Resistor - 10K......................x1

5) Resistor - 220 Ohm...........x1

6) LED........................................x1

7) Arduino Uno.....................x1

some connecting wires, and you are good to go.

Step 2: Initial Connection

This basic setup will power up your IC and you'll be ready for bootloading.

Pin 1 - Vcc via 10K resistor

Pin 7 and Pin 20 - Vcc

Pin 8 and Pin 22 - Gnd

Pin 9 and Pin 10 - Crystal Oscillator

Pin 9 and Pin10 - Gnd via 22pF Capacitors each

Pin 19 - Gnd Via a series combination of 220 Ohm resistor and LED

Step 3: Bootloading

Microcontrollers are usually programmed through a programmer unless you have a piece of firmware in your microcontroller that allows installing new firmware without the need of an external programmer. This is called a bootloader.

IMPORTANT - This will be a one time process.

To upload the bootloader, we'll make some extra connections to the basic power connections.

Atmega - Arduino UNO

Pin 1 - D10 (RESET)

Pin 17 - D11 (MOSI)

Pin 18 - D12 (MISO)

Pin 19 - D13 (SCK)

Now open Arduino IDE

1) Go to File > Examples > ArduinoISP

2) Go to Tools > Board > Arduino UNO

3) Select port from the Tools > Port

4) Upload the ArudinoISP sketch to your board

5) After succeful uploading of the code go to Tools > Board > and select Arduino Pro or Pro Mini

6) Go to Tools > Processor > and select ATmega328P (3.3V, 8MHz)

7) Go to Tools > Programmer > and select Arduino as ISP (Not ArduinoISP)

8) Go to Tools > Burn Bootloader

This may take a while, and you'll be shown Done burning bootloader.

At this moment the LED on your breadboard and the default Arduino UNO LED will start blinking in sync.

Step 4: Programming the IC

You are now ready to Program your ATmega328P IC just like your arduino.

IMPORTANT - After bootloading, remove the ATmega chip form the Arduino UNO because now we will be using the Arduino board just as an ISP Programmer (In System Programmer).

Now remove all the 4 connections made in the bootloading process and do the following connections

ATmega - Arduino

Pin 1 - RESET

Pin 2 - D0 (Rx)

Pin 3 - D1 (Tx)

Now, go to Tools > Programmer > and select AVRISP mkll

Go to File > Examples > Basic > Blink

Upload change the delays as you wish and upload the Sketch

You are now ready with your Minimal Arduino, you can now integrate whatever you want with your Microcontroller and make Custom Arudinos and reduce the size and cost of your projects.

*Also, while uploading sketches remeber to use Arduino Pro or Pro Mini as the Board with Processor as ATmega328P (3.3V, 8Mhz) rather than Arduino UNO as we have used Pro Mini's bootloader because we have connected a 8MHz crystal.

Be the First to Share


    • Back to School: Student Design Challenge

      Back to School: Student Design Challenge
    • Lamps and Lighting Contest

      Lamps and Lighting Contest
    • Make it Move Challenge

      Make it Move Challenge