Programming Arduino using ATMEL Studio 7 | applied electronics engineering

Latest

Programming Arduino using ATMEL Studio 7

By Applied Electronics - Monday, February 13, 2017 No Comments
In this tutorial we show how to program arduino using ATMEL Studio 7.

Programming Arduino with Arduino IDE is great. But if you program ATmega328P microcontroller in real C or C++ then you need to work with some other Ardiuno Programming software. One of such software is the ATMEL studio 7. In fact ATMEL studio is the vendors own AMTEL based microcontroller programming software or IDE(Integrated Programming Environment). Hence it supports all AVR microcontrollers including the ATmega328P that is used in Arduino board.

So we are going to show you the steps required for programming Arduino using ATMEL studio 7. We assumes that you already have Arduino IDE installed.

Step 1 : Download ATMEL Studio 7 for Programming Arduino using ATMEL Studio 7


The first step is download ATMEL studio 7 which you can download for free in the following website.

http://www.atmel.com/microsite/atmel-studio

Click on the download ATMEL Studio button and you will be redirected to a page containing the download link. The download page has two download option- web installer and the offline installer. You can choose anyone but ATMEL recommends web installer. Click either one of them and install ATMEL studio. If you choose web installer then a small 2.4MB installer will first download. Click on it and then the real ATMEL stuio IDE will gets downloaded. It is about 860 MB or more so it will take some time download. Once it is downloaded install it.

This step is shown below.

Download ATMEL studio for Programming Arduino using ATMEL Studio 7



Step 2: Configure ATMEL Studio 7 for Programming Arduino using ATMEL Studio 7


The next step is to launch the ATMEL Studio 7 and configure it as a programmer for the Arduino board. Launch ATMEL studio and go to Tools then choose External Tools. You will see a window that allows you to add external programmer to upload(download/ manipulate) hex file to the Arduino ATmega328P EEPROM. In this case the external program or utility is the AVRdude.

In the window that you see enter the following for the fields:

Title: Arduino UNO Programmer

Command : C:\Program Files\Arduino\hardware\tools\avr\bin\avrdude.exe

Arguments: -C "C:\Program Files\Arduino\hardware\tools\avr\etc\avrdude.conf" -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:$(TargetDir)$(TargetName).hex:i

You can leave the Initial Directory field empty.

Tick mark the Use Output Window.

Click Apply or just OK and you are done.

Important Notes:

 #1. In the arguments field you should change the com port PCOM3 according to your computer setting. PCOM3 means my computer com port for arduino is COM 3. Yours might be different. To check which com port your computer is using for Arduino UNO check the device manager. The following screenshot shows this.



#2. You can give any Title, this is for you to know what the external tool is about. 

#3. The command field is for letting ATMEL studio know which uploader program is to be used. In case of Arduino it is avrdude. The path to avrdude.exe should be entered here. Your path to avrdude.exe may be different. 

#4. The Argument field is for letting know ATMEL studio other information such as the configurationf file, avrdude.conf, the part to be used- ATmega328p, the port which is com 3 in this case, the baud rate and the place where the hex file is located and the hex file format(i at the end). The meaning of the syntax are shown below.


The steps for configuring and programming Arduino using ATMEL Studio 7 is show below.



Step 3: Programming Arduino using ATMEL Studio 7


Once the external tool has been configured the final step is to program the Arduino. To do this we need to write bare C program(or bare C++ program) for arduino. We will a C program for blinking LED connected to the pin 13.

You can start a new project or use existing c code file and write the following code.

#define F_CPU 16000000L // Specify oscillator frequency
#include 
#include 
 
int main(void)
{
    DDRB = 0b00100000; // configure pin 7 of PORTB as output (digital pin 13 on the Arduino UNO)
    while(1)
    {
        PORTB = 0b00100000; // set 7th bit to HIGH
        _delay_ms(500);
        PORTB = 0b00000000; // set 7th bit to LOW
        _delay_ms(500);
    }
}


Now build the solution.

It's time to check the Arduino programmer tool that we configured. Construct your hardware, that is, connect a LED to pin 13 and the other to the ground. Then go to the tools and click on Arduino UNO Programmer. You should see message "avrdude.exe done.  Thank you." in the output window of ATMEL Studio. Then you should see the LED blinking. And thats it, you have successfully programmed Arduino using ATMEL studio 7 using a C program.

See the following if you haven't understood how to do it.

Programming Arduino using ATMEL Studio 7


  Video Demonstration


Following is a short video demonstration of the LED blinking just to let you know how it works.

video


If you liked this tutorial share it. Also subscribe to our blog.

Other Arduino Tutorials:

No Comment to " Programming Arduino using ATMEL Studio 7 "