Getting Started with Atmel Studio

Introduction

Atmel, AVR microcontrollers (MCUs) are very easy to use. All AVR microcontrollers require Integrated Development Environment(IDE) such as Atmel Studio. Using this IDE, we can create, compile, and debug programs on all AVR microcontrollers.

Atmel Studio is available free of charge. To download and install the latest Atmel studio use this link.

Note: There are possibly two options for downloading and installing Atmel Studio as online/offline. Atmel recommends for online web installer so use an online web installer if possible.

Here, we are using Atmel Studio 7 as the currently the latest IDE for developing the program of Atmega16 microcontroller.

Atmel Studio 7 includes the GCC C and C++ compiler, assembler, and a simulator, and interfaces seamlessly with in-system debuggers and programmers to make code development easier.

Let’s develop a simple LED Blinking program for ATmega16 using Atmel Studio 7

1. After done with downloading and installing, Open Atmel Studio 7. We can see Start Page as shown in the below figure.

2. Now to create a new project Click on File -> New -> Project or simply use Ctrl+Shift+N Short keys.

3. A New Project window will pop up as shown in the below figure. In the New Project window, we need to select the project type as listed in the below figure, the Name for the project (which may title of the project), and the Location to where we can save project work.

Also, there is an option Create directory for a solution, which will create a project directory with the name of the project at the provided location.

4. After clicking on OK, the Device Selection window will pop up as shown in the below figure. In that, we can directly type the device name to get the required device from the device list shown in the below figure.

Click on the device name and then click OK. Here we have selected the ATmega16 microcontroller device.

5. Now wait till Atmel studio creates a project and main.c file to write a program for the selected device as shown in the below figure.

6. Now write a program. Here we are writing a program for LED Blinking connected to a PORTB of ATmega16.

Program

/*
 * ATmega16_LED_Blinking.c
 * http://www.electronicwings.com
 * Created: Created Date & Created Time
 * Author : Author Name
 */ 

#define F_CPU 8000000UL	/* Define CPU frequency here 8MHz */
#include <avr/io.h>
#include <util/delay.h>


int main(void)
{
    DDRB = 0xFF;	/* Make all pins of PORTB as output pins */
    
    while (1)		/* Blink PORTB infinitely */
    {
	PORTB = 0x00;
	_delay_ms(500);	/* Delay of 500 milli second */
	PORTB = 0xFF;
	_delay_ms(500);
    }
}

7. After writing the program, save (Ctrl+S) the program and click on Build Solution from the Build menu as shown in the below figure.

Also, we can use the F7 short key for the Build solution.

8. Now we can see build succeeded output in Output Window (lower left corner of window) as shown in below figure.

9. Now we can see generated.hex file in the Debug directory of the main project directory. Here we have created a hex file at,

D:\AtmelProjects\ATmega16_LED_Blinking\ATmega16_LED_Blinking\Debug\ ATmega16_LED_Blinking.hex

10. Now upload this hex file to the ATmega microcontroller. AVRDUDE is a program to burn hex code into the Atmel AVR microcontroller.

SinaProg (find in attachment given below) is AVRDUDE GUI software, which utilizes the AVRDUDE program to burn hex code into the Atmel AVR microcontroller using USBasp.

USBasp is a USB in-circuit programmer for Atmel AVR controllers.

11. After uploading the above program connect the LED to ATmega16, it will start blinking as shown below.

Source: Getting Started with Atmel Studio

About The Author

Muhammad Bilal

I am highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.

Scroll to Top