AVR microcontrollers come in a variety of sizes, and specs. They have a great range of features and capabilities.

Their applications range from the humble hobbyist in his/her garage, to the machinery used in the medical applications.

But, these microcontrollers do not come pre-programmed with software/programs that are ready to take care of any task at hand.

It is the job of the designer, programmer, engineer to write a set of instructions that the microcontroller will later be able to interpret and execute.

After writing the program, this program needs to be downloaded onto the microcontroller.

That is where an AVR programmer comes to the rescue. The main role of the AVR programmer is to be able to transfer the code one has written onto the microcontroller. 

Without an AVR programmer, your microcontroller would remain blank and not capable of performing any tasks.

Say you have just completed a simple program you have just written to blink an LED. You have the hardware all wired up. Now the only thing left to do, is to download the program onto the microcontroller using an AVR Programmer.

This article will cover the different types of AVR programmers, the difference between an AVR programmer and a debugger, and many more key points.

What is AVR Programming?

The term AVR refers to the architecture used by many of Atmel’s microcontrollers. 

There are many different types of microcontrollers and programmers available, so AVR programming refers to the programming of microcontrollers that utilise the AVR type of architecture. 

With different architectures come different forms of programming. I shall cover only AVR programming from here on. 

The program can be written in a variety of softwares, and programmed using a variety of programmers, which I will cover later in this article. 

AVR programming is essentially the act of writing a program, and then ‘programming’ your microcontroller using an appropriate AVR programmer.

What is a Program?

So the first step to AVR Programming is ‘The Program’.

The first step of the program is that the user writes their program using a software language.

You have many choices available and depending on the microcontroller itself. They include, binary, assembly, C, C++, Python , Java and many more.

Binary is what was used initially at the dawn of microcontrollers and isn’t used anymore due to its inefficiency and complexity. 

Assemble language is also quite primitive and isn’t used as much as C, C++, Python and Java.

C,C++, Python and Java are higher level languages which are human-readable. 

Human-readable is not good for a microcontroller. A microcontroller can only interpret machine-readable code.

Binary and Assembly are machine-readable languages. However, it is quite rare to write programs in machine-readable code these days.

So, if you have written your code with ‘human-readable’ code, it must be converted to ‘machine-readable’ code, which is binary (0’s and 1’s).

The software or compiler you are writing your code in must be able to ‘compile’ your code. Compiling your code consists of converting your project into machine readable code. 

A list of software that are capable of doing this include:

  • WinAvr
  • Arduino IDE
  • Visual Studio
  • Atmel Studio
  • Codevision AVR
  • VMLAB

The file that results after compiling is a .hex file. There are other file extensions but this is the most common.

The next step is transferring this .hex file onto your microcontroller’s flash memory.

What is flash? 

Flash is memory where your program goes to live.

When you turn your microcontroller on, it will execute whatever is stored in flash memory. 

Being able to write Flash memory is what is essential.

Every AVR microcontroller has a set of pins that are used for programming. 

So, in order to program a microntroller’s flash memory, you need to connect your AVR programmer to those specific pins. 

This form of programming is known as In System Programming (ISP) or In Circuit System Programming (ICSP). This is the most common way to program a microcontroller. 

All AVR microcontroller programming pins are not the same. You will have to consult the datasheet of the microcontroller you are programming to figure out what are the right pins.
The pins associated with programming are; GND,VCC, RESET, SCK, MOSI, and MISO.

What is an AVR Programmer?

An AVR programmer plays a crucial role in the programming process.

It provides a direct connection between your compiler and the microcontroller.

Without an AVR programmer your program would remain just that, a program. You would not be able to load it onto the microcontroller.

There are many types of programming interfaces from ISP, PDI, UPDI, High-Voltage serial, High-Voltage Parallel, Bootloader and ROM.

When it comes to AVR programmers you have a few options available that utilise either of the programming interfaces mentioned above.

Each option has different characteristics as well as pros and cons.

The different options include; Serial/Parallel port bit-bang, ISP,  and Development boards

Serial/Parallel Port bit-bang Programmers

This kind of programmer connects to the serial or parallel port of a PC.

It communicates with the parallel/serial ports to send data to the microcontroller.

The distinction between a parallel and serial programmer is that one plugs into the parallel port of the PC and the other to serial port respectively.

Pros 

  • Cheap
  • Easy to understand, so great for beginners
  • Great from simple projects

Cons

  • Not very smart, so not ideal for complex projects
  • Requires that your computer has parallel/serial ports. A MAC will not be compatible unfortunately

ISP Programmers

The ISP (In system programmer) is a better, smarter version of the older bit-bang programmers.

There are two different versions. 

One uses a serial port to communicate, while the other uses USB.

There are many options of ISP programmers available, but the most common are the AVR ISP v1 and v2.

V1 uses the serial jack, and V2 uses USB.

Pros

  • Smarter 
  • Easy to use
  • Complex projects are possible

Cons

  • A little on the expensive side

Development Boards

If you are starting out with microcontrollers, development boards are a great place to start.

Many universities use development boards to teach students the basics of microcontrollers which include clocks, inputs, outputs, sensors etc.

A development board can be as simple as just a microcontroller and clock circuitry.

Or, it can include outputs like LED’s, Motors, LCD’s, as well as inputs like switches, pushbuttons, and sensors.

So it takes away all the guesswork of having to set up peripheral circuitry. 

Also, you can use a range of microcontrollers depending on your need, as there are sockets that support many different pin configurations.

There are many development boards available today.

But the most common are the STK500, and AVR Dragon.

The STK500 is a development board that supports most of Atmel’s microcontrollers.

This programmer is used in conjunction with AVR Studio (a programming environment developed by Atmel).

The communication protocol that it uses to talk to the computer is known as ‘STK500’. 

The other common development board is the AVR Dragon. 

The AVR Dragon has many sockets for a range of microcontrollers and includes a programmer as well. 

However, the AVR Dragon acts more like a programmer than a development board.

Pros

  • Great for beginners
  • No need for setup of peripheral circuitry
  • Programmer included

Cons

  • Can be quite expensive
  • While it is good for starting out, it can be a bit complex

What is a Debugger?

Being able to load programs onto your microcontroller is a crucial step in programming.

But, sometimes your program does not work how you intended to, or you might want to test parts of your program.

This is where a Debugger comes in handy.

As the name suggests, the Debugger allows you to ‘Debug’ your code.

Going back to our previous example of blinking an LED. If you have a debugger connected to your microcontroller and the software that compliments the debugger, you can execute your code line by line.

You can also have an inside look of the inside of the microcontroller at its internal workings that include its input/registers, variables, clock values and much more.

You can have breakpoints that allow your debugger stop at specific points in your code depending on certain conditions.

It can also react to external events such as button presses.

The advantage is that not only does it allow you to debug your code, you can still program your microcontroller.

The most commonly used and available debuggers are the JTAG (Joint Test Action Group).

Atmel has a range of JTAG adapters for their AVR microcontrollers which consist of the Atmel-ICE, JTAG-ICE, JTAG-ICE mkII, and AVR Dragon.

Should I get an AVR Programmer or Debugger?

Choosing between an AVR programmer and debugger all depends on your need.

Debuggers due to their capabilities can be quite expensive.

So, if you are just a beginner learning the ins and outs of programming your first microcontroller project, you will not require a debugger. An AVR programmer is all you need to get started.

Your initial projects will be basic enough that you will be able to debug your code and circuits by trial and error.

As you advance in skill, and project complexity, a debugger will be a great tool to add your arsenal, as you will be able to debug your code and circuits much easily.

Software used to program

The software, also commonly referred to as the IDE (Integrated Development Environment) is what you used to write your code in,compile it to create a .HEX file and then be able to connect your programmer to your microcontroller in order to program it.

The most familiar code to write in is C. There are other IDE’s that offer basic, java, C++ etc.

When acquiring an IDE, make sure it has the capability of compiling code to create a .HEX file, and has the ability of talking with your programmer.

The good news is that Atmel has created its own range of IDE’s to be used specifically with its AVR programmers. 

You can write code, compile it, program your microcontroller and debug it as well. The IDE is Atmel AVR Studio.

It has many versions available, but Atmel AVR Studio 6,or any higher version should be fine.
Other common IDE’s include Codevision AVR, WinAVR, BASCOM-AVR, and MikroC.

Can I use my AVR programmer with any AVR microcontroller?

As there are many programmers/ debuggers available,it all depends on what microcontrollers the particular programmer/debugger provides support for.

The list of what microcontrollers you can program are outlined on the programmers datasheet that can be found online on the manufacturer’s website.

As an example, below is the programming and debugging capabilities of the ATMEL-ICE (taken from the ATMEL-ICE datasheet):

UPDITPISPIdebugWIREJTAGPDIaWIRESWD
tinyAVRNew devicesSome devicesSome devicesSome devices
megaAVRAll devicesSome devicesSome devices
AVRxMEgaSome devicesAll devices
AVR UCAll devicesSome devices
SAMSome devicesAll devices

Does an Arduino need a special programmer?

While the Arduino itself is not part of the AVR family (AVR is a branch of microcontrollers manufactured by Atmel), at the heart of every (if not most) Ardunios is an AVR microcontroller.

Arduino is a hardware and software platform built around an AVR.

A standalone AVR microcontroller requires a programmer in order to program it (programmers like the ones mentioned above).

Most Arduino boards however, include the same functionality that an AVR programmer does. 

This means that you do not need to buy an additional programmer to load your program onto it. 

The tell tale sign that an Arduino board has an onboard programmer is that it has a USB port. All you will need to program it is a USB cable.

Some Ardunios however, to save cost, do not include an on board programmer. Rather than having a USB port, they will have an ISP header which you can connect an AVR programmer to. 

An Ardunio can be seen as a development board. Except it does not have additional components such as motors, sensors, switches in built.

Can you use AVR Programmers to program non-AVR microcontrollers?

An AVR microcontroller is a family of integrated chips manufactured by Atmel.

But, these aren’t the only microcontrollers available on the market. There are other companies that manufacture other types of microcontrollers.

The most common of them include the PIC and 8051

The process of programming these chips is the same as the AVR (write the code, compile it to a .hex file and then load that file onto the microcontroller). Most of them use ISP as a means of programming the chip as well.

However, because each type of microcontroller has its own hardware platform, companies have developed their own unique programmer for them. 

So an AVR programmer should be used to program AVR microcontrollers.

Conclusion

So, you can see that the AVR programmer is a crucial element when it comes to the process of programming an AVR microcontroller.

It provides a means of communication between your computer and microcontroller.

It allows you to be able to load your code that you have written onto to the microcontroller to see it in action.

AVR programmers perform only one task, that is loading code into a microcontroller. If you want to test your code line by line while it is running, as well as have the ability to program it, you will need a debugger.