ATmega16L with AVR pocket programmer and Xplore Flash programmer

This is a simple tutorial on how to program ATmega16L with AVR pocket programmer and Xplore Flash programmer with an example of simple LED blink C program.. ATmega16/ATmega16L are 8 bit AVR microcontroller which are popular among electronics hobbyist and professional alike. They are used in microcontroller based electronics system or embedded system design. It comes in various IC package but they are most popular in the 40 pin PDIP IC. The ATmega16 is same as ATmega32 microcontroller with just one difference which is that the memory is half.  Here a simple C program to turn on a LED on and OFF is illustrated.

The following shows ATmega16L microcontroller setup on breadboard with 4MHz quartz crystal and 22pF capacitors, reset button and 10KOhm resistor, 220Ohm current limiting resistor and LED. The power supplied using 5V breadboard power supply module.

atmega16L led blink on breadboard

The schematic diagram of the led blink circuit with ATmega16L is shown below.

ATmega16L LED blink circuit diagram

The program code for the led blink which was written and compiled in KEIL IDE is below.

#ifndef F_CPU
#define F_CPU 4000000UL

#include <avr/io.h>
#include <util/delay.h>

#define LED (1<<PD7)

int main(){ 
   DDRD |= LED;

   while (1){
   return 0;

You must compile and generate the hex program code which you need later down below.

To program the ATmega16L chip we will use the following hardware and software programmer.

1. AVR pocket programmer

avr pocket programmer

2. Xplore Flash programmer

xplore flash programmer

In order to use this xplore programmer you need to do the following.

1. Install Win AVR compiler which comes with avrdude which you can donwload from the following link:

2. Download and install USBasp - USB programmer for Atmel AVR controllers which you find in the link below.

3. Download and install the XploreFlash GUI which you can find in the following link.

Once you have installed the above application, you should place the Atmega16L chip into the zip socket as shown.

AVR pocket programmer with atmega16L

 Then plug in the USB and open the xplore flash programmer. You should then set the programmer to USBasp, choose the ATmega16 from the drop downlist in MCU, browse for hex file for the blinking led program in the Flash field with write option selected and finally click on the Program button as shown below.

xplore flash programmer with atmega16L

If everything done right, then you should see writing process and finally ...bytes of flash verified message. At this point the atmega16 microcontroller is programmed with the led blink program. Now remove the micrcontroller from the AVR pocket programmer and insert into the breadboard. You should see the LED blinking.

Post a Comment

Previous Post Next Post