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 program on all AVR microcontrollers.

Atmel Studio is available free of charge. To download and install 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 online web installer if possible.

Here, we are using Atmel Studio 7 as currently latest IDE for developing 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 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 below figure.

Atmel Studio Start Page Window

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

Atmel Studio New Project Window

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

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

Atmel Studio New Project Window

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

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

Atmel Studio Device Selection Window

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

Atmel Studio main.c file

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

ATmega16 and LED connection diagram
ATmega16 and LED connection diagram

Program

#define F_CPU 8000000UL /* Define CPU frequency here 8MHz */
#include
#include

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 program, save(Ctrl+S) the program and click on Build Solution from Build menu as shown in below figure.

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

Atmel Studio Build Program

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

Atmel Studio Output Window

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

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

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

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

USBasp is USB in circuit programmer for Atmel AVR controllers.

USBasp Programmer
USBasp Programmer for AVR microcontrollers

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

ATmega16 LED Blinking

Design a site like this with WordPress.com
Get started