Introduction: How to Load Programs to an Arduino UNO From Atmel Studio 7

In this short Instructable we are going to learn how to load a program to an Arduino UNO board using Atmel Studio instead of the Arduino IDE. This is useful when you need to develop a program using more advance features or in another language, in this case we are going to use Assembly language. If you have already try this you should know that loading a program via de arduino USB is very tricky because Atmel Studio don't have the option for doing that ,instead you should use a ICSP programmer. But we don't want to do that, so we are going to integrate the built in USB programming capabilities of our board. To do that we are going to use "avrdude" and "external tools" option in Atmel Studio.

Let's get started, the first step is download and install the Arduino IDE and Atmel Studio. You can download it from here:

This will take a lot of time to complete, but is the easiest way to have everything we will need. When you are done you can continue to the next step.

Step 1: Configuring Atmel Studio

Now plug your Arduino UNO board into your computer and wait while the drivers installs. When is done take note of the COM port it is using. You can check it in the device administrator if you missed it. In my case is "COM4" but yours may be different, so pay attention to this.

Now the real fun begins, open Atmel Studio click in the menu "tools/external tools" You will see a dialog box asking for some parameters. So let's fill the required information.

  1. In title: "Send to Arduino UNO" or the name you want.
  2. In command: "C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude.exe" this may vary according to the installation directory of the Arduino IDE. Check for avrdude.exe directory in your install.
  3. In arguments: "-C "C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf" -p atmega328p -c arduino -P COM4 -b 115200 -U flash:w:"$(ProjectDir)Debug\$(TargetName).hex":i" again this can vary according to the installation directory of the Arduino IDE. You need to replace the COM4 with the actual COM port your board is using as we see in the device administrator.
  4. Check "Use output window" box.
  5. Click OK.

We are done, you will see the new option "Send to Arduino UNO" in the tools menu.

Note: for Atmel Studio 6 users you will need to click in Tools\Select Profile and then set it to Advanced before doing this steps. Thanks to "cysix" for the information.

For Arduino Due you will need to use bossac.exe, please do this instead:

  1. In title: "Send to Arduino Due" or the name you want.
  2. In command: "C:\Program Files (x86)\Arduino\hardware\tools\bossac.exe" this may vary according to the installation directory of the Arduino IDE. Check for bossac.exe directory in your install.
  3. In arguments: "-i -d --port=COM4 -U false -e -w -v -b "$(TargetDir)$(TargetName).bin" -R" You need to replace the COM4 with the actual COM port your board is using as we see in the device administrator.
  4. Check "Use output window" box.
  5. Click OK.

Step 2: Make a Test

We are ready to go, all we need to do is make a little test. So click file/new/project and select "AVR assembler project under "Assembler" option. Click OK and select ATMEGA328P and click OK again. Now in the text editor copy and paste the following code:

 .ORG   0x0000                  // Tells the next instruction to be written
 RJMP   main                    // State that the program begins at the main label

 main:
 LDI    r16, 0xFF               // Load the immedate value 0xFF (all bits 1) into register 16
 OUT    DDRB, r16               // Set Data Direction Register B to output for all pins

 loop:
 SBI    PortB, 5                // Set the 5th bit in PortB. (i.e. turn on the LED)
 RCALL  delay_05
 CBI    PortB, 5                // Clear the 5th bit in PortB. (i.e. turn off the LED)
 RCALL  delay_05
 RJMP   loop                    // Loop again

 // Everything beneath is part of the delay loop
 delay_05:
 LDI    r16, 8

 outer_loop:
 LDI    r24, low(3037)
 LDI    r25, high(3037)

 delay_loop:
 ADIW   r24, 1
 BRNE   delay_loop
 DEC    r16
 BRNE   outer_loop
 RET

This will make the built-in led of the Arduino blink. Now click in build/build solution and after that go to tools/Send to Arduino UNO. You should see the Rx/Tx leds flashing and after that the built-in led will start blinking. And that's all, I hope you found this information useful. Now you are free to use Atmel Studio to make your Arduino projects.

This is a non-invasive way to connect your Arduino board to Atmel Studio, so you can still using it as normal with the Arduino IDE. If you have a different board avrdude must be configured properly according the board you want to use.

If you like it, and want to support me give me a like in my store fanpage: DAFR ELECTRONICS and also vote for this instructable in the contest.
Thank you, I hope you find it helpful. If you have a question feel free to ask ;)

Written by:

Daniel Fernandez R.

Comments

author
keaaw (author)2017-03-11

Thanks, worked great!

author
MoustafaM9 (author)2017-02-03

i have Arduino Due... what should i do?
The Arduino Due is a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU.

author
PerchE (author)2017-01-31

Do I have to add quotation marks?

author
electronicm (author)2017-01-22

Thank so much.

Greetings from Peru.

author
nyculescu made it! (author)2017-01-10

Many thanks! Very useful.

15966562_1570423849653847_1969161367_o.jpg15991828_1570423852987180_1546745782_o.jpg
author
TheRockstarOzzy (author)2016-07-16

Congratulation. Right now you became my personal hero.

author
Hafiz MuhammadU1 (author)2016-07-14

Hey thanks for this, however when I rn the c code in atmel studio using this new option in the tools, I am show this message in the error window:
avrdude.exe: error at C:\WinAVR-20100110\bin\avrdude.conf:320: programmer type must be written as "id_type"

author
Bateleur2 (author)2016-05-07

Now we have to learn a new language? that does not look anything like what i use in the arduino ide, even though it works. Thanks for the tutorial.

author
Daniel ArturoF (author)Bateleur22016-05-17

Not exactly, It just for people who want to use more functions and characteristic that are not included in the Arduino IDE and only are possible trouht Atmel Studio

author
cysix (author)2016-03-21

Unlike with Atmel Studio 6.x, before Tool\External Tools will even show up in the menu, you have to go to Tools\Select Profile and then set it to Advanced. Once you do this, the rest of the steps work as documented.

author
Daniel ArturoF (author)cysix2016-03-25

Thanks for the information, I will update the instructable soon for Atmel Studio 6 users. I used Atmel Studio 7 so I didn't have that problem.

Thanks for sharing!

author
Daniel ArturoF (author)cysix2016-03-25

Thanks for the information, I will update the instructable soon for Atmel Studio 6 users. I used Atmel Studio 7 so I didn't have that problem.

Thanks for sharing!

About This Instructable

34,213views

154favorites

License:

Bio: I´m a guy interested in new tecnologies and the things that we can make in house with a few components and a bit of ... More »
More by Daniel ArturoF:How to load programs to an Arduino UNO from Atmel Studio 7Neopixel ClockRaspberry Pi IoT ticket printer for online stores
Add instructable to: