New to programming AVR microcontrollers? Don’t know where to start from? You have come to the right spot. In this post, I will tell you all the right tools you need before you start programming an AVR microcontroller.

Getting started with programming AVR microcontroller for the first time, seems pretty daunting. You might have already searched Google and come up with lengthy descriptions telling you about various programmers and IDEs and all. Some of the tools might even cost you hundreds of dollars to purchase. I mean, as a start, you don’t want to spend that amount of money! I remember myself going through tens of Youtube videos and blogs, downloading crappy software and that first LED still not blinking from my ATmega32A.

It took me almost a week of trial and error to finally end up with the cheapest and working tools to get my first AVR microcontroller project up and running. Here I have organized what I found.

What do you actually need?

There are two types of tools you need to program an AVR microcontroller.

  • Hardware
    • A microcontroller
    • A programmer
  • Software
    • An IDE
    • A programming software
    • Driver software for the programmer

Now, let’s dive into each of these tools to understand why we need them and what should we choose.

Hardware

Microcontroller

Microcontroller is the brain of your whole project. Changing the microcontroller in the middle of the project will be a nightmare. So, be sure to choose the right one as the first step of programming. There are several main key points you should consider when you are choosing the right microcontroller for your project.

The first thing you should consider is the number of IO pins. If you project is simple and requires less inputs and outputs, go for AVR MCUs with less IO pins as they are smaller and easier to handle. But make sure, that the microcontroller you choose has several extra IO pins so that your project has ability to grow if the need be, for an example, if you want to add an extra button!

Also make sure you have enough number of PWM pins required for your project. PWM pins are used to output analog voltage levels to control aspects like speed of a motor. In AVR microcontrollers, these pins are named as OCxA/OCxB (x=1,2,..). Get the pinout of the microcontroller and see whether it has enough number of them.

Another type of pins you should be mindful to consider is the number of Analog Input Pins. Even though all the IO pins on the microcontroller can read and write digital inputs and outputs, only a specific number of pins has ADC (Analog to Digital Conversion) to read analog inputs. So depending on the number of analog sensors you use in your project, your choice of microcontroller should vary.

ATmega328P Pinout

Make sure your microcontroller has enough memory to store your program. If your project is complex, the code will most probably be lengthy.

There are many other factors to consider but for the start these two factors will help you determine the right microcontroller for your project. ATmega328P which is the brain of the Arduino UNO and ATmega16/ATmega32 are great for the start!

For more help on choosing the right AVR microcontroller for your project follow this link to a comparison table.

Programmer

You write the code on your computer. But you have no way of connecting your AVR microcontroller directly to your computer to upload your code. This is where the programmer comes into play. This simply provides a way of communication between your computer and the microcontroller.

Atmel-ICE is the recommended programmer by AVR microcontroller manufacturer, Microchip, but it costs about $100. If you have enough money, this is the perfect programmer. With Atmel-ICE, you can directly program the MCU through Atmel Studio/Microchip Studio (more about that later) without a separate programming software.

Atmel-ICE Programmer

But to be honest, as newbies, we don’t want to spend that much of money. There are many other programmers you can use but the cheapest and the easiest to use is USBasp. USBasp programmer is open source and uses an ATmega88/ATmega8 itself. You can even make one at home or buy one for around $3-$4. The USBasp is connected to the AVR microcontroller through 4 pins and connected to the computer through a USB port.

USBasp

You can find more about USBasp from the creator’s website.

Software

IDE

A simple text editor can be used to write code for AVR microcontrollers. Code is written in AVR C++, the language used to write code for AVR MCUs. The compilation generates a .hex file which can be written into the memory of the microcontroller through the programmer.

Using a specific IDE over a text editor is easier as it contains the necessary compiler to generate the .hex file. Atmel Studio used to be the best programming platform for AVR microcontrollers, developed by Atmel itself. However, since Microchip purchased Atmel, they introduced Microchip Studio as an IDE to program not only AVR but also SAM MCUs. It is the IDE that is now being distributed through the Microchip website and can be downloaded by following this link. Both softwares are very similar to each other so you can use either of them for your project.

Microchip Studio

You can also download Atmel Studio through this external link or from the manufacturer’s download archive, if you prefer.

There are other options like AVR Eclipse plugin and MikroC but Atmel Studio/Microchip Studio can be stated as the best to work with ATmega microcontrollers.

Driver for the programmer

This is only necessary if you are using USBasp as the programmer and have Windows OS on your computer. You can use driver installation tool Zadig and download the right driver for the USBasp.

After downloading Zadig, plug in the programmer and install the libsub driver (not WinUSB) onto your computer.

Installing Driver for USBasp

Programming Tool

A separate programming tool is used to program AVR microcontroller through USBasp. This is not necessary if you are using Atmel-ICE as you can program it directly through Atmel Studio/Microchip Studio.

Several programming tools are recommended on the USBasp’s creators website (link above). After trying out all of them, I can state Extreme Burner as the best for the start as it is completely free and has a user-friendly GUI. You can download it from this link. The site includes the instructions that should be followed when uploading the .hex file to the microcontroller also.

Extreme Burner as the programming tool

Next Steps…

Great! Now you are ready to start programming your first microcontroller. Follow this link to learn how to actually use these tools to blink an LED with ATmega128P!

One Reply to “Programming AVR microcontrollers – What do you need?”

Leave a Reply

Your email address will not be published. Required fields are marked *